/// <summary> /// The main generation function for the whole game /// Creates a <see cref="GameGenerator"/> and then creates a world using <see cref="GameGenerator.GenerateWorld"/> /// Then generates all quests using <see cref="GameGenerator.GenerateQuests(World)"/> /// </summary> /// <param name="seed">Seed fed to the <see cref="GameGenerator"/> that defines the generation</param> private void GenerateGame(int seed) { //Initiate GameGenerator, then generate and set world //Debug.BeginDeepProfile("generate_world"); GameGenerator = new GameGenerator(seed); GameGenerator.GenerateWorld(WorldManager); GameGenerator.GenerateEntities(WorldManager.World); GameGenerator.GenerateDungeons(); GameGenerator.GenerateWorldMap(); QuestManager.SetQuests(GameGenerator.GenerateQuests(WorldManager.World)); Vec2i wpos = Vec2i.FromVector2(QuestManager.Unstarted[0].Initiator.GetNPC().Position2); //Vec2i wpos = WorldManager.World.GetChunkStructure(0).Position * World.ChunkSize + new Vec2i(2, 2); Vec2i wEntr = WorldManager.World.GetSubworld(1).WorldEntrance; TestSettle = QuestManager.Unstarted[0].Initiator.GetNPC().NPCKingdomData.GetSettlement(); Debug.Log(TestSettle); Vec2i playerStartreg = World.GetRegionCoordFromChunkCoord(World.GetChunkPosition(wpos)); ChunkRegionGenerator = GameGenerator.GenerateChunks(playerStartreg); GeneratePlayer(wpos); }
/// <summary> /// Starts the generation of chunk regions for the world. /// Initially generates regions near to the specified midpoint. /// All remaining regions are then generated on a seperate thread /// with those closest to the initial point being generated first /// </summary> /// <param name="midpoint">The region coordinate to centre inital region generation about</param> public ChunkRegionGenerator GenerateChunks(Vec2i midpoint) { Debug.BeginDeepProfile("start_region_gen"); //Create the generator and start the initial generation ChunkRegionGenerator crg = new ChunkRegionGenerator(this, PreGeneratedChunks); crg.GenStartRegion(midpoint); Debug.EndDeepProfile("start_region_gen"); return(crg); }
/// <summary> /// The main generation function for the whole game /// Creates a <see cref="GameGenerator"/> and then creates a world using <see cref="GameGenerator.GenerateWorld"/> /// Then generates all quests using <see cref="GameGenerator.GenerateQuests(World)"/> /// </summary> /// <param name="seed">Seed fed to the <see cref="GameGenerator"/> that defines the generation</param> private void GenerateGame(int seed) { //Initiate GameGenerator, then generate and set world //Debug.BeginDeepProfile("generate_world"); GameGenerator = new GameGenerator2(seed); GameGenerator.GenerateWorld(); //GameGenerator.GenerateWorld(WorldManager); /* * GameGenerator.GenerateEntities(WorldManager.World); * GameGenerator.GenerateDungeons();*/ //GameGenerator.GenerateWorldMap(); //QuestManager.SetQuests(GameGenerator.GenerateQuests(WorldManager.World)); //Vec2i wpos = Vec2i.FromVector2(QuestManager.Unstarted[0].Initiator.GetNPC().Position2); //Vec2i wpos = WorldManager.World.GetChunkStructure(0).Position * World.ChunkSize + new Vec2i(2, 2); Vec2i wpos = null; foreach (KeyValuePair <int, WorldLocation> tl in WorldManager.World.WorldLocations) { wpos = tl.Value.ChunkPos * World.ChunkSize; break; } //Vec2i wpos = new Vec2i(1, 1) * World.ChunkSize * World.WorldSize / 2; // Vec2i wEntr = WorldManager.World.GetSubworld(1).WorldEntrance; //TestSettle = QuestManager.Unstarted[0].Initiator.GetNPC().NPCKingdomData.GetSettlement(); Debug.Log(TestSettle); Vec2i playerStartreg = World.GetRegionCoordFromChunkCoord(World.GetChunkPosition(wpos)); Debug.Log("Player start region: " + playerStartreg); ChunkRegionGenerator = GameGenerator.GenerateChunks(playerStartreg); GeneratePlayer(wpos); }