Package com.kraken.api.sim.engine
Class SimulationEngine
- java.lang.Object
-
- com.kraken.api.sim.engine.SimulationEngine
-
public class SimulationEngine extends java.lang.ObjectSimulation engine for NPC and player movement.
-
-
Constructor Summary
Constructors Constructor Description SimulationEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNpc(SimNpc npc)Adds an NPC to the simulationvoidaddNPCPathPoint(SimNpc npc, java.awt.Point point)Adds an NPC path pointvoidaddObserver(SimulationObserver observer)Add an observer to be notified of simulation updatesjava.util.List<java.awt.Point>getNpcLineOfSight(SimNpc simNpc)voidprevTick()Re-winds the game state by 1 tick.voidrefresh()Refresh will re-load the simulation with collision, npc, and player data gathered directly from the game USING defaults like 0 for the tick and player path index.voidrefresh(CollisionMap map, java.awt.Point playerPosition, int tick, int playerPathIndex, java.util.List<java.awt.Point> playerCurrentPath)Refresh will re-load the simulation with collision, npc, and player data gathered directly from the game.voidremoveLastNPCPathPoint(SimNpc npc)Removes the last NPC pathing pointvoidremoveNpc(SimNpc npc)Removes an NPC from the simulationvoidremoveObserver(SimulationObserver observer)Remove an observervoidreset()Resets the state of the simulationvoidsetPlayerTarget(java.awt.Point target)Sets the target point for a player to move towards and runs a BFS calculation to determine the shortest path.voidstart()Starts a timer which runs the simulation on 0.6s (1 game tick) intervals.voidstop()Stops the primary simulation timer and resets history.voidtick()
-
-
-
Method Detail
-
refresh
public void refresh(CollisionMap map, java.awt.Point playerPosition, int tick, int playerPathIndex, java.util.List<java.awt.Point> playerCurrentPath)
Refresh will re-load the simulation with collision, npc, and player data gathered directly from the game. The collision map is passed as a parameter so that when refresh() is called without parameters the players location will be set to their in-game location. This prevents the collision map load from being called twice in the event a refresh is needed for player, tick or npc data WITHOUT the need to reload collision data.- Parameters:
map- The calculated collision maps from the collision dumper.playerPosition- The players current position (this determines where the player is placed on the visualization initially).tick- The game tickplayerPathIndex- The current index in the players current pathplayerCurrentPath- The players current path
-
refresh
public void refresh()
Refresh will re-load the simulation with collision, npc, and player data gathered directly from the game USING defaults like 0 for the tick and player path index. This method assumes that the player has no current path but will still create the players and NPC's at their proper locations in game.
-
start
public void start()
Starts a timer which runs the simulation on 0.6s (1 game tick) intervals.
-
stop
public void stop()
Stops the primary simulation timer and resets history.
-
addObserver
public void addObserver(SimulationObserver observer)
Add an observer to be notified of simulation updates- Parameters:
observer- The simulation observer
-
removeObserver
public void removeObserver(SimulationObserver observer)
Remove an observer- Parameters:
observer- The simulation observer
-
prevTick
public void prevTick()
Re-winds the game state by 1 tick.
-
tick
public void tick()
-
setPlayerTarget
public void setPlayerTarget(java.awt.Point target)
Sets the target point for a player to move towards and runs a BFS calculation to determine the shortest path.- Parameters:
target- Target point to move towards
-
getNpcLineOfSight
public java.util.List<java.awt.Point> getNpcLineOfSight(SimNpc simNpc)
-
removeLastNPCPathPoint
public void removeLastNPCPathPoint(SimNpc npc)
Removes the last NPC pathing point- Parameters:
npc- Simulated NPC to remove point from
-
addNPCPathPoint
public void addNPCPathPoint(SimNpc npc, java.awt.Point point)
Adds an NPC path point- Parameters:
npc- NpcSim The npc to add topoint- Point the point to add
-
addNpc
public void addNpc(SimNpc npc)
Adds an NPC to the simulation- Parameters:
npc- the NPC to add
-
removeNpc
public void removeNpc(SimNpc npc)
Removes an NPC from the simulation- Parameters:
npc- The NPC to remove
-
reset
public void reset()
Resets the state of the simulation
-
-