本文整理汇总了C#中fCraft.World.UnloadMap方法的典型用法代码示例。如果您正苦于以下问题:C# World.UnloadMap方法的具体用法?C# World.UnloadMap怎么用?C# World.UnloadMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fCraft.World
的用法示例。
在下文中一共展示了World.UnloadMap方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReplaceWorld
internal static void ReplaceWorld( World oldWorld, World newWorld ) {
if( oldWorld == null ) throw new ArgumentNullException( "oldWorld" );
if( newWorld == null ) throw new ArgumentNullException( "newWorld" );
lock( WorldListLock ) {
if( oldWorld == newWorld ) {
throw new WorldOpException( oldWorld.Name, WorldOpExceptionCode.NoChangeNeeded );
}
if( !Worlds.ContainsValue( oldWorld ) ) {
throw new WorldOpException( oldWorld.Name, WorldOpExceptionCode.WorldNotFound );
}
if( Worlds.ContainsValue( newWorld ) ) {
throw new InvalidOperationException( "New world already exists on the list." );
}
// cycle load/unload on the new world to save it under the new name
newWorld.Name = oldWorld.Name;
newWorld.UnloadMap( false );
Worlds[oldWorld.Name.ToLower()] = newWorld;
// change the main world, if needed
if( oldWorld == MainWorld ) {
MainWorld = newWorld;
}
UpdateWorldList();
}
}
示例2: AddWorld
public static World AddWorld( string name, Map map, bool neverUnload )
{
lock( worldListLock ) {
if( worlds.ContainsKey( name ) ) return null;
if( !Player.IsValidName( name ) ) return null;
World newWorld = new World( name );
newWorld.neverUnload = neverUnload;
if( map != null ) {
// if a map is given
newWorld.map = map;
if( !neverUnload ) {
newWorld.UnloadMap();// UnloadMap also saves the map
} else {
newWorld.SaveMap( null );
}
} else {
// generate default map
if( neverUnload ) newWorld.LoadMap();
}
worlds.Add( name, newWorld );
newWorld.updateTaskId = AddTask( UpdateBlocks, Config.GetInt( ConfigKey.TickInterval ), newWorld );
if( Config.GetInt( ConfigKey.SaveInterval ) > 0 ) {
int saveInterval = Config.GetInt( ConfigKey.SaveInterval ) * 1000;
newWorld.saveTaskId = AddTask( SaveMap, saveInterval, newWorld, saveInterval );
}
if( Config.GetInt( ConfigKey.BackupInterval ) > 0 ) {
int backupInterval = Config.GetInt( ConfigKey.BackupInterval ) * 1000 * 60;
newWorld.backupTaskId = AddTask( AutoBackup, backupInterval, newWorld, (Config.GetBool( ConfigKey.BackupOnStartup ) ? 0 : backupInterval) );
}
newWorld.UpdatePlayerList();
return newWorld;
}
}
示例3: AddWorld
public static World AddWorld( Player player, string name, Map map, bool neverUnload ) {
if( name == null ) throw new ArgumentNullException( "name" );
if( !World.IsValidName( name ) ) {
throw new WorldOpException( name, WorldOpExceptionCode.InvalidWorldName );
}
lock( WorldListLock ) {
if( Worlds.ContainsKey( name.ToLower() ) ) {
throw new WorldOpException( name, WorldOpExceptionCode.DuplicateWorldName );
}
if( RaiseWorldCreatingEvent( player, name, map ) ) {
throw new WorldOpException( name, WorldOpExceptionCode.PluginDenied );
}
World newWorld = new World( name, neverUnload );
if( map != null ) {
newWorld.Map = map;
map.World = newWorld;
/*
string accessSecurityString = map.GetMeta( "security", "access" );
if( accessSecurityString != null ) {
try {
newWorld.AccessSecurity = new SecurityController( XElement.Parse( accessSecurityString ) );
} catch( XmlException ex ) {
Logger.Log( "WorldManager.AddWorld: Error loading stored access permissions: {0}", LogType.Error, ex );
}
}
string buildSecurityString = map.GetMeta( "security", "build" );
if( buildSecurityString != null ) {
try {
newWorld.BuildSecurity = new SecurityController( XElement.Parse( buildSecurityString ) );
} catch( XmlException ex ) {
Logger.Log( "WorldManager.AddWorld: Error loading stored build permissions: {0}", LogType.Error, ex );
}
}
*/
// if a map is given
if( neverUnload ) {
newWorld.StartTasks();
}else{
newWorld.UnloadMap( false );
}
} else if( neverUnload ){
newWorld.LoadMap();
map = newWorld.Map;
}
Worlds.Add( name.ToLower(), newWorld );
UpdateWorldList();
RaiseWorldCreatedEvent( player, newWorld );
return newWorld;
}
}