Package model
Class Actor
java.lang.Object
model.Actor
A character in the game, which can store and update its location on the game graph and interact
with the game model based on its location. Subclasses are responsible for that actor's vertex
visitation behavior and navigation.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final record
A record class that represents ordered pairs of doublesstatic final record
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Actor.Location
The current location of this actor, modeled as a record of the edge that they are currently traversing and their relative progress along this edge.protected final GameModel
The game model with which this actor is associated. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract double
Return the current base speed of this actor, before factoring in the weight of the edge they are traversing.Return the current edge that this actor is traversing.protected double
Return the speed of this actor, which is primarily a function of its `currentEdge`'s weight.Return the upper left corner of this actor's bounding box.abstract List
<MazeGraph.MazeEdge> Return the list of Edges in this actor's current planned path through the maze (if any).location()
Return Location object summarizing this actor's current location.double
Return the amount of game time (in ms) that this actor is able to travel at its current speed before reaching a vertex or changing state.Return the closest vertex to this actor's current position, which will be either `currentEdge.src()` or `currentEdge.dst()`, depending on `distanceAlongEdge`.abstract MazeGraph.MazeEdge
nextEdge()
Returns the next edge that this actor will traverse in the game graph.void
propagate
(double dt) Update this actor's location and state by propagating its current motion along its edge by `dt` ms of game time.abstract void
reset()
Resets this actor to its state at the start of a life.void
traverseEdge
(MazeGraph.MazeEdge newEdge) Set this actor's location to the start of `newEdge`.abstract void
Update the model based on this actor's arrival at vertex v.
-
Field Details
-
model
The game model with which this actor is associated. -
location
The current location of this actor, modeled as a record of the edge that they are currently traversing and their relative progress along this edge.
-
-
Constructor Details
-
Actor
Construct a new actor associated with the given `model`.
-
-
Method Details
-
visitVertex
Update the model based on this actor's arrival at vertex v. -
nextEdge
Returns the next edge that this actor will traverse in the game graph. Navigation strategy is delegated to the subclass. Will only be called when this actor is standing on a vertex, which must equal the returned edge's starting vertex. -
guidancePath
Return the list of Edges in this actor's current planned path through the maze (if any). This is intended to be used for visualizing actors' intended behavior. Sequence of edges must form a continuous path (e.g., `ans.get(i).dst().equals(ans.get(i+1).src())`). -
reset
public abstract void reset()Resets this actor to its state at the start of a life. -
baseSpeed
public abstract double baseSpeed()Return the current base speed of this actor, before factoring in the weight of the edge they are traversing. -
location
Return Location object summarizing this actor's current location. -
currentEdge
Return the current edge that this actor is traversing. -
nearestVertex
Return the closest vertex to this actor's current position, which will be either `currentEdge.src()` or `currentEdge.dst()`, depending on `distanceAlongEdge`. -
maxPropagationTime
public double maxPropagationTime()Return the amount of game time (in ms) that this actor is able to travel at its current speed before reaching a vertex or changing state. Return POSITIVE_INFINITY if this actor is standing still and has no anticipated state changes. -
propagate
public void propagate(double dt) Update this actor's location and state by propagating its current motion along its edge by `dt` ms of game time. If `dt` is sufficient for the actor to traverse the remainder of its edge, it will stop at that edge's destination vertex. -
traverseEdge
Set this actor's location to the start of `newEdge`. May only be called when this actor is standing on a vertex, which must equal `newEdge`'s source. -
edgeSpeed
protected double edgeSpeed()Return the speed of this actor, which is primarily a function of its `currentEdge`'s weight. -
getBoundingBoxUL
Return the upper left corner of this actor's bounding box. When an actor is positioned directly atop a vertex (i.e., `distanceAlongEdge` is 0 or 1), this is 0.25 tiles NW (northwest) of the NW corner of that vertex's tile. Otherwise, `distanceAlongEdge` is used to linearly interpolate the bounding box position between `currentEdge.src()` and `currentEdge.dst()` (accounting for tunnels).
-