Exemplo n.º 1
0
 internal static void RemoveMap(BaseGameMap map)
 {
     lock ( m_Maps ) {
         if (m_Maps.ContainsKey(map.Keyword))
         {
             // GameDebugger.Log("World removed map");
             m_Maps.Remove(map.Keyword);
             map.Removed = true;
         }
     }
 }
Exemplo n.º 2
0
 public static void AddMap(BaseGameMap map)
 {
     lock ( m_Maps ) {
         if (m_Maps.ContainsKey(map.Keyword))
         {
             throw new UserFriendlyException("Map with such keyword is already registered", "There was an error when game tried to add a new map with an already existing keyword to the game universe");
         }
         // GameDebugger.Log("World added map");
         m_Maps.Add(map.Keyword, map);
         ActiveMaps.Add(map);                 // by default newly added maps are always active in the beginning
     }
 }
Exemplo n.º 3
0
        internal static void MoveObjectAcrossMaps(BaseGameObject obj, BaseGameMap map)
        {
            lock ( Objects ) {
                if (obj.BaseGameMap != map)
                {
                    if (Objects.ContainsKey(obj.UID))
                    {
                        // GameDebugger.Log("World moved object across maps");
                        bool wasActive = obj.m_ObjectActive;
                        if (obj.m_BaseGameMap != null)
                        {
                            obj.m_BaseGameMap.RemoveObject(obj);
                        }
                        else if (wasActive)
                        {
                            // GameDebugger.Log("World deactivated object (moam)");
                            ActiveObjects.Remove(obj);
                            obj.m_ObjectActive = false;
                            obj.OnDeactivateObjectInternal();
                        }

                        obj.m_BaseGameMap = map;

                        if (map != null)
                        {
                            map.AddObject(obj);
                            if (wasActive)
                            {
                                map.ActivateObject(obj);
                            }
                        }
                        else if (wasActive)
                        {
                            // GameDebugger.Log("World activated object (moam)");
                            ActiveObjects.Add(obj);
                            obj.m_ObjectActive = true;
                            obj.OnActivateObjectInternal();
                        }
                    }
                    else
                    {
                        // GameDebugger.Log("World updated object map");
                        obj.m_BaseGameMap = map;
                    }
                }
            }
        }
Exemplo n.º 4
0
 public static void RemoveObject(BaseGameObject obj)
 {
     lock ( Objects ) {
         if (Objects.ContainsKey(obj.UID))
         {
             obj.OnBeforeRemoveObjectInternal();
             // GameDebugger.Log("World removed object");
             Objects.Remove(obj.UID);
             BaseGameMap map = obj.BaseGameMap;
             if (map != null)
             {
                 map.RemoveObject(obj);
             }
             else if (obj.m_ObjectActive)
             {
                 // GameDebugger.Log("World deactivated object (on remove)");
                 ActiveObjects.Remove(obj);
                 obj.m_ObjectActive = false;
                 obj.OnDeactivateObjectInternal();
             }
             obj.OnAfterRemoveObjectInternal();
         }
     }
 }