예제 #1
0
    void IECSSystem.Execute(ECSEngine engine, ECSEntity[] entities)
    {
        for (int i = 0; i < entities.Length; i++)
        {
            ECSEntity entity = entities[i];

            CollisionDataComponent cdc = engine.GetComponent <CollisionDataComponent>(entity);

            ECSEntity entity1 = cdc.Entity1;
            ECSEntity entity2 = cdc.Entity2;

            engine.DestroyEntity(entity);

            if (!this.entitiesToDestroy.Contains(entity1))
            {
                this.entitiesToDestroy.Add(entity1);
            }

            if (!this.entitiesToDestroy.Contains(entity2))
            {
                this.entitiesToDestroy.Add(entity2);
            }
        }

        this.entitiesToDestroy.Sort((x1, x2) => - x1.CompareTo(x2));

        for (int i = 0; i < this.entitiesToDestroy.Count; i++)
        {
            ECSEntity entity = this.entitiesToDestroy[i];
            engine.DestroyEntity(entity);
        }

        this.entitiesToDestroy.Clear();
    }
예제 #2
0
        // system execution
        void IECSSystem.Execute(ECSEngine engine, ECSEntity[] entities)
        {
            for (int i = 0; i < entities.Length; i++)
            {
                //get entity
                ECSEntity entity = entities[i];

                // get data
                PositionComponent pc = engine.GetComponent <PositionComponent>(entity);
                VelocityComponent vc = engine.GetComponent <VelocityComponent>(entity);

                // manipulate data
                pc.Position += vc.Velocity * Time.DeltaTime;

                // set data
                engine.SetComponent(entity, pc);

                Debug.Log("Entity: " + entity + " - Pos: " + pc.Position, ConsoleColor.Green, entity);

                // other operations
                if (pc.Position.y < -10)
                {
                    Console.Clear();
                    Debug.Log("Destroyed: " + entity, ConsoleColor.Red, entity);

                    // destroy entities
                    engine.DestroyEntity(entity);
                }
            }
        }
예제 #3
0
    void IECSSystem.Execute(ECSEngine engine, ECSEntity[] entities)
    {
        for (int i = 0; i < entities.Length; i++)
        {
            ECSEntity entity = entities[i];

            PositionComponent pc = engine.GetComponent <PositionComponent>(entity);

            if (this.IsOutOfScreen(pc.Position))
            {
                engine.DestroyEntity(entity);
            }
        }
    }