當前位置: 首頁>>代碼示例>>C#>>正文


C# World.UnloadMap方法代碼示例

本文整理匯總了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();
            }
        }
開發者ID:fragmer,項目名稱:fCraft,代碼行數:31,代碼來源:WorldManager.cs

示例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;
            }
        }
開發者ID:asiekierka,項目名稱:afCraft,代碼行數:40,代碼來源:Server.cs

示例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;
            }
        }
開發者ID:fragmer,項目名稱:fCraft,代碼行數:62,代碼來源:WorldManager.cs


注:本文中的fCraft.World.UnloadMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。