Advertisement
Guest User

Program.cs

a guest
Jun 6th, 2015
222
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ClassBasedES
  8. {
  9.     class Program
  10.     {
  11.         /// <summary>
  12.         /// This entity system is OOP / has a class based interface using Extension Methods.
  13.         /// We can use entity Guids as though they were each individual classes,
  14.         ///   using this nifty C# language feature (Extension Methods).
  15.         /// </summary>
  16.         static void Main(string[] args)
  17.         {
  18.             //Test our ES
  19.             Console.WriteLine("===== Class Based ES v0.2 =====");
  20.  
  21.  
  22.             Console.WriteLine("                           ");
  23.             Console.WriteLine("                           ");
  24.             Console.WriteLine("===== FUNCTIONS TEST  =====");
  25.             Console.WriteLine("                           ");
  26.             entity e = ES.create();
  27.  
  28.             e.addComponent("GfxComponent");
  29.             e.addComponent("MoveComponent");
  30.             Console.WriteLine("Entity components string: " + e.getComponentsString());
  31.  
  32.             Type comp = e.getComponentTypes()[0];
  33.             Type comp2 = e.getComponentTypes()[1];
  34.             Console.WriteLine("component Type: " + comp.Name);
  35.             Console.WriteLine("component Type: " + comp2.Name);
  36.  
  37.             e.removeComponent("GfxComponent");
  38.             Console.WriteLine("Entity components string: " + e.getComponentsString());
  39.  
  40.             e.removeComponent("MoveComponent");
  41.             Console.WriteLine("Entity components string: " + e.getComponentsString());
  42.  
  43.             //equal to check for two Guids
  44.             {
  45.                 entity e2 = ES.create();
  46.                 if (e2.isEqualTo(e))
  47.                     throw new Exception();
  48.                 Console.WriteLine("Guids working correctly.");
  49.             }
  50.  
  51.             //other init method
  52.             {
  53.                 entity e2 = ES.create("MoveComponent GfxComponent");
  54.                 Console.WriteLine("e2 components string: " + e2.getComponentsString());
  55.             }
  56.  
  57.  
  58.             Console.WriteLine("                           ");
  59.             Console.WriteLine("                           ");
  60.             Console.WriteLine("===== ROBUSTNESS TEST (should be all empty) =====");
  61.             Console.WriteLine("                           ");
  62.  
  63.             //ensure it's properly emptied with any string removal order
  64.             e.addComponent("GfxComponent");
  65.             e.addComponent("MoveComponent");
  66.             e.removeComponent("MoveComponent");
  67.             e.removeComponent("GfxComponent");
  68.             Console.WriteLine("Entity components string: " + e.getComponentsString());
  69.  
  70.             //ensure it's properly emptied with any string removal order
  71.             e.addComponent("MoveComponent");
  72.             e.addComponent("GfxComponent");
  73.             e.removeComponent("MoveComponent");
  74.             e.removeComponent("GfxComponent");
  75.             Console.WriteLine("Entity components string: " + e.getComponentsString());
  76.  
  77.             //ensure it's properly emptied with any string removal order
  78.             e.addComponent("MoveComponent");
  79.             e.addComponent("GfxComponent");
  80.             e.removeComponent("GfxComponent");
  81.             e.removeComponent("MoveComponent");
  82.             Console.WriteLine("Entity components string: " + e.getComponentsString());
  83.  
  84.  
  85.  
  86.  
  87.             Console.ReadKey(); //wait for input
  88.  
  89.  
  90.         }
  91.     }
  92. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement