protected void AddVisibleTiles(Level level, Living living, HashSet <GameObject> changedObjects)
        {
            List <GameObject> vision = level.FindAll(obj => obj is Tile && (obj as Tile).SeenBy.ContainsKey(living));

            foreach (GameObject go in vision)
            {
                changedObjects.Add(go);
            }
        }
        public override bool OnClientReceive(LocalClient client)
        {
            //First, make gui elements store their state in a dictionary.
            Dictionary <Guid, Dictionary <string, object> > guiStates = new Dictionary <Guid, Dictionary <string, object> >();

            if (client.Level != null)
            {
                HashSet <GameObject> set = new HashSet <GameObject>(client.Level.FindAll(obj => obj is IGUIGameObject));
                foreach (GameObject obj in set)
                {
                    Dictionary <string, object> guiState = new Dictionary <string, object>();
                    (obj as IGUIGameObject).CleanupGUI(guiState);
                    guiStates.Add(obj.GUID, guiState);
                }
            }

            //Actually update the level.
            client.Level = updatedLevel;
            updatedLevel.InitGUI(null);

            //Now initialise the gui again using the state stored in the dictionaries.
            foreach (GameObject obj in new HashSet <GameObject>(updatedLevel.FindAll(obj => obj is IGUIGameObject)))
            {
                Dictionary <string, object> guiState;
                guiStates.TryGetValue(obj.GUID, out guiState);

                (obj as IGUIGameObject).InitGUI(guiState ?? new Dictionary <string, object>());
            }

            //Finally load animations.
            foreach (GameObject obj in new HashSet <GameObject>(updatedLevel.FindAll(obj => obj is AnimatedGameObject)))
            {
                (obj as AnimatedGameObject).LoadAnimations();
            }

            //And center the camera on the player.
            if (!client.Camera.BoundingBox.Intersects(client.Player.BoundingBox))
            {
                client.Camera.CenterOn(client.Player);
            }

            return(true);
        }
 public void InitLivingObjects()
 {
     livingObjects = Level.FindAll(obj => obj is Living).Cast <Living>().ToList();
     livingObjects.Sort((obj1, obj2) => obj1.Dexterity - obj2.Dexterity);
     turnIndex = livingObjects.Count - 1;
 }
 public override List <Guid> GetFullySerialized(Level level)
 {
     return(level.FindAll(obj => true).ConvertAll(obj => obj.GUID)); //All
 }