public static void DoAir(Level lvl, ref PhysInfo C)
        {
            if (C.Data.Type1 == PhysicsArgs.Custom)
            {
                DoorPhysics.Do(lvl, ref C); return;
            }

            ushort x = C.X, y = C.Y, z = C.Z;

            ActivateablePhysics.CheckNeighbours(lvl, x, y, z);
            ActivateablePhysics.CheckAt(lvl, x, (ushort)(y - 1), z);

            //Edge of map water
            if (lvl.Config.EdgeWater && (y < lvl.Config.EdgeLevel && y >= (lvl.Config.EdgeLevel + lvl.Config.SidesOffset)))
            {
                if (x == 0 || x == lvl.Width - 1 || z == 0 || z == lvl.Length - 1)
                {
                    BlockID horizon = lvl.Config.HorizonBlock;
                    lvl.AddUpdate(C.Index, horizon == Block.Invalid ? Block.Water : horizon);
                }
            }
            if (!C.Data.HasWait)
            {
                C.Data.Data = PhysicsArgs.RemoveFromChecks;
            }
        }
Example #2
0
        public static bool DoNormal(Level lvl, ref Check C)
        {
            if (C.data.Type1 == PhysicsArgs.Custom)
            {
                return(true);
            }
            if (!C.data.HasWait && lvl.blocks[C.b] == Block.air)
            {
                C.data.ResetTypes();
            }

            ExtraInfoArgs args = default(ExtraInfoArgs);

            ParseType(C.data.Type1, ref args, C.data.Value1);
            ParseType(C.data.Type2, ref args, C.data.Value2);
            args.ExtBlock = C.data.ExtBlock;

            if (args.Wait)
            {
                if (C.data.Door && C.data.Data == 0)
                {
                    bool tdoor = false;
                    if (!C.data.ExtBlock)
                    {
                        tdoor = Block.Props[C.data.Value2].IsTDoor;
                    }
                    else
                    {
                        tdoor = lvl.CustomBlockProps[C.data.Value2].IsTDoor;
                    }

                    if (tdoor)
                    {
                        DoorPhysics.tDoor(lvl, ref C);
                    }
                    else
                    {
                        DoorPhysics.Door(lvl, ref C);
                    }
                }

                if (C.data.Data <= args.WaitTime)
                {
                    C.data.Data++; return(true);
                }
                if (C.data.Type1 == PhysicsArgs.Wait)
                {
                    C.data.Type1 = 0;
                }
                if (C.data.Type2 == PhysicsArgs.Wait)
                {
                    C.data.Type2 = 0;
                }
            }
            DoOther(lvl, ref C, ref args);
            return(false);
        }
Example #3
0
        public static bool DoDoorsOnly(Level lvl, ref Check C)
        {
            if (C.data.Type1 == PhysicsArgs.Custom)
            {
                return(true);
            }
            if (!C.data.HasWait && lvl.blocks[C.b] == Block.Air)
            {
                C.data.ResetTypes();
            }
            if (!C.data.HasWait)
            {
                return(false);
            }

            if (C.data.Door && C.data.Data == 0)
            {
                int  i     = C.data.Value2 + (C.data.ExtBlock ? Block.Count : 0);
                bool tdoor = lvl.Props[i].IsTDoor;

                if (tdoor)
                {
                    DoorPhysics.tDoor(lvl, ref C);
                }
                else
                {
                    DoorPhysics.Door(lvl, ref C);
                }
            }

            int waitTime = 0;

            if (C.data.Type1 == PhysicsArgs.Wait)
            {
                waitTime = C.data.Value1;
            }
            if (C.data.Type2 == PhysicsArgs.Wait)
            {
                waitTime = C.data.Value2;
            }

            if (C.data.Data <= waitTime)
            {
                C.data.Data++; return(true);
            }
            if (C.data.Type1 == PhysicsArgs.Wait)
            {
                C.data.Type1 = 0;
            }
            if (C.data.Type2 == PhysicsArgs.Wait)
            {
                C.data.Type2 = 0;
            }

            if (C.data.Door)
            {
                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);
        }