@DependentInitialisation(value=ch.sahits.game.openpatrician.util.MapInitializedBean.class)
public class ShipPositionUpdateTask
extends ch.sahits.game.openpatrician.model.event.PausableSchedulableTask
| Modifier and Type | Field and Description |
|---|---|
private com.google.common.eventbus.AsyncEventBus |
clientServerEventBus |
private PathInterpolatorMap |
interpolators |
private org.apache.logging.log4j.Logger |
logger |
private ch.sahits.game.openpatrician.model.map.IMap |
map |
private MapService |
mapService |
private IPathConverter |
pathConverter |
private long |
pausedTimeStamp |
private PointService |
pointService |
private com.google.common.eventbus.EventBus |
syncServerClientEventBus |
private com.google.common.eventbus.AsyncEventBus |
timerEventBus |
| Constructor and Description |
|---|
ShipPositionUpdateTask() |
| Modifier and Type | Method and Description |
|---|---|
private int |
calculateDamagePoints(int kmPerDamage,
double distanceSinceLastDamageUpdate)
Calculate the damage for the traveld distance
|
private void |
damageShip(VesselPositionUpdateData value,
double distanceSinceLastDamageUpdate,
ch.sahits.game.openpatrician.model.ship.IShip ship)
Update the damage of the ship that is taken by traveling.
|
void |
handle(long now) |
void |
handleGameSpeedChange(ClockTickIntervalChange intervallChange) |
void |
loadedGame(GameStateChange change) |
void |
pause(PauseGame evt) |
protected void |
register() |
void |
resume(ResumeGame evt) |
void |
unregister() |
(package private) void |
updateShipDamage(VesselPositionUpdateData value,
ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel,
double travelPerTick)
Handle the update of damage to the ship.
|
private final org.apache.logging.log4j.Logger logger
@Autowired private PathInterpolatorMap interpolators
@Autowired @Qualifier(value="serverClientEventBus") private com.google.common.eventbus.AsyncEventBus clientServerEventBus
@Autowired @Qualifier(value="syncServerClientEventBus") private com.google.common.eventbus.EventBus syncServerClientEventBus
@Autowired @Qualifier(value="timerEventBus") private com.google.common.eventbus.AsyncEventBus timerEventBus
@Autowired private ch.sahits.game.openpatrician.model.map.IMap map
@Autowired private IPathConverter pathConverter
@Autowired private PointService pointService
@Autowired private MapService mapService
private long pausedTimeStamp
@PostConstruct protected void register()
register in class ch.sahits.game.openpatrician.model.event.PausableSchedulableTask@PreDestroy public void unregister()
unregister in class ch.sahits.game.openpatrician.model.event.PausableSchedulableTaskpublic void handle(long now)
handle in class ch.sahits.game.openpatrician.model.event.SchedulableTaskvoid updateShipDamage(VesselPositionUpdateData value, ch.sahits.game.openpatrician.model.ship.INavigableVessel vessel, double travelPerTick)
value - vessel data that needs to be updated with the distance that is not yet considered in the damagevessel - that should be damagedtravelPerTick - number of pixels that were traveled.private void damageShip(VesselPositionUpdateData value, double distanceSinceLastDamageUpdate, ch.sahits.game.openpatrician.model.ship.IShip ship)
value - vessel data that needs to be updated with the distance that is not yet considered in the damagedistanceSinceLastDamageUpdate - traveled distance in km since the last update of the damageship - instance of the ship that is to be damaged.private int calculateDamagePoints(int kmPerDamage,
double distanceSinceLastDamageUpdate)
kmPerDamage - amount of km that will cause 1 damage point.distanceSinceLastDamageUpdate - distance traveled since the damage was updated the last timepublic void handleGameSpeedChange(ClockTickIntervalChange intervallChange)
public void pause(PauseGame evt)
pause in class ch.sahits.game.openpatrician.model.event.PausableSchedulableTaskpublic void resume(ResumeGame evt)
resume in class ch.sahits.game.openpatrician.model.event.PausableSchedulableTaskpublic void loadedGame(GameStateChange change)
Copyright © 2011-2017 Sahits GmbH. All Rights Reserved.