Skip to content

Commit

Permalink
Update the area overlay when changing a turf's area
Browse files Browse the repository at this point in the history
  • Loading branch information
wixoaGit committed Jan 2, 2025
1 parent 3a8c33b commit 5593112
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions OpenDreamRuntime/DreamMapManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,12 @@ public DreamObjectArea Area {
_area.Turfs.Remove(Turf);
_area.ResetCoordinateCache();

var oldArea = _area;
_area = value;
_area.Turfs.Add(Turf);
_area.ResetCoordinateCache();

Turf.OnAreaChange(oldArea);
}
}

Expand Down
10 changes: 10 additions & 0 deletions OpenDreamRuntime/Objects/Types/DreamObjectTurf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ public void SetTurfType(DreamObjectDefinition objectDefinition) {
Initialize(new());
}

public void OnAreaChange(DreamObjectArea oldArea) {
if (Cell == null!)
return;

var newAppearance = Appearance.ToMutable();

newAppearance.Overlays.Remove(oldArea.Appearance);
DreamMapManager.SetTurfAppearance(this, newAppearance);
}

protected override bool TryGetVar(string varName, out DreamValue value) {
switch (varName) {
case "x":
Expand Down

0 comments on commit 5593112

Please sign in to comment.