HarvesterNPC should spawn a biomass in-place after they die (#33)

This commit is contained in:
James T
2017-12-29 22:35:02 -08:00
parent 9e402fe8a1
commit eea9420192
6 changed files with 81 additions and 19 deletions

View File

@@ -0,0 +1,18 @@
package net.simon987.server.event;
/**
* Event dispatched by a GameObject who has needed callbacks on death
*/
public class ObjectDeathEvent extends GameEvent {
/**
* The GameObject type ID of object that init this event
*/
private int sourceObjectId;
public ObjectDeathEvent(Object source, int sourceObjectId) {
setSource(source);
this.sourceObjectId = sourceObjectId;
}
public int getSourceObjectId() { return sourceObjectId; }
}

View File

@@ -251,4 +251,9 @@ public abstract class GameObject implements JSONSerialisable {
public void setDead(boolean dead) {
this.dead = dead;
}
/**
* Called before this GameObject is removed from the world - defaults to doing nothing
*/
public void onDeadCallback() { }
}

View File

@@ -103,6 +103,7 @@ public class World implements JSONSerialisable {
//Clean up dead objects
if (object.isDead()) {
gameObjects.remove(object);
object.onDeadCallback();
//LogManager.LOGGER.fine("Removed object " + object + " id: " + object.getObjectId());
} else if (object instanceof Updatable) {
((Updatable) object).update();