Cubot implements Attackable (untested)

This commit is contained in:
simon
2018-03-10 09:49:34 -05:00
parent d1a3cf9307
commit 8ed192f8d0
7 changed files with 157 additions and 14 deletions

View File

@@ -257,6 +257,9 @@ public abstract class GameObject implements JSONSerialisable, MongoSerialisable
/**
* Called before this GameObject is removed from the world - defaults to doing nothing
* @return true if cancelled
*/
public void onDeadCallback() { }
public boolean onDeadCallback() {
return false;
}
}

View File

@@ -147,9 +147,12 @@ public class World implements MongoSerialisable {
for (GameObject object : gameObjects.values()) {
//Clean up dead objects
if (object.isDead()) {
object.onDeadCallback();
removeObject(object);
//LogManager.LOGGER.fine("Removed object " + object + " id: " + object.getObjectId());
if (!object.onDeadCallback()) {
removeObject(object);
//LogManager.LOGGER.fine("Removed object " + object + " id: " + object.getObjectId());
}
} else if (object instanceof Updatable) {
((Updatable) object).update();
}