Added radioactive obstacle.

This commit is contained in:
Unknown 2018-06-07 21:40:59 +02:00
parent b6a206f3c7
commit 4b7ebd7ad6
2 changed files with 47 additions and 0 deletions

View File

@ -34,6 +34,7 @@ public class NpcPlugin extends ServerPlugin {
registry.registerGameObject(ElectricBox.class);
registry.registerGameObject(Portal.class);
registry.registerGameObject(VaultExitPortal.class);
registry.registerGameObject(RadioactiveObstacle.class);
registry.registerHardware(RadioReceiverHardware.class);

View File

@ -0,0 +1,46 @@
package net.simon987.npcplugin;
import org.bson.Document;
import net.simon987.server.game.objects.ControllableUnit;
import net.simon987.server.game.objects.Enterable;
import net.simon987.server.game.objects.GameObject;
import net.simon987.server.game.objects.Radioactive;
public class RadioactiveObstacle extends GameObject implements Radioactive, Enterable {
private int corruptionBlockSize;
public RadioactiveObstacle(int corruptionBlockSize) {
this.corruptionBlockSize = corruptionBlockSize;
}
@Override
public char getMapInfo() {
// TODO I don't know how this should be done.
return 0;
}
@Override
public boolean enter(GameObject object) {
if (object instanceof ControllableUnit)
((ControllableUnit) object).getCpu().getMemory().corrupt(corruptionBlockSize);
return false;
}
public Document mongoSerialize() {
Document dbObject = super.mongoSerialise();
dbObject.put("corruptionBlockSize", corruptionBlockSize);
return dbObject;
}
public void setBlockSize(int corruptionBlockSize) {
this.corruptionBlockSize = corruptionBlockSize;
}
public int getBlockSize() {
return corruptionBlockSize;
}
}