Package name.moore.kevin.ze.game.states
Class movementState
java.lang.Object
com.jme3.app.state.BaseAppState
name.moore.kevin.ze.game.states.movementState
- All Implemented Interfaces:
com.jme3.app.state.AppState,iZodiacState
This JMonkeyEngine application state handles the movement of the game pieces
ie ships.
- Author:
- Kevin Moore
<dev@kevin.moore.name>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.jme3.asset.AssetManager(package private) com.google.common.cache.LoadingCache<com.simsilica.es.EntityId,Double>Cache some of the movement calculations that don't need to be repeated.(package private) com.google.common.cache.LoadingCache<com.simsilica.es.EntityId,org.jscience.physics.amount.Amount<javax.measure.quantity.Mass>>Cache mass calculations.private com.simsilica.es.EntitySetAll Entities with an distribution component.private com.jme3.input.InputManagerprivate static org.slf4j.Loggerprivate com.simsilica.es.EntitySetEntities that are actively moving ie have a destination.private intprivate com.jme3.scene.Nodeprivate com.jme3.app.state.AppStateManagerprivate com.jme3.renderer.ViewPortprivate iZodiacApp -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidarrived(com.simsilica.es.EntityId vehicle)protected voidcleanup(com.jme3.app.Application app)private voiddepart(com.simsilica.es.EntityId vehicle, com.simsilica.es.EntityId dest)Leave orbit and set destination to an entity.voidListen on the eventbus for movement events and enact the appropriate changes to the involved entities.voidinitialize(com.jme3.app.Application a)Called once when attached, copies the JME application for local use, loads XML specifications and a default game.private voidmove(com.simsilica.es.EntityId eid)Move the entity, the distance covered depends on factors such as the engine, damage and if we are moving tactically or strategically (FTL)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.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, stateDetachedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface name.moore.kevin.ze.game.states.iZodiacState
windowEvent
-
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 -
movingSet
private com.simsilica.es.EntitySet movingSetEntities that are actively moving ie have a destination. -
distributionSet
private com.simsilica.es.EntitySet distributionSetAll Entities with an distribution component. -
cacheEPM
com.google.common.cache.LoadingCache<com.simsilica.es.EntityId,Double> cacheEPMCache some of the movement calculations that don't need to be repeated. -
cacheMass
com.google.common.cache.LoadingCache<com.simsilica.es.EntityId,org.jscience.physics.amount.Amount<javax.measure.quantity.Mass>> cacheMassCache mass calculations. -
renderingCounter
private int renderingCounter
-
-
Constructor Details
-
movementState
- Parameters:
id-
-
-
Method Details
-
initialize
public void initialize(com.jme3.app.Application a)Called once when attached, copies the JME application for local use, loads XML specifications and a default game.- Specified by:
initializein classcom.jme3.app.state.BaseAppState- Parameters:
a- A zodiac object.- 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
Listen on the eventbus for movement events and enact the appropriate changes to the involved entities.- Specified by:
gameEventin interfaceiZodiacState- Parameters:
event-
-
depart
private void depart(com.simsilica.es.EntityId vehicle, com.simsilica.es.EntityId dest)Leave orbit and set destination to an entity. This entity is now in the movingSet and will trigger getAddedEntities()- Parameters:
vehicle- vehicle to getEntityComponent moving eg a ship.dest- destination entity
-
arrived
private void arrived(com.simsilica.es.EntityId vehicle)- Parameters:
vehicle- the entity entering orbit eg ship.
-
move
private void move(com.simsilica.es.EntityId eid)Move the entity, the distance covered depends on factors such as the engine, damage and if we are moving tactically or strategically (FTL)Entities that are moving use coordinates. These are set by events such as breaking orbit.
- Parameters:
eid-
-
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
-