mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-12 22:38:54 +00:00
Merge pull request #66 from jtara1/master
HarvesterNPC should spawn a biomass in-place after they die. Fixes #33
This commit is contained in:
@@ -19,4 +19,4 @@
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -254,4 +254,9 @@ public abstract class GameObject implements JSONSerialisable, MongoSerialisable
|
||||
public void setDead(boolean dead) {
|
||||
this.dead = dead;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before this GameObject is removed from the world - defaults to doing nothing
|
||||
*/
|
||||
public void onDeadCallback() { }
|
||||
}
|
||||
@@ -104,6 +104,7 @@ public class World implements MongoSerialisable {
|
||||
for (GameObject object : gameObjects_) {
|
||||
//Clean up dead objects
|
||||
if (object.isDead()) {
|
||||
object.onDeadCallback();
|
||||
gameObjects.remove(object);
|
||||
//LogManager.LOGGER.fine("Removed object " + object + " id: " + object.getObjectId());
|
||||
} else if (object instanceof Updatable) {
|
||||
|
||||
Reference in New Issue
Block a user