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.
*/
using System;
using MCGalaxy.BlockPhysics;
using MCGalaxy.Blocks.Physics;
namespace MCGalaxy.Blocks {

View File

@ -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);

View File

@ -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 {

View File

@ -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;
}

View File

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

View File

@ -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

View File

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

View File

@ -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) {

View File

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

View File

@ -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);
}
}
}
}

View File

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

View File

@ -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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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) {

View File

@ -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 {

View File

@ -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; } }

View File

@ -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;

View File

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

View File

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

View File

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

View File

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

View File

@ -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;

View File

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

View File

@ -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;

View File

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