internal SpawnCondition(SpawnCondition parent, Func <NPCSpawnInfo, bool> condition, float blockWeight = 1f) { this.condition = condition; this.children = new List <SpawnCondition>(); this.blockWeight = blockWeight; parent.children.Add(this); }
static SpawnCondition() { NebulaTower = new SpawnCondition((info) => info.player.ZoneTowerNebula); VortexTower = new SpawnCondition((info) => info.player.ZoneTowerVortex); StardustTower = new SpawnCondition((info) => info.player.ZoneTowerStardust); SolarTower = new SpawnCondition((info) => info.player.ZoneTowerSolar); Sky = new SpawnCondition((info) => info.sky); Invasion = new SpawnCondition((info) => info.invasion); GoblinArmy = new SpawnCondition(Invasion, (info) => Main.invasionType == 1); FrostLegion = new SpawnCondition(Invasion, (info) => Main.invasionType == 2); Pirates = new SpawnCondition(Invasion, (info) => Main.invasionType == 3); MartianMadness = new SpawnCondition(Invasion, (info) => Main.invasionType == 4); Bartender = new SpawnCondition((info) => !NPC.savedBartender && DD2Event.ReadyToFindBartender && !NPC.AnyNPCs(NPCID.BartenderUnconscious) && !info.water, 1f / 80f); SpiderCave = new SpawnCondition((info) => GetTile(info).wall == WallID.SpiderUnsafe || info.spiderCave); DesertCave = new SpawnCondition((info) => (WallID.Sets.Conversion.HardenedSand[info.spawnTileType] || WallID.Sets.Conversion.Sandstone[GetTile(info).wall] || info.desertCave) && WorldGen.checkUnderground(info.spawnTileX, info.spawnTileY)); HardmodeJungleWater = new SpawnCondition((info) => Main.hardMode && info.water && info.player.ZoneJungle, 2f / 3f); HardmodeCrimsonWater = new SpawnCondition((info) => Main.hardMode && info.water && info.player.ZoneCrimson, 8f / 9f); Ocean = new SpawnCondition((info) => info.water && (info.spawnTileX <250 || info.spawnTileX> Main.maxTilesX - 250) && Main.tileSand[info.spawnTileType] && info.spawnTileY < Main.rockLayer); OceanAngler = new SpawnCondition(Ocean, (info) => !NPC.savedAngler && !NPC.AnyNPCs(NPCID.SleepingAngler) && WaterSurface(info)); OceanMonster = new SpawnCondition(Ocean, (info) => true); BeachAngler = new SpawnCondition((info) => !info.water && !NPC.savedAngler && !NPC.AnyNPCs(NPCID.SleepingAngler) && (info.spawnTileX <340 || info.spawnTileX> Main.maxTilesX - 340) && Main.tileSand[info.spawnTileType] && info.spawnTileY < Main.worldSurface); JungleWater = new SpawnCondition((info) => info.water && info.spawnTileType == TileID.JungleGrass); CavePiranha = new SpawnCondition((info) => info.water && info.spawnTileY > Main.rockLayer, 0.5f); CaveJellyfish = new SpawnCondition((info) => info.water && info.spawnTileY > Main.worldSurface, 1f / 3f); WaterCritter = new SpawnCondition((info) => info.water, 0.25f); CorruptWaterCritter = new SpawnCondition(WaterCritter, (info) => info.player.ZoneCorrupt); OverworldWaterCritter = new SpawnCondition(WaterCritter, (info) => info.spawnTileY < Main.worldSurface && info.spawnTileY > 50 && Main.dayTime, 2f / 3f); OverworldWaterSurfaceCritter = new SpawnCondition(OverworldWaterCritter, WaterSurface); OverworldUnderwaterCritter = new SpawnCondition(OverworldWaterCritter, (info) => true); DefaultWaterCritter = new SpawnCondition(WaterCritter, (info) => true); BoundCaveNPC = new SpawnCondition((info) => !info.water && info.spawnTileY >= Main.rockLayer && info.spawnTileY < Main.maxTilesY - 210, 1f / 20f); TownCritter = new SpawnCondition((info) => info.playerInTown); TownWaterCritter = new SpawnCondition(TownCritter, (info) => info.water); TownOverworldWaterCritter = new SpawnCondition(TownWaterCritter, (info) => info.spawnTileY < Main.worldSurface && info.spawnTileY > 50 && Main.dayTime, 2f / 3f); TownOverworldWaterSurfaceCritter = new SpawnCondition(TownOverworldWaterCritter, WaterSurface); TownOverworldUnderwaterCritter = new SpawnCondition(TownOverworldWaterCritter, (info) => true); TownDefaultWaterCritter = new SpawnCondition(TownWaterCritter, (info) => true); TownSnowCritter = new SpawnCondition(TownCritter, (info) => info.spawnTileType == TileID.SnowBlock || info.spawnTileType == TileID.IceBlock); TownJungleCritter = new SpawnCondition(TownCritter, (info) => info.spawnTileType == TileID.JungleGrass); TownGeneralCritter = new SpawnCondition(TownCritter, (info) => info.spawnTileType == TileID.Grass || info.spawnTileType == TileID.HallowedGrass || info.spawnTileY > Main.worldSurface); Dungeon = new SpawnCondition((info) => info.player.ZoneDungeon); DungeonGuardian = new SpawnCondition(Dungeon, (info) => !NPC.downedBoss3); DungeonNormal = new SpawnCondition(Dungeon, (info) => true); Meteor = new SpawnCondition((info) => info.player.ZoneMeteor); OldOnesArmy = new SpawnCondition((info) => DD2Event.Ongoing && info.player.ZoneOldOneArmy); FrostMoon = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface && !Main.dayTime && Main.snowMoon); PumpkinMoon = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface && !Main.dayTime && Main.pumpkinMoon); SolarEclipse = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface && Main.dayTime && Main.eclipse); HardmodeMushroomWater = new SpawnCondition((info) => Main.hardMode && info.spawnTileType == TileID.MushroomGrass && info.water); OverworldMushroom = new SpawnCondition((info) => info.spawnTileType == TileID.MushroomGrass && info.spawnTileY <= Main.worldSurface, 2f / 3f); UndergroundMushroom = new SpawnCondition((info) => info.spawnTileType == TileID.MushroomGrass && Main.hardMode && info.spawnTileY >= Main.worldSurface, 2f / 3f); CorruptWorm = new SpawnCondition((info) => info.player.ZoneCorrupt && !info.playerSafe, 1f / 65f); UndergroundMimic = new SpawnCondition((info) => Main.hardMode && info.spawnTileY > Main.worldSurface, 1f / 70f); OverworldMimic = new SpawnCondition((info) => Main.hardMode && GetTile(info).wall == WallID.DirtUnsafe, 0.05f); Wraith = new SpawnCondition((info) => Main.hardMode && info.spawnTileY <= Main.worldSurface && !Main.dayTime, 0.05f); WraithNewMoon = new SpawnCondition((info) => Main.hardMode && info.spawnTileY <= Main.worldSurface && !Main.dayTime && Main.moonPhase == 4, 0.2f); HoppinJack = new SpawnCondition((info) => Main.hardMode && Main.halloween && info.spawnTileY <= Main.worldSurface && !Main.dayTime, 0.1f); DoctorBones = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass && !Main.dayTime, 0.002f); LacBeetle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass && info.spawnTileY > Main.worldSurface, 1f / 60f); WormCritter = new SpawnCondition((info) => info.spawnTileY > Main.worldSurface && info.spawnTileY < Main.maxTilesY - 210 && !info.player.ZoneSnow && !info.player.ZoneCrimson && !info.player.ZoneCorrupt && !info.player.ZoneJungle && !info.player.ZoneHoly, 1f / 8f); MouseCritter = new SpawnCondition((info) => info.spawnTileY > Main.worldSurface && info.spawnTileY < Main.maxTilesY - 210 && !info.player.ZoneSnow && !info.player.ZoneCrimson && !info.player.ZoneCorrupt && !info.player.ZoneJungle && !info.player.ZoneHoly, 1f / 13f); SnailCritter = new SpawnCondition((info) => info.spawnTileY > Main.worldSurface && info.spawnTileY < (Main.rockLayer + Main.maxTilesY) / 2 && !info.player.ZoneSnow && !info.player.ZoneCrimson && !info.player.ZoneCorrupt && !info.player.ZoneHoly, 1f / 13f); FrogCritter = new SpawnCondition((info) => info.spawnTileY < Main.worldSurface && info.player.ZoneJungle, 1f / 9f); HardmodeJungle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass && Main.hardMode, 2f / 3f); JungleTemple = new SpawnCondition((info) => info.spawnTileType == TileID.LihzahrdBrick && info.lihzahrd); UndergroundJungle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass && info.spawnTileY > (Main.worldSurface + Main.rockLayer) / 2); SurfaceJungle = new SpawnCondition((info) => info.spawnTileType == TileID.JungleGrass, 11f / 32f); SandstormEvent = new SpawnCondition((info) => Sandstorm.Happening && info.player.ZoneSandstorm && TileID.Sets.Conversion.Sand[info.spawnTileType] && NPC.Spawning_SandstoneCheck(info.spawnTileX, info.spawnTileY)); Mummy = new SpawnCondition((info) => Main.hardMode && info.spawnTileType == TileID.Sand, 1f / 3f); DarkMummy = new SpawnCondition((info) => Main.hardMode && (info.spawnTileType == TileID.Ebonsand || info.spawnTileType == TileID.Crimsand), 0.5f); LightMummy = new SpawnCondition((info) => Main.hardMode && info.spawnTileType == TileID.Pearlsand, 0.5f); OverworldHallow = new SpawnCondition((info) => Main.hardMode && !info.water && info.spawnTileY < Main.rockLayer && (info.spawnTileType == TileID.Pearlsand || info.spawnTileType == TileID.Pearlstone || info.spawnTileType == TileID.HallowedGrass || info.spawnTileType == TileID.HallowedIce)); EnchantedSword = new SpawnCondition((info) => !info.playerSafe && Main.hardMode && !info.water && info.spawnTileY >= Main.rockLayer && (info.spawnTileType == TileID.Pearlsand || info.spawnTileType == TileID.Pearlstone || info.spawnTileType == TileID.HallowedGrass || info.spawnTileType == TileID.HallowedIce), 0.02f); Crimson = new SpawnCondition((info) => (info.spawnTileType == TileID.Crimtane && info.player.ZoneCrimson) || info.spawnTileType == TileID.FleshGrass || info.spawnTileType == TileID.FleshIce || info.spawnTileType == TileID.Crimstone || info.spawnTileType == TileID.Crimsand); Corruption = new SpawnCondition((info) => (info.spawnTileType == TileID.Demonite && info.player.ZoneCorrupt) || info.spawnTileType == TileID.CorruptGrass || info.spawnTileType == TileID.Ebonstone || info.spawnTileType == TileID.Ebonsand || info.spawnTileType == TileID.CorruptIce); Overworld = new SpawnCondition((info) => info.spawnTileY <= Main.worldSurface); IceGolem = new SpawnCondition(Overworld, (info) => info.player.ZoneSnow && Main.hardMode && Main.cloudAlpha > 0f && !NPC.AnyNPCs(NPCID.IceGolem), 0.05f); RainbowSlime = new SpawnCondition(Overworld, (info) => info.player.ZoneHoly && Main.hardMode && Main.cloudAlpha > 0f && !NPC.AnyNPCs(NPCID.RainbowSlime), 0.05f); AngryNimbus = new SpawnCondition(Overworld, (info) => !info.player.ZoneSnow && Main.hardMode && Main.cloudAlpha > 0f && NPC.CountNPCS(NPCID.AngryNimbus) < 2, 0.1f); //TODO? - martian probe OverworldDay = new SpawnCondition(Overworld, (info) => Main.dayTime); OverworldDaySnowCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info) && (GetTile(info).type == TileID.SnowBlock || GetTile(info).type == TileID.IceBlock), 1f / 15f); OverworldDayGrassCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info) && (GetTile(info).type == TileID.Grass || GetTile(info).type == TileID.HallowedGrass), 1f / 15f); OverworldDaySandCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info) && GetTile(info).type == TileID.Sand, 1f / 15f); OverworldMorningBirdCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info) && Main.time < 18000.0 && (GetTile(info).type == TileID.Grass || GetTile(info).type == TileID.HallowedGrass), 0.25f); OverworldDayBirdCritter = new SpawnCondition(OverworldDay, (info) => InnerThird(info) && (GetTile(info).type == TileID.Grass || GetTile(info).type == TileID.HallowedGrass || GetTile(info).type == TileID.SnowBlock), 1f / 15f); }