Exemple #1
0
 /// <summary>
 /// Allows for removal of a doorway.
 /// </summary>
 /// <param name="direction">The direction of travel that the doorway should be removed.</param>
 /// <param name="autoRemoveReverseDirection">If true, the room on the otherside of the doorway will have it's door removed as well.</param>
 public virtual void RemoveDoorway(AvailableTravelDirections direction, bool autoRemoveReverseDirection = true)
 {
     if (Doorways.ContainsKey(direction))
     {
         if (autoRemoveReverseDirection)
         {
             //When removig the reverse direction, always set "autoRemoveReverseDirection" within the Arrival room
             //to false, otherwise a circular loop will start.
             Doorways[direction].Arrival.RemoveDoorway(TravelDirections.GetReverseDirection(direction), false);
         }
         Doorways.Remove(direction);
     }
 }
Exemple #2
0
        /// <summary>
        /// Adds a doorway to the Room, linking it to another Room in the world.
        /// </summary>
        /// <param name="direction">The direction that the player must travel in order to move through the doorway</param>
        /// <param name="arrivalRoom">The room that the player will enter, once they walk through the doorway</param>
        /// <param name="autoAddReverseDirection">If true, the arrival room will have the opposite doorway automatically linked back to this Room</param>
        /// <param name="forceOverwrite">If true, if a doorway already exists for the specified direction, it will overwrite it.</param>
        public virtual void AddDoorway(AvailableTravelDirections direction, IRoom arrivalRoom, bool autoAddReverseDirection = true, bool forceOverwrite = true)
        {
            // Check if room is null.
            if (arrivalRoom == null)
            {
                return; // No null references within our collections!
            }
            // If this direction already exists, overwrite it
            // but only if 'forceOverwrite' is true
            if (Doorways.ContainsKey(direction))
            {
                // Remove the old door
                RemoveDoorway(direction);
                // Get a scripted Door instance to add back to the collection
                var door = (Door)ScriptFactory.GetScript(MudDesigner.Engine.Properties.EngineSettings.Default.DoorScript);
                door.SetArrivalRoom(arrivalRoom);
                door.SetDepartingRoom(this);
                door.SetFacingDirection(direction);

                Doorways.Add(direction, door);
            }
            // Direction does not exist, so lets add a new doorway
            else
            {
                // Get a scripted instance of a Door.
                var door = (Door)ScriptFactory.GetScript(MudDesigner.Engine.Properties.EngineSettings.Default.DoorScript);
                door.SetFacingDirection(direction);
                door.SetArrivalRoom(arrivalRoom);
                door.SetDepartingRoom(this);


                // Add the new doorway to this rooms collection.
                Doorways.Add(direction, door);

                // If autoreverse is enabled, add the doorway to the arrival room too.
                if (autoAddReverseDirection)
                {
                    arrivalRoom.AddDoorway(TravelDirections.GetReverseDirection(direction), this, false, forceOverwrite);
                }
            }
        }