public bool Move(int DeltaX, int DeltaY) //Mainly for players. It'll move the player on the board { //Changes entity's X and Y location so that it can move around the board int NewX = X + DeltaX; int NewY = Y + DeltaY; //Stores the old X and Y values for later comparisons int OldX = X; int OldY = Y; //If the new location is out of the bounds of the room if (NewX < 0 || NewY < 0 || NewX >= CurrentRoom.Width || NewY >= CurrentRoom.Height) { return(false); } //Checking if the new tile is null; only because you can't get a null value's navigable if (CurrentRoom.Get(NewX, NewY) == null) { X = NewX; Y = NewY; CurrentRoom.Move(OldX, OldY, NewX, NewY); return(true); } else { //HasValue is for nullable booleans, so you don't accidently check if null is true if (CurrentRoom.Get(NewX, NewY).Navigable) { X = NewX; Y = NewY; bool DoMove = CurrentRoom.map[NewY][NewX] is Exit exit && !exit.Locked && exit.Enterable; CurrentRoom.Move(OldX, OldY, NewX, NewY); if (DoMove) { ((Exit)CurrentRoom.ImmutableMap[NewY][NewX]).NewRoom((Player)this, OldX, OldY); } return(true); } } return(false); }