Пример #1
0
 protected virtual void RaiseOnEntityRemoved(IEntityOld entity)
 {
     if (OnEntityRemoved != null)
     {
         OnEntityRemoved(entity);
     }
 }
Пример #2
0
        public void UpdateEntity(IEntityOld entity, bool isValid)
        {
            // Entity Groups
            if (entityGroups.Count > 0)
            {
                var enumerator = entityGroups.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    enumerator.Current.Value.UpdateEntity(entity, isValid && IsEntityGroupValid(entity, enumerator.Current.Key));
                }

                enumerator.Dispose();
            }

            // Component Groups
            if (componentGroups.Count > 0)
            {
                var enumerator = componentGroups.GetEnumerator();

                while (enumerator.MoveNext())
                {
                    enumerator.Current.Value.UpdateEntity(entity, isValid && IsComponentGroupValid(entity, enumerator.Current.Key));
                }

                enumerator.Dispose();
            }
        }
Пример #3
0
 void UnregisterEntity(IEntityOld entity)
 {
     if (entities.Remove(entity))
     {
         RaiseOnEntityRemoved(entity);
     }
 }
Пример #4
0
        public static bool Matches(IEntityOld entity, ByteFlag components, EntityMatchesOld match = EntityMatchesOld.All)
        {
            bool matches = false;

            switch (match)
            {
            case EntityMatchesOld.All:
                matches = MatchesAll(entity, components);
                break;

            case EntityMatchesOld.Any:
                matches = MatchesAny(entity, components);
                break;

            case EntityMatchesOld.None:
                matches = !MatchesAny(entity, components);
                break;

            case EntityMatchesOld.Exact:
                matches = MatchesExact(entity, components);
                break;
            }

            return(matches);
        }
Пример #5
0
 void RegisterEntity(IEntityOld entity)
 {
     if (!entities.Contains(entity))
     {
         entities.Add(entity);
         RaiseOnEntityAdded(entity);
     }
 }
Пример #6
0
        public static void UnregisterEntity(IEntityOld entity)
        {
            masterGroup.UpdateEntity(entity, false);

            if (entity is IEntityUpdateable)
            {
                updateables.Remove((IEntityUpdateable)entity);
            }
        }
Пример #7
0
        public static void RegisterEntity(IEntityOld entity)
        {
            InitializeManager();
            masterGroup.UpdateEntity(entity, true);

            var updateable = entity as IEntityUpdateable;

            if (updateable != null)
            {
                updateables.Add(updateable);
            }
        }
Пример #8
0
        static bool MatchesExact(IEntityOld entity, ByteFlag components)
        {
            for (byte i = 0; i < EntityUtility.IdCount; i++)
            {
                if (components[i] != entity.HasComponent(EntityUtility.GetComponentType(i)))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #9
0
        public void UpdateEntity(IEntityOld entity, bool isValid)
        {
            if (isValid)
            {
                RegisterEntity(entity);
            }
            else
            {
                UnregisterEntity(entity);
            }

            for (int i = 0; i < subGroups.Length; i++)
            {
                var subGroup = subGroups[i];

                if (subGroup != null)
                {
                    subGroup.UpdateEntity(entity, isValid);
                }
            }
        }
Пример #10
0
 public static void UpdateEntity(IEntityOld entity)
 {
     masterGroup.UpdateEntity(entity, true);
 }
Пример #11
0
 public bool IsEntityGroupValid(IEntityOld entity, ByteFlag groups)
 {
     return EntityMatchOld.Matches(entity.Groups, groups, match);
 }
Пример #12
0
        public static bool Matches(IEntityOld entity, ByteFlag components, EntityMatchesOld match = EntityMatchesOld.All)
        {
            bool matches = false;

            switch (match)
            {
                case EntityMatchesOld.All:
                    matches = MatchesAll(entity, components);
                    break;
                case EntityMatchesOld.Any:
                    matches = MatchesAny(entity, components);
                    break;
                case EntityMatchesOld.None:
                    matches = !MatchesAny(entity, components);
                    break;
                case EntityMatchesOld.Exact:
                    matches = MatchesExact(entity, components);
                    break;
            }

            return matches;
        }
Пример #13
0
 public bool IsComponentGroupValid(IEntityOld entity, ByteFlag components)
 {
     return(EntityMatchOld.Matches(entity, components, match));
 }
Пример #14
0
 public bool IsEntityGroupValid(IEntityOld entity, ByteFlag groups)
 {
     return(EntityMatchOld.Matches(entity.Groups, groups, match));
 }
Пример #15
0
        public void UpdateEntity(IEntityOld entity, bool isValid)
        {
            // Entity Groups
            if (entityGroups.Count > 0)
            {
                var enumerator = entityGroups.GetEnumerator();

                while (enumerator.MoveNext())
                    enumerator.Current.Value.UpdateEntity(entity, isValid && IsEntityGroupValid(entity, enumerator.Current.Key));

                enumerator.Dispose();
            }

            // Component Groups
            if (componentGroups.Count > 0)
            {
                var enumerator = componentGroups.GetEnumerator();

                while (enumerator.MoveNext())
                    enumerator.Current.Value.UpdateEntity(entity, isValid && IsComponentGroupValid(entity, enumerator.Current.Key));

                enumerator.Dispose();
            }
        }
Пример #16
0
        static bool MatchesExact(IEntityOld entity, ByteFlag components)
        {
            for (byte i = 0; i < EntityUtility.IdCount; i++)
            {
                if (components[i] != entity.HasComponent(EntityUtility.GetComponentType(i)))
                    return false;
            }

            return true;
        }
Пример #17
0
 public static void SetEntity(Component component, IEntityOld entity)
 {
     entities[component] = entity;
 }
Пример #18
0
 public static void SetEntity(Component component, IEntityOld entity)
 {
     entities[component] = entity;
 }
Пример #19
0
 public bool IsComponentGroupValid(IEntityOld entity, ByteFlag components)
 {
     return EntityMatchOld.Matches(entity, components, match);
 }