mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-07-30 00:15:50 -04:00
Merge branch 'master' of https://bitbucket.org/projectswg/core3 into awareness
Conflicts: src/services/objects/ObjectManager.java src/services/player/ZoneService.java
This commit is contained in:
@@ -145,37 +145,13 @@ public class ObjectManager extends Manager {
|
||||
addObjectAttributes(obj, template);
|
||||
obj.setTemplate(template);
|
||||
obj.setLocation(l);
|
||||
addToQuadtree(obj, l);
|
||||
// moveObject(obj, null, l);
|
||||
// addToQuadtree(obj, l);
|
||||
moveObject(obj, null, l);
|
||||
objects.put(objectId, obj);
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
// Adds an object to the quadtree and refreshes awareness lists in the object added as well as adds the Player to objects in range (if there is one)
|
||||
private void addToQuadtree(SWGObject obj, Location loc) {
|
||||
if (loc == null || loc.isNaN()) // Object is inside a container or it's a slot of an item
|
||||
return;
|
||||
|
||||
double x = loc.getX(), z = loc.getY();
|
||||
|
||||
List<Player> awarePlayers = new ArrayList<Player>();
|
||||
|
||||
QuadTree<SWGObject> tree = quadTree.get(loc.getTerrain());
|
||||
for (SWGObject inRange : tree.getWithinRange(x, z, AWARE_RANGE)) {
|
||||
if (inRange != null && inRange.getOwner() != null && inRange.getObjectId() != obj.getObjectId()) {
|
||||
if (obj.getOwner() != null)
|
||||
inRange.updateAwareness(obj.getOwner(), true);
|
||||
|
||||
awarePlayers.add(inRange.getOwner());
|
||||
}
|
||||
}
|
||||
if (awarePlayers.size() > 0)
|
||||
obj.updateAwareness(awarePlayers);
|
||||
|
||||
quadTree.get(loc.getTerrain()).put(x, z, obj);
|
||||
}
|
||||
|
||||
private void moveObject(SWGObject obj, Location oldLocation, Location newLocation) {
|
||||
if (oldLocation != null && oldLocation.getTerrain() != null) { // Remove from QuadTree
|
||||
double x = oldLocation.getX();
|
||||
|
||||
Reference in New Issue
Block a user