Tomm0017 / rsmod

New repository: https://github.com/rsmod/rsmod
https://github.com/rsmod/rsmod
Apache License 2.0
125 stars 101 forks source link

[✅API BACK-COMPAT] Fixed TileCondition functionality #177

Open nbness2 opened 4 years ago

nbness2 commented 4 years ago

Problem: TileCondition (used by QueueTask.waitTile(Tile) does not work correctly.

Symptom: Tile properties that are used in Tile.sameAs(Tile) are val thus cannot be changed. When a Tile was passed to TileCondition as src. It seems as though the intention was for src to update as a reference the properties update, but the properties will never update (because they are val), thus rendering TileCondition useless.

Solution: TileCondition now takes Pawn and Tile (TileCondition(Pawn, Tile)), and since Pawn.tile is a var it means that it changes as Pawn.tile changes, and it allows TileCondition to work as expected.

QueueTask.waitTile(tile: Tile) has been changed to QueueTask.waitTile(tile: Tile, pawn: Pawn = ctx as Pawn) to keep backwards compatibility and preserve previous functionality while also giving the developer a bit more control over which Pawn they want to reach the tile before continuing the logic.