Package name.moore.kevin.ze.game.states
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
This JMonkeyEngine application state handles the users requests to load and
save the gamefile.
- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.jme3.asset.AssetManagerprivate com.jme3.input.InputManagerprivate static org.slf4j.Loggerprivate intprivate com.jme3.scene.Nodeprivate com.jme3.app.state.AppStateManagerprivate com.jme3.renderer.ViewPortprivate iZodiacApp -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcleanup(com.jme3.app.Application app)voidRespond to gameEvents broadcast on the eventbus.voidinitialize(com.jme3.app.Application a)private booleanprivate voidLoad the specified gamefile save file and map, populating the entityrepository.private voidloadSpecifications(File dir)Populate the entity-components-systems with the fixed specifications.protected voidprotected voidonEnable()voidtrace()Output a detailed report to LOGGER.trace appropriate to this state - typically of the contents of the entity repository.voidtrace(com.simsilica.es.EntityId primary)Provide a detailed report to LOGGER.trace on the specific entity.voidupdate(float tpf)Called automatically and repeatedly while the state is enabled and attached.voidwindowEvent(windowEvent event)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
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
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
- Parameters:
id-
-
-
Method Details
-
initialize
public void initialize(com.jme3.app.Application a)- Specified by:
initializein classcom.jme3.app.state.BaseAppState- See Also:
zodiac
-
cleanup
protected void cleanup(com.jme3.app.Application app)- Specified by:
cleanupin classcom.jme3.app.state.BaseAppState
-
onEnable
protected void onEnable()- Specified by:
onEnablein classcom.jme3.app.state.BaseAppState
-
onDisable
protected void onDisable()- Specified by:
onDisablein classcom.jme3.app.state.BaseAppState
-
update
public void update(float tpf)Called automatically and repeatedly while the state is enabled and attached.- Specified by:
updatein interfacecom.jme3.app.state.AppState- Overrides:
updatein classcom.jme3.app.state.BaseAppState- Parameters:
tpf-
-
gameEvent
Description copied from interface:iZodiacStateRespond 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:
gameEventin interfaceiZodiacState
-
windowEvent
Description copied from interface:iZodiacStateRespond to windowEvents broadcast on this eventbus.- Specified by:
windowEventin interfaceiZodiacState
-
load
-
loadSpecifications
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
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:
tracein interfaceiZodiacState
-
trace
public void trace(com.simsilica.es.EntityId primary)Description copied from interface:iZodiacStateProvide a detailed report to LOGGER.trace on the specific entity.- Specified by:
tracein interfaceiZodiacState
-