Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed instancing feature in awareness, so we can use it for the NPE t… #1552

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import com.projectswg.holocore.resources.gameplay.crafting.trade.TradeSession;
import com.projectswg.holocore.resources.gameplay.player.group.GroupInviterData;
import com.projectswg.holocore.resources.support.data.collections.SWGSet;
import com.projectswg.holocore.resources.support.data.location.InstanceLocation;
import com.projectswg.holocore.resources.support.global.network.BaselineBuilder;
import com.projectswg.holocore.resources.support.global.player.Player;
import com.projectswg.holocore.resources.support.global.player.PlayerState;
Expand Down Expand Up @@ -215,6 +216,9 @@ public boolean isWithinAwarenessRange(SWGObject target) {
SWGObject targetParent = target.getSuperParent();
if (myParent != null && myParent == targetParent)
return true;

if (isDifferentInstance(target))
return false;

return switch (target.getBaselineType()) {
case WAYP -> false;
Expand All @@ -223,7 +227,16 @@ public boolean isWithinAwarenessRange(SWGObject target) {
default -> flatDistanceTo(target) <= 400;
};
}


private boolean isDifferentInstance(SWGObject target) {
InstanceLocation myInstanceLocation = getInstanceLocation();
InstanceLocation targetInstanceLocation = target.getInstanceLocation();
boolean differentInstanceType = myInstanceLocation.getInstanceType() != targetInstanceLocation.getInstanceType();
boolean differentInstanceNumber = myInstanceLocation.getInstanceNumber() != targetInstanceLocation.getInstanceNumber();

return differentInstanceType || differentInstanceNumber;
}

@Override
public boolean isVisible(CreatureObject target) {
return !isLoggedOutPlayer() && super.isVisible(target);
Expand Down