Package megamek.client.bot.princess
Class UnitBehavior
java.lang.Object
megamek.client.bot.princess.UnitBehavior
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintaddEntityWaypoint(Entity entity, List<Coords> waypoints, Princess owner) Adds waypoints to the end of the unit's route, dropping any the unit cannot reach.booleanaddEntityWaypoint(Entity entity, Coords destination, Princess owner) Deprecated, for removal: This API element is subject to removal in a future version.voidbeginRanking(Entity entity, Princess owner) Works out a unit's active waypoint once before its moves are ranked, and answers with it untilendRanking(): the path ranker asks for it four or five times for every move it scores.voidclear()Clears the entity behavior cache, should be done at the start of each movement phasevoidclearWaypoints(Princess owner) Clears the orders of every unit of the bot.voidclearWaypoints(Entity entity, Princess owner) Clears all of one unit's orders.voidEnds the waypoint snapshotbeginRanking(megamek.common.units.Entity, megamek.client.bot.princess.Princess)took, once the unit's moves are ranked.getActiveWaypoint(Entity entity, Princess owner) Returns the waypoint that decides where the unit moves this phase, if a waypoint does.getBehaviorType(Entity entity, Princess owner) Gets (and calculates, if necessary), the behavior type for the given entity.getCachedBehaviorType(Entity entity) The behavior already worked out for this unit, without working one out if none has been.getWaypointForEntity(Entity entity) booleanisDestinationValidForEntity(Entity entity, Coords destination, Princess owner) static booleanisFleeOrdered(Princess owner) Returns whether the bot has a standing order to flee toward an edge, given from the Bot Commands panel or thefleechat command.booleanisFollowingOrdersOverWithdrawal(Entity entity, Princess owner) Returns whether a withdrawing unit follows the player's orders instead of heading for its retreat edge.voidoverrideBehaviorType(Entity entity, UnitBehavior.BehaviorType behaviorType) voidremoveTailWaypoint(Entity entity, Princess owner) Removes the last waypoint of the unit's route, good for an "undo" behavior.intsetEntityWaypoints(Entity entity, List<Coords> waypoints, Princess owner) Replaces the unit's route with the given waypoints, dropping any the unit cannot reach.
-
Constructor Details
-
UnitBehavior
public UnitBehavior()
-
-
Method Details
-
isFleeOrdered
Returns whether the bot has a standing order to flee toward an edge, given from the Bot Commands panel or thefleechat command.- Parameters:
owner- the bot- Returns:
trueif every unit of the bot is ordered toward the bot's destination edge
-
isFollowingOrdersOverWithdrawal
Returns whether a withdrawing unit follows the player's orders instead of heading for its retreat edge.A player's direct order outranks the unit's own Forced Withdrawal: a crippled unit sent to a hex or an edge goes there (issue #9038). A gamemaster's order to withdraw still wins over everything, and the bot-wide flee order wins over a route, sending a withdrawing unit toward the ordered edge instead.
- Parameters:
entity- the unitowner- the bot that owns the unit- Returns:
trueif the unit is withdrawing under the bot's rules but has orders to follow instead
-
getActiveWaypoint
Returns the waypoint that decides where the unit moves this phase, if a waypoint does. An edge order, a bot-wide flee order and a withdrawal the player has not overridden all send the unit to an edge instead, so they return empty.- Parameters:
entity- the unitowner- the bot that owns the unit- Returns:
- the unit's current waypoint when it is following its route, otherwise empty
-
beginRanking
Works out a unit's active waypoint once before its moves are ranked, and answers with it untilendRanking(): the path ranker asks for it four or five times for every move it scores.- Parameters:
entity- the unit about to have its moves rankedowner- the bot that owns the unit
-
endRanking
public void endRanking()Ends the waypoint snapshotbeginRanking(megamek.common.units.Entity, megamek.client.bot.princess.Princess)took, once the unit's moves are ranked. -
getBehaviorType
Gets (and calculates, if necessary), the behavior type for the given entity. -
getCachedBehaviorType
The behavior already worked out for this unit, without working one out if none has been.For logging and analysis only.
getBehaviorType(megamek.common.units.Entity, megamek.client.bot.princess.Princess)computes and caches on a miss, and what it computes depends on where everything is standing at the time - so asking early, for a unit that has not moved yet, would pin an answer the bot would otherwise have reached later with better information.- Parameters:
entity- the unit to look up- Returns:
- the cached behavior, or
nullif this unit has not been evaluated this turn
-
overrideBehaviorType
-
getWaypointForEntity
- Parameters:
entity- the unit- Returns:
- the next waypoint of the unit's route, which is stored on the unit, or empty when it has none
-
isDestinationValidForEntity
-
addEntityWaypoint
Adds waypoints to the end of the unit's route, dropping any the unit cannot reach. The route is stored on the unit and sent to the server.- Returns:
- how many of the given waypoints were kept;
0when none of them can be reached
-
addEntityWaypoint
@Deprecated(since="0.51.0", forRemoval=true) public boolean addEntityWaypoint(Entity entity, Coords destination, Princess owner) Deprecated, for removal: This API element is subject to removal in a future version. -
removeTailWaypoint
Removes the last waypoint of the unit's route, good for an "undo" behavior.- Parameters:
entity- the unitowner- the bot that owns the unit
-
setEntityWaypoints
Replaces the unit's route with the given waypoints, dropping any the unit cannot reach. The route is stored on the unit and sent to the server.- Returns:
- how many of the given waypoints were kept;
0when none of them can be reached, in which case the unit's orders are left as they were
-
clearWaypoints
Clears all of one unit's orders.- Parameters:
entity- the unitowner- the bot that owns the unit
-
clearWaypoints
Clears the orders of every unit of the bot.- Parameters:
owner- the bot
-
clear
public void clear()Clears the entity behavior cache, should be done at the start of each movement phase
-