public SWGObject destroyObject(SWGObject object) { long objId = object.getObjectId(); for (SWGObject slottedObj : object.getSlots().values()) { if (slottedObj != null) destroyObject(slottedObj); } Iterator<SWGObject> containerIterator = object.getContainedObjects().iterator(); while (containerIterator.hasNext()) { SWGObject containedObject = containerIterator.next(); if (containedObject != null) destroyObject(containedObject); } // Remove object from the parent SWGObject parent = object.getParent(); if (parent != null) { if (parent instanceof CreatureObject) { ((CreatureObject) parent).removeEquipment(object); } object.sendObserversAndSelf(new SceneDestroyObject(objId)); parent.removeObject(object); } else { object.sendObservers(new SceneDestroyObject(objId)); } // Finally, remove from the awareness tree deleteObject(object.getObjectId()); return object; }
private void updateBuildoutParent(SWGObject obj) { if (obj.getParent() != null) { if (obj.getParent().isBuildout()) { long id = obj.getParent().getObjectId(); obj.getParent().removeObject(obj); SWGObject parent = objectMap.get(id); if (parent != null) parent.addObject(obj); else { System.err.println("Parent for " + obj + " is null! ParentID: " + id); Log.e("ObjectManager", "Parent for %s is null! ParentID: %d", obj, id); } } else { updateBuildoutParent(obj.getParent()); } } }
private void zoneInCharacter( PlayerManager playerManager, String galaxy, long netId, long characterId) { Player player = playerManager.getPlayerFromNetworkId(netId); if (player == null) { Log.e("ObjectManager", "Unable to zone in null player '%d'", netId); return; } SWGObject creatureObj = objectMap.get(characterId); if (creatureObj == null) { System.err.println( "ObjectManager: Failed to start zone - CreatureObject could not be fetched from database [Character: " + characterId + " User: "******"]"); Log.e( "ObjectManager", "Failed to start zone - CreatureObject could not be fetched from database [Character: %d User: %s]", characterId, player.getUsername()); sendClientFatal( player, "Failed to zone", "You were not found in the database\nTry relogging to fix this problem", 10, TimeUnit.SECONDS); return; } if (!(creatureObj instanceof CreatureObject)) { System.err.println( "ObjectManager: Failed to start zone - Object is not a CreatureObject for ID " + characterId); Log.e( "ObjectManager", "Failed to start zone - Object is not a CreatureObject [Character: %d User: %s]", characterId, player.getUsername()); sendClientFatal( player, "Failed to zone", "There has been an internal server error: Not a Creature.\nPlease delete your character and create a new one", 10, TimeUnit.SECONDS); return; } if (((CreatureObject) creatureObj).getPlayerObject() == null) { System.err.println( "ObjectManager: Failed to start zone - " + player.getUsername() + "'s CreatureObject has a null ghost!"); Log.e( "ObjectManager", "Failed to start zone - CreatureObject doesn't have a ghost [Character: %d User: %s", characterId, player.getUsername()); sendClientFatal( player, "Failed to zone", "There has been an internal server error: Null Ghost.\nPlease delete your character and create a new one", 10, TimeUnit.SECONDS); return; } if (creatureObj.getParent() != null) { objectAwareness.update(creatureObj); Log.d( "ObjectManager", "Zoning in to %s/%s - %s", creatureObj.getParent(), creatureObj.getTerrain(), creatureObj.getLocation().getPosition()); } else { objectAwareness.remove(creatureObj); objectAwareness.add(creatureObj); Log.d( "ObjectManager", "Zoning in to %s - %s", creatureObj.getTerrain(), creatureObj.getLocation().getPosition()); } new RequestZoneInIntent(player, (CreatureObject) creatureObj, galaxy).broadcast(); }