/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 Chuck Ritola
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl.beh;

public abstract class DamageTrigger extends Behavior {
private boolean triggered=false;
private int threshold=2048;

	@Override
	public void tick(long timeInMillis){
	    if(!triggered){
		if(getParent().probeForBehavior(DamageableBehavior.class).getHealth()<threshold){
		    triggered=true;//Just in case disabling has latency
		    setEnable(false);///zzz...
		    healthBelowThreshold();
		}//end if(damaged)
	    }//end if(!triggered)
	}//end _tick(...)
	
	public abstract void healthBelowThreshold();

	/**
	 * @return the threshold
	 */
	public int getThreshold() {
	    return threshold;
	}

	/**
	 * @param threshold the threshold to set
	 */
	public DamageTrigger setThreshold(int threshold) {
	    this.threshold = threshold;
	    return this;
	}
}//end DamageTrigger

@@ -605,122 +605,337 @@
 h;%0A%0A
-public abstract class DamageTrigger extends Behavior %7B%0Aprivate boolean triggered=false;%0Aprivate int threshold=2048
+import java.beans.PropertyChangeListener;%0Aimport java.beans.PropertyChangeSupport;%0A%0Apublic abstract class DamageTrigger extends Behavior %7B%0A    public static final String TRIGGERED = %22triggered%22;%0Aprivate boolean triggered=false;%0Aprivate int threshold=2048;%0Aprivate final PropertyChangeSupport pcs = new PropertyChangeSupport(this)
 ;%0A%0A%09
@@ -1093,25 +1093,28 @@
 %7B%0A%09%09    
-t
+setT
 riggered
 =true;//
@@ -1109,13 +1109,14 @@
 ered
-=
+(
 true
+)
 ;//J
@@ -1153,71 +1153,8 @@
 ncy%0A
-%09%09    setEnable(false);///zzz...%0A%09%09    healthBelowThreshold();%0A
 %09%09%7D/
@@ -1514,16 +1514,1376 @@
 this;%0A%09%7D
+%0A%0A%09public boolean isTriggered() %7B%0A%09    return triggered;%0A%09%7D%0A%0A%09public void setTriggered(boolean triggered) %7B%0A%09    if(triggered==this.triggered)%0A%09%09return;%0A%09    final boolean oldValue = this.triggered;%0A%09    this.triggered = triggered;%0A%09    pcs.firePropertyChange(TRIGGERED, oldValue, triggered);%0A%09    if(triggered)%7B%0A%09%09setEnable(false);///zzz...%0A%09%09healthBelowThreshold();%0A%09    %7D//end if(triggered)%0A%09%7D//end setTriggered()%0A%0A%09public void addPropertyChangeListener(PropertyChangeListener listener) %7B%0A%09    pcs.addPropertyChangeListener(listener);%0A%09%7D%0A%0A%09public void addPropertyChangeListener(String propertyName,%0A%09%09PropertyChangeListener listener) %7B%0A%09    pcs.addPropertyChangeListener(propertyName, listener);%0A%09%7D%0A%0A%09public PropertyChangeListener%5B%5D getPropertyChangeListeners() %7B%0A%09    return pcs.getPropertyChangeListeners();%0A%09%7D%0A%0A%09public PropertyChangeListener%5B%5D getPropertyChangeListeners(%0A%09%09String propertyName) %7B%0A%09    return pcs.getPropertyChangeListeners(propertyName);%0A%09%7D%0A%0A%09public boolean hasListeners(String propertyName) %7B%0A%09    return pcs.hasListeners(propertyName);%0A%09%7D%0A%0A%09public void removePropertyChangeListener(PropertyChangeListener listener) %7B%0A%09    pcs.removePropertyChangeListener(listener);%0A%09%7D%0A%0A%09public void removePropertyChangeListener(String propertyName,%0A%09%09PropertyChangeListener listener) %7B%0A%09    pcs.removePropertyChangeListener(propertyName, listener);%0A%09%7D
 %0A%7D//end 

Add triggering bound property plus listener support to DamageTrigger.