Engine
Class WarpZoneInfo

source: e:\games\UnrealTournament\Engine\Classes\WarpZoneInfo.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.ZoneInfo
            |
            +--Engine.WarpZoneInfo
Direct Known Subclasses:None

class WarpZoneInfo
extends Engine.ZoneInfo

//============================================================================= // WarpZoneInfo. For making disjoint spaces appear as if they were connected; // supports both in-level warp zones and cross-level warp zones. //=============================================================================
Variables
 string Destinations[8]
 WarpZoneInfo OtherSideActor
 Object OtherSideLevel
 string OtherSideURL
 name ThisTag
 coords WarpCoords
 bool bNoTeleFrag
 int iWarpZone
 int numDestinations

States
DelayedWarp

Function Summary
 
simulated
ActorEntered(Actor Other)
     
// When an actor enters this warp zone.
 void PreBeginPlay()
 void Trigger(Actor Other, Pawn EventInstigator)
 void UnWarp(out vector, out vector, out rotator)
 void Warp(out vector, out vector, out rotator)
     
// Warp coordinate system transformations.


State DelayedWarp Function Summary
 void Tick(float DeltaTime)



Source Code


00001	//=============================================================================
00002	// WarpZoneInfo. For making disjoint spaces appear as if they were connected;
00003	// supports both in-level warp zones and cross-level warp zones.
00004	//=============================================================================
00005	class WarpZoneInfo extends ZoneInfo
00006		native;
00007	
00008	//-----------------------------------------------------------------------------
00009	// Information set by the level designer.
00010	
00011	var() string     OtherSideURL;
00012	var() name       ThisTag;
00013	var() bool		 bNoTeleFrag;
00014	
00015	//-----------------------------------------------------------------------------
00016	// Internal.
00017	
00018	var const int              iWarpZone;
00019	var const coords           WarpCoords;
00020	var transient WarpZoneInfo OtherSideActor;
00021	var transient object       OtherSideLevel;
00022	var() string		       Destinations[8];
00023	var int					   numDestinations;
00024	
00025	//-----------------------------------------------------------------------------
00026	// Network replication.
00027	
00028	replication
00029	{
00030		reliable if( Role==ROLE_Authority )
00031			OtherSideURL, ThisTag, OtherSideActor;
00032	}
00033	
00034	//-----------------------------------------------------------------------------
00035	// Functions.
00036	
00037	// Warp coordinate system transformations.
00038	native(314) final function Warp  ( out vector Loc, out vector Vel, out rotator R );
00039	native(315) final function UnWarp( out vector Loc, out vector Vel, out rotator R );
00040	
00041	function PreBeginPlay()
00042	{
00043		Super.PreBeginPlay();
00044	
00045		// Generate the local connection.
00046		Generate();
00047	
00048		// Setup destination list.
00049		numDestinations = 0;
00050		While( numDestinations < 8 )
00051			if (Destinations[numDestinations] != "")
00052				numDestinations++;
00053			else
00054				numDestinations = 8;
00055	
00056		// Generate URL if necessary.
00057		if( numDestinations>0 && (OtherSideURL == "") )
00058			OtherSideURL = Destinations[0];
00059	}
00060	
00061	function Trigger( actor Other, pawn EventInstigator )
00062	{
00063		local int nextPick;
00064		if (numDestinations == 0)
00065			return;
00066		
00067		nextPick = 0;
00068		While( (nextPick < 8) && (Destinations[nextPick] != OtherSideURL )  )
00069			nextPick++;
00070	
00071		nextPick++;
00072		if ( (nextPick > 7) || (Destinations[nextPick] == "") )
00073			nextPick = 0;
00074		
00075		OtherSideURL = Destinations[nextPick];
00076		ForceGenerate();
00077	}
00078	
00079	// Set up this warp zone's destination.
00080	simulated event Generate()
00081	{
00082		if( OtherSideLevel != None )
00083			return;
00084		ForceGenerate();
00085	}
00086	
00087	// Set up this warp zone's destination.
00088	simulated event ForceGenerate()
00089	{
00090		if( InStr(OtherSideURL,"/") >= 0 )
00091		{
00092			// Remote level.
00093			//log( "Warpzone " $ Self $ " remote" );
00094			OtherSideLevel = None;
00095			OtherSideActor = None;
00096		}
00097		else
00098		{
00099			// Local level.
00100			OtherSideLevel = XLevel;
00101			foreach AllActors( class 'WarpZoneInfo', OtherSideActor )
00102				if( string(OtherSideActor.ThisTag)~=OtherSideURL && OtherSideActor!=Self )
00103					break;
00104			//log( "Warpzone " $ Self $ " local, connected to " $ OtherSideActor );
00105		}
00106	}
00107	
00108	// When an actor enters this warp zone.
00109	simulated function ActorEntered( actor Other )
00110	{
00111		local vector L;
00112		local rotator R;
00113		local Pawn P;
00114	
00115		//if ( Other.Role == ROLE_AutonomousProxy )
00116		//	return; // don't simulate for client players
00117		Super.ActorEntered( Other );
00118		if( !Other.bJustTeleported )
00119		{
00120			Generate();
00121			if( OtherSideActor != None )
00122			{
00123				// This needs to also perform a coordinate system transformation,
00124				// in case the portals aren't directionally aligned. This is easy to
00125				// do but UnrealScript doesn't provide coordinate system operators yet.
00126				Other.Disable('Touch');
00127				Other.Disable('UnTouch');
00128	
00129				L = Other.Location;
00130				if( Other.IsA('PlayerPawn') )
00131					R = PlayerPawn(Other).ViewRotation;
00132				else
00133					R = Other.Rotation;
00134	
00135				UnWarp( L, Other.Velocity, R );
00136				OtherSideActor.Warp( L, Other.Velocity, R );
00137	
00138				if( Other.IsA('Pawn') )
00139				{
00140					Pawn(Other).bWarping = bNoTelefrag;
00141					if ( Other.SetLocation(L) )
00142					{
00143						//tell enemies about teleport
00144						if ( Role == ROLE_Authority )
00145						{
00146							P = Level.PawnList;
00147							While ( P != None )
00148							{
00149								if (P.Enemy == Other)
00150									P.LastSeenPos = Other.Location; 
00151								P = P.nextPawn;
00152							}
00153						}
00154						R.Roll = 0;
00155						Pawn(Other).ViewRotation = R;
00156						Pawn(Other).ClientSetLocation(L, R );
00157						Pawn(Other).MoveTimer = -1.0;
00158					}
00159					else
00160					{
00161						// set up to keep trying to teleport
00162						GotoState('DelayedWarp');
00163					}
00164				}
00165				else
00166				{
00167					Other.SetLocation(L);
00168					Other.SetRotation( R );
00169				}
00170				Other.Enable('Touch');
00171				Other.Enable('UnTouch');
00172				// Change rotation according to portal's rotational change.
00173			}
00174		}
00175	}
00176	
00177	event ActorLeaving( actor Other )
00178	{
00179		Super.ActorLeaving(Other);
00180		If ( Other.IsA('Pawn') )
00181			Pawn(Other).bWarping = false;
00182	}
00183	
00184	State DelayedWarp
00185	{
00186		function Tick(float DeltaTime)
00187		{
00188			local Pawn P;
00189			local bool bFound;
00190	
00191			For ( P=Level.PawnList; P!=None; P=P.NextPawn )
00192				if ( P.bWarping && (P.Region.Zone == Self) )
00193				{
00194					bFound = true;
00195					ActorEntered(P);
00196				}
00197	
00198			If ( !bFound )
00199				GotoState('');
00200		}
00201	}
00202	
00203	defaultproperties
00204	{
00205	     MaxCarcasses=0
00206	}

End Source Code