Class SimulationController
java.lang.Object
me.desht.pneumaticcraft.common.hacking.secstation.SimulationController
- All Implemented Interfaces:
ISimulationController
Runs both the player and AI simulation objects and mediates between them.
This is done on both client and server side. Both sides will be ticked but the server will periodically sync
its state to the client, so client is using dead reckoning with periodic updates from the server. Only the
server state actually matters for security station hacking, of course; the client state is purely for display
by SecurityStationHackingScreen.
-
Nested Class Summary
Nested classes/interfaces inherited from interface me.desht.pneumaticcraft.common.hacking.secstation.ISimulationController
ISimulationController.HackingSide -
Constructor Summary
ConstructorsConstructorDescriptionSimulationController(SecurityStationBlockEntity te, net.minecraft.world.entity.player.Player hacker, boolean justTesting) Called server-side when a hack is startedSimulationController(SecurityStationBlockEntity te, net.minecraft.world.entity.player.Player hacker, HackSimulation playerSimulation, HackSimulation aiSimulation, boolean justTesting) Called client-side on start of hack to sync the initial simulation state. -
Method Summary
Modifier and TypeMethodDescriptionnet.minecraft.world.entity.player.PlayerGet the player currently trying to hack the security station.Get the simulation object for the given side (player or AI)booleanIs this just a test by the station's owner, or other whitelisted player? If just testing, the security station will not retaliate on a failed hack.booleanAre we done with this hack simulation?voidonConnectionStarted(HackSimulation hackSimulation, int fromPos, int toPos, float initialProgress) A connection from one node to another has just begun.voidonNodeFortified(HackSimulation hackSimulation, int pos) A simulation has just had a hacked node fortified by the playervoidonNodeHacked(HackSimulation hackSimulation, int pos) A simulation has just had a node hacked (connection completed).voidtick()Called every game tick (both client and server) by the owning security station block entity.voidtoBytes(net.minecraft.network.FriendlyByteBuf buffer) Serialize the simulation controller for sync to client on open of hacking GUI
-
Constructor Details
-
SimulationController
public SimulationController(SecurityStationBlockEntity te, net.minecraft.world.entity.player.Player hacker, boolean justTesting) Called server-side when a hack is started- Parameters:
te- the security stationhacker- the hacking player
-
SimulationController
public SimulationController(SecurityStationBlockEntity te, net.minecraft.world.entity.player.Player hacker, HackSimulation playerSimulation, HackSimulation aiSimulation, boolean justTesting) Called client-side on start of hack to sync the initial simulation state.- Parameters:
te- the security stationhacker- the hacking player (will be the client player)playerSimulation- the hacking player's simulation objectaiSimulation- the security station's simulation object
-
-
Method Details
-
onConnectionStarted
public void onConnectionStarted(HackSimulation hackSimulation, int fromPos, int toPos, float initialProgress) Description copied from interface:ISimulationControllerA connection from one node to another has just begun.- Specified by:
onConnectionStartedin interfaceISimulationController- Parameters:
hackSimulation- the simulationfromPos- position of the hacking nodetoPos- position of the target nodeinitialProgress- initial progress of the connection (usually but not necessarily 0)
-
isJustTesting
public boolean isJustTesting()Description copied from interface:ISimulationControllerIs this just a test by the station's owner, or other whitelisted player? If just testing, the security station will not retaliate on a failed hack.- Specified by:
isJustTestingin interfaceISimulationController- Returns:
- true if just testing, false otherwise
-
toBytes
public void toBytes(net.minecraft.network.FriendlyByteBuf buffer) Description copied from interface:ISimulationControllerSerialize the simulation controller for sync to client on open of hacking GUI- Specified by:
toBytesin interfaceISimulationController- Parameters:
buffer- packet buffer
-
onNodeHacked
Description copied from interface:ISimulationControllerA simulation has just had a node hacked (connection completed).- Specified by:
onNodeHackedin interfaceISimulationController- Parameters:
hackSimulation- the simulationpos- position of the newly hacked node
-
onNodeFortified
Description copied from interface:ISimulationControllerA simulation has just had a hacked node fortified by the player- Specified by:
onNodeFortifiedin interfaceISimulationController- Parameters:
hackSimulation- the simulationpos- position of the newly fortified node
-
tick
public void tick()Description copied from interface:ISimulationControllerCalled every game tick (both client and server) by the owning security station block entity.- Specified by:
tickin interfaceISimulationController
-
isSimulationDone
public boolean isSimulationDone()Description copied from interface:ISimulationControllerAre we done with this hack simulation?- Specified by:
isSimulationDonein interfaceISimulationController- Returns:
- true if finished, false otherwise
-
getSimulation
Description copied from interface:ISimulationControllerGet the simulation object for the given side (player or AI)- Specified by:
getSimulationin interfaceISimulationController- Parameters:
side- the side to get- Returns:
- the simulation
-
getHacker
public net.minecraft.world.entity.player.Player getHacker()Description copied from interface:ISimulationControllerGet the player currently trying to hack the security station. This does not validate if the player is still online.- Specified by:
getHackerin interfaceISimulationController- Returns:
- the player
-