SpatialFear.SFSeqTrigger

00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
//=============================================================================
// Spatial Fear
// Name: SFSeqTrigger
// Description: This is a subclass of a trigger and is used to specify the sequence number
// for this trigger. A SFSeqTrigger is linked to a SFSeqCounter by the appropriate use of the 
// CounterEvent/Tag pairs. The SFSeqCounter with a matching tag will be trigged from this class.
//
// Remark: 	!!Since this class uses a custom event you won't see a connecting line in UED.
//
// Author: Markus Nuebel
//=============================================================================
class SFSeqTrigger extends Trigger;

// Sequence number
var (Sequence) int Sequence; // Sequence number starting with zero
var (Sequence) float fFloatFreezeTimeAfterTouch; // Freeze time after touch, prevents multiple touch event when moving very slowly over the trigger. Defaults to 2.0 secs.
var (Events) name CounterEvent; // Special event sent to trigger a SFSeqCounter, must match the tag of a SFSeqCounter. 

var bool bFreeze; // private.

// Called from a SFSeqTrigger
function FireCounterEvent(actor Other, bool bUntrigger)
{
	local SFSeqCounter A;
	local pawn instigator;

	//class'SFUtils'.Static.sfLogEx(10,"FireEventCounter");

	//Check freeze state
	if(bFreeze)
		return;

	if(CounterEvent != '')
	{
		// Fire event on all SFSeqCounters assigned to this trigger
		foreach AllActors( class 'SFSeqCounter', A )
		{
			if(A.IsA('SFSeqCounter'))
			{
				// Find all matching tiggers for this counter
				if(A.Tag == CounterEvent)
				{
					if(!bUntrigger)
					{
						//class'SFUtils'.Static.sfLogEx(10,"Sending trigger event to " $ string(A.name));
						instigator = pawn(Other);
						A.TriggerCounter(Sequence, self, instigator);
						bFreeze=true;
						SetTimer(fFloatFreezeTimeAfterTouch, false);
					}
					else
					{
						//class'SFUtils'.Static.sfLogEx(10,"Sending UNTRIGGER event to " $ string(A.name));
						A.UnTrigger( Other, Other.Instigator );
					}
				}

			}
		}
	}
}

// Timer event, used to reset freeze state.
event timer()
{
	//class'SFUtils'.Static.sfLogEx(10,"Timer");

	Super.Timer();

	bFreeze=false;
	//class'SFUtils'.Static.sfLogEx(10,"Reset freeze state.");
}

// Called when something touches the trigger.
function Touch(actor Other)
{

	local actor A;

	//class'SFUtils'.Static.sfLogEx(10,"Touch");

	if( IsRelevant( Other ) )
	{
		if ( ReTriggerDelay > 0 )
		{
			class'SFUtils'.Static.sfLogEx(10,"ReTrigger Delay > 0");
			if ( Level.TimeSeconds - TriggerTime < ReTriggerDelay )
				return;
			TriggerTime = Level.TimeSeconds;
		}

		FireCounterEvent(Other, false);
	}

	// Call to base class
	Super.Touch(Other);
}

// Called when something untouches the trigger
function UnTouch( actor Other )
{
	local actor A;

	if( IsRelevant( Other ) )
	{
		// Untrigger all matching actors.
		FireCounterEvent(Other, true);
	}

	// Call to base class
	Super.UnTouch(Other);
}

// Called when something triggers the counter
function Trigger(actor Other, pawn EventInstigator)
{
	local actor A;

	if( IsRelevant( Other ) )
	{
		// Untrigger all matching actors.
		FireCounterEvent(Other, true);
	}

	// Call to base class
	Super.Trigger(Other, EventInstigator);
}

defaultproperties
{
     fFloatFreezeTimeAfterTouch=2.000000
}

class file time: 12/7/2003 3:58:24 PM - creation time: 12/7/2003 4:03:45 PM
Created with UnCodeX