Merged development into CORE-103-inventory-features

This commit is contained in:
Mads Boddum
2015-05-22 06:03:45 +02:00
11 changed files with 148 additions and 23 deletions
+17 -14
View File
@@ -60,7 +60,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
private static final long serialVersionUID = 1L;
private final List <SWGObject> children;
private final List <SWGObject> children; // TODO Move this into slot-type system as only containers can have multiple children in 1 slot
private final Location location;
private final long objectId;
private final Map <String, SWGObject> slots; // Can only be occupied one time, containers are slots who have children
@@ -111,7 +111,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
private void updateContainment(SWGObject child) {
if (child.parent != null)
child.parent.removeChild(child);
child.parent.removeChild(child); // Is this necessary?
child.parent = this;
Integer containmentType = (Integer)child.getTemplateAttribute("containerType");
if (containmentType == null)
@@ -144,7 +144,9 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
public boolean hasSlot(String slot) {
return slots.containsKey(slot);
}
// TODO Refactor slots to just be used in addChild and removeChild as the proper slots can be set by using arrangement descriptors
public boolean setSlot(String slot, SWGObject obj) {
if (!slots.containsKey(slot)) {
System.err.println("Could not set " + obj.getTemplate() + " to " + getTemplate() + " as it doesn't contain slot " + slot + "!");
@@ -161,7 +163,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
}
if (occupiedAvailSlots.size() != arrangement.size()) {
System.err.println("Doesn't have all the slots.");
System.err.println("Needed slots are not available for " + obj);
return false;
}
@@ -173,8 +175,8 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
return true;
}
public void clearSlot(String slot) {
private void clearSlot(String slot) {
if (!slots.containsKey(slot)) {
System.err.println("Could not clear " + slot + " as it doesn't contain that slot!");
return;
@@ -190,6 +192,11 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
synchronized (children) {
children.remove(object);
}
for (String slot : object.getArrangement().get(0)) {
clearSlot(slot);
}
object.parent = null;
}
@@ -313,8 +320,8 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
public List<List<String>> getArrangement() {
return arrangement;
}
public void setArrangment(List<List<String>> arrangement) {
public void setArrangement(List<List<String>> arrangement) {
this.arrangement = arrangement;
}
@@ -349,11 +356,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
createChildrenObjects(target);
target.sendPacket(new SceneEndBaselines(getObjectId()));
}
protected void destroyObject(Player target) {
sendSceneDestroyObject(target);
}
public void clearAware() {
SWGObject [] objects;
synchronized (objectsAware) {
@@ -414,7 +417,7 @@ public class SWGObject implements Serializable, Comparable<SWGObject> {
synchronized (objectsAware) {
if (objectsAware.remove(o)) {
if (o.getOwner() != null) {
destroyObject(o.getOwner());
sendSceneDestroyObject(o.getOwner());
}
if (getOwner() != null)
o.awarenessOutOfRange(this);