/// <summary> /// Creates a new instance of the <see cref="MmoWorld"/> class. /// </summary> /// <param name="server"> The main peer used for communication with other servers and clients. </param> /// <param name="gameConfiguration"> </param> /// <param name="worldDescription"> The world data which contains data of the whole world </param> private MmoWorld(IWorldServer server, GameConfig gameConfiguration, WorldDescription worldDescription) { this.server = server; // world bounds will adjust its size based on the zones this.bounds = new Bounds(Vector3.Zero, Vector3.Zero); this.configuration = gameConfiguration; this.primaryFiber = new SerialThreadFiber(ThreadPriority.Highest); this.primaryFiber.Start(); this.zones = new ConcurrentStorageMap <int, MmoZone>(1000); this.sessionCache = new WorldSessionCache(PeerSettings.MaxLockWaitTime); this.itemCache = new WorldItemCache(); this.LoadWorld(); }
/// <summary> /// Instantiates the singleton of the <see cref="MmoWorld"/>. If it has already been instantiated returns the old instance. /// </summary> public static MmoWorld Instantiate(IWorldServer server, GameConfig gameConfiguration, WorldDescription worldDescription) { lock (typeof(MmoWorld)) return(Instance ?? (Instance = new MmoWorld(server, gameConfiguration, worldDescription))); }