static void Main(string[] args) { var ctx = new FissureContext(); ctx.AddSystem(new ExampleSystem(ctx, typeof(ExampleComponent))); ctx.AddSystem(new ExampleSystem2(ctx, typeof(ExampleComponent2))); ctx.AddSystem(new ExampleSystem3(ctx, typeof(ExampleComponent), typeof(ExampleComponent2))); ctx.CreateEntity("Test").AddComponents(new ExampleComponent { Message = "Hello World" }); ctx.CreateEntity("Test1").AddComponents(new ExampleComponent2 { Number = 1 }); var ent3 = ctx.CreateEntity("Test3"); ent3.AddComponents(new ExampleComponent { Message = "Hello from the other side" }, new ExampleComponent2 { Number = 1 }); ctx.Run(); ent3.RemoveComponent <ExampleComponent>(); ctx.Run(); Console.ReadLine(); }
protected BaseSystem(FissureContext context, params Type[] compatibleTypes) { if (compatibleTypes.Any(x => !x.IsComponent())) { throw new NotComponentException($"One or more types passed into System is not a Component"); } _entitiesToActOn = new List <FissureEntity>(); Context = context; CompatibleComponents = new List <Type>(compatibleTypes); Context.EntityAdded += OnContextEntityAdded; Context.EntityRemoved += OnContextEntityRemoved; Context.EntityComponentAdded += OnContextEntityComponentAdded; Context.EntityComponentRemoved += OnContextEntityComponentRemoved; }
public ExampleSystem2(FissureContext context, params Type[] compatibleTypes) : base(context, compatibleTypes) { }