Class SimulationEngine


  • public class SimulationEngine
    extends java.lang.Object
    Simulation engine for NPC and player movement.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNpc​(SimNpc npc)
      Adds an NPC to the simulation
      void addNPCPathPoint​(SimNpc npc, java.awt.Point point)
      Adds an NPC path point
      void addObserver​(SimulationObserver observer)
      Add an observer to be notified of simulation updates
      java.util.List<java.awt.Point> getNpcLineOfSight​(SimNpc simNpc)  
      void prevTick()
      Re-winds the game state by 1 tick.
      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.
      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.
      void removeLastNPCPathPoint​(SimNpc npc)
      Removes the last NPC pathing point
      void removeNpc​(SimNpc npc)
      Removes an NPC from the simulation
      void removeObserver​(SimulationObserver observer)
      Remove an observer
      void reset()
      Resets the state of the simulation
      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.
      void start()
      Starts a timer which runs the simulation on 0.6s (1 game tick) intervals.
      void stop()
      Stops the primary simulation timer and resets history.
      void tick()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SimulationEngine

        public SimulationEngine()
    • 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 tick
        playerPathIndex - The current index in the players current path
        playerCurrentPath - 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 to
        point - 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