Package com.b3dgs.lionengine.helper
Class StateHelper<M extends EntityModelHelper>
- java.lang.Object
-
- com.b3dgs.lionengine.game.feature.state.StateAbstract
-
- com.b3dgs.lionengine.helper.StateHelper<M>
-
- Type Parameters:
M- The model feature.
- All Implemented Interfaces:
State,TileCollidableListener,Updatable
public class StateHelper<M extends EntityModelHelper> extends StateAbstract implements TileCollidableListener
State base implementation.
-
-
Field Summary
Fields Modifier and Type Field Description protected AnimatableanimatableAnimator reference.protected AnimationanimationState animation data.protected BodybodyBody reference.protected CollidablecollidableCollidable reference.protected InputDeviceControlinputInput control reference.protected MirrorablemirrorableMirrorable reference.protected MmodelEntity model reference.protected RasterablerasterableRasterable reference.protected TileCollidabletileCollidableTile collidable reference.protected TransformabletransformableTransformable reference.
-
Constructor Summary
Constructors Modifier Constructor Description protectedStateHelper(M model, Animation animation)Create the state.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidenter()voidexit()protected booleanis(AnimState state)Check if is anim state.protected booleanis(Mirror mirror)Check if is current mirror state.protected booleanisChangingDirectionHorizontal(Force force)Check if checking horizontal direction side.protected booleanisCollideX()Check if horizontal collide.protected booleanisCollideY()Check if vertical collide.protected booleanisFire(java.lang.Integer index)Check if fire button is enabled.protected booleanisFireOnce(java.lang.Integer index)Check if fire button is enabled once.protected booleanisGo()Check if going somewhere.protected booleanisGoDown()Check if going down.protected booleanisGoDownOnce()Check if going down one time.protected booleanisGoHorizontal()Check if going horizontally in any way.protected booleanisGoLeft()Check if going left.protected booleanisGoLeftOnce()Check if going left once.protected booleanisGoNone()Check if going nowhere.protected booleanisGoRight()Check if going right.protected booleanisGoRightOnce()Check if going right once.protected booleanisGoUp()Check if going up.protected booleanisGoUpOnce()Check if going up one time.protected booleanisGoVertical()Check if going vertically in any way.protected voidmirrorHorizontal()Perform horizontal mirroring.voidnotifyTileCollided(CollisionResult result, CollisionCategory category)protected voidonCollided(CollisionResult result, CollisionCategory category)Called on collided.voidupdate(double extrp)protected voidupdateMirrorHorizontal()Update mirror on horizontal axis (perform mirror when going on the opposite side).protected voidupdateMirrorVertical()Update mirror on vertical axis (perform mirror when going on the opposite side).-
Methods inherited from class com.b3dgs.lionengine.game.feature.state.StateAbstract
addTransition, checkTransitions, clearTransitions, postUpdate
-
-
-
-
Field Detail
-
model
protected final M extends EntityModelHelper model
Entity model reference.
-
animation
protected final Animation animation
State animation data.
-
input
protected final InputDeviceControl input
Input control reference.
-
transformable
protected final Transformable transformable
Transformable reference.
-
mirrorable
protected final Mirrorable mirrorable
Mirrorable reference.
-
rasterable
protected final Rasterable rasterable
Rasterable reference.
-
body
protected final Body body
Body reference.
-
animatable
protected final Animatable animatable
Animator reference.
-
tileCollidable
protected final TileCollidable tileCollidable
Tile collidable reference.
-
collidable
protected final Collidable collidable
Collidable reference.
-
-
Method Detail
-
onCollided
protected void onCollided(CollisionResult result, CollisionCategory category)
Called on collided.- Parameters:
result- The collided tile.category- The collided axis.
-
mirrorHorizontal
protected void mirrorHorizontal()
Perform horizontal mirroring.
-
updateMirrorHorizontal
protected void updateMirrorHorizontal()
Update mirror on horizontal axis (perform mirror when going on the opposite side).
-
updateMirrorVertical
protected void updateMirrorVertical()
Update mirror on vertical axis (perform mirror when going on the opposite side).
-
is
protected final boolean is(AnimState state)
Check if is anim state.- Parameters:
state- The expected anim state.- Returns:
trueif is state,falseelse.
-
is
protected final boolean is(Mirror mirror)
Check if is current mirror state.- Parameters:
mirror- The expected mirror to be.- Returns:
trueif is mirror,falseelse.
-
isGo
protected final boolean isGo()
Check if going somewhere.- Returns:
trueif not going to move,falseelse.
-
isGoNone
protected final boolean isGoNone()
Check if going nowhere.- Returns:
trueif not going to move,falseelse.
-
isGoHorizontal
protected final boolean isGoHorizontal()
Check if going horizontally in any way.- Returns:
trueif going to left or right,falseelse.
-
isGoLeft
protected final boolean isGoLeft()
Check if going left.- Returns:
trueif going to left,falseelse.
-
isGoRight
protected final boolean isGoRight()
Check if going right.- Returns:
trueif going to right,falseelse.
-
isGoVertical
protected final boolean isGoVertical()
Check if going vertically in any way.- Returns:
trueif going to up or down,falseelse.
-
isGoUp
protected final boolean isGoUp()
Check if going up.- Returns:
trueif going to up,falseelse.
-
isGoDown
protected final boolean isGoDown()
Check if going down.- Returns:
trueif going to down,falseelse.
-
isGoUpOnce
protected final boolean isGoUpOnce()
Check if going up one time.- Returns:
trueif going to up,falseelse.
-
isGoDownOnce
protected final boolean isGoDownOnce()
Check if going down one time.- Returns:
trueif going to down,falseelse.
-
isGoLeftOnce
protected final boolean isGoLeftOnce()
Check if going left once.- Returns:
trueif going to left,falseelse.
-
isGoRightOnce
protected final boolean isGoRightOnce()
Check if going right once.- Returns:
trueif going to right,falseelse.
-
isFire
protected final boolean isFire(java.lang.Integer index)
Check if fire button is enabled.- Parameters:
index- The button index (must not benull, must be positive).- Returns:
trueif active,falseelse.
-
isFireOnce
protected final boolean isFireOnce(java.lang.Integer index)
Check if fire button is enabled once.- Parameters:
index- The button index (must not benull, must be positive).- Returns:
trueif active,falseelse.
-
isChangingDirectionHorizontal
protected final boolean isChangingDirectionHorizontal(Force force)
Check if checking horizontal direction side.- Parameters:
force- The force reference.- Returns:
trueif going to the opposite,falseelse.
-
isCollideX
protected final boolean isCollideX()
Check if horizontal collide.- Returns:
trueif horizontal collide,falseelse.
-
isCollideY
protected final boolean isCollideY()
Check if vertical collide.- Returns:
trueif vertical collide,falseelse.
-
exit
public void exit()
- Specified by:
exitin interfaceState- Overrides:
exitin classStateAbstract
-
notifyTileCollided
public void notifyTileCollided(CollisionResult result, CollisionCategory category)
- Specified by:
notifyTileCollidedin interfaceTileCollidableListener
-
-