Esempio n. 1
0
        private void UnsubscribeFromManagers(WorldObject worldObject)
        {
            if (worldObject is ICollidable)
            {
                CollisionManager.AddCollidable(worldObject as ICollidable);
            }
            else if (worldObject is IDrawManageable)
            {
                DrawManager.Remove(worldObject as IDrawManageable);
            }

            // unsubscribe the components recursively
            foreach (WorldObject wo in worldObject.GetComponents())
            {
                UnsubscribeFromManagers(wo);
            }
        }
Esempio n. 2
0
        private void SubscribeToManagers(WorldObject worldObject)
        {
            if (worldObject is ICollidable)
            {
                CollisionManager.AddCollidable(worldObject as ICollidable);
            }
            else if (worldObject is IDrawManageable)
            {
                DrawManager.AddDrawable(worldObject as IDrawManageable);
            }

            // subscribe components recursively
            foreach (WorldObject wo in worldObject.GetComponents())
            {
                SubscribeToManagers(wo);
            }
        }
Esempio n. 3
0
        private static bool CircularComponentCheck(WorldObject root, HashSet <WorldObject> log)
        {
            // check if the root is in the log, if it is, that means that we have a loop
            if (log.Contains(root))
            {
                return(false);
            }

            // otherwise add the root, and perform a recursive call on all of the components.
            log.Add(root);
            foreach (WorldObject wo in root.GetComponents())
            {
                // if any fail, then stop checking.
                if (!CircularComponentCheck(wo, log))
                {
                    return(false);
                }
            }

            // if none failed, then it checks out
            return(true);
        }
Esempio n. 4
0
        private static bool CircularComponentCheck(WorldObject root, HashSet<WorldObject> log)
        {
            // check if the root is in the log, if it is, that means that we have a loop
            if (log.Contains(root))
                return false;

            // otherwise add the root, and perform a recursive call on all of the components.
            log.Add(root);
            foreach(WorldObject wo in root.GetComponents())
            {
                // if any fail, then stop checking.
                if (!CircularComponentCheck(wo, log))
                    return false;
            }

            // if none failed, then it checks out
            return true;
        }
Esempio n. 5
0
        private void UnsubscribeFromManagers(WorldObject worldObject)
        {
            if (worldObject is ICollidable)
                CollisionManager.AddCollidable(worldObject as ICollidable);
            else if (worldObject is IDrawManageable)
                DrawManager.Remove(worldObject as IDrawManageable);

            // unsubscribe the components recursively
            foreach (WorldObject wo in worldObject.GetComponents())
            {
                UnsubscribeFromManagers(wo);
            }
        }
Esempio n. 6
0
        private void SubscribeToManagers(WorldObject worldObject)
        {
            if (worldObject is ICollidable)
                CollisionManager.AddCollidable(worldObject as ICollidable);
            else if (worldObject is IDrawManageable)
                DrawManager.AddDrawable(worldObject as IDrawManageable);

            // subscribe components recursively
            foreach (WorldObject wo in worldObject.GetComponents())
            {
                SubscribeToManagers(wo);
            }
        }