コード例 #1
0
        static void Main(string[] args)
        {
            // create engine
            ECSEngine engine = new ECSEngine();

            // register components (NO MORE NEEDED)
            //engine.RegisterComponent<PositionComponent>();
            //engine.RegisterComponent<VelocityComponent>();

            // add systems
            MoveSystem moveSystem = new MoveSystem();

            engine.AddSystem(moveSystem);

            for (int i = 0; i < 5; i++)
            {
                // create entities
                ECSEntity entity = engine.CreateEntity();

                // add components
                engine.AddComponent(entity, new PositionComponent());
                engine.AddComponent(entity, new VelocityComponent()
                {
                    Velocity = new Vector3(0f, -1f * (i + 1), 0f)
                });
            }

            // init engine
            engine.Init();

            while (true)
            {
                // run engine
                engine.Run();
                System.Threading.Thread.Sleep((int)(Time.DeltaTime * 1000));
            }
        }