Added onObjectMovedInAware function to SWGObject

This commit is contained in:
Obique PSWG
2017-05-21 10:31:58 -05:00
parent 0dd32bb1a5
commit d41438ad65
2 changed files with 20 additions and 0 deletions
@@ -82,6 +82,7 @@ public class AwarenessHandler implements AutoCloseable {
obj.setLocation(requestedLocation);
if (obj.getParent() != null)
obj.moveToContainer(null);
notifyObjectMoved(obj);
// Update awareness
if (obj.getTerrain() != Terrain.GONE) {
TerrainMap map = getTerrainMap(requestedLocation.getTerrain());
@@ -101,6 +102,7 @@ public class AwarenessHandler implements AutoCloseable {
oldMap.removeWithoutUpdate(obj);
// Update location
obj.setLocation(requestedLocation);
notifyObjectMoved(obj);
// Update awareness
if (obj.getParent() != parent)
obj.moveToContainer(parent);
@@ -120,6 +122,16 @@ public class AwarenessHandler implements AutoCloseable {
obj.clearCustomAware(true);
}
private void notifyObjectMoved(SWGObject obj) {
try {
for (SWGObject aware : obj.getObjectsAware())
obj.onObjectMoveInAware(aware);
} catch (Throwable t) {
Log.e("Throwable caught when notifying onObjectMoveInAware");
Log.e(t);
}
}
private TerrainMap getTerrainMap(SWGObject object) {
Terrain t = object.getTerrain();
if (t == null)