Fixed vehicles

This commit is contained in:
Light2
2014-04-13 17:17:25 +02:00
parent 6b4f6e7741
commit cf9bcf66f9
4 changed files with 32 additions and 33 deletions
@@ -68,7 +68,7 @@ import resources.objects.player.PlayerObject;
import resources.objects.tangible.TangibleObject;
import services.command.BaseSWGCommand;
@Entity(version=7)
@Entity(version=8)
public class CreatureObject extends TangibleObject implements IPersistent {
@NotPersistent
@@ -188,6 +188,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
private ConcurrentHashMap<String, Long> cooldowns = new ConcurrentHashMap<String, Long>();
public boolean mounted = false;
@NotPersistent
public CreatureObject mountedVehicle;
public CreatureObject(long objectID, Planet planet, Point3D position, Quaternion orientation, String Template) {
@@ -540,6 +541,7 @@ public class CreatureObject extends TangibleObject implements IPersistent {
synchronized(objectMutex) {
this.ownerId = ownerId;
}
notifyObservers(messageBuilder.buildOwnerIdDelta(ownerId), true);
}
public float getAccelerationMultiplierBase() {
@@ -1797,30 +1799,43 @@ public class CreatureObject extends TangibleObject implements IPersistent {
}
public void mount(CreatureObject owner) {
boolean remove = false;
synchronized(objectMutex) {
if ((this.getOptionsBitmask() & Options.MOUNT) == Options.MOUNT){
UpdateContainmentMessage updateContainmentMessage= new UpdateContainmentMessage(owner.getObjectID(), this.getObjectID(), -1);
owner.getClient().getSession().write(updateContainmentMessage.serialize());
owner.setParent(this);
remove = true;
_add(owner);
UpdateContainmentMessage updateContainmentMessage = new UpdateContainmentMessage(owner.getObjectID(), this.getObjectID(), 4);
notifyObservers(updateContainmentMessage, true);
}
}
if(remove)
NGECore.getInstance().simulationService.remove(owner, owner.getWorldPosition().x, owner.getWorldPosition().z, false);
}
public void unmount(CreatureObject owner) {
boolean add = false;
synchronized(objectMutex) {
if ((this.getOptionsBitmask() & Options.MOUNT) == Options.MOUNT){
UpdateContainmentMessage updateContainmentMessage= new UpdateContainmentMessage(owner.getObjectID(), this.getObjectID(), -1);
owner.getClient().getSession().write(updateContainmentMessage.serialize());
add = true;
_remove(owner);
UpdateContainmentMessage updateContainmentMessage = new UpdateContainmentMessage(owner.getObjectID(), 0, -1);
notifyObservers(updateContainmentMessage, true);
}
}
if(add) {
owner.setMounted(false);
owner.setMountedVehicle(null);
owner.setStateBitmask(0);
owner.setPosture((byte) 0);
NGECore.getInstance().simulationService.add(owner, getWorldPosition().x, getWorldPosition().z, false);
NGECore.getInstance().simulationService.teleport(owner, getWorldPosition(), getOrientation(), 0);
}
}
public void initMount(CreatureObject owner) {
synchronized(objectMutex) {
this.ownerId = owner.getObjectID();
setStateBitmask(0x10000000);
owner.setParent(this);
owner.getClient().getSession().write(messageBuilder.buildOwnerIdDelta(ownerId));
owner.setMountedVehicle(this);
this.setOwnerId(owner.getObjectID());
//this.add(owner); // NPE at engine.resources.objects.SWGObject.getCorrectArrangementId(kd:844)