<commit_before>package rj.helmet;

import rj.helmet.Actor.ActorState;
import rj.helmet.Entity;
import rj.helmet.Entity.EntityType;

/**
 * Triggers when the player stands on it.
 * 
 * @author roguedjack
 */
class Trigger extends Entity {
	
	public var repeatable(default, null):Bool;
	public var delay(default, null):Float;
	var triggerTime:Float;

	public function new(delay:Float = 0, repeatable:Bool = false) {		
		super(EntityType.TRIGGER);
		this.repeatable = repeatable;
		this.delay = delay;
		triggerTime = 0;
		canCollide = false;
		isVisible = false;
		setCollisionBox(0, 0, Main.TILE_SIZE, Main.TILE_SIZE);
	}
	
	override public function update(elapsed:Float) {
		super.update(elapsed);
		
		if (triggerTime > 0) {
			if ((triggerTime -= elapsed) <= 0) {
				fireTrigger();
				if (!repeatable) {
					remove();
				}
			}
		} else {
			if (world.player == null || world.player.state != ActorState.LIVING) {
				return;
			}
			if (world.player.bounds.collide(bounds)) {
				triggerTime = delay;
			}
		}
	}
	
	function fireTrigger() { }
}<commit_msg>fixed trigger with delay=0 not firing<commit_after>package rj.helmet;

import rj.helmet.Actor.ActorState;
import rj.helmet.Entity;
import rj.helmet.Entity.EntityType;

/**
 * Triggers when the player stands on it.
 * 
 * @author roguedjack
 */
class Trigger extends Entity {
	
	public var repeatable(default, null):Bool;
	public var delay(default, null):Float;
	var triggerTime:Float;
	var triggered:Bool;

	public function new(delay:Float = 0, repeatable:Bool = false) {		
		super(EntityType.TRIGGER);
		this.repeatable = repeatable;
		this.delay = delay;
		triggerTime = 0;
		canCollide = false;
		isVisible = false;
		setCollisionBox(0, 0, Main.TILE_SIZE, Main.TILE_SIZE);
	}
	
	override public function update(elapsed:Float) {
		super.update(elapsed);
		
		if (triggered) {
			if ((triggerTime -= elapsed) <= 0) {
				fireTrigger();
				if (!repeatable) {
					remove();
				}
			}
		} else {
			if (world.player == null || world.player.state != ActorState.LIVING) {
				return;
			}
			if (world.player.bounds.collide(bounds)) {
				triggerTime = delay;
				triggered = true;
			}
		}
	}
	
	function fireTrigger() { }
}
{'fraction_non_alphanumeric': 0.12985825331504344, 'fraction_numerical': 0.0054869684499314125, 'mean_word_length': 3.4836065573770494, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 4, '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': '6506123', 'n_tokens_mistral': 872, 'n_tokens_neox': 748, 'n_words': 170}