Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

# Tyrion.AI_SensorAction

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

    //=====================================================================
    // AI_SensorAction
    // The Tyrion SensorAction class: Special actions that collect and report
    // information
    //=====================================================================

    class AI_SensorAction extends AI_RunnableAction
    	abstract
    	native;

    // SensorActions don't achieve goals, they don't have a selection heuristic
    // SensorActions aren't stored with a char's "abilities", for instead are globally available
    // to any action (for now)
    // I see no pressing need to add sensorActions to parent's "child" list, since sensors pass
    //  their messages through their own methods anyway and they don't succeed/fail, so consequently
    //  never need to be interrupted
    // Really the only thing they have in common with actions is that they can start children,
    //  and they can be idle/running

    // Note on state code usage in sensor actions:
    // - sensor actions update the sensors whose "queryUsage()" is > 0
    // - when no sensors need updating, THE SENSOR ACTION WILL NOT RUN AT ALL
    // - consequently, a sensor action that maintains non periodic sensors must not assume any of
    //   its state code will ever get executed (which is why we have the "begin()" function)

    // Ideas about finding sensorActions:
    // 1. Always create all sensorActions and sensors for the resource when the resource is created,
    //    but make the sensor action idle until sensor data is requested
    //    - how? in the resource's default params, keep a list of sensor actions
    //    - each sensor action creates all its sensors in a init function, and sticks them on the
    //      resource sensor list (with a link back to the action)
    // 2. Keep idle list around or make sensorAction list;
    //    traverse it to see if sensorAction you want already exists

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

    var int usageCount;		// how many actions (in total) are using sensor values updated by this action?
    var bool bCallBegin;	// need to call "begin()" function?

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

    //---------------------------------------------------------------------
    // Constructor

    overloaded function construct( AI_Resource r )
    {
    	resource = r;
    	GotoState( 'Running' );
    }

    //---------------------------------------------------------------------
    // increments refCount and returns object

    function AI_SensorAction myAddRef()
    {
    	AddRef();
    	return self;
    }

    //---------------------------------------------------------------------
    // set up the sensors this action may update

    function setupSensors( AI_Resource r );

    //---------------------------------------------------------------------
    // do one time initializations before state code is run
    // (called from "activateSensor")

    function begin();

    //---------------------------------------------------------------------
    // Run an action

    function runAction()
    {
    #if IG_TRIBES3
    	if ( !resource.bUnInitialized && !resource.isActive() )
    	{
    		log( "AI WARNING: runAction called on" @ name @ "(" @ resource.pawn().name @ ") but resource is inactive" );
    	}
    #endif

    	Super.runAction();
    }

    //---------------------------------------------------------------------
    // Called by an action when it has failed at accomplishing its goal

    event instantFail( ACT_ErrorCodes errorCode, optional bool bRemoveGoal )
    {
    	//log( "instantFail called on" @ name @ "(" @ resource.pawn() @ ")" );
    	//removeAction();
    }

    //---------------------------------------------------------------------
    // add a sensor to a sensor action

    function AI_Sensor addSensorClass( class<AI_Sensor> sensorClass )
    {
    	local AI_Sensor sensor;

    	sensor = new(resource) sensorClass( self );
    	resource.sensors[resource.sensors.length] = sensor;	// push()

    	//if ( resource.pawn() != None )
    	//	log( "=> addSensorClass: adding" @ sensor.name @ "to" @ name @ "on" @ resource.name @ resource.pawn().name );

    	return sensor;
    }

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

    defaultproperties
    {
    	bSensorAction	= true
    	bCallBegin		= true
    }

Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation
previous class next class | frames no frames

Class file time: ne 5.9.2004 15:54:22.000 - Creation time: st 23.5.2018 00:10:41.648 - Created with UnCodeX