コード例 #1
0
        private static void Main()
        {
            var rand = new Random();

            for (var i = 0; i < 100000; i++)
            {
                Universe.AddEntity(new TreeEntity($"{i+1}", (ulong)rand.Next(500), (byte)rand.Next(5), rand.NextDouble() * 3 + 1));
            }

            Universe.AddSystem(new AgingSystem(Universe));
            Universe.AddSystem(new BranchingSystem(Universe));
            //Universe.AddSystem(new PrintSystem(Universe));
            Universe.AddSystem(new LumberjackSystem(Universe));

            //Console.WriteLine("System primed and ready.");
            //Console.ReadLine();

            //var rounds = 0;
            var count = 1;
            var tdata = new TriggerData(rand);

            //var sw = new Stopwatch();
            while (count > 0)
            {
                //rounds++;
                //sw.Restart();
                Universe.Trigger(TriggerEnum.PreTick, tdata);
                Universe.Trigger(TriggerEnum.Tick, tdata);
                Universe.Trigger(TriggerEnum.PostTick, tdata);
                //sw.Stop();
                count = Universe.GetEntities().Count();
                //Console.WriteLine($"{count,6:N0} trees remain, updated took {sw.ElapsedMilliseconds,6:N0}ms.\t{new string('|', (int) Math.Log(sw.ElapsedMilliseconds, 2))}");
            }
            //Console.WriteLine($"Finished in {rounds:N0} rounds");
            //Console.ReadKey();
        }