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