public class

MoveHandler

extends Object
implements ActionHandler
java.lang.Object
   ↳ uk.ac.imperial.presage2.util.location.MoveHandler

Summary

Fields
protected final HasArea environment
protected final EnvironmentServiceProvider serviceProvider
protected final EnvironmentSharedStateAccess sharedState
Public Constructors
MoveHandler(HasArea environment, EnvironmentServiceProvider serviceProvider, EnvironmentSharedStateAccess sharedState)
Public Methods
boolean canHandle(Action action)
Check if this Handler can handle the given action.
Input handle(Action action, UUID actor)
Processes a Move action.
Protected Methods
AreaService getAreaService()
LocationService getLocationService()
[Expand]
Inherited Methods
From class java.lang.Object
From interface uk.ac.imperial.presage2.core.environment.ActionHandler

Fields

protected final HasArea environment

protected final EnvironmentServiceProvider serviceProvider

protected final EnvironmentSharedStateAccess sharedState

Public Constructors

public MoveHandler (HasArea environment, EnvironmentServiceProvider serviceProvider, EnvironmentSharedStateAccess sharedState)

Public Methods

public boolean canHandle (Action action)

Check if this Handler can handle the given action.

Parameters
action Action to handle
Returns
  • true if it can, false otherwise

public Input handle (Action action, UUID actor)

Processes a Move action. In the case of a basic Move we do a vector addition of the agent's current location with the move to determine a resultant location. This is then passed to the LocationService to update the agent's location. If the resultant location is not in the simulation Area we ask the area for a valid version of the move and apply that instead. In the case of a CellMove we simply check the destination cell, and if it's empty we set the new location through the LocationService. Otherwise we throw an ActionHandlingException.

Parameters
action action to handle
actor actor performing this action
Returns
  • May return a further Object to be returned to the actor, or null if not.

Protected Methods

protected AreaService getAreaService ()

protected LocationService getLocationService ()