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

Engine.Tyrion_ResourceBase


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
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
//=====================================================================
// Tyrion_ResourceBase
// The Tyrion Resource class: Resources are the entities that can
// perform actions.
// This class should be embedded in every data structure that
// functions as a resource (such as Rook)
//=====================================================================

class Tyrion_ResourceBase extends Core.RefCount
	abstract
	threaded
	native;

//=====================================================================
// Constants

enum ResourceTypes
{
	RT_DEFAULT,
	RT_VEHICLE,
	RT_GUNNER,
	RT_DRIVER,
	RT_TURRET,
	RT_CHARACTER,
	RT_SQUAD,
	RT_ARMS,
	RT_LEGS,
	RT_HEAD
};

enum AI_LOD_Levels
{
	AILOD_NONE,		// AI doesn't know this rook exists; AI control must be activated in script
	AILOD_MINIMAL,	// AI does minimal processing on this rook to determine when it needs to activate full AI
	AILOD_IDLE,		// AI has rook perform idle animations, but no complex behavior; monitors whether to activate full AI
	AILOD_NORMAL,	// Normal AI control, can drop back to AILOD_Minimal
	AILOD_ALWAYS_ON	// Normal AI control, never changes LOD state
};

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

var(AI) editinline DeepCopy array<Tyrion_GoalBase> goals;	// goals the resource is trying to achieve
var(AI)	editinline array<Tyrion_ActionBase> abilities;	// the actions this resource is capable of performing
/*
var(AI) editinline array< class<Tyrion_GoalBase> > goals;	// goals the resource is trying to achieve
var(AI)	editinline array< class<Tyrion_ActionBase> > abilities;	// the actions this resource is capable of performing
*/

var bool bMatchGoals;						// is action-to-goal matching necessary?
var bool bUnInitialized;					// resource still needs to be initialized?
var bool bGoalsReset;						// is goal list in its initial state?

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

//---------------------------------------------------------------------
// Called before the resource is first ticked

event init();

//---------------------------------------------------------------------
// Store a back pointer to the actor (pawn or squad) that this resource is attached to

function setResourceOwner( Actor p );

//---------------------------------------------------------------------
// Stores index of this resource in "positions" array
// (only used in vehicles)

function setIndex( int index );

//---------------------------------------------------------------------
// Clean up resource-related stuff when pawn dies

function cleanup();

//---------------------------------------------------------------------
// Delete all the sensors attached to this resource

function deleteSensors();

//---------------------------------------------------------------------
// Delete actions that have been removed from idle and running lists

event deleteRemovedActions();

//---------------------------------------------------------------------
// Mark all goals as achieved: this will reset the resource to have
// only permanent goals (used when a mount loses its driver)

event resetGoals();

//---------------------------------------------------------------------
// Should this resource be trying to satisfy goals?
// (A dead resource should not, for example)
// The default is true but individual resources can define their own logic

event bool isActive()
{
	return true;
}

//---------------------------------------------------------------------
// Does the resource have the sub-resources available to run an action?
// legspriority:  priority of the sub-goal that will be posted on the legs (0 if no goal)
// armsPriority:  priority of the sub-goal that will be posted on the arms (0 if no goal)
// headPriority:  priority of the sub-goal that will be posted on the arms (0 if no goal)

function bool requiredResourcesAvailable( int legsPriority, int armsPriority, optional int headPriority );

//---------------------------------------------------------------------
// Inform a resource that a particular pawn died

function pawnDied( Pawn pawn );

//---------------------------------------------------------------------
// Move designer-assigned goals to the resource

function assignGoal( class<Tyrion_GoalBase> goalClass )
{
	if ( goalClass != None )
	{
		if ( ClassIsChildOf( class, goalClass.static.getResourceClass() ) )
		{
			goals[goals.length] = new goalClass;	// goals.push( goalClass )
			goals[goals.length-1].addRef();			// corresponds to the one given by "addGoal()" for non-designer goals
			goals[goals.length-1].addRef();			// guarantees that designer-created goals never get deleted

			//log( name @ "added" @ goals[goals.length-1] @ "Outer:" @ goals[goals.length-1].Outer );
		}
	}
}

//---------------------------------------------------------------------
// Move designer-assigned abilities (actions) of type "resourceType" to the resource

function assignAbility( class<Tyrion_ActionBase> abilityClass )
{
	if ( abilityClass != None )
	{
		if ( ClassIsChildOf( class, abilityClass.static.getResourceClass() ) )
		{
			abilities[abilities.length] = new abilityClass;		// abilities.push( abilityClass )
			//log( name @ "added" @ abilities[abilities.length-1]);
		}
	}
}

//---------------------------------------------------------------------
// Called whenever time passes

native function Tick( float deltaTime );

//---------------------------------------------------------------------
// adds an ability to a resource

function addAbility(Tyrion_ActionBase newAbility)
{
    assert(NewAbility != None);
    abilities[abilities.Length] = newAbility;
}

//---------------------------------------------------------------------
// action/goal debug display function

function displayTyrionDebug();

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

defaultproperties
{
	bUnInitialized = true
	bGoalsReset = true
}


Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: ne 5.9.2004 16:01:32.000 - Creation time: st 23.5.2018 00:10:49.659 - Created with UnCodeX