Advertisement
Guest User

Untitled

a guest
Jan 27th, 2019
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.26 KB | None | 0 0
  1.         private static void Main(string[] args)
  2.         {
  3.             EntityManager entityManager = new EntityManager();
  4.             entityManager.AddComponentPool<Position>();
  5.             entityManager.AddComponentPool<MovementSpeed>();
  6.  
  7.             entityManager.AddSystem(new Movement(entityManager));
  8.  
  9.             Guid playerId = entityManager.CreateEntity();
  10.             entityManager.AddComponentToEntity(playerId, new Position() { X = 4, Y = 13 });
  11.             entityManager.AddComponentToEntity(playerId, new MovementSpeed() { Value = 1 });
  12.  
  13.             Guid firstDragonId = entityManager.CreateEntity();
  14.             entityManager.AddComponentToEntity(firstDragonId, new Position() { X = 30, Y = 100 });
  15.             entityManager.AddComponentToEntity(firstDragonId, new MovementSpeed() { Value = 5 });
  16.  
  17.             Console.WriteLine("### 1. Update ###");
  18.  
  19.             foreach (ISystem system in entityManager.Systems)
  20.             {
  21.                 system.UpdateCacheEntities();
  22.             }
  23.  
  24.             Console.WriteLine("### 2. Update ###");
  25.  
  26.             entityManager.RemoveComponentFromEntity<Position>(firstDragonId);
  27.  
  28.             foreach (ISystem system in entityManager.Systems)
  29.             {
  30.                 system.UpdateCacheEntities();
  31.             }
  32.  
  33.             Console.WriteLine("### 3. Update ###");
  34.  
  35.             entityManager.AddComponentToEntity(firstDragonId, new Position() { X = -55440, Y = -95544 });
  36.  
  37.             foreach (ISystem system in entityManager.Systems)
  38.             {
  39.                 system.UpdateCacheEntities();
  40.             }
  41.  
  42.             Console.WriteLine("### 4. Update ###");
  43.  
  44.             Guid secondDragonId = entityManager.CreateEntity();
  45.             entityManager.AddComponentToEntity(secondDragonId, new Position() { X = 30, Y = 100 });
  46.             entityManager.AddComponentToEntity(secondDragonId, new MovementSpeed() { Value = 5 });
  47.  
  48.             foreach (ISystem system in entityManager.Systems)
  49.             {
  50.                 system.UpdateCacheEntities();
  51.             }
  52.  
  53.             Console.WriteLine("### 5. Update ###");
  54.  
  55.             foreach (ISystem system in entityManager.Systems)
  56.             {
  57.                 system.UpdateCacheEntities();
  58.             }
  59.  
  60.             Console.ReadLine();
  61.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement