Exemple #1
0
        public EventSystem_Any_(Contexts contexts) : base(contexts.Get <TScope>())
        {
            _contexts = contexts;
            var context = contexts.Get <TScope>(  );

            _listeners       = context.GetGroup(Matcher <TScope, Event_AnyComponent <TScope, TData> > .I);
            _listenersBuffer = new List <Entity <TScope> >(  );
            _interfaceBuffer = new List <IOnAny <TScope, TData> >(  );
        }
Exemple #2
0
        private static void RunGenericEntitasBenchmark()
        {
            // register scopes & components
            ScopeManager.RegisterScopes <Simulation, Input>();
            ComponentTypeManager <Simulation> .Autoscan();

            var contexts          = new Contexts(AERCFactories.UnsafeAERCFactory);
            var systems           = new Systems().Add(new MoveSystem(contexts));
            var simulationContext = contexts.Get <Simulation>();

            for (var i = 0; i < EntitiesCount; i++)
            {
                simulationContext.CreateEntity()
                .Add(new Position(new Vector3(1, 2, 0), 0))
                .Add(new Velocity(new Vector3(2, 2, 1), 0.01f));
            }

            // Warm up
            systems.Execute();

            Measure("Generic Entity", () => {
                for (var i = 0; i < RepeatCount; i++)
                {
                    systems.Execute();
                }
            });
        }
Exemple #3
0
 public EventSystem_Any_Removed2(Contexts db, Context <Entity <TScope> > context = null) : base(context ?? db.Get <TScope>( ))
 {
     if (OnAny_Removed <TScope, TComp> .I == null)
     {
         OnAny_Removed <TScope, TComp> .I = new OnAny_Removed <TScope, TComp>(db);
     }
     _context = context ?? db.Get <TScope>();
 }
Exemple #4
0
 public EventSystem_Self_Flag2(Contexts db, Context <Entity <TScope> > context = null) : base(context ?? db.Get <TScope>())
 {
     if (OnSelf_Flag <TScope, TComp> .I == null)
     {
         OnSelf_Flag <TScope, TComp> .I = new OnSelf_Flag <TScope, TComp>(db);
     }
     _context = context ?? db.Get <TScope>(  );
 }
Exemple #5
0
 public EventSystem_Any_Flag2(Contexts db, Context <Entity <TScope> > context = null) : base(context ?? db.Get <TScope>())
 {
     if (OnAny_Flag <TScope, TComp> .I == null)
     {
         // GG 如果有Context同类型多例,则用那个来创建都无所谓。然而只有db是缺省的。
         OnAny_Flag <TScope, TComp> .I = new OnAny_Flag <TScope, TComp>(db);
     }
     _context = context ?? db.Get <TScope>();
 }
Exemple #6
0
 public MoveSystem(Contexts contexts)
 {
     _group = contexts.Get <Simulation>()
              .GetGroup(
         Matcher <Entity <Simulation> > .AllOf(
             Matchers.For <Simulation, Position>(),
             Matchers.For <Simulation, Velocity>()
             )
         );
 }
 public EventSystem_Self(Contexts contexts) : base((IContext <Entity <TScope> >)contexts.Get <TScope>())
 {
     _contexts = contexts;
 }
 public void                                    Sub(Action <Entity <TScope> > action)
 {
     Sub(action, _db.Get <TScope>());
 }
 public void                                    Sub(Int32 id, Action <Entity <TScope> > action)
 {
     Sub(id, action, _db.Get <TScope>());
 }
Exemple #10
0
 public EventSystem_SelfRemoved_(Contexts contexts) : base(contexts.Get <TScope>())
 {
     _contexts = contexts;
 }