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

Tyrion.NavigationStressTest


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
class NavigationStressTest extends TyrionUnitTest;

var() array<name> names;
var() array<vector> destinations;

var array<pawn> rooks;

var array<AI_Controller> controllers;

var array<NS_Action> actions;

var array<vector> startLocations;

var array<int> goingTo;

var vector workVectorA;

var int workIndex;

var NS_MoveToLocation.TerminalConditions terminalConditions;

state UnitTestState
{
	function BeginState()
	{
		local int rookIndex;
		local int controllerIndex;

		if (names.Length != destinations.Length)
		{
			signalFailed("Number of pawns does not match number of destinations.");
			return;
		}

		// get specified pawns
		rooks.Length = destinations.Length;
		for (rookIndex = 0; rookIndex < rooks.Length; ++rookIndex)
		{
			rooks[rookIndex] = getPawn(string(names[rookIndex]));
			if ((rooks[rookIndex] == None) || ((rookIndex != 0) && rooks[rookIndex] == rooks[rookIndex - 1]))
			{
				signalFailed("Failed to find Pawn named " $ string(names[rookIndex]) $ ".");
				return;
			}
		}

		// get AI controllers
		controllers.Length = rooks.Length;
		for (controllerIndex = 0; controllerIndex < controllers.Length; ++controllerIndex)
		{
			controllers[controllerIndex] = AI_Controller(rooks[controllerIndex].controller);
			if (controllers[controllerIndex] == None)
			{
				signalFailed("Rook without an AI_Controller.");
				return;
			}
		}

		// get start locations
		startLocations.Length = rooks.Length;
		for (controllerIndex = 0; controllerIndex < controllers.Length; ++controllerIndex)
		{
			startLocations[controllerIndex] = rooks[controllerIndex].Location;
		}

		goingTo.Length = rooks.Length;
	}

Begin:

	logTest("Stress Test Started");

	// start move actions
	actions.Length = controllers.Length;
	for (workIndex = 0; workIndex < controllers.Length; ++workIndex)
	{
		assert(controllers[workIndex] != None);
//		log("Starting move for " $ string(rooks[workIndex].name) $ " who has controller " $
//				controllers[workIndex].name $ ".");
		terminalConditions.distanceXY = 1000;
		terminalConditions.distanceZ = 1000;
		actions[workIndex] = class'NS_MoveToLocation'.static.startAction(controllers[workIndex], None,
				destinations[workIndex], None, , , , , terminalConditions).myAddRef();
		goingTo[workIndex] = 1;
	}

	// restart any actions that are finished
	workIndex = 0;
ActionWait:
	for (workIndex = 0; workIndex < controllers.Length; ++workIndex)
	{
		assert(controllers[workIndex] != None);

		if (!actions[workIndex].hasCompleted())
			continue;

		terminalConditions.distanceXY = 1000;
		terminalConditions.distanceZ = 1000;

		if ( actions[workIndex] != None )
		{
			actions[workIndex].Release();
			actions[workIndex] = None;
		}

		if (goingTo[workIndex] == 0)
		{
//			Log("Starting move to destination for " $ string(rooks[workIndex].name) $ " who has controller " $
//					controllers[workIndex].name $ ".");
			actions[workIndex] = class'NS_MoveToLocation'.static.startAction(controllers[workIndex], None,
					destinations[workIndex], None, , , , , terminalConditions).myAddRef();

			goingTo[workIndex] = 1;
		}
		else
		{
//			Log("Starting move to start for " $ string(rooks[workIndex].name) $ " who has controller " $
//					controllers[workIndex].name $ ".");
			actions[workIndex] = class'NS_MoveToLocation'.static.startAction(controllers[workIndex], None,
					startLocations[workIndex], None, , , , , terminalConditions).myAddRef();

			goingTo[workIndex] = 0;
		}
	}

	//if (!actions[workIndex].hasCompleted())
	//{
		Sleep(1.0);
		goto 'ActionWait';
	//}
	//else if ((workIndex + 1) < controllers.Length)
	//{
	//	++workIndex;
	//	goto 'ActionWait';
	//}

	for ( workIndex = 0; workIndex < controllers.Length; ++workIndex )
	{
		if ( actions[workIndex] != None )
		{
			actions[workIndex].Release();
			actions[workIndex] = None;
		}
	}

	//logTest("Stress Test Finished");

	//signalPassed();
}

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