Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void Main(string[] args)
- {
- EntityManager entityManager = new EntityManager();
- entityManager.AddComponentPool<Position>();
- entityManager.AddComponentPool<MovementSpeed>();
- entityManager.AddSystem(new Movement(entityManager));
- Guid playerId = entityManager.CreateEntity();
- entityManager.AddComponentToEntity(playerId, new Position() { X = 4, Y = 13 });
- entityManager.AddComponentToEntity(playerId, new MovementSpeed() { Value = 1 });
- Guid firstDragonId = entityManager.CreateEntity();
- entityManager.AddComponentToEntity(firstDragonId, new Position() { X = 30, Y = 100 });
- entityManager.AddComponentToEntity(firstDragonId, new MovementSpeed() { Value = 5 });
- Console.WriteLine("### 1. Update ###");
- foreach (ISystem system in entityManager.Systems)
- {
- system.UpdateCacheEntities();
- }
- Console.WriteLine("### 2. Update ###");
- entityManager.RemoveComponentFromEntity<Position>(firstDragonId);
- foreach (ISystem system in entityManager.Systems)
- {
- system.UpdateCacheEntities();
- }
- Console.WriteLine("### 3. Update ###");
- entityManager.AddComponentToEntity(firstDragonId, new Position() { X = -55440, Y = -95544 });
- foreach (ISystem system in entityManager.Systems)
- {
- system.UpdateCacheEntities();
- }
- Console.WriteLine("### 4. Update ###");
- Guid secondDragonId = entityManager.CreateEntity();
- entityManager.AddComponentToEntity(secondDragonId, new Position() { X = 30, Y = 100 });
- entityManager.AddComponentToEntity(secondDragonId, new MovementSpeed() { Value = 5 });
- foreach (ISystem system in entityManager.Systems)
- {
- system.UpdateCacheEntities();
- }
- Console.WriteLine("### 5. Update ###");
- foreach (ISystem system in entityManager.Systems)
- {
- system.UpdateCacheEntities();
- }
- Console.ReadLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement