public void HandleAmbientSound() { AmbienceTimer.Update(DwarfTime.LastTime); if (!AmbienceTimer.HasTriggered && !firstAmbience) { return; } firstAmbience = false; // Before doing anything, determine if there is a rain or snow storm. if (Weather.IsRaining()) { PlaySpecialAmbient("sfx_amb_rain_storm"); return; } if (Weather.IsSnowing()) { PlaySpecialAmbient("sfx_amb_snow_storm"); return; } // First check voxels to see if we're underground or underwater. var vox = VoxelHelpers.FindFirstVisibleVoxelOnScreenRay(ChunkManager, GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2, Renderer.Camera, GraphicsDevice.Viewport, 100.0f, false, null); if (vox.IsValid) { float height = WaterRenderer.GetTotalWaterHeightCells(ChunkManager, vox); if (height > 0) { PlaySpecialAmbient("sfx_amb_ocean"); return; } else { // Unexplored voxels assumed to be cave. if (vox.IsValid && !vox.IsExplored) { PlaySpecialAmbient("sfx_amb_cave"); return; } var above = VoxelHelpers.GetVoxelAbove(vox); // Underground, do the cave test. if (above.IsValid && above.IsEmpty && above.Sunlight == false) { PlaySpecialAmbient("sfx_amb_cave"); return; } } } else { return; } // Now check for biome ambience. var pos = vox.WorldPosition; if (Overworld.Map.GetBiomeAt(pos, Overworld.InstanceSettings.Origin).HasValue(out var biome)) { if (!string.IsNullOrEmpty(biome.DayAmbience)) { if (prevAmbience[0] != biome.DayAmbience) { if (!string.IsNullOrEmpty(prevAmbience[0])) { SoundManager.StopAmbience(prevAmbience[0]); prevAmbience[0] = null; } if (!string.IsNullOrEmpty(prevAmbience[1])) { SoundManager.StopAmbience(prevAmbience[1]); prevAmbience[1] = null; } SoundManager.PlayAmbience(biome.DayAmbience); } prevAmbience[0] = biome.DayAmbience; } if (!string.IsNullOrEmpty(biome.NightAmbience) && prevAmbience[1] != biome.NightAmbience) { prevAmbience[1] = biome.NightAmbience; SoundManager.PlayAmbience(biome.NightAmbience); } } }
public static void Initialize(WorldManager world) { World = world; RegisterEntity("Crate", (position, data) => new Crate(world.ComponentManager, position)); RegisterEntity("Balloon", (position, data) => CreateBalloon(position + new Vector3(0, 1000, 0), position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, null, world.PlayerFaction)); RegisterEntity("Work Pile", (position, data) => new WorkPile(world.ComponentManager, position)); RegisterEntity("Pine Tree", (position, data) => new Tree("Pine Tree", world.ComponentManager, position, "pine", ResourceLibrary.ResourceType.PineCone, data.GetData("Scale", 1.0f))); RegisterEntity("Snow Pine Tree", (position, data) => new Tree("Pine Tree", world.ComponentManager, position, "snowpine", ResourceLibrary.ResourceType.PineCone, data.GetData("Scale", 1.0f))); RegisterEntity("Palm Tree", (position, data) => new Tree("Palm Tree", world.ComponentManager, position, "palm", ResourceLibrary.ResourceType.Coconut, data.GetData("Scale", 1.0f))); RegisterEntity("Apple Tree", (position, data) => new Tree("Apple Tree", world.ComponentManager, position, "appletree", ResourceLibrary.ResourceType.Apple, data.GetData("Scale", 1.0f))); RegisterEntity("Cactus", (position, data) => new Cactus(world.ComponentManager, position, "cactus", data.GetData("Scale", 1.0f))); RegisterEntity("Berry Bush", (position, data) => new Bush(world.ComponentManager, position, "berrybush", data.GetData("Scale", 1.0f))); RegisterEntity("Bird", (position, data) => new Bird(ContentPaths.Entities.Animals.Birds.GetRandomBird(), position, world.ComponentManager, "Bird")); RegisterEntity("Bat", (position, data) => new Bat(world.ComponentManager, position)); RegisterEntity("Scorpion", (position, data) => new Scorpion(ContentPaths.Entities.Animals.Scorpion.scorption_animation, position, world.ComponentManager, "Scorpion")); RegisterEntity("Spider", (position, data) => new Spider(world.ComponentManager, ContentPaths.Entities.Animals.Spider.spider_animation, position)); RegisterEntity("Frog", (position, data) => new Frog(ContentPaths.Entities.Animals.Frog.frog0_animation, position, world.ComponentManager, "Frog")); RegisterEntity("Tree Frog", (position, data) => new Frog(ContentPaths.Entities.Animals.Frog.frog1_animation, position, world.ComponentManager, "Frog")); RegisterEntity("Brown Rabbit", (position, data) => new Rabbit(ContentPaths.Entities.Animals.Rabbit.rabbit0_animation, position, world.ComponentManager, "Brown Rabbit")); RegisterEntity("White Rabbit", (position, data) => new Rabbit(ContentPaths.Entities.Animals.Rabbit.rabbit1_animation, position, world.ComponentManager, "White Rabbit")); RegisterEntity("Deer", (position, data) => new Deer(ContentPaths.Entities.Animals.Deer.deer, position, world.ComponentManager, "Deer")); RegisterEntity("Dwarf", (position, data) => GenerateDwarf(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, world.PlayerFaction, world.PlanService, "Player", JobLibrary.Classes[JobLibrary.JobType.Worker], 0)); //RegisterEntity("TestDwarf", (position, data) => GenerateTestDwarf(position)); //RegisterEntity("TestGoblin", (position, data) => GenerateTestGoblin(position)); //RegisterEntity("TestSkeleton", (position, data) => GenerateTestSeketon(position)); //RegisterEntity("TestMoleman", (position, data) => GenerateTestMoleman(position)); RegisterEntity("AxeDwarf", (position, data) => GenerateDwarf(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, world.PlayerFaction, world.PlanService, "Player", JobLibrary.Classes[JobLibrary.JobType.AxeDwarf], 0)); RegisterEntity("CraftsDwarf", (position, data) => GenerateDwarf(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, world.PlayerFaction, world.PlanService, "Player", JobLibrary.Classes[JobLibrary.JobType.CraftsDwarf], 0)); RegisterEntity("Wizard", (position, data) => GenerateDwarf(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, world.PlayerFaction, world.PlanService, "Player", JobLibrary.Classes[JobLibrary.JobType.Wizard], 0)); RegisterEntity("MusketDwarf", (position, data) => GenerateDwarf(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, world.PlayerFaction, world.PlanService, "Player", JobLibrary.Classes[JobLibrary.JobType.MusketDwarf], 0)); RegisterEntity("Moleman", (position, data) => GenerateMoleman(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, World.Factions.Factions["Molemen"], world.PlanService, "Molemen")); RegisterEntity("Goblin", (position, data) => GenerateGoblin(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, World.Factions.Factions["Goblins"], world.PlanService, "Goblins")); RegisterEntity("Skeleton", (position, data) => GenerateSkeleton(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, World.Factions.Factions["Undead"], world.PlanService, "Undead")); RegisterEntity("Necromancer", (position, data) => GenerateNecromancer(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager, world.Camera, World.Factions.Factions["Undead"], world.PlanService, "Undead")); RegisterEntity("Bed", (position, data) => new Bed(world.ComponentManager, position)); RegisterEntity("Barrel", (position, data) => new Barrel(world.ComponentManager, position)); RegisterEntity("Bear Trap", (position, data) => new BearTrap(world.ComponentManager, position)); RegisterEntity("Lamp", (position, data) => new Lamp(world.ComponentManager, position)); RegisterEntity("Table", (position, data) => new Table(world.ComponentManager, position)); RegisterEntity("Chair", (position, data) => new Chair(world.ComponentManager, position)); RegisterEntity("Flag", (position, data) => new Flag(world.ComponentManager, position, world.PlayerCompany.Information)); RegisterEntity("Mushroom", (position, data) => new Mushroom(world.ComponentManager, position, ContentPaths.Entities.Plants.mushroom, ResourceLibrary.ResourceType.Mushroom, 2, false)); RegisterEntity("Cave Mushroom", (position, data) => new Mushroom(world.ComponentManager, position, ContentPaths.Entities.Plants.cavemushroom, ResourceLibrary.ResourceType.CaveMushroom, 4, true)); RegisterEntity("Wheat", (position, data) => new Wheat(world.ComponentManager, position)); RegisterEntity("Kitchen Table", (position, data) => new Table(world.ComponentManager, position, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32), new Point(0, 7)) { Tags = new List <string>() { "Cutting Board" } }); RegisterEntity("Books", (position, data) => new Table(world.ComponentManager, position, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32), new Point(0, 4)) { Tags = new List <string>() { "Research" }, Battery = new Table.ManaBattery() { Charge = 0.0f, MaxCharge = 100.0f } }); RegisterEntity("Potions", (position, data) => new Table(world.ComponentManager, position, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32), new Point(1, 4)) { Tags = new List <string>() { "Research" }, Battery = new Table.ManaBattery() { Charge = 0.0f, MaxCharge = 100.0f } }); RegisterEntity("Anvil", (position, data) => new Anvil(world.ComponentManager, position)); RegisterEntity("Forge", (position, data) => new Forge(world.ComponentManager, position)); RegisterEntity("Elf", (position, data) => GenerateElf(world, position, World.Factions.Factions["Elf"], "Elf")); RegisterEntity("Demon", (position, data) => GenerateDemon(world, position, World.Factions.Factions["Demon"], "Demon")); RegisterEntity("Arrow", (position, data) => new ArrowProjectile(world.ComponentManager, position, data.GetData("Velocity", Vector3.Up * 10 + MathFunctions.RandVector3Box(-10, 10, 0, 0, -10, 10)), data.GetData <Body>("Target", null))); RegisterEntity("Bullet", (position, data) => new BulletProjectile(world.ComponentManager, position, data.GetData("Velocity", Vector3.Up * 10 + MathFunctions.RandVector3Box(-10, 10, 0, 0, -10, 10)), data.GetData <Body>("Target", null))); RegisterEntity("Web", (position, data) => new WebProjectile(world.ComponentManager, position, data.GetData("Velocity", Vector3.Up * 10 + MathFunctions.RandVector3Box(-10, 10, 0, 0, -10, 10)), data.GetData <Body>("Target", null))); RegisterEntity("Fireball", (position, data) => new FireballProjectile(world.ComponentManager, position, data.GetData("Velocity", Vector3.Up * 10 + MathFunctions.RandVector3Box(-10, 10, 0, 0, -10, 10)), data.GetData <Body>("Target", null))); RegisterEntity("Fairy", (position, data) => new Fairy(world.ComponentManager, "Player", position)); RegisterEntity("Target", (position, data) => new Target(world.ComponentManager, position)); RegisterEntity("Stove", (position, data) => new Stove(world.ComponentManager, position)); RegisterEntity("Strawman", (position, data) => { float value = (float)MathFunctions.Random.NextDouble(); return(value < 0.33 ? (Body)(new Strawman(world.ComponentManager, position)) : (value < 0.66 ? (Body)(new WeightRack(world.ComponentManager, position)) : (Body)(new PunchingBag(world.ComponentManager, position)))); }); RegisterEntity("Snake", (position, data) => GenerateSnake(position, world.ComponentManager, GameState.Game.Content, GameState.Game.GraphicsDevice, world.ChunkManager)); RegisterEntity("Bookshelf", (position, data) => new Bookshelf(world.ComponentManager, position) { Tags = new List <string>() { "Research" } }); RegisterEntity("Wooden Door", (position, data) => new Door(world.ComponentManager, position, world.PlayerFaction, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32), new Point(3, 1), 50)); RegisterEntity("Metal Door", (position, data) => new Door(world.ComponentManager, position, world.PlayerFaction, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32), new Point(1, 8), 100)); RegisterEntity("Stone Door", (position, data) => new Door(world.ComponentManager, position, world.PlayerFaction, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32), new Point(0, 8), 75)); RegisterEntity("Wooden Ladder", (position, data) => new Ladder(world.ComponentManager, position, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32), new Point(2, 0))); RegisterEntity("Stone Ladder", (position, data) => new Ladder(world.ComponentManager, position, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32), new Point(2, 8))); RegisterEntity("Metal Ladder", (position, data) => new Ladder(world.ComponentManager, position, new SpriteSheet(ContentPaths.Entities.Furniture.interior_furniture, 32, 32), new Point(3, 8))); RegisterEntity("RandTrinket", (position, data) => CreateRandomTrinket(world, position)); RegisterEntity("RandFood", (position, data) => CreateRandomFood(world, position)); RegisterEntity("Turret", (position, data) => new TurretTrap(world.ComponentManager, position, world.PlayerFaction)); RegisterEntity("Snow Cloud", (position, data) => new Weather.Cloud(world.ComponentManager, 0.1f, 50, 40, position) { TypeofStorm = Weather.StormType.SnowStorm }); RegisterEntity("Rain Cloud", (position, data) => new Weather.Cloud(world.ComponentManager, 0.1f, 50, 40, position) { TypeofStorm = Weather.StormType.RainStorm }); RegisterEntity("Storm", (position, data) => { Weather.CreateForecast(world.Time.CurrentDate, world.ChunkManager.Bounds, world, 3); Weather.CreateStorm(MathFunctions.RandVector3Cube() * 10, MathFunctions.Rand(0.05f, 1.0f), world); return(new Weather.Cloud(world.ComponentManager, 0.1f, 50, 40, position)); }); RegisterEntity("Chicken", (position, data) => new Chicken(position, world.ComponentManager, "Chicken")); RegisterEntity("MudGolem", (position, data) => new MudGolem(new CreatureStats(new MudGolemClass(), 0), "Carnivore", world.PlanService, World.Factions.Factions["Carnivore"], world.ComponentManager, "Mud Golem", position)); RegisterEntity("Mud", (position, data) => new MudProjectile(world.ComponentManager, position, data.GetData("Velocity", Vector3.Up * 10 + MathFunctions.RandVector3Box(-10, 10, 0, 0, -10, 10)), data.GetData <Body>("Target", null))); RegisterEntity("Grave", (position, data) => new Grave(world.ComponentManager, position)); RegisterEntity("Coins", (position, data) => new CoinPileFixture(world.ComponentManager, position)); }
private static GameComponent __factory2(ComponentManager Manager, Vector3 Position, Blackboard Data) { Weather.CreateForecast(Manager.World.Time.CurrentDate, Manager.World.ChunkManager.Bounds, Manager.World, 3); Weather.CreateStorm(MathFunctions.RandVector3Cube() * 10, MathFunctions.Rand(0.05f, 1.0f), Manager.World); return(new Cloud(Manager, 0.1f, 50, 40, Position)); }