Core: Get custom doors working, mostly.

This commit is contained in:
UnknownShadow200 2016-10-24 15:00:10 +11:00
parent ad7b0d4d1a
commit aa17aebbe2
38 changed files with 98 additions and 59 deletions

View File

@ -16,7 +16,7 @@
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using System; using System;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
namespace MCGalaxy.Blocks { namespace MCGalaxy.Blocks {

View File

@ -16,7 +16,7 @@
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using System; using System;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
namespace MCGalaxy.Blocks { namespace MCGalaxy.Blocks {
@ -76,8 +76,14 @@ namespace MCGalaxy.Blocks {
internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) { 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; 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); p.level.Blockchange(x, y, z, physForm, false, args);
} else { } else {
p.RevertBlock(x, y, z); p.RevertBlock(x, y, z);
@ -100,6 +106,10 @@ namespace MCGalaxy.Blocks {
return WalkthroughBehaviour.Portal(p, block, x, y, z, false); return WalkthroughBehaviour.Portal(p, block, x, y, z, false);
} else if (p.level.CustomBlockProps[extBlock].IsMessageBlock) { } else if (p.level.CustomBlockProps[extBlock].IsMessageBlock) {
return WalkthroughBehaviour.MessageBlock(p, block, x, y, z, false); 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); p.ChangeBlock(x, y, z, Block.air, 0);

View File

@ -15,7 +15,7 @@
or implied. See the Licenses for the specific language governing or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using System; using System;
namespace MCGalaxy.Blocks { namespace MCGalaxy.Blocks {

View File

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.SQL; using MCGalaxy.SQL;
namespace MCGalaxy.Blocks { namespace MCGalaxy.Blocks {
@ -26,8 +26,14 @@ namespace MCGalaxy.Blocks {
internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) { internal static bool Door(Player p, byte block, ushort x, ushort y, ushort z) {
if (p.level.physics == 0) return true; 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; 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); p.level.Blockchange(x, y, z, physForm, false, args);
return true; return true;
} }
@ -43,6 +49,9 @@ namespace MCGalaxy.Blocks {
return Portal(p, block, x, y, z, true); return Portal(p, block, x, y, z, true);
} else if (p.level.CustomBlockProps[extBlock].IsMessageBlock) { } else if (p.level.CustomBlockProps[extBlock].IsMessageBlock) {
return MessageBlock(p, block, x, y, z, true); 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; return false;
} }

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class AIPhysics { public static class AIPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class ActivateablePhysics { public static class ActivateablePhysics {
/// <summary> Activates fireworks, rockets, and TNT in 1 block radius around (x, y, z) </summary> /// <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) { public static void DoDoors(Level lvl, ushort x, ushort y, ushort z, bool instant) {
int index = lvl.PosToInt(x, y, z); int index = lvl.PosToInt(x, y, z);
if (index < 0) return; 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; byte physForm;
PhysicsArgs args = GetDoorArgs(b, out physForm); PhysicsArgs args = GetDoorArgs(block, ext, out physForm);
if (!instant) lvl.AddUpdate(index, physForm, false, args); if (!instant) lvl.AddUpdate(index, physForm, false, args);
else lvl.Blockchange(index, physForm, false, args); else lvl.Blockchange(index, physForm, false, args);
} else if (Block.Props[b].IsTDoor) { } else if (props[block].IsTDoor) {
PhysicsArgs args = GetTDoorArgs(b); PhysicsArgs args = GetTDoorArgs(block, ext);
lvl.AddUpdate(index, Block.air, false, args); lvl.AddUpdate(index, Block.air, false, args);
} else { } else {
byte oDoor = Block.Props[b].ODoorId; byte oDoor = props[block].ODoorId;
if (oDoor != Block.Invalid) if (oDoor != Block.Invalid)
lvl.AddUpdate(index, oDoor, true); lvl.AddUpdate(index, oDoor, true);
} }
@ -86,7 +93,8 @@ namespace MCGalaxy.BlockPhysics {
args.ExtBlock = isExt; args.ExtBlock = isExt;
physForm = Block.door_tree_air; // air 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; args.Value1 = 4 - 1;
} else if (raw == Block.door_green) { } else if (raw == Block.door_green) {
physForm = Block.door_green_air; // red wool physForm = Block.door_green_air; // red wool

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public enum AirFlood { Full, Layer, Down, Up, } public enum AirFlood { Full, Layer, Down, Up, }
public static class AirPhysics { public static class AirPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class BirdPhysics { public static class BirdPhysics {
public static void Do(Level lvl, ref Check C) { public static void Do(Level lvl, ref Check C) {

View File

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class C4Physics { public static class C4Physics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class DoorPhysics { public static class DoorPhysics {
// Change anys door blocks nearby into air forms // Change anys door blocks nearby into air forms
@ -25,7 +25,8 @@ namespace MCGalaxy.BlockPhysics {
ushort x, y, z; ushort x, y, z;
lvl.IntToPos(C.b, out x, out y, out z); lvl.IntToPos(C.b, out x, out y, out z);
byte block = C.data.Value2; 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);
ActivateablePhysics.DoDoors(lvl, (ushort)(x - 1), y, z, instant); ActivateablePhysics.DoDoors(lvl, (ushort)(x - 1), y, z, instant);
@ -76,10 +77,18 @@ namespace MCGalaxy.BlockPhysics {
static void ActivateTDoor(Level lvl, int index) { static void ActivateTDoor(Level lvl, int index) {
byte block = lvl.blocks[index]; byte block = lvl.blocks[index];
if (block != Block.custom_block) {
if (!Block.Props[block].IsTDoor) return; if (!Block.Props[block].IsTDoor) return;
PhysicsArgs args = ActivateablePhysics.GetTDoorArgs(block); 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); lvl.AddUpdate(index, Block.air, false, args);
} }
} }
} }
}

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class ExtLiquidPhysics { public static class ExtLiquidPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public delegate bool ExtraInfoHandler(Level lvl, ref Check C); 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.Type2 == PhysicsArgs.Wait) C.data.Type2 = 0;
if (C.data.Door) { 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; C.data.Data = PhysicsArgs.RemoveFromChecks;
} }
return false; return false;

View File

@ -18,7 +18,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class FinitePhysics { public static class FinitePhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class FirePhysics { public static class FirePhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class FireworkPhysics { public static class FireworkPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class HunterPhysics { public static class HunterPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class LeafPhysics { public static class LeafPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class LiquidPhysics { public static class LiquidPhysics {

View File

@ -18,7 +18,7 @@
using System; using System;
using MCGalaxy.Generator.Foilage; using MCGalaxy.Generator.Foilage;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class OtherPhysics { public static class OtherPhysics {

View File

@ -18,7 +18,7 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
[StructLayout(LayoutKind.Sequential, Pack = 4)] [StructLayout(LayoutKind.Sequential, Pack = 4)]
public struct PhysicsArgs { public struct PhysicsArgs {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class RocketPhysics { public static class RocketPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class SimpleLiquidPhysics { public static class SimpleLiquidPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class SnakePhysics { public static class SnakePhysics {

View File

@ -19,7 +19,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.Games; using MCGalaxy.Games;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class TntPhysics { public static class TntPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class TrainPhysics { public static class TrainPhysics {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
namespace MCGalaxy.BlockPhysics { namespace MCGalaxy.Blocks.Physics {
public static class ZombiePhysics { public static class ZombiePhysics {

View File

@ -165,7 +165,8 @@ namespace MCGalaxy.Commands.CPE {
if (!ExistsInScope(def, i, global)) continue; if (!ExistsInScope(def, i, global)) continue;
defsInScope.Add(def); 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) { static string FormatBlock(BlockDefinition def, int i) {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
namespace MCGalaxy.Commands.Building { namespace MCGalaxy.Commands.Building {
public sealed class CmdRestartPhysics : Command { public sealed class CmdRestartPhysics : Command {

View File

@ -15,12 +15,10 @@
or implied. See the Licenses for the specific language governing or implied. See the Licenses for the specific language governing
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
namespace MCGalaxy.Commands namespace MCGalaxy.Commands {
{ public sealed class CmdC4 : Command {
public sealed class CmdC4 : Command
{
public override string name { get { return "c4"; } } public override string name { get { return "c4"; } }
public override string shortcut { get { return ""; } } public override string shortcut { get { return ""; } }
public override string type { get { return CommandTypes.Other; } } public override string type { get { return CommandTypes.Other; } }

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.Commands; using MCGalaxy.Commands;
using MCGalaxy.Drawing.Brushes; using MCGalaxy.Drawing.Brushes;
using MCGalaxy.Drawing.Ops; using MCGalaxy.Drawing.Ops;

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.Drawing.Brushes; using MCGalaxy.Drawing.Brushes;
using MCGalaxy.Undo; using MCGalaxy.Undo;

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.Drawing.Brushes; using MCGalaxy.Drawing.Brushes;
using MCGalaxy.Undo; using MCGalaxy.Undo;

View File

@ -16,7 +16,7 @@
permissions and limitations under the Licenses. permissions and limitations under the Licenses.
*/ */
using System; using System;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
namespace MCGalaxy { namespace MCGalaxy {

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.Games; using MCGalaxy.Games;
using MCGalaxy.SQL; using MCGalaxy.SQL;

View File

@ -19,7 +19,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using MCGalaxy.Blocks; using MCGalaxy.Blocks;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.Config; using MCGalaxy.Config;
using MCGalaxy.Games; using MCGalaxy.Games;
using Timer = System.Timers.Timer; using Timer = System.Timers.Timer;

View File

@ -18,7 +18,7 @@
using System; using System;
using System.Threading; using System.Threading;
using MCGalaxy.Blocks; using MCGalaxy.Blocks;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.Games; using MCGalaxy.Games;
namespace MCGalaxy { namespace MCGalaxy {

View File

@ -19,7 +19,7 @@ using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading; using System.Threading;
using MCGalaxy.Blocks; using MCGalaxy.Blocks;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
using MCGalaxy.Commands; using MCGalaxy.Commands;
using MCGalaxy.Games; using MCGalaxy.Games;
using MCGalaxy.SQL; using MCGalaxy.SQL;

View File

@ -17,7 +17,7 @@
*/ */
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using MCGalaxy.BlockPhysics; using MCGalaxy.Blocks.Physics;
namespace MCGalaxy { namespace MCGalaxy {