示例#1
0
        /// <summary>
        /// Loads a world to the server. If a world by that name is already loaded, will simply return that world.
        /// </summary>
        /// <param name="name">The name of the world.</param>
        /// <returns>A world object.</returns>
        public World LoadWorld(string name)
        {
            string nl = name.ToLowerFast();

            for (int i = 0; i < LoadedWorlds.Count; i++)
            {
                if (LoadedWorlds[i].Name == nl)
                {
                    return(LoadedWorlds[i]);
                }
            }
            WorldLoadPreEventArgs e = new WorldLoadPreEventArgs()
            {
                WorldName = name
            };

            OnWorldLoadPreEvent.Fire(e);
            if (e.Cancelled)
            {
                return(null);
            }
            World world = new World()
            {
                Name      = nl,
                TheServer = this
            };
            WorldLoadEventArgs e2 = new WorldLoadEventArgs()
            {
                TheWorld = world
            };

            OnWorldLoadEvent.Fire(e2);
            if (e.Cancelled)
            {
                world.UnloadFully(null);
                return(null);
            }
            LoadedWorlds.Add(world);
            OnWorldLoadPostEvent.Fire(new WorldLoadPostEventArgs()
            {
                TheWorld = world
            });
            world.Start();
            return(world);
        }
示例#2
0
 public World LoadWorld(string name)
 {
     string nl = name.ToLowerFast();
     for (int i = 0; i < LoadedWorlds.Count; i++)
     {
         if (LoadedWorlds[i].Name == nl)
         {
             return LoadedWorlds[i];
         }
     }
     WorldLoadPreEventArgs e = new WorldLoadPreEventArgs() { WorldName = name };
     OnWorldLoadPreEvent.Fire(e);
     if (e.Cancelled)
     {
         return null;
     }
     World world = new World();
     world.Name = nl;
     world.TheServer = this;
     WorldLoadEventArgs e2 = new WorldLoadEventArgs() { TheWorld = world };
     OnWorldLoadEvent.Fire(e2);
     if (e.Cancelled)
     {
         world.UnloadFully(null);
         return null;
     }
     LoadedWorlds.Add(world);
     OnWorldLoadPostEvent.Fire(new WorldLoadPostEventArgs() { TheWorld = world });
     world.Start();
     return world;
 }