/// <summary> Retrieves the default physics block handler for the given block. </summary> internal static HandlePhysics GetPhysicsHandler(BlockID block, BlockProps[] props) { switch (block) { case Block.Door_Log_air: return(DoorPhysics.Do); case Block.Door_TNT_air: return(DoorPhysics.Do); case Block.Door_Green_air: return(DoorPhysics.Do); case Block.SnakeTail: return(SnakePhysics.DoTail); case Block.Snake: return(SnakePhysics.Do); case Block.RocketHead: return(RocketPhysics.Do); case Block.Fireworks: return(FireworkPhysics.Do); case Block.ZombieBody: return(ZombiePhysics.Do); case Block.ZombieHead: return(ZombiePhysics.DoHead); case Block.Creeper: return(ZombiePhysics.Do); case Block.Water: return(SimpleLiquidPhysics.DoWater); case Block.Deadly_ActiveWater: return(SimpleLiquidPhysics.DoWater); case Block.Lava: return(SimpleLiquidPhysics.DoLava); case Block.Deadly_ActiveLava: return(SimpleLiquidPhysics.DoLava); case Block.WaterDown: return(ExtLiquidPhysics.DoWaterfall); case Block.LavaDown: return(ExtLiquidPhysics.DoLavafall); case Block.WaterFaucet: return((Level lvl, ref PhysInfo C) => ExtLiquidPhysics.DoFaucet(lvl, ref C, Block.WaterDown)); case Block.LavaFaucet: return((Level lvl, ref PhysInfo C) => ExtLiquidPhysics.DoFaucet(lvl, ref C, Block.LavaDown)); case Block.FiniteWater: return(FinitePhysics.DoWaterOrLava); case Block.FiniteLava: return(FinitePhysics.DoWaterOrLava); case Block.FiniteFaucet: return(FinitePhysics.DoFaucet); case Block.Magma: return(ExtLiquidPhysics.DoMagma); case Block.Geyser: return(ExtLiquidPhysics.DoGeyser); case Block.FastLava: return(SimpleLiquidPhysics.DoFastLava); case Block.Deadly_FastLava: return(SimpleLiquidPhysics.DoFastLava); case Block.Air: return(AirPhysics.DoAir); case Block.Leaves: return(LeafPhysics.DoLeaf); case Block.Sapling: return(OtherPhysics.DoShrub); case Block.Fire: return(FirePhysics.Do); case Block.LavaFire: return(FirePhysics.Do); case Block.Sand: return(OtherPhysics.DoFalling); case Block.Gravel: return(OtherPhysics.DoFalling); case Block.FloatWood: return(OtherPhysics.DoFloatwood); case Block.Sponge: return((Level lvl, ref PhysInfo C) => OtherPhysics.DoSponge(lvl, ref C, false)); case Block.LavaSponge: return((Level lvl, ref PhysInfo C) => OtherPhysics.DoSponge(lvl, ref C, true)); // Special blocks that are not saved case Block.Air_Flood: return((Level lvl, ref PhysInfo C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Full, Block.Air_Flood)); case Block.Air_FloodLayer: return((Level lvl, ref PhysInfo C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Layer, Block.Air_FloodLayer)); case Block.Air_FloodDown: return((Level lvl, ref PhysInfo C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Down, Block.Air_FloodDown)); case Block.Air_FloodUp: return((Level lvl, ref PhysInfo C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Up, Block.Air_FloodUp)); case Block.TNT_Small: return(TntPhysics.DoSmallTnt); case Block.TNT_Big: return(TntPhysics.DoBigTnt); case Block.TNT_Nuke: return(TntPhysics.DoNukeTnt); case Block.TNT_Explosion: return(TntPhysics.DoTntExplosion); case Block.Train: return(TrainPhysics.Do); } HandlePhysics animalAI = AnimalAIHandler(props[block].AnimalAI); if (animalAI != null) { return(animalAI); } if (props[block].oDoorBlock != Block.Invalid) { return(DoorPhysics.oDoor); } if (props[block].GrassBlock != Block.Invalid) { return(OtherPhysics.DoDirtGrow); } if (props[block].DirtBlock != Block.Invalid) { return(OtherPhysics.DoGrassDie); } // TODO: should this be checking WaterKills/LavaKills // Adv physics updating anything placed next to water or lava if ((block >= Block.Red && block <= Block.RedMushroom) || block == Block.Wood || block == Block.Log || block == Block.Bookshelf) { return(OtherPhysics.DoOther); } return(null); }
internal static void SetupCorePhysicsHandlers() { physicsHandlers[Block.birdblack] = BirdPhysics.Do; physicsHandlers[Block.birdwhite] = BirdPhysics.Do; physicsHandlers[Block.birdlava] = BirdPhysics.Do; physicsHandlers[Block.birdwater] = BirdPhysics.Do; physicsHandlers[Block.birdred] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.air); physicsHandlers[Block.birdblue] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.air); physicsHandlers[Block.birdkill] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.air); physicsHandlers[Block.snaketail] = SnakePhysics.DoTail; physicsHandlers[Block.snake] = SnakePhysics.Do; physicsHandlers[Block.rockethead] = RocketPhysics.Do; physicsHandlers[Block.firework] = FireworkPhysics.Do; physicsHandlers[Block.zombiebody] = ZombiePhysics.Do; physicsHandlers[Block.zombiehead] = ZombiePhysics.DoHead; physicsHandlers[Block.creeper] = ZombiePhysics.Do; physicsHandlers[Block.fishbetta] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.water); physicsHandlers[Block.fishshark] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.water); physicsHandlers[Block.fishlavashark] = (Level lvl, ref Check C) => HunterPhysics.DoKiller(lvl, ref C, Block.lava); physicsHandlers[Block.fishgold] = (Level lvl, ref Check C) => HunterPhysics.DoFlee(lvl, ref C, Block.water); physicsHandlers[Block.fishsalmon] = (Level lvl, ref Check C) => HunterPhysics.DoFlee(lvl, ref C, Block.water); physicsHandlers[Block.fishsponge] = (Level lvl, ref Check C) => HunterPhysics.DoFlee(lvl, ref C, Block.water); physicsHandlers[Block.water] = SimpleLiquidPhysics.DoWater; physicsHandlers[Block.activedeathwater] = SimpleLiquidPhysics.DoWater; physicsHandlers[Block.lava] = SimpleLiquidPhysics.DoLava; physicsHandlers[Block.activedeathlava] = SimpleLiquidPhysics.DoLava; physicsHandlers[Block.WaterDown] = ExtLiquidPhysics.DoWaterfall; physicsHandlers[Block.LavaDown] = ExtLiquidPhysics.DoLavafall; physicsHandlers[Block.WaterFaucet] = (Level lvl, ref Check C) => ExtLiquidPhysics.DoFaucet(lvl, ref C, Block.WaterDown); physicsHandlers[Block.LavaFaucet] = (Level lvl, ref Check C) => ExtLiquidPhysics.DoFaucet(lvl, ref C, Block.LavaDown); physicsHandlers[Block.finiteWater] = FinitePhysics.DoWaterOrLava; physicsHandlers[Block.finiteLava] = FinitePhysics.DoWaterOrLava; physicsHandlers[Block.finiteFaucet] = FinitePhysics.DoFaucet; physicsHandlers[Block.magma] = ExtLiquidPhysics.DoMagma; physicsHandlers[Block.geyser] = ExtLiquidPhysics.DoGeyser; physicsHandlers[Block.lava_fast] = SimpleLiquidPhysics.DoFastLava; physicsHandlers[Block.fastdeathlava] = SimpleLiquidPhysics.DoFastLava; physicsHandlers[Block.air] = AirPhysics.DoAir; physicsHandlers[Block.dirt] = OtherPhysics.DoDirt; physicsHandlers[Block.leaf] = LeafPhysics.DoLeaf; physicsHandlers[Block.shrub] = OtherPhysics.DoShrub; physicsHandlers[Block.fire] = FirePhysics.Do; physicsHandlers[Block.lava_fire] = FirePhysics.Do; physicsHandlers[Block.sand] = OtherPhysics.DoFalling; physicsHandlers[Block.gravel] = OtherPhysics.DoFalling; physicsHandlers[Block.cobblestoneslab] = OtherPhysics.DoStairs; physicsHandlers[Block.staircasestep] = OtherPhysics.DoStairs; physicsHandlers[Block.wood_float] = OtherPhysics.DoFloatwood; physicsHandlers[Block.sponge] = (Level lvl, ref Check C) => OtherPhysics.DoSponge(lvl, ref C, false); physicsHandlers[Block.lava_sponge] = (Level lvl, ref Check C) => OtherPhysics.DoSponge(lvl, ref C, true); //Special blocks that are not saved physicsHandlers[Block.air_flood] = (Level lvl, ref Check C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Full, Block.air_flood); physicsHandlers[Block.air_flood_layer] = (Level lvl, ref Check C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Layer, Block.air_flood_layer); physicsHandlers[Block.air_flood_down] = (Level lvl, ref Check C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Down, Block.air_flood_down); physicsHandlers[Block.air_flood_up] = (Level lvl, ref Check C) => AirPhysics.DoFlood(lvl, ref C, AirFlood.Up, Block.air_flood_up); physicsHandlers[Block.smalltnt] = TntPhysics.DoSmallTnt; physicsHandlers[Block.bigtnt] = (Level lvl, ref Check C) => TntPhysics.DoLargeTnt(lvl, ref C, 1); physicsHandlers[Block.nuketnt] = (Level lvl, ref Check C) => TntPhysics.DoLargeTnt(lvl, ref C, 4); physicsHandlers[Block.tntexplosion] = TntPhysics.DoTntExplosion; physicsHandlers[Block.train] = TrainPhysics.Do; for (int i = 0; i < 256; i++) { //Adv physics updating anything placed next to water or lava if ((i >= Block.red && i <= Block.redmushroom) || i == Block.wood || i == Block.trunk || i == Block.bookcase) { physicsHandlers[i] = OtherPhysics.DoOther; continue; } if (Block.Props[i].ODoorId != Block.Invalid) { physicsHandlers[i] = DoorPhysics.oDoor; physicsDoorsHandlers[i] = DoorPhysics.oDoor; } } }