Esempio n. 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;
  }
Esempio n. 2
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();
   }
 }
Esempio n. 3
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);
  }
Esempio n. 4
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;
   }
 }
Esempio n. 5
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;
   }
 }
Esempio n. 6
0
 private void processObjectCreateIntent(ObjectCreateIntent intent) {
   SWGObject object = intent.getObject();
   objectMap.put(object.getObjectId(), object);
 }
Esempio n. 7
0
 private void addChildrenObjects(SWGObject obj) {
   for (SWGObject child : obj.getContainedObjects()) {
     objectMap.put(child.getObjectId(), child);
     addChildrenObjects(child);
   }
 }