Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

Tyrion.AI_PeriodicSensor


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
//=====================================================================
// AI_PeriodicSensor
// A sensor that gets updated by sensor action's state code
//
// By default, periodic sensors send a sensor message only when
// their value changes.
//=====================================================================

class AI_PeriodicSensor extends AI_Sensor
	abstract;

//=====================================================================
// Variables

//=====================================================================
// Functions

//---------------------------------------------------------------------
// Create a new sensor (or find a pre-existing one)
// low-level function called by activateSensor and activateSentinel

protected static function AI_Sensor activateSensorInternal( class<AI_Sensor> sensorClass,
														  AI_Resource r,
														  optional float lowerBound,
														  optional float upperBound,
														  optional Object userData,
														  optional ISensorNotification recipient)
{
	local AI_PeriodicSensor sensor;

	sensor = AI_PeriodicSensor(super.activateSensorInternal( sensorClass, r, lowerBound, upperBound, userData, recipient ));

	if ( sensor != None )
	{
		sensor.sensorAction.usageCount++;
		if ( sensor.sensorAction.usageCount == 1 )
			sensor.sensorAction.runAction();
	}

	return sensor;
}

//---------------------------------------------------------------------
// Remove a sensor
// low-level function called by deactivateSensor and deactivateSentinel

protected function deactivateSensorInternal( ISensorNotification recipient, optional float lowerBound, optional float upperBound )
{
	super.deactivateSensorInternal( recipient, lowerBound, upperBound );

	sensorAction.usageCount--;

	// stop sensorAction?
	if ( recipients.length == 0 && sensorAction.usageCount == 0 )
	{
		//log( "----> Pausing" @ sensorAction.name @ "(" @ name @ "deactivated )" );
		sensorAction.pauseAction();
	}
}

//=====================================================================

defaultproperties
{
	bNotifyOnValueChange = true
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 15:54:20.000 - Creation time: st 23.5.2018 00:10:41.516 - Created with UnCodeX