From 9162ca4be8f6ade2cd9e4cf574e9e30afe4b2454 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 6 Feb 2017 22:59:50 +1100 Subject: [PATCH] H:/PortableApps/GitPortable/App/Git/c4 now works as a mode instead of a separate command --- MCGalaxy/Blocks/Behaviour/PlaceBehaviour.cs | 24 ++++++-- MCGalaxy/Commands/other/CmdC4.cs | 61 --------------------- MCGalaxy/MCGalaxy_.csproj | 1 - MCGalaxy/Player/Player.Handlers.cs | 7 +-- MCGalaxy/Player/Player.cs | 2 +- 5 files changed, 22 insertions(+), 73 deletions(-) delete mode 100644 MCGalaxy/Commands/other/CmdC4.cs diff --git a/MCGalaxy/Blocks/Behaviour/PlaceBehaviour.cs b/MCGalaxy/Blocks/Behaviour/PlaceBehaviour.cs index 7aac07e73..72cf987db 100644 --- a/MCGalaxy/Blocks/Behaviour/PlaceBehaviour.cs +++ b/MCGalaxy/Blocks/Behaviour/PlaceBehaviour.cs @@ -37,7 +37,7 @@ namespace MCGalaxy.Blocks { } byte above = lvl.GetTile(x, (ushort)(y + 1), z), extAbove = 0; - if (above == Block.custom_block) + if (above == Block.custom_block) extAbove = lvl.GetExtTile(x, (ushort)(y + 1), z); block = (above == Block.Invalid || Block.LightPass(above, extAbove, lvl.CustomBlockDefs)) @@ -49,7 +49,7 @@ namespace MCGalaxy.Blocks { internal static void Stairs(Player p, byte block, ushort x, ushort y, ushort z) { if (!(p.level.physics == 0 || p.level.physics == 5) || p.level.GetTile(x, (ushort)(y - 1), z) != Block.staircasestep) { - p.ChangeBlock(x, y, z, Block.staircasestep, 0); return; + p.ChangeBlock(x, y, z, Block.staircasestep, 0); return; } p.SendBlockchange(x, y, z, Block.air); // send the air block back only to the user @@ -66,11 +66,27 @@ namespace MCGalaxy.Blocks { p.ChangeBlock(x, (ushort)(y - 1), z, Block.stone, 0); } + internal static void C4(Player p, byte block, ushort x, ushort y, ushort z) { if (p.level.physics == 0 || p.level.physics == 5) { p.RevertBlock(x, y, z); return; } + // Use red wool to detonate c4 + byte held = p.RawHeldBlock; + if (held < Block.CpeCount) held = p.bindings[held]; + if (held == Block.red) { + Player.Message(p, "Placed detonator block, delete it to detonate."); + C4Det(p, Block.c4det, x, y, z); return; + } + + if (p.c4circuitNumber == -1) { + sbyte num = C4Physics.NextCircuit(p.level); + p.level.C4list.Add(new C4Data(num)); + p.c4circuitNumber = num; + Player.Message(p, "Place more blocks for more c4, then place a &c{0} %Sblock for the detonator.", Block.Name(Block.red)); + } + C4Data c4 = C4Physics.Find(p.level, p.c4circuitNumber); if (c4 != null) c4.list.Add(p.level.PosToInt(x, y, z)); p.ChangeBlock(x, y, z, Block.c4, 0); @@ -78,13 +94,13 @@ namespace MCGalaxy.Blocks { internal static void C4Det(Player p, byte block, ushort x, ushort y, ushort z) { if (p.level.physics == 0 || p.level.physics == 5) { - p.c4circuitNumber = -1; + p.c4circuitNumber = -1; p.RevertBlock(x, y, z); return; } C4Data c4 = C4Physics.Find(p.level, p.c4circuitNumber); if (c4 != null) c4.detIndex = p.level.PosToInt(x, y, z); - p.c4circuitNumber = -1; + p.c4circuitNumber = -1; p.ChangeBlock(x, y, z, Block.c4det, 0); } } diff --git a/MCGalaxy/Commands/other/CmdC4.cs b/MCGalaxy/Commands/other/CmdC4.cs deleted file mode 100644 index b22bc3650..000000000 --- a/MCGalaxy/Commands/other/CmdC4.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright 2010 MCSharp team (Modified for use with MCZall/MCLawl/MCGalaxy) - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. - */ -using MCGalaxy.Blocks.Physics; - -namespace MCGalaxy.Commands { - public sealed class CmdC4 : Command { - public override string name { get { return "c4"; } } - public override string shortcut { get { return ""; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.AdvBuilder; } } - public CmdC4() { } - - public override void Use(Player p, string message) { - if (Player.IsSuper(p)) { MessageInGameOnly(p); return; } - - if (p.level.physics >= 1 && p.level.physics < 5) { - sbyte numb = C4Physics.NextCircuit(p.level); - C4Data c4 = new C4Data(numb); - p.level.C4list.Add(c4); - p.c4circuitNumber = numb; - Player.Message(p, "Place any block for c4 and place a &cred %Sblock for the detonator!"); - p.Blockchange += PlacedNext; - } else { - Player.Message(p, "To use c4, the physics level must be 1, 2, 3 or 4"); - } - } - - void PlacedNext(Player p, ushort x, ushort y, ushort z, byte type, byte extType) { - p.ClearBlockchange(); - if (type == Block.red) { - p.ManualChange(x, y, z, 1, Block.c4det); - Player.Message(p, "Placed detonator block!"); - return; - } else if (type != Block.air) { - p.ManualChange(x, y, z, 1, Block.c4); - } - p.Blockchange += PlacedNext; - } - - public override void Help(Player p) { - Player.Message(p, "%T/c4"); - Player.Message(p, "%HPlace c4!"); - } - } -} diff --git a/MCGalaxy/MCGalaxy_.csproj b/MCGalaxy/MCGalaxy_.csproj index 0da9b8866..903fc32c5 100644 --- a/MCGalaxy/MCGalaxy_.csproj +++ b/MCGalaxy/MCGalaxy_.csproj @@ -335,7 +335,6 @@ - diff --git a/MCGalaxy/Player/Player.Handlers.cs b/MCGalaxy/Player/Player.Handlers.cs index 2ac149d73..7b765466a 100644 --- a/MCGalaxy/Player/Player.Handlers.cs +++ b/MCGalaxy/Player/Player.Handlers.cs @@ -118,6 +118,7 @@ namespace MCGalaxy { } } + if (modeType != 0) block = modeType; if (doDelete) { DeleteBlock(oldB, x, y, z, block, extBlock); } else { @@ -150,12 +151,6 @@ namespace MCGalaxy { } void PlaceBlock(byte old, ushort x, ushort y, ushort z, byte block, byte extBlock) { - if (modeType != 0) { - if (old == modeType) SendBlockchange(x, y, z, old); - else ChangeBlock(x, y, z, modeType, 0); - return; - } - HandlePlace handler = BlockBehaviour.placeHandlers[block]; if (handler != null) { handler(this, old, x, y, z); diff --git a/MCGalaxy/Player/Player.cs b/MCGalaxy/Player/Player.cs index aec8e6260..d068e15b7 100644 --- a/MCGalaxy/Player/Player.cs +++ b/MCGalaxy/Player/Player.cs @@ -32,7 +32,7 @@ namespace MCGalaxy { public byte GetActualHeldBlock(out byte extBlock) { byte block = RawHeldBlock; extBlock = 0; - if (modeType != 0) return modeType; + if (modeType != 0) return modeType; if (block < Block.CpeCount) return bindings[block]; extBlock = block;