R
- Resource enumeration type.T
- Tile type used.E
- Entity type used.C
- Control panel type.public abstract class HandlerEntityStrategy<R extends Enum<R>,T extends TileStrategy<?,R>,E extends EntityStrategy,C extends ControlPanelModel<E>> extends HandlerEntityGame<E> implements ControlPanelListener
createLayers(MapTile)
after map creation (when its size is
established).Modifier and Type | Field and Description |
---|---|
protected C |
panel
Control panel reference.
|
protected int |
playerId
Player (main owner) reference.
|
Constructor and Description |
---|
HandlerEntityStrategy(CameraStrategy camera,
CursorStrategy cursor,
C panel,
MapTileStrategy<?,R,T> map)
Create a new entity handler.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(EntityStrategyListener<E> listener)
Add an entity listener.
|
void |
createLayers(MapTile<?,T> map)
Prepare rendering layers, depending of the map height.
|
E |
getClosestEntity(E from,
Class<?> type,
boolean samePlayer)
Get the closest entity from its type.
|
E |
getEntityAt(int tx,
int ty)
Get the entity at the specified location in tile.
|
E |
getEntityAt(Tiled location)
Get the entity at the specified location in tile.
|
protected abstract com.b3dgs.lionengine.ColorRgba |
getEntityColorOver(E entity)
Get the corresponding color when the mouse is over this entity.
|
protected abstract com.b3dgs.lionengine.ColorRgba |
getEntityColorSelection(E entity)
Get the corresponding color when the entity is selected.
|
protected CoordTile |
getPositioning(int dtx,
int dty,
int i)
Get the positioning offset in case of multiple entity destination assignment.
|
Set<E> |
getSelection()
Get list of selected entries during cursor selection.
|
void |
notifySelectionDone(com.b3dgs.lionengine.Rectangle selection)
Notify when selection is done.
|
void |
notifySelectionStarted(com.b3dgs.lionengine.Rectangle selection)
Notify when selection started.
|
protected abstract void |
notifyUpdatedSelection(Set<E> selection)
Check the last selected entities.
|
void |
render(com.b3dgs.lionengine.Graphic g) |
protected void |
render(com.b3dgs.lionengine.Graphic g,
E entity) |
protected void |
renderEntityOver(com.b3dgs.lionengine.Graphic g,
E entity,
CameraStrategy camera,
com.b3dgs.lionengine.ColorRgba color)
Rendering function when cursor is over an entity.
|
protected void |
renderEntitySelection(com.b3dgs.lionengine.Graphic g,
E entity,
CameraStrategy camera,
com.b3dgs.lionengine.ColorRgba color)
Rendering function when entity is selected.
|
protected void |
renderingEntity(com.b3dgs.lionengine.Graphic g,
E entity,
CameraStrategy camera,
CursorStrategy cursor)
Rendering function for an entity.
|
void |
setClickAssignment(int click)
Set the mouse click assignment.
|
void |
setPlayerId(int playerId)
Set player id (player id owning this panel).
|
void |
update(double extrp) |
protected void |
update(double extrp,
E entity) |
protected void |
updateSelection(com.b3dgs.lionengine.Rectangle selection)
Update the selection list.
|
protected abstract void |
updatingEntity(E entity,
CursorStrategy cursor,
CameraStrategy camera)
Update the entity.
|
protected void |
updatingEntityClickAssignment(E entity,
CursorStrategy cursor,
CameraStrategy camera,
int i)
Update the entity click assignment.
|
add, canBeAdded, get, list, remove, removeAll, size
protected final C extends ControlPanelModel<E> panel
protected int playerId
public HandlerEntityStrategy(CameraStrategy camera, CursorStrategy cursor, C panel, MapTileStrategy<?,R,T> map)
createLayers(MapTile)
after map creation (when its
size is established).camera
- The camera viewpoint.cursor
- The cursor reference (used for selection).panel
- The control panel reference.map
- The map reference.protected abstract void updatingEntity(E entity, CursorStrategy cursor, CameraStrategy camera)
entity
- The entity reference.cursor
- The cursor reference.camera
- The camera reference.protected abstract com.b3dgs.lionengine.ColorRgba getEntityColorOver(E entity)
entity
- The current entity.protected abstract com.b3dgs.lionengine.ColorRgba getEntityColorSelection(E entity)
entity
- The current entity.protected abstract void notifyUpdatedSelection(Set<E> selection)
EntityStrategy.setSelection(boolean)
and remove the entity from
the selection which is given as a parameter. Example: Ignore a certain type of entity.selection
- The selected entities.public void addListener(EntityStrategyListener<E> listener)
listener
- Entity listener.public void createLayers(MapTile<?,T> map)
map
- The map reference.public void setClickAssignment(int click)
click
- The mouse click value.public void setPlayerId(int playerId)
playerId
- The player id.public E getEntityAt(Tiled location) throws EntityNotFoundException
location
- The location.EntityNotFoundException
- Thrown if no entity is found at this location.public E getEntityAt(int tx, int ty) throws EntityNotFoundException
tx
- The horizontal tile.ty
- The vertical tile.EntityNotFoundException
- Thrown if no entity is found at this location.public E getClosestEntity(E from, Class<?> type, boolean samePlayer) throws EntityNotFoundException
from
- The entity source (from which entity to search).type
- The entity class type to find (used as filter).samePlayer
- true
if returned reference has to be owned by the same player as the entity from,
false
else.EntityNotFoundException
- If no entity was found.public Set<E> getSelection()
protected void updatingEntityClickAssignment(E entity, CursorStrategy cursor, CameraStrategy camera, int i)
entity
- The entity reference.cursor
- The cursor reference.camera
- The camera reference.i
- The entity number in the local group.protected void updateSelection(com.b3dgs.lionengine.Rectangle selection)
selection
- The selection area.protected void renderingEntity(com.b3dgs.lionengine.Graphic g, E entity, CameraStrategy camera, CursorStrategy cursor)
g
- The graphic output.entity
- The current entity.camera
- The camera reference.cursor
- The cursor reference.protected void renderEntityOver(com.b3dgs.lionengine.Graphic g, E entity, CameraStrategy camera, com.b3dgs.lionengine.ColorRgba color)
g
- The graphic output.entity
- The current entity.camera
- The camera reference.color
- The box color.protected void renderEntitySelection(com.b3dgs.lionengine.Graphic g, E entity, CameraStrategy camera, com.b3dgs.lionengine.ColorRgba color)
g
- The graphic output.entity
- The current entity.camera
- The camera reference.color
- The box color.protected CoordTile getPositioning(int dtx, int dty, int i)
dtx
- The original horizontal tile destination.dty
- The original vertical tile destination.i
- The entity number in local group.public void update(double extrp)
update
in class HandlerObjectGame<E extends EntityStrategy>
public void render(com.b3dgs.lionengine.Graphic g)
render
in class HandlerObjectGame<E extends EntityStrategy>
protected void update(double extrp, E entity)
update
in class HandlerEntityGame<E extends EntityStrategy>
protected void render(com.b3dgs.lionengine.Graphic g, E entity)
render
in class HandlerObjectGame<E extends EntityStrategy>
public void notifySelectionStarted(com.b3dgs.lionengine.Rectangle selection)
ControlPanelListener
notifySelectionStarted
in interface ControlPanelListener
selection
- The selection.public void notifySelectionDone(com.b3dgs.lionengine.Rectangle selection)
ControlPanelListener
notifySelectionDone
in interface ControlPanelListener
selection
- The selection.Copyright © 2014 Byron 3D Games Studio. All rights reserved.