Advertisement
Guest User

ReusGrowthRunner

a guest
May 30th, 2013
391
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Reus.Model.Civilizations;
  6. using Reus.Controller.Civilizations;
  7. using Microsoft.Xna.Framework;
  8. using Reus.Model;
  9. using Reus.IO;
  10. using SpaceTech.Content;
  11. using Reus.Controller;
  12. using SpaceTech;
  13. using Reus.Settings.Model;
  14. using Reus.Model.Flora;
  15. namespace GrowthRunner
  16. {
  17.     class Program
  18.     {
  19.         private static ModelSettings modelSettings;
  20.         public static void LoadModelSettings(string dir)
  21.         {
  22.             ReferencedContentManager referencedContentManager = new ReferencedContentManager(new ServiceProvider(), dir, new string[] { "" });
  23.             IUnlockService unlockService = new UnlockManager();
  24.             modelSettings = new ModelSettings(referencedContentManager, unlockService);            
  25.         }
  26.         public static Planet CreatePlanet()
  27.         {
  28.             Planet planet = new Planet(Token.Null, false, GameMode.Freeplay);
  29.             foreach (Patch p in planet.Surface)
  30.             {
  31.                 p.Water = -1;
  32.             }
  33.             foreach (Patch p in planet.Surface)
  34.             {
  35.                 p.FertileType = PatchType.Forest;
  36.             }
  37.  
  38.  
  39.             FloraAssetDefinition floraAssetDefinition = modelSettings.FloraDefinitions["Superior Blueberry"];
  40.             FloraAssetDefinition floraAssetDefinition2 = modelSettings.FloraDefinitions["Superior Strawberry"];
  41.             planet.Flora.SpawnFloraAsset(floraAssetDefinition, planet.Surface[47], new ScalableAssetStatWrapper(0, 0, 0, 0, 0));
  42.             foreach (Patch p in planet.Surface)
  43.             {
  44.                 //if (p.Index < 46 || p.Index > 53)
  45.                 {
  46.                     //   planet.Flora.SpawnFloraAsset((p.Index%3) != 0 ? floraAssetDefinition : floraAssetDefinition2, p, new ScalableAssetStatWrapper(0, 0, 0, 0, 0));
  47.                 }
  48.             }
  49.             return planet;
  50.         }
  51.  
  52.         static void Main(string[] args)
  53.         {
  54.             LoadModelSettings("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Reus\\");
  55.             Planet planet = CreatePlanet();
  56.            
  57.             Civilization civ = new Civilization(planet, planet.Surface[50], 0.77f, "Testciv");
  58.             Growth g = new Growth(civ);
  59.  
  60.             // run the initial tick
  61.             g.Update(new GameTime(new TimeSpan(0, 0, (int)modelSettings.CivParams.Growth.TickTime), new TimeSpan(0, 0, (int)modelSettings.CivParams.Growth.TickTime)));
  62.  
  63.             int prevReachSize = 0;
  64.             int tickOfLastIncrease = 0;
  65.             int tickInSeconds = 1; // or (int)modelSettings.CivParams.Growth.TickTime;
  66.             for (int i = 1; i < 120 * 60 / tickInSeconds; i++)
  67.             {
  68.                 // GameTime gt = new GameTime(totalGameTime: new TimeSpan(0, 0, 0, i/10, (i%10)*100), elapsedGameTime: new TimeSpan(0,0,0,0,100)); // once per 0.1 s                
  69.                 GameTime gt = new GameTime(totalGameTime: new TimeSpan(0, 0, tickInSeconds), elapsedGameTime: new TimeSpan(0, 0, tickInSeconds)); // once per TickTime
  70.                 g.Update(gt);
  71.                                
  72.                 if (civ.Reach.Length != prevReachSize)
  73.                 {
  74.                     Console.WriteLine("Reach changed on tick " + i + ", #ticks after previous:" + (i - tickOfLastIncrease));
  75.                     Console.WriteLine("Food use is now " + civ.Population + " (out of " + civ.TotalFood + ") ");
  76.                     tickOfLastIncrease = i;
  77.                     Console.WriteLine("Reach = " + civ.Reach.Length+ " squares: " + civ.Reach.First().Index + " to " + civ.Reach.Last().Index);
  78.                                        
  79.                     prevReachSize = civ.Reach.Length;
  80.                     Console.ReadKey();                    
  81.                 }
  82.             }
  83.            
  84.  
  85.  
  86.             Console.WriteLine("Press Enter ...");
  87.             Console.ReadLine();
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement