public class GoalSelector extends Object
A running goal will always be replaced with a goal with a lower priority, if
such a goal exists, it's competing for the same control and its
canStart()
method returns true. (Note that some goals randomize
this method.)
If two goals have the same priority and are competing for the same control, then one goal cannot replace the other if it's running. The goal selector tries to run goals in the order they were added.
Modifier and Type | Field and Description |
---|---|
private EnumSet<Goal.Control> |
disabledControls |
private Set<PrioritizedGoal> |
goals |
private Map<Goal.Control,PrioritizedGoal> |
goalsByControl |
private static Logger |
LOGGER |
private Supplier<Profiler> |
profiler |
private static PrioritizedGoal |
REPLACEABLE_GOAL |
private int |
timeInterval |
Constructor and Description |
---|
GoalSelector(Supplier<Profiler> profiler) |
Modifier and Type | Method and Description |
---|---|
void |
add(int priority,
Goal goal)
Adds a goal with a certain priority.
|
void |
disableControl(Goal.Control control) |
void |
enableControl(Goal.Control control) |
Stream<PrioritizedGoal> |
getRunningGoals() |
void |
remove(Goal goal) |
void |
setControlEnabled(Goal.Control control,
boolean enabled) |
void |
tick() |
private static final Logger LOGGER
private static final PrioritizedGoal REPLACEABLE_GOAL
private final Map<Goal.Control,PrioritizedGoal> goalsByControl
private final Set<PrioritizedGoal> goals
private final EnumSet<Goal.Control> disabledControls
private int timeInterval
public void add(int priority, Goal goal)
public void remove(Goal goal)
public void tick()
public Stream<PrioritizedGoal> getRunningGoals()
public void disableControl(Goal.Control control)
public void enableControl(Goal.Control control)
public void setControlEnabled(Goal.Control control, boolean enabled)