mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 21:51:19 -04:00
Core: Get custom doors working, mostly.
This commit is contained in:
parent
ad7b0d4d1a
commit
aa17aebbe2
@ -16,7 +16,7 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
|
||||
namespace MCGalaxy.Blocks {
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
|
||||
namespace MCGalaxy.Blocks {
|
||||
|
||||
@ -75,9 +75,15 @@ namespace MCGalaxy.Blocks {
|
||||
}
|
||||
|
||||
internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) {
|
||||
if (p.level.physics != 0) {
|
||||
if (p.level.physics != 0) {
|
||||
bool isExt = false;
|
||||
if (block == Block.custom_block) {
|
||||
isExt = true;
|
||||
block = p.level.GetExtTile(x, y, z);
|
||||
}
|
||||
|
||||
byte physForm;
|
||||
PhysicsArgs args = ActivateablePhysics.GetDoorArgs(block, out physForm);
|
||||
PhysicsArgs args = ActivateablePhysics.GetDoorArgs(block, isExt, out physForm);
|
||||
p.level.Blockchange(x, y, z, physForm, false, args);
|
||||
} else {
|
||||
p.RevertBlock(x, y, z);
|
||||
@ -100,6 +106,10 @@ namespace MCGalaxy.Blocks {
|
||||
return WalkthroughBehaviour.Portal(p, block, x, y, z, false);
|
||||
} else if (p.level.CustomBlockProps[extBlock].IsMessageBlock) {
|
||||
return WalkthroughBehaviour.MessageBlock(p, block, x, y, z, false);
|
||||
} else if (p.level.CustomBlockProps[extBlock].IsTDoor) {
|
||||
return RevertDoor(p, block, x, y, z);
|
||||
} else if (p.level.CustomBlockProps[extBlock].IsDoor) {
|
||||
return Door(p, block, x, y, z);
|
||||
}
|
||||
|
||||
p.ChangeBlock(x, y, z, Block.air, 0);
|
||||
|
@ -15,7 +15,7 @@
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.Blocks {
|
||||
|
@ -18,7 +18,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.SQL;
|
||||
|
||||
namespace MCGalaxy.Blocks {
|
||||
@ -26,8 +26,14 @@ namespace MCGalaxy.Blocks {
|
||||
|
||||
internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) {
|
||||
if (p.level.physics == 0) return true;
|
||||
bool isExt = false;
|
||||
if (block == Block.custom_block) {
|
||||
isExt = true;
|
||||
block = p.level.GetExtTile(x, y, z);
|
||||
}
|
||||
|
||||
byte physForm;
|
||||
PhysicsArgs args = ActivateablePhysics.GetDoorArgs(block, out physForm);
|
||||
PhysicsArgs args = ActivateablePhysics.GetDoorArgs(block, isExt, out physForm);
|
||||
p.level.Blockchange(x, y, z, physForm, false, args);
|
||||
return true;
|
||||
}
|
||||
@ -43,6 +49,9 @@ namespace MCGalaxy.Blocks {
|
||||
return Portal(p, block, x, y, z, true);
|
||||
} else if (p.level.CustomBlockProps[extBlock].IsMessageBlock) {
|
||||
return MessageBlock(p, block, x, y, z, true);
|
||||
} else if (p.level.CustomBlockProps[extBlock].IsDoor
|
||||
&& p.level.CustomBlockDefs[extBlock].CollideType != 0) {
|
||||
return Door(p, block, x, y, z);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class AIPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
public static class ActivateablePhysics {
|
||||
|
||||
/// <summary> Activates fireworks, rockets, and TNT in 1 block radius around (x, y, z) </summary>
|
||||
@ -61,18 +61,25 @@ namespace MCGalaxy.BlockPhysics {
|
||||
public static void DoDoors(Level lvl, ushort x, ushort y, ushort z, bool instant) {
|
||||
int index = lvl.PosToInt(x, y, z);
|
||||
if (index < 0) return;
|
||||
byte b = lvl.blocks[index];
|
||||
|
||||
if (Block.Props[b].IsDoor) {
|
||||
byte block = lvl.blocks[index];
|
||||
bool ext = block == Block.custom_block;
|
||||
BlockProps[] props = Block.Props;
|
||||
if (ext) {
|
||||
block = lvl.GetExtTile(x, y, z);
|
||||
props = lvl.CustomBlockProps;
|
||||
}
|
||||
|
||||
if (props[block].IsDoor) {
|
||||
byte physForm;
|
||||
PhysicsArgs args = GetDoorArgs(b, out physForm);
|
||||
PhysicsArgs args = GetDoorArgs(block, ext, out physForm);
|
||||
if (!instant) lvl.AddUpdate(index, physForm, false, args);
|
||||
else lvl.Blockchange(index, physForm, false, args);
|
||||
} else if (Block.Props[b].IsTDoor) {
|
||||
PhysicsArgs args = GetTDoorArgs(b);
|
||||
} else if (props[block].IsTDoor) {
|
||||
PhysicsArgs args = GetTDoorArgs(block, ext);
|
||||
lvl.AddUpdate(index, Block.air, false, args);
|
||||
} else {
|
||||
byte oDoor = Block.Props[b].ODoorId;
|
||||
byte oDoor = props[block].ODoorId;
|
||||
if (oDoor != Block.Invalid)
|
||||
lvl.AddUpdate(index, oDoor, true);
|
||||
}
|
||||
@ -86,7 +93,8 @@ namespace MCGalaxy.BlockPhysics {
|
||||
args.ExtBlock = isExt;
|
||||
|
||||
physForm = Block.door_tree_air; // air
|
||||
if (raw == Block.air_door || raw == Block.air_switch) {
|
||||
if (isExt) {
|
||||
} else if (raw == Block.air_door || raw == Block.air_switch) {
|
||||
args.Value1 = 4 - 1;
|
||||
} else if (raw == Block.door_green) {
|
||||
physForm = Block.door_green_air; // red wool
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public enum AirFlood { Full, Layer, Down, Up, }
|
||||
public static class AirPhysics {
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
public static class BirdPhysics {
|
||||
|
||||
public static void Do(Level lvl, ref Check C) {
|
||||
|
@ -18,7 +18,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class C4Physics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
public static class DoorPhysics {
|
||||
|
||||
// Change anys door blocks nearby into air forms
|
||||
@ -25,7 +25,8 @@ namespace MCGalaxy.BlockPhysics {
|
||||
ushort x, y, z;
|
||||
lvl.IntToPos(C.b, out x, out y, out z);
|
||||
byte block = C.data.Value2;
|
||||
bool instant = block == Block.air_door || block == Block.air_switch;
|
||||
bool instant = !C.data.ExtBlock &&
|
||||
(block == Block.air_door || block == Block.air_switch);
|
||||
|
||||
ActivateablePhysics.DoDoors(lvl, (ushort)(x + 1), y, z, instant);
|
||||
ActivateablePhysics.DoDoors(lvl, (ushort)(x - 1), y, z, instant);
|
||||
@ -54,7 +55,7 @@ namespace MCGalaxy.BlockPhysics {
|
||||
}
|
||||
|
||||
static void ActivateODoor(Level lvl, ref Check C, int index) {
|
||||
byte block = Block.Props[lvl.blocks[index]].ODoorId;
|
||||
byte block = Block.Props[lvl.blocks[index]].ODoorId;
|
||||
if (block == lvl.blocks[C.b]) {
|
||||
lvl.AddUpdate(index, block, true);
|
||||
}
|
||||
@ -76,10 +77,18 @@ namespace MCGalaxy.BlockPhysics {
|
||||
|
||||
static void ActivateTDoor(Level lvl, int index) {
|
||||
byte block = lvl.blocks[index];
|
||||
if (!Block.Props[block].IsTDoor) return;
|
||||
|
||||
PhysicsArgs args = ActivateablePhysics.GetTDoorArgs(block);
|
||||
lvl.AddUpdate(index, Block.air, false, args);
|
||||
if (block != Block.custom_block) {
|
||||
if (!Block.Props[block].IsTDoor) return;
|
||||
|
||||
PhysicsArgs args = ActivateablePhysics.GetTDoorArgs(block, false);
|
||||
lvl.AddUpdate(index, Block.air, false, args);
|
||||
} else {
|
||||
block = lvl.GetExtTile(index);
|
||||
if (!lvl.CustomBlockProps[block].IsTDoor) return;
|
||||
|
||||
PhysicsArgs args = ActivateablePhysics.GetTDoorArgs(block, true);
|
||||
lvl.AddUpdate(index, Block.air, false, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class ExtLiquidPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public delegate bool ExtraInfoHandler(Level lvl, ref Check C);
|
||||
|
||||
@ -47,7 +47,11 @@ namespace MCGalaxy.BlockPhysics {
|
||||
if (C.data.Type2 == PhysicsArgs.Wait) C.data.Type2 = 0;
|
||||
|
||||
if (C.data.Door) {
|
||||
lvl.AddUpdate(C.b, C.data.Value2); C.data.ResetTypes();
|
||||
PhysicsArgs dArgs = default(PhysicsArgs);
|
||||
dArgs.ExtBlock = C.data.ExtBlock;
|
||||
lvl.AddUpdate(C.b, C.data.Value2, false, dArgs);
|
||||
|
||||
C.data.ResetTypes();
|
||||
C.data.Data = PhysicsArgs.RemoveFromChecks;
|
||||
}
|
||||
return false;
|
||||
|
@ -18,7 +18,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class FinitePhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class FirePhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class FireworkPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class HunterPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class LeafPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class LiquidPhysics {
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
using System;
|
||||
using MCGalaxy.Generator.Foilage;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class OtherPhysics {
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, Pack = 4)]
|
||||
public struct PhysicsArgs {
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class RocketPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class SimpleLiquidPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class SnakePhysics {
|
||||
|
||||
|
@ -19,7 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.Games;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class TntPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class TrainPhysics {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
|
||||
namespace MCGalaxy.BlockPhysics {
|
||||
namespace MCGalaxy.Blocks.Physics {
|
||||
|
||||
public static class ZombiePhysics {
|
||||
|
||||
|
@ -165,7 +165,8 @@ namespace MCGalaxy.Commands.CPE {
|
||||
if (!ExistsInScope(def, i, global)) continue;
|
||||
defsInScope.Add(def);
|
||||
}
|
||||
MultiPageOutput.Output(p, defsInScope, FormatBlock, cmd.Substring(1), "custom blocks", modifier, true);
|
||||
MultiPageOutput.Output(p, defsInScope, FormatBlock, cmd.Substring(1) + " list",
|
||||
"custom blocks", modifier, true);
|
||||
}
|
||||
|
||||
static string FormatBlock(BlockDefinition def, int i) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
|
||||
namespace MCGalaxy.Commands.Building {
|
||||
public sealed class CmdRestartPhysics : Command {
|
||||
|
@ -15,12 +15,10 @@
|
||||
or implied. See the Licenses for the specific language governing
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
|
||||
namespace MCGalaxy.Commands
|
||||
{
|
||||
public sealed class CmdC4 : Command
|
||||
{
|
||||
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; } }
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.Commands;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Drawing.Ops;
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Undo;
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.Drawing.Brushes;
|
||||
using MCGalaxy.Undo;
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
permissions and limitations under the Licenses.
|
||||
*/
|
||||
using System;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.Games;
|
||||
using MCGalaxy.SQL;
|
||||
|
||||
|
@ -19,7 +19,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using MCGalaxy.Blocks;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.Config;
|
||||
using MCGalaxy.Games;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
@ -18,7 +18,7 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using MCGalaxy.Blocks;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.Games;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
@ -19,7 +19,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using MCGalaxy.Blocks;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
using MCGalaxy.Commands;
|
||||
using MCGalaxy.Games;
|
||||
using MCGalaxy.SQL;
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MCGalaxy.BlockPhysics;
|
||||
using MCGalaxy.Blocks.Physics;
|
||||
|
||||
namespace MCGalaxy {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user