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

Engine.SavedMove


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
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
//=============================================================================
// SavedMove is used during network play to buffer recent client moves,
// for use when the server modifies the clients actual position, etc.
// Copyright 1998-2008 Epic Games, Inc. All Rights Reserved.
//=============================================================================
class SavedMove extends Object
	native;

// also stores info in Acceleration attribute
var SavedMove NextMove;		// Next move in linked list.
var float TimeStamp;		// Time of this move.
var float Delta;			// amount of time for this move
var bool	bRun;
var bool	bDuck;
var bool	bPressedJump;
var bool	bDoubleJump;
var bool	bPreciseDestination;
var bool	bForceRMVelocity;			// client-side only (for replaying moves) - not replicated
var EDoubleClickDir DoubleClickMove;	// Double click info.
var EPhysics SavedPhysics;
var vector StartLocation, StartRelativeLocation, StartVelocity, StartFloor, SavedLocation, SavedVelocity, SavedRelativeLocation, RMVelocity, Acceleration;
var rotator Rotation;
var Actor StartBase, EndBase;
var float CustomTimeDilation;
var float AccelDotThreshold;	// threshold for deciding this is an "important" move based on DP with last acked acceleration

function Clear()
{
	TimeStamp = 0;
	Delta = 0;
	DoubleClickMove = DCLICK_None;
	Acceleration = vect(0,0,0);
	StartVelocity = vect(0,0,0);
	bRun = false;
	bDuck = false;
	bPressedJump = false;
	bDoubleJump = false;
	bPreciseDestination = false;
	bForceRMVelocity = false;
	CustomTimeDilation = 1.0;
}

function PostUpdate(PlayerController P)
{
	bDoubleJump = P.bDoubleJump || bDoubleJump;
	if ( P.Pawn != None )
	{
		RMVelocity = P.Pawn.RMVelocity;
		SavedLocation = P.Pawn.Location;
		SavedVelocity = P.Pawn.Velocity;
		EndBase = P.Pawn.Base;
		if ( (EndBase != None) && !EndBase.bWorldGeometry )
			SavedRelativeLocation = P.Pawn.Location - EndBase.Location;
	}
	Rotation = P.Rotation;
}

function bool IsImportantMove(vector CompareAccel)
{
	local vector AccelNorm;

	// check if any important movement flags set
	if ( bPressedJump || bDoubleJump
		|| ((DoubleClickMove != DCLICK_None) && (DoubleClickMove != DCLICK_Active) && (DoubleClickMove != DCLICK_Done)) )
		return true;

	// check if acceleration has changed significantly
	AccelNorm = Normal(Acceleration);
	return ( (CompareAccel != AccelNorm) && ((CompareAccel Dot AccelNorm) < AccelDotThreshold) );
}

function vector GetStartLocation()
{
	if( (StartBase != None) && !StartBase.bWorldGeometry )
	{
		return StartBase.Location + StartRelativeLocation;
	}

	return StartLocation;
}

function SetInitialPosition(Pawn P)
{
	SavedPhysics = P.Physics;
	StartLocation = P.Location;
	StartVelocity = P.Velocity;
	StartBase = P.Base;
	StartFloor = P.Floor;
	CustomTimeDilation = P.CustomTimeDilation;
	
	if( (StartBase != None) && !StartBase.bWorldGeometry )
	{
		StartRelativeLocation = P.Location - StartBase.Location;
	}
}

function bool CanCombineWith(SavedMove NewMove, Pawn InPawn, float MaxDelta)
{
	if( InPawn == None )
	{
		return FALSE;
	}

	if ( NewMove.Acceleration == vect(0,0,0) )
	{
		return ( (Acceleration == vect(0,0,0))
			&& (StartVelocity == vect(0,0,0))
			&& (NewMove.StartVelocity == vect(0,0,0))
			&& (SavedPhysics == InPawn.Physics)
			&& !bPressedJump && !NewMove.bPressedJump
			&& (bRun == NewMove.bRun)
			&& (bDuck == NewMove.bDuck)
			&& (bPreciseDestination == NewMove.bPreciseDestination)
			&& (bDoubleJump == NewMove.bDoubleJump)
			&& ((DoubleClickMove == DCLICK_None) || (DoubleClickMove == DCLICK_Active))
			&& (NewMove.DoubleClickMove == DoubleClickMove)
			&& !bForceRMVelocity && !NewMove.bForceRMVelocity)
			&& (CustomTimeDilation == NewMove.CustomTimeDilation);
	}
	else
	{
		return ( (InPawn != None)
			&& (NewMove.Delta + Delta < MaxDelta)
			&& (SavedPhysics == InPawn.Physics)
			&& !bPressedJump && !NewMove.bPressedJump
			&& (bRun == NewMove.bRun)
			&& (bDuck == NewMove.bDuck)
			&& (bDoubleJump == NewMove.bDoubleJump)
			&& (bPreciseDestination == NewMove.bPreciseDestination)
			&& ((DoubleClickMove == DCLICK_None) || (DoubleClickMove == DCLICK_Active))
			&& (NewMove.DoubleClickMove == DoubleClickMove)
			&& ((Normal(Acceleration) Dot Normal(NewMove.Acceleration)) > 0.99)
			&& !bForceRMVelocity && !NewMove.bForceRMVelocity)
			&& (CustomTimeDilation == NewMove.CustomTimeDilation);
	}
}

function SetMoveFor(PlayerController P, float DeltaTime, vector NewAccel, EDoubleClickDir InDoubleClick)
{
	Delta = DeltaTime;

	// NOTE: max replicated vector component magnitude is 2^18, and acceleration is multiplied by 10 before replication
	// quick check to make sure we never cross this limit of 2^18/10
	if ( VSize(NewAccel) > 26214 )
		NewAccel = 26214 * Normal(NewAccel);
	if ( P.Pawn != None )
	{
		SetInitialPosition(P.Pawn);
	}
	Acceleration = NewAccel;
	DoubleClickMove = InDoubleClick;
	bRun = (P.bRun > 0);
	bDuck = (P.bDuck > 0);
	bPressedJump = P.bPressedJump;
	bDoubleJump = P.bDoubleJump;
	bPreciseDestination = P.bPreciseDestination;
	bForceRMVelocity = P.bPreciseDestination ||
						(P.Pawn != None) && (P.Pawn.Mesh != None) && ((P.Pawn.Mesh.RootMotionMode == RMM_Accel) || (P.Pawn.Mesh.RootMotionMode == RMM_Velocity));
	TimeStamp = P.WorldInfo.TimeSeconds;
}

/* CompressedFlags()
returns a byte containing encoded special movement information (jumping, crouching, etc.)
SetFlags() and UnCompressFlags() should be overridden to allow game specific special movement information
*/
function byte CompressedFlags()
{
	local byte Result;

	Result = DoubleClickMove;

	if ( bRun )
		Result += 8;
	if ( bDuck )
		Result += 16;
	if ( bPressedJump )
		Result += 32;
	if ( bDoubleJump )
		Result += 64;
	if ( bPreciseDestination )
		Result += 128;

	return Result;
}

/* SetFlags()
Set the movement parameters for PC based on the passed in Flags
*/
static function EDoubleClickDir SetFlags(byte Flags, PlayerController PC)
{
		if ( (Flags & 8) != 0 )
			PC.bRun = 1;
		else
			PC.bRun = 0;
		if ( (Flags & 16) != 0 )
			PC.bDuck = 1;
		else
			PC.bDuck = 0;

		PC.bPreciseDestination = ( (Flags & 128) != 0 );
		PC.bDoubleJump = ( (Flags & 64) != 0 );
		PC.bPressedJump = ( (Flags & 32) != 0 );
		switch (Flags & 7)
		{
			case 0:
				return DCLICK_None;
				break;
			case 1:
				return DCLICK_Left;
				break;
			case 2:
				return DCLICK_Right;
				break;
			case 3:
				return DCLICK_Forward;
				break;
			case 4:
				return DCLICK_Back;
				break;
		}
		return DCLICK_None;
}

defaultproperties
{
   AccelDotThreshold=0.900000
   Name="Default__SavedMove"
   ObjectArchetype=Object'Core.Default__Object'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: tr 31-1-2018 17:17:56.000 - Creation time: sk 18-3-2018 10:01:12.340 - Created with UnCodeX