Example #1
0
  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;
  }
Example #2
0
 public SWGObject deleteObject(long objId) {
   synchronized (objectMap) {
     SWGObject obj = objectMap.remove(objId);
     database.remove(objId);
     if (obj == null) return null;
     obj.clearAware();
     objectAwareness.remove(obj);
     Log.i("ObjectManager", "Deleted object %d [%s]", obj.getObjectId(), obj.getTemplate());
     return obj;
   }
 }
Example #3
0
 private void loadClientObjects() {
   for (SWGObject obj : clientBuildoutService.loadClientObjects().values()) {
     synchronized (objectMap) {
       if (obj.getObjectId() >= maxObjectId) {
         maxObjectId = obj.getObjectId() + 1;
       }
     }
     objectMap.put(obj.getObjectId(), obj);
     new ObjectCreatedIntent(obj).broadcast();
   }
 }
Example #4
0
 public SWGObject createObject(
     SWGObject parent, String template, Location l, boolean addToDatabase) {
   synchronized (objectMap) {
     long objectId = getNextObjectId();
     SWGObject obj = ObjectCreator.createObjectFromTemplate(objectId, template);
     if (obj == null) {
       System.err.println("ObjectManager: Unable to create object with template " + template);
       return null;
     }
     obj.setLocation(l);
     objectMap.put(objectId, obj);
     if (parent != null) {
       parent.addObject(obj);
     }
     if (addToDatabase) {
       database.put(objectId, obj);
     }
     Log.i("ObjectManager", "Created object %d [%s]", obj.getObjectId(), obj.getTemplate());
     new ObjectCreatedIntent(obj).broadcast();
     return obj;
   }
 }
Example #5
0
 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());
     }
   }
 }
Example #6
0
 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();
 }
Example #7
0
 private void processObjectCreateIntent(ObjectCreateIntent intent) {
   SWGObject object = intent.getObject();
   objectMap.put(object.getObjectId(), object);
 }
Example #8
0
 private void addChildrenObjects(SWGObject obj) {
   for (SWGObject child : obj.getContainedObjects()) {
     objectMap.put(child.getObjectId(), child);
     addChildrenObjects(child);
   }
 }
Example #9
0
  private void loadObject(SWGObject obj) {
    obj.setOwner(null);
    // if player is not a player
    if (!(obj instanceof CreatureObject && ((CreatureObject) obj).hasSlot("ghost")))
      objectAwareness.add(obj);
    if (obj instanceof CreatureObject && ((CreatureObject) obj).getPlayerObject() != null) {
      if (!obj.hasSlot("bank")) {
        SWGObject missing =
            createObject(obj, "object/tangible/bank/shared_character_bank.iff", false);
        missing.setContainerPermissions(ContainerPermissions.INVENTORY);
      }

      if (!obj.hasSlot("mission_bag")) {
        SWGObject missing =
            createObject(obj, "object/tangible/mission_bag/shared_mission_bag.iff", false);
        missing.setContainerPermissions(ContainerPermissions.INVENTORY);
      }

      if (!obj.hasSlot("appearance_inventory")) {
        SWGObject missing =
            createObject(obj, "object/tangible/inventory/shared_appearance_inventory.iff", false);
        missing.setContainerPermissions(ContainerPermissions.INVENTORY);
      }
    }
    objectMap.put(obj.getObjectId(), obj);
    updateBuildoutParent(obj);
    addChildrenObjects(obj);
  }