mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 22:59:02 +00:00
HarvesterNPC should spawn a biomass in-place after they die (#33)
This commit is contained in:
@@ -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; }
|
||||
}
|
||||
@@ -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() { }
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user