Skip to content

Commit

Permalink
Tidying of some remaining logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ben_singer committed Nov 22, 2024
1 parent f9f5978 commit cac7dd3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion NetAF.Tests/Assets/Locations/Room_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public void GivenNotBeenVisited_WhenGetHasBeenVisited_ThenFalse()
public void GivenVisited_WhenGetHasBeenVisited_ThenTrue()
{
var room = new Room(string.Empty, string.Empty);
room.MovedInto(null);
room.MovedInto();

Assert.IsTrue(room.HasBeenVisited);
}
Expand Down
4 changes: 2 additions & 2 deletions NetAF/Assets/Locations/Region.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public bool Move(Direction direction)
public void SetStartRoom(Room room)
{
CurrentRoom = room;
CurrentRoom.MovedInto(null);
CurrentRoom.MovedInto();
}

/// <summary>
Expand Down Expand Up @@ -280,7 +280,7 @@ public bool JumpToRoom(Point3D location)
return false;

CurrentRoom = roomPosition.Room;
CurrentRoom.MovedInto(null);
CurrentRoom.MovedInto();

return true;
}
Expand Down
20 changes: 14 additions & 6 deletions NetAF/Assets/Locations/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ public sealed class Room : ExaminableObject, IInteractWithItem, IItemContainer,
public Exit this[Direction direction] => Array.Find(Exits, e => e.Direction == direction);

/// <summary>
/// Get which direction this Room was entered from.
/// Get which direction this room was entered from.
/// </summary>
public Direction? EnteredFrom { get; private set; }

/// <summary>
/// Get an introduction for this Room.
/// Get an introduction for this room.
/// </summary>
public IDescription Introduction { get; private set; }

Expand Down Expand Up @@ -440,15 +440,23 @@ public bool FindCharacter(string characterName, out NonPlayableCharacter charact
}

/// <summary>
/// Handle movement into this GameLocation.
/// Handle movement into this room.
/// </summary>
/// <param name="fromDirection">The direction movement into this Room is from. Use null if there is no direction.</param>
public void MovedInto(Direction? fromDirection)
public void MovedInto()
{
EnteredFrom = fromDirection;
HasBeenVisited = true;
}

/// <summary>
/// Handle movement into this room.
/// </summary>
/// <param name="fromDirection">The direction movement into this room.</param>
public void MovedInto(Direction fromDirection)
{
EnteredFrom = fromDirection;
MovedInto();
}

#endregion

#region IInteractWithItem Members
Expand Down

0 comments on commit cac7dd3

Please sign in to comment.