mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 14:49:03 +00:00
HarvesterNPC should spawn a biomass in-place after they die (#33)
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
package net.simon987.npcplugin;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.event.ObjectDeathEvent;
|
||||
import net.simon987.server.game.Direction;
|
||||
import net.simon987.biomassplugin.BiomassBlob;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.lang.util.Random;
|
||||
|
||||
public class HarvesterNPC extends NonPlayerCharacter {
|
||||
|
||||
public static final int ID = 10;
|
||||
@@ -36,6 +41,36 @@ public class HarvesterNPC extends NonPlayerCharacter {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDead(boolean dead) {
|
||||
super.setDead(dead);
|
||||
// GameServer.INSTANCE.getEventDispatcher().dispatch(
|
||||
// new ObjectDeathEvent((Object)this, ID));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeadCallback() {
|
||||
GameServer.INSTANCE.getEventDispatcher().dispatch(
|
||||
new ObjectDeathEvent((Object)this, ID));
|
||||
}
|
||||
|
||||
public BiomassBlob createBiomassBlobInPlace() {
|
||||
Random random = new Random();
|
||||
// random integer in range [2, 4]
|
||||
int yield = random.nextInt(2) + 2;
|
||||
|
||||
BiomassBlob biomassBlob = new BiomassBlob();
|
||||
biomassBlob.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
|
||||
// biomassBlob.setStyle(0); //TODO: set style depending on difficulty level? or random? from config?
|
||||
biomassBlob.setBiomassCount(yield);
|
||||
biomassBlob.setX(getX());
|
||||
biomassBlob.setY(getY());
|
||||
biomassBlob.setWorld(getWorld());
|
||||
LogManager.LOGGER.info("HarvesterNPC spawned biomass in its place");
|
||||
|
||||
return biomassBlob;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject serialise() {
|
||||
JSONObject json = super.serialise();
|
||||
|
||||
Reference in New Issue
Block a user