Beispiel #1
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;
   }
 }
Beispiel #2
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;
   }
 }