예제 #1
0
 /// <summary>
 /// The try get.
 /// </summary>
 /// <param name="name">
 /// The world name.
 /// </param>
 /// <param name="world">
 /// The world.
 /// </param>
 /// <returns>
 /// true if found.
 /// </returns>
 public bool TryGet(string name, out MmoWorld world)
 {
     using (ReadLock.TryEnter(this.readWriteLock, Settings.MaxLockWaitTimeMilliseconds))
     {
         return this.dict.TryGetValue(name, out world);
     }
 }
예제 #2
0
        /// <summary>
        /// The try create.
        /// </summary>
        /// <param name="name">
        /// The world name.
        /// </param>
        /// <param name="topLeftCorner">
        /// The top left corner.
        /// </param>
        /// <param name="bottomRightCorner">
        /// The bottom right corner.
        /// </param>
        /// <param name="tileDimensions">
        /// The tile dimensions.
        /// </param>
        /// <param name="world">
        /// The world.
        /// </param>
        /// <returns>
        /// true if create.
        /// </returns>
        public bool TryCreate(string name, Vector topLeftCorner, Vector bottomRightCorner, Vector tileDimensions, out MmoWorld world)
        {
            using (WriteLock.TryEnter(this.readWriteLock, Settings.MaxLockWaitTimeMilliseconds))
            {
                if (this.dict.TryGetValue(name, out world))
                {
                    return false;
                }

                world = new MmoWorld(name, topLeftCorner, bottomRightCorner, tileDimensions);
                this.dict.Add(name, world);
                return true;
            }
        }