예제 #1
0
        /// <summary>
        /// Reload game objects in your region
        /// </summary>
        /// <param name="plr">Player that initiated the command</param>
        /// <param name="values">List of command arguments (after command name)</param>
        /// <returns>True if command was correctly handled, false if operation was canceled</returns>
        public static bool ReloadGameObjects(Player plr, ref List <string> values)
        {
            GameObjectService.LoadGameObjectProtos();
            plr.SendClientMessage("RELOADGAMEOBJECTS: Game objects loaded : " + GameObjectService.GameObjectProtos.Count);

            List <Object> allCells = new List <Object>();

            allCells.AddRange(plr._Cell.Objects);
            foreach (Object obj in allCells)
            {
                GameObject gameObject = obj as GameObject;

                if (gameObject != null)
                {
                    try
                    {
                        GameObject_proto proto = GameObjectService.GameObjectProtos[gameObject.Entry];
                        gameObject.Spawn.Proto = proto;
                    }
                    catch
                    {
                        plr.SendClientMessage("RELOADGAMEOBJECTS: GameObject with Entry " + gameObject.Entry + " not found in GameObjects, removing GameObject");
                        gameObject.Spawn.Proto = null;
                    }
                    gameObject.Region.CreateGameObject(gameObject.Spawn);
                    gameObject.Dispose();
                }
            }
            plr.SendClientMessage("RELOADGAMEOBJECTS: GameObject spawns loaded : " + GameObjectService.GameObjectSpawns.Count);
            return(true);
        }