use of com.ixale.starparse.parser.Parser.ActorState in project StarParse by Ixale.
the class HotsPopoutPresenter method setActorStates.
public void setActorStates(final Map<Actor, ActorState> actorStates, final String currentCharacterName) {
this.currentCharacterName = currentCharacterName;
autosizeButton.setVisible(currentCharacterName != null);
if (!isEnabled()) {
return;
}
if (players.size() > matrix.length * matrix[0].length) {
// safety
return;
}
final List<Object[]> newPlayers = new ArrayList<>();
for (final Actor actor : actorStates.keySet()) {
if (!(Actor.Type.SELF.equals(actor.getType()) || Actor.Type.PLAYER.equals(actor.getType()))) {
continue;
}
final ActorState state = actorStates.get(actor);
if (state.hotLast != null) {
// ignore extremely old
if (state.hotLast < TimeUtils.getCurrentTime() - TIMEOUT_WITHOUT_DURATION) {
continue;
}
if (!players.containsKey(actor.getName())) {
if (ignorePlayers.containsKey(actor.getName())) {
if (ignorePlayers.get(actor.getName()) >= state.hotLast) {
continue;
}
ignorePlayers.remove(actor.getName());
}
newPlayers.add(new Object[] { actor.getName(), state });
}
}
}
if (newPlayers.isEmpty()) {
return;
}
// ensure the players are added according to their HOT application to allow simpler overlay setup
newPlayers.sort(Comparator.comparing(o -> ((ActorState) o[1]).hotLast));
for (final Object[] pair : newPlayers) {
addPlayer((String) pair[0], (ActorState) pair[1]);
}
}
Aggregations