<commit_before>package de.gurkenlabs.litiengine.entities;

import de.gurkenlabs.litiengine.Game;
import de.gurkenlabs.litiengine.IUpdateable;
import de.gurkenlabs.litiengine.environment.tilemap.MapObjectProperty;
import de.gurkenlabs.litiengine.environment.tilemap.MapObjectType;
import de.gurkenlabs.litiengine.environment.tilemap.TmxProperty;
import de.gurkenlabs.litiengine.environment.tilemap.TmxType;
import de.gurkenlabs.litiengine.graphics.RenderType;
import de.gurkenlabs.litiengine.util.geom.GeometricUtilities;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * TODO: Triggers should be able to call entity actions (similar to the current message approach)
 */
@CollisionInfo(collision = false)
@EntityInfo(renderType = RenderType.OVERLAY)
@TmxType(MapObjectType.TRIGGER)
public class Trigger extends CollisionEntity implements IUpdateable {
  public enum TriggerActivation {
    COLLISION,
    INTERACT
  }

  private static final Logger log = Logger.getLogger(Trigger.class.getName());

  private final Collection<TriggerActivatedListener> activatedListeners =
      ConcurrentHashMap.newKeySet();
  private final Collection<TriggerDeactivatedListener> deactivatedListeners =
      ConcurrentHashMap.newKeySet();
  private final Collection<TriggerActivatingCondition> activatingConditions =
      ConcurrentHashMap.newKeySet();

  private final Collection<IEntity> collisionActivated = ConcurrentHashMap.newKeySet();

  @TmxProperty(name = MapObjectProperty.TRIGGER_ACTIVATORS)
  private final List<Integer> activators = new CopyOnWriteArrayList<>();

  @TmxProperty(name = MapObjectProperty.TRIGGER_TARGETS)
  private final List<Integer> targets = new CopyOnWriteArrayList<>();

  @TmxProperty(name = MapObjectProperty.TRIGGER_ACTIVATION)
  private final TriggerActivation activationType;

  @TmxProperty(name = MapObjectProperty.TRIGGER_ONETIME)
  private final boolean isOneTimeTrigger;

  @TmxProperty(name = MapObjectProperty.TRIGGER_MESSAGE)
  private String message;

  @TmxProperty(name = MapObjectProperty.TRIGGER_COOLDOWN)
  private int cooldown;

  private long lastActivation;
  private boolean isActivated;

  /**
   * Instantiates a new {@code Trigger} entity.
   *
   * @param activation The activation method for this trigger.
   * @param message The message that gets sent by this trigger upon activation.
   */
  public Trigger(final TriggerActivation activation, final String message) {
    this(activation, null, message);
  }

  /**
   * Instantiates a new {@code Trigger} entity.
   *
   * @param activation The activation method for this trigger.
   * @param name The name of this trigger.<commit_msg>Serializable tmx properties should not be final.<commit_after>package de.gurkenlabs.litiengine.entities;

import de.gurkenlabs.litiengine.Game;
import de.gurkenlabs.litiengine.IUpdateable;
import de.gurkenlabs.litiengine.environment.tilemap.MapObjectProperty;
import de.gurkenlabs.litiengine.environment.tilemap.MapObjectType;
import de.gurkenlabs.litiengine.environment.tilemap.TmxProperty;
import de.gurkenlabs.litiengine.environment.tilemap.TmxType;
import de.gurkenlabs.litiengine.graphics.RenderType;
import de.gurkenlabs.litiengine.util.geom.GeometricUtilities;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * TODO: Triggers should be able to call entity actions (similar to the current message approach)
 */
@CollisionInfo(collision = false)
@EntityInfo(renderType = RenderType.OVERLAY)
@TmxType(MapObjectType.TRIGGER)
public class Trigger extends CollisionEntity implements IUpdateable {
  public enum TriggerActivation {
    COLLISION,
    INTERACT
  }

  private static final Logger log = Logger.getLogger(Trigger.class.getName());

  private final Collection<TriggerActivatedListener> activatedListeners =
      ConcurrentHashMap.newKeySet();
  private final Collection<TriggerDeactivatedListener> deactivatedListeners =
      ConcurrentHashMap.newKeySet();
  private final Collection<TriggerActivatingCondition> activatingConditions =
      ConcurrentHashMap.newKeySet();

  private final Collection<IEntity> collisionActivated = ConcurrentHashMap.newKeySet();

  @TmxProperty(name = MapObjectProperty.TRIGGER_ACTIVATORS)
  private final List<Integer> activators = new CopyOnWriteArrayList<>();

  @TmxProperty(name = MapObjectProperty.TRIGGER_TARGETS)
  private final List<Integer> targets = new CopyOnWriteArrayList<>();

  @TmxProperty(name = MapObjectProperty.TRIGGER_ACTIVATION)
  private TriggerActivation activationType;

  @TmxProperty(name = MapObjectProperty.TRIGGER_ONETIME)
  private boolean isOneTimeTrigger;

  @TmxProperty(name = MapObjectProperty.TRIGGER_MESSAGE)
  private String message;

  @TmxProperty(name = MapObjectProperty.TRIGGER_COOLDOWN)
  private int cooldown;

  private long lastActivation;
  private boolean isActivated;

  /**
   * Instantiates a new {@code Trigger} entity.
   *
   * @param activation The activation method for this trigger.
   * @param message The message that gets sent by this trigger upon activation.
   */
  public Trigger(final TriggerActivation activation, final String message) {
    this(activation, null, message);
  }

  /**
   * Instantiates a new {@code Trigger} entity.
   *
   * @param activation The activation method for this trigger.
   * @param name The name of this trigger.
{'fraction_non_alphanumeric': 0.08195580302766661, 'fraction_numerical': 0.0, 'mean_word_length': 5.591743119266055, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7150461', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1669, 'n_words': 389}