Exemple #1
0
 protected virtual void RaiseOnEntityRemoved(IEntityOld entity)
 {
     if (OnEntityRemoved != null)
     {
         OnEntityRemoved(entity);
     }
 }
Exemple #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();
            }
        }
Exemple #3
0
 void UnregisterEntity(IEntityOld entity)
 {
     if (entities.Remove(entity))
     {
         RaiseOnEntityRemoved(entity);
     }
 }
Exemple #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);
        }
Exemple #5
0
 void RegisterEntity(IEntityOld entity)
 {
     if (!entities.Contains(entity))
     {
         entities.Add(entity);
         RaiseOnEntityAdded(entity);
     }
 }
Exemple #6
0
        public static void UnregisterEntity(IEntityOld entity)
        {
            masterGroup.UpdateEntity(entity, false);

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

            var updateable = entity as IEntityUpdateable;

            if (updateable != null)
            {
                updateables.Add(updateable);
            }
        }
Exemple #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);
        }
Exemple #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);
                }
            }
        }
Exemple #10
0
 public static void UpdateEntity(IEntityOld entity)
 {
     masterGroup.UpdateEntity(entity, true);
 }
 public bool IsEntityGroupValid(IEntityOld entity, ByteFlag groups)
 {
     return EntityMatchOld.Matches(entity.Groups, groups, match);
 }
        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;
        }
Exemple #13
0
 public bool IsComponentGroupValid(IEntityOld entity, ByteFlag components)
 {
     return(EntityMatchOld.Matches(entity, components, match));
 }
Exemple #14
0
 public bool IsEntityGroupValid(IEntityOld entity, ByteFlag groups)
 {
     return(EntityMatchOld.Matches(entity.Groups, groups, match));
 }
        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();
            }
        }
        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;
        }
Exemple #17
0
 public static void SetEntity(Component component, IEntityOld entity)
 {
     entities[component] = entity;
 }
 public static void SetEntity(Component component, IEntityOld entity)
 {
     entities[component] = entity;
 }
 public bool IsComponentGroupValid(IEntityOld entity, ByteFlag components)
 {
     return EntityMatchOld.Matches(entity, components, match);
 }