Пример #1
0
        public void RemoveSystem(AbstractSystem system)
        {
            SystemRemoved(system);
            systems.Remove(system);

            // @Hack If a system is created with the same group as a group listener there's going to be problems
            //groupMembership.Remove(system.Group);
        }
Пример #2
0
        public void AddSystem(AbstractSystem system)
        {
            system.Engine = this;
            systems.Add(system);

            // This will throw an error if a group already exists but thats OK
            // because we don't want people adding multiple systems with the same
            // group. It doesn't make sense and it adds unnecessary complications.
            if (!groupMembership.ContainsKey(system.Group))
            {
                groupMembership.Add(system.Group, new List <Entity>());
            }
            //groupMembership.Add(system.Group, new List<Entity>());
            system.AddedToEngine();
            SystemAdded(system);
        }
Пример #3
0
        // This method goes through all the entities in the Engine and adds them
        // to the group if they match.
        private void UpdateEntityMembership(AbstractSystem system)
        {
            var group = system.Group;

            if (!groupMembership.ContainsKey(group))
            {
                return;
            }

            // Clear so we don't add duplicates
            groupMembership[group].Clear();

            foreach (Entity entity in entities.Values)
            {
                if (group.Matches(entity))
                {
                    groupMembership[group].Add(entity);
                }
            }
        }