Class loadandsaveState

java.lang.Object
com.jme3.app.state.BaseAppState
name.moore.kevin.ze.game.states.loadandsaveState
All Implemented Interfaces:
com.jme3.app.state.AppState, iZodiacState

public class loadandsaveState extends com.jme3.app.state.BaseAppState implements iZodiacState
This JMonkeyEngine application state handles the users requests to load and save the gamefile.
Author:
Kevin Moore <dev@kevin.moore.name>
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private com.jme3.asset.AssetManager
     
    private com.jme3.input.InputManager
     
    private static org.slf4j.Logger
     
    private int
     
    private com.jme3.scene.Node
     
    private com.jme3.app.state.AppStateManager
     
    private com.jme3.renderer.ViewPort
     
    private iZodiacApp
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    cleanup​(com.jme3.app.Application app)
    void
    gameEvent​(gameEvent event)
    Respond to gameEvents broadcast on the eventbus.
    void
    initialize​(com.jme3.app.Application a)
    private boolean
    load​(File arg)
     
    private void
    loadGame​(File gf, File maps)
    Load the specified gamefile save file and map, populating the entityrepository.
    private void
    Populate the entity-components-systems with the fixed specifications.
    protected void
     
    protected void
     
    void
    Output a detailed report to LOGGER.trace appropriate to this state - typically of the contents of the entity repository.
    void
    trace​(com.simsilica.es.EntityId primary)
    Provide a detailed report to LOGGER.trace on the specific entity.
    void
    update​(float tpf)
    Called automatically and repeatedly while the state is enabled and attached.
    void
    Respond to windowEvents broadcast on this eventbus.

    Methods inherited from class com.jme3.app.state.BaseAppState

    cleanup, getApplication, getId, getState, getState, getState, getState, getStateManager, initialize, isEnabled, isInitialized, postRender, render, setEnabled, setId, stateAttached, stateDetached

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • zapp

      private iZodiacApp zapp
    • rootNode

      private com.jme3.scene.Node rootNode
    • assetManager

      private com.jme3.asset.AssetManager assetManager
    • stateManager

      private com.jme3.app.state.AppStateManager stateManager
    • inputManager

      private com.jme3.input.InputManager inputManager
    • viewPort

      private com.jme3.renderer.ViewPort viewPort
    • renderingCounter

      private int renderingCounter
  • Constructor Details

    • loadandsaveState

      public loadandsaveState(String id)
      Parameters:
      id -
  • Method Details

    • initialize

      public void initialize(com.jme3.app.Application a)
      Specified by:
      initialize in class com.jme3.app.state.BaseAppState
      See Also:
      zodiac
    • cleanup

      protected void cleanup(com.jme3.app.Application app)
      Specified by:
      cleanup in class com.jme3.app.state.BaseAppState
    • onEnable

      protected void onEnable()
      Specified by:
      onEnable in class com.jme3.app.state.BaseAppState
    • onDisable

      protected void onDisable()
      Specified by:
      onDisable in class com.jme3.app.state.BaseAppState
    • update

      public void update(float tpf)
      Called automatically and repeatedly while the state is enabled and attached.
      Specified by:
      update in interface com.jme3.app.state.AppState
      Overrides:
      update in class com.jme3.app.state.BaseAppState
      Parameters:
      tpf -
    • gameEvent

      public void gameEvent(gameEvent event)
      Description copied from interface: iZodiacState
      Respond to gameEvents broadcast on the eventbus.

      Since the bus is async the code will run on a different thread from the main application. best to make the event handling short and sharp!

      Specified by:
      gameEvent in interface iZodiacState
    • windowEvent

      public void windowEvent(windowEvent event)
      Description copied from interface: iZodiacState
      Respond to windowEvents broadcast on this eventbus.
      Specified by:
      windowEvent in interface iZodiacState
    • load

      private boolean load(File arg)
    • loadSpecifications

      private void loadSpecifications(File dir) throws FileNotFoundException
      Populate the entity-components-systems with the fixed specifications.

      Uses a specLoader to read XML specs into objects, then convert those objects into appropriate entities+components for addition to the entity-component-system.

      Requires configured xstream and entityrepository.

      Parameters:
      dir - filepath to load spec files from.
      Throws:
      FileNotFoundException
      See Also:
      specLoader
    • loadGame

      private void loadGame(File gf, File maps) throws IOException
      Load the specified gamefile save file and map, populating the entityrepository.

      This requires a certain amount of 'fixup' to build some components that capture relations between entities, such as ownership.

      Parameters:
      gf - absolute filename to load eg "/home/zodiac-empire/src/main/resources/games/default.xml"
      maps - pathname from MAPS constant
      Throws:
      IOException
      See Also:
      Properties.keys()
    • trace

      public void trace()
      Output a detailed report to LOGGER.trace appropriate to this state - typically of the contents of the entity repository.
      Specified by:
      trace in interface iZodiacState
    • trace

      public void trace(com.simsilica.es.EntityId primary)
      Description copied from interface: iZodiacState
      Provide a detailed report to LOGGER.trace on the specific entity.
      Specified by:
      trace in interface iZodiacState