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

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: org.java-websocket:Java-WebSocket:1.3.6" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.42" level="project" />
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
</component>
</module>

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();