mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2026-08-28 05:45:10 -06:00
Scenery object size as it's area
This commit is contained in:
parent
9c5a4c88d5
commit
d7c03670c6
2 changed files with 38 additions and 3 deletions
|
|
@ -121,13 +121,13 @@ public abstract class Pathfinder {
|
|||
*/
|
||||
public static Path find(Location start, int moverSize, Node destination, boolean near, Pathfinder finder, ClipMaskSupplier clipMaskSupplier) {
|
||||
if (destination instanceof Scenery) {
|
||||
Scenery object = (Scenery) destination;
|
||||
Scenery object = getRouteScenery((Scenery) destination);
|
||||
int type = object.getType();
|
||||
int rotation = object.getRotation();
|
||||
if (type == 10 || type == 11 || type == 22) {
|
||||
return finder.find(start, moverSize, destination.getLocation(), object.getDefinition().sizeX, object.getDefinition().sizeY, rotation, type, object.getDefinition().getWalkingFlag(), near, clipMaskSupplier);
|
||||
return finder.find(start, moverSize, object.getLocation(), object.getDefinition().sizeX, object.getDefinition().sizeY, rotation, type, object.getDefinition().getWalkingFlag(), near, clipMaskSupplier);
|
||||
}
|
||||
return finder.find(start, moverSize, destination.getLocation(), 0, 0, rotation, type, 0, near, clipMaskSupplier);
|
||||
return finder.find(start, moverSize, object.getLocation(), 0, 0, rotation, type, 0, near, clipMaskSupplier);
|
||||
}
|
||||
int size = 0;
|
||||
if (destination instanceof Entity) {
|
||||
|
|
@ -138,6 +138,21 @@ public abstract class Pathfinder {
|
|||
return finder.find(start, moverSize, destination.getLocation(), size, size, 0, -1, 0, near, clipMaskSupplier);
|
||||
}
|
||||
|
||||
private static Scenery getRouteScenery(Scenery object) {
|
||||
Scenery wrapper = object.getWrapper();
|
||||
if (wrapper == object) {
|
||||
return object;
|
||||
}
|
||||
if (getFootprintArea(wrapper) <= getFootprintArea(object)) {
|
||||
return object;
|
||||
}
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
private static int getFootprintArea(Scenery object) {
|
||||
return object.getDefinition().sizeX * object.getDefinition().sizeY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if interaction with decoration is possible.
|
||||
* @param curX The current x-coordinate in viewport.
|
||||
|
|
|
|||
|
|
@ -172,6 +172,26 @@ class PathfinderTests {
|
|||
}
|
||||
}
|
||||
|
||||
@Test fun pathfinderShouldUseWrapperFootprintWhenSceneryChildIsSmallerThanWrapper() {
|
||||
TestUtils.getMockPlayer("taverleyPatchChildPath").use { p ->
|
||||
val wrapper = RegionManager.getObject(0, 2935, 3437, 8388)
|
||||
?: throw AssertionError("Expected Taverley tree patch wrapper.")
|
||||
val child = wrapper.getChild(p)
|
||||
val start = Location.create(2936, 3440, 0)
|
||||
|
||||
Assertions.assertEquals(8395, child.id)
|
||||
Assertions.assertTrue(wrapper.definition.sizeX * wrapper.definition.sizeY > child.definition.sizeX * child.definition.sizeY)
|
||||
|
||||
val path = Pathfinder.find(start, child)
|
||||
val last = path.points.lastOrNull() ?: throw AssertionError("Expected a path point.")
|
||||
val approach = Location.create(last.x, last.y, start.z)
|
||||
|
||||
Assertions.assertTrue(path.isSuccessful)
|
||||
Assertions.assertFalse(path.isMoveNear)
|
||||
Assertions.assertEquals(start, approach)
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun entityMovementPulseShouldTriggerWhenDestinationOverrideIsAlreadyReached() {
|
||||
TestUtils.getMockPlayer("bankerOverrideApproach").use { p ->
|
||||
val npc = NPC.create(0, NPC_TEST_LOC)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue