コード例 #1
0
ファイル: Program.cs プロジェクト: AustinSmith13/CaboodleES
        static void Main(string[] args)
        {
            Console.WriteLine(Caboodle.GetVersion());

            Stopwatch watch = new Stopwatch();

            var world = new Caboodle();

            //world.Systems.Add(Assembly.GetAssembly(typeof(Program)));
            world.Systems.Add <MockSystem1>();
            world.Systems.Add <MockSystem2>();

            var system = world.Systems.Get <MockSystem1>();

            Console.WriteLine(system);
            var system2 = world.Systems.Get <MockSystem2>();

            Console.WriteLine(system2);
            world.Systems.Init();
            int           iterations = 1000;
            List <Entity> buffer     = new List <Entity>();

            while (true)
            {
                world.Systems.Update();
                var a = Console.ReadKey(true);

                if (a.KeyChar == 'a')
                {
                }

                if (a.KeyChar == 'q')
                {
                    watch.Reset();
                    watch.Start();

                    world.Systems.Update();

                    Console.WriteLine("Systems Processed : " + watch.Elapsed.TotalMilliseconds + " ms");
                }

                if (a.KeyChar == 'w')
                {
                    watch.Reset();
                    watch.Start();

                    var ent = world.Entities.Create();
                    var c1  = ent.AddComponent <Test>();
                    c1.x = 33434334343;
                    c1.y = 34234234234;
                    MockTransform c = ent.AddComponent <MockTransform>();
                    ent.AddComponent <Mock1>();
                    ent.AddComponent <Mock2>();
                    ent.AddComponent <Mock3>();
                    ent.AddComponent <Mock4>();
                    ent.AddComponent <Mock5>();
                    ent.AddComponent <Mock6>();
                    c.x = 234;
                    c.y = 3434;
                    buffer.Add(ent);

                    Console.WriteLine("created ents/comps - TIME : " + watch.Elapsed.TotalMilliseconds + " ms");
                }

                if (a.KeyChar == 'c')
                {
                    watch.Reset();
                    watch.Start();

                    for (int i = 0; i < iterations; i++)
                    {
                        var ent = world.Entities.Create();
                        var c1  = ent.AddComponent <Test>();
                        c1.x = 1;
                        c1.y = 1;
                        MockTransform c = ent.AddComponent <MockTransform>();
                        ent.AddComponent <Mock1>();
                        ent.AddComponent <Mock2>();
                        ent.AddComponent <Mock3>();
                        ent.AddComponent <Mock4>();
                        ent.AddComponent <Mock5>();
                        ent.AddComponent <Mock6>();
                        ent.AddComponent <Mock7>();
                        c.x = 234;
                        c.y = 3434;
                        buffer.Add(ent);

                        ent = world.Entities.Create();
                        ent.AddComponent <Mock1>().x = 9999;
                        buffer.Add(ent);
                    }

                    Console.WriteLine("created ents/comps - TIME : " + watch.Elapsed.TotalMilliseconds + " ms");
                }

                if (a.KeyChar == 'i')
                {
                    Console.WriteLine("Entity Count - " + world.Entities.Count);
                }

                if (a.KeyChar == 'g')
                {
                    watch.Reset();
                    watch.Start();

                    var c = buffer[750].GetComponent <Test>();

                    Console.WriteLine(c.x);

                    // if (buffer.Count > 0)
                    //Console.WriteLine("Value = "+buffer[765].GetComponent<Test>().x);

                    Console.WriteLine("get ents comp - TIME : " + watch.Elapsed.TotalMilliseconds + " ms");
                }

                if (a.KeyChar == 'r')
                {
                    watch.Reset();
                    watch.Start();

                    Console.WriteLine(buffer.Count);

                    for (int i = 0; i < buffer.Count; i++)
                    {
                        buffer[i].Destroy();
                    }

                    buffer.Clear();

                    Console.WriteLine("deleted ents/comps - TIME : " + watch.Elapsed.TotalMilliseconds + " ms");
                }
            }
        }
コード例 #2
0
 public EventManager(Caboodle caboodle) : base(caboodle)
 {
     this.genTypes = new HashSet <Type>();
 }