diff --git a/src/main/java/net/simon987/mar/mischwplugin/Clock.java b/src/main/java/net/simon987/mar/cubot/Clock.java similarity index 96% rename from src/main/java/net/simon987/mar/mischwplugin/Clock.java rename to src/main/java/net/simon987/mar/cubot/Clock.java index c1e0ae5..826c6d7 100644 --- a/src/main/java/net/simon987/mar/mischwplugin/Clock.java +++ b/src/main/java/net/simon987/mar/cubot/Clock.java @@ -1,4 +1,4 @@ -package net.simon987.mar.mischwplugin; +package net.simon987.mar.cubot; import net.simon987.mar.server.GameServer; import net.simon987.mar.server.assembly.HardwareModule; diff --git a/src/main/java/net/simon987/mar/mischwplugin/RandomNumberGenerator.java b/src/main/java/net/simon987/mar/cubot/RandomNumberGenerator.java similarity index 96% rename from src/main/java/net/simon987/mar/mischwplugin/RandomNumberGenerator.java rename to src/main/java/net/simon987/mar/cubot/RandomNumberGenerator.java index 96555bc..b736905 100644 --- a/src/main/java/net/simon987/mar/mischwplugin/RandomNumberGenerator.java +++ b/src/main/java/net/simon987/mar/cubot/RandomNumberGenerator.java @@ -1,4 +1,4 @@ -package net.simon987.mar.mischwplugin; +package net.simon987.mar.cubot; import net.simon987.mar.server.assembly.HardwareModule; import net.simon987.mar.server.assembly.Status; diff --git a/src/main/java/net/simon987/mar/cubot/event/CpuInitialisationListener.java b/src/main/java/net/simon987/mar/cubot/event/CpuInitialisationListener.java index d716134..2bb49bf 100644 --- a/src/main/java/net/simon987/mar/cubot/event/CpuInitialisationListener.java +++ b/src/main/java/net/simon987/mar/cubot/event/CpuInitialisationListener.java @@ -44,6 +44,11 @@ public class CpuInitialisationListener implements GameEventListener { CubotShield shieldHw = new CubotShield(cubot); shieldHw.setCpu(cpu); + Clock clockHw = new Clock(); + clockHw.setCpu(cpu); + RandomNumberGenerator rngHw = new RandomNumberGenerator(); + rngHw.setCpu(cpu); + cubot.attachHardware(legHw, CubotLeg.DEFAULT_ADDRESS); cubot.attachHardware(laserHw, CubotLaser.DEFAULT_ADDRESS); cubot.attachHardware(radarHw, CubotLidar.DEFAULT_ADDRESS); @@ -57,5 +62,8 @@ public class CpuInitialisationListener implements GameEventListener { cubot.attachHardware(comPortHw, CubotComPort.DEFAULT_ADDRESS); cubot.attachHardware(coreHw, CubotCore.DEFAULT_ADDRESS); cubot.attachHardware(shieldHw, CubotShield.DEFAULT_ADDRESS); + + cubot.attachHardware(clockHw, Clock.DEFAULT_ADDRESS); + cubot.attachHardware(rngHw, RandomNumberGenerator.DEFAULT_ADDRESS); } } diff --git a/src/main/java/net/simon987/mar/mischwplugin/event/CpuInitialisationListener.java b/src/main/java/net/simon987/mar/mischwplugin/event/CpuInitialisationListener.java deleted file mode 100644 index 55569b3..0000000 --- a/src/main/java/net/simon987/mar/mischwplugin/event/CpuInitialisationListener.java +++ /dev/null @@ -1,33 +0,0 @@ -package net.simon987.mar.mischwplugin.event; - -import net.simon987.mar.mischwplugin.Clock; -import net.simon987.mar.mischwplugin.RandomNumberGenerator; -import net.simon987.mar.server.assembly.CPU; -import net.simon987.mar.server.event.CpuInitialisationEvent; -import net.simon987.mar.server.event.GameEvent; -import net.simon987.mar.server.event.GameEventListener; -import net.simon987.mar.server.game.objects.HardwareHost; - -public class CpuInitialisationListener implements GameEventListener { - - @Override - public Class getListenedEventType() { - return CpuInitialisationEvent.class; - } - - @Override - public void handle(GameEvent event) { - - CPU cpu = (CPU) event.getSource(); - HardwareHost cubot = ((CpuInitialisationEvent) event).getUnit(); - cpu.setHardwareHost(cubot); - - RandomNumberGenerator rngHW = new RandomNumberGenerator(); - rngHW.setCpu(cpu); - Clock clock = new Clock(); - clock.setCpu(cpu); - - cpu.getHardwareHost().attachHardware(rngHW, RandomNumberGenerator.DEFAULT_ADDRESS); - cpu.getHardwareHost().attachHardware(clock, Clock.DEFAULT_ADDRESS); - } -} diff --git a/src/main/java/net/simon987/mar/server/GameServer.java b/src/main/java/net/simon987/mar/server/GameServer.java index 7eb6141..494b2af 100644 --- a/src/main/java/net/simon987/mar/server/GameServer.java +++ b/src/main/java/net/simon987/mar/server/GameServer.java @@ -13,8 +13,8 @@ import net.simon987.mar.construction.ItemBluePrint; import net.simon987.mar.construction.Obstacle; import net.simon987.mar.cubot.*; import net.simon987.mar.cubot.event.*; -import net.simon987.mar.mischwplugin.Clock; -import net.simon987.mar.mischwplugin.RandomNumberGenerator; +import net.simon987.mar.cubot.Clock; +import net.simon987.mar.cubot.RandomNumberGenerator; import net.simon987.mar.npc.*; import net.simon987.mar.npc.event.BeforeSaveListener; import net.simon987.mar.npc.event.LoadListener;