Example #1
0
        public IEcsComponentManagerOf <TComponent> RegisterComponent <TComponent>() where TComponent : class, IEcsComponent
        {
            IEcsComponentManager existing;

            if (!ComponentManagers.TryGetValue(typeof(TComponent), out existing))
            {
                existing = new EcsComponentManagerOf <TComponent>();
                ComponentManagers.Add(typeof(TComponent), existing);
                return((IEcsComponentManagerOf <TComponent>)existing);
            }
            else
            {
                return((IEcsComponentManagerOf <TComponent>)existing);
            }
        }
Example #2
0
        public IEcsComponentManagerOf <TComponent> RegisterComponent <TComponent>(int componentId = 0) where TComponent : class, IEcsComponent
        {
            IEcsComponentManager existing;

            if (!ComponentManagers.TryGetValue(typeof(TComponent), out existing))
            {
                existing             = new EcsComponentManagerOf <TComponent>();
                existing.ComponentId = componentId;
                ComponentManagers.Add(typeof(TComponent), existing);
                //if (componentId > 0)
                //    ComponentManagersById.Add(componentId, existing);
                //else
                //{
                //    // Throw warning here?
                //}
                return((IEcsComponentManagerOf <TComponent>)existing);
            }
            else
            {
                return((IEcsComponentManagerOf <TComponent>)existing);
            }
        }