コード例 #1
0
        public System(int SystemLevel)
        {
            var Result = GetType().GetCustomAttribute <SystemReader>();

            if (Result != null)
            {
                foreach (var B in Result.ComponentType)
                {
                    EntityBits myReturnedComponentID = ComponentRegistration.GetComponentBitset(B);
                    SystemReader.AddToAndSet(myReturnedComponentID);
                }
            }
            var Result2 = GetType().GetCustomAttribute <SystemWriter>();

            if (Result2 != null)
            {
                foreach (var B in Result2.ComponentType)
                {
                    EntityBits myReturnedComponentID = ComponentRegistration.GetComponentBitset(B);
                    SystemWriter.AddToAndSet(myReturnedComponentID);
                }
            }

            this.ExecutionOrder = SystemLevel;
        }
コード例 #2
0
        public void RemoveEntity(Entity entity)
        {
            EntityBits returned = null;

            EntityToEntityBits.TryGetValue(entity, out returned);
            myBase.myEntityManager.EntityRemoveWatcher?.Invoke(entity);
            if (returned != null)
            {
                EntityToEntityBits.Remove(entity);
                entity.myWorldOwner = null;
            }
        }
コード例 #3
0
        private ComponentMapper <T> CreateMapperForType <T>(EntityBits componentTypeId)
            where T : class
        {
            if (typeof(T) == typeof(Component))
            {
                throw new Exception("Mapper using Component Base Class was created!");
            }
            var mapper = new ComponentMapper <T>(componentTypeId, ComponentsChanged);

            _componentMappers[componentTypeId] = mapper;
            return(mapper);
        }
コード例 #4
0
        public static void Register(Type myType)
        {
            if (_componentTypes.TryGetValue(myType, out var id))
            {
                return;
            }

            EntityBits myVector = new EntityBits();

            myVector[_componentTypes.Count()] = true;
            Debug.WriteLine("Registered Component: " + myType + " : " + myVector);
            _componentTypes.Add(myType, myVector);
            _componentBitvectorToTypes.Add(myVector, myType);
        }
コード例 #5
0
        public EntityBits CreateComponentBits(int entityId)
        {
            var componentBits = new EntityBits();
            int bit           = 0;

            foreach (var T in _componentMappers)
            {
                if (T.Value.Has(entityId))
                {
                    componentBits = componentBits | (T.Key);
                }
            }
            return(componentBits);
        }
コード例 #6
0
        public EntityBits Get()
        {
            EntityBits Result = null;

            if (myArrays.Count != 0)
            {
                Result = new EntityBits();
                foreach (EntityBits A in myArrays)
                {
                    Result = Result | (A);
                }
            }

            return(Result);
        }
コード例 #7
0
        public List <Component> GetAssociatedComponents(int entityID, EntityBits ComponentBits)
        {
            Matcher myMatcher = new Matcher();

            myMatcher.AddToOrSet(ComponentBits);
            List <Component> myComponents = new List <Component>();

            foreach (var A in _componentMappers)
            {
                if (myMatcher.Matches(A.Key))
                {
                    var Value = A.Value.Get(entityID);
                    myComponents.AddRange((IEnumerable <Component>)Value);
                }
            }
            return(myComponents);
        }
コード例 #8
0
 internal void ComponentRemoved(Entity arg1, EntityBits arg2)
 {
 }
コード例 #9
0
 internal void ComponentAdded(Entity arg1, EntityBits arg2)
 {
 }
コード例 #10
0
 internal void UpdateEntityEntityBits(Entity ID, EntityBits result)
 {
     EntityToEntityBits[ID] = result;
 }
コード例 #11
0
 protected override void ProcessEntityChange(Entity myEntity, EntityBits ComponentBits)
 {
     base.ProcessEntityChange(myEntity, ComponentBits);
 }
コード例 #12
0
 public void Add(EntityBits EntityBits)
 {
     myArrays.Add(EntityBits);
 }
コード例 #13
0
 protected ComponentMapper(EntityBits id, Type componentType)
 {
     Id            = id;
     ComponentType = componentType;
 }
コード例 #14
0
 public ComponentMapper GetMapper(EntityBits componentTypeId)
 {
     return(_componentMappers[componentTypeId]);
 }