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

Engine.WarpZoneInfo


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
//=============================================================================
// WarpZoneInfo. For making disjoint spaces appear as if they were connected;
// supports both in-level warp zones and cross-level warp zones.
//=============================================================================
class WarpZoneInfo expands ZoneInfo
    intrinsic
    localized;

//-----------------------------------------------------------------------------
// Information set by the level designer.

var() localized string[80] OtherSideURL; // URL of otherside WarpZoneInfo.
var() name       ThisTag;      // Tag of this warp zone.

//-----------------------------------------------------------------------------
// Internal.

var const int              iWarpZone;
var const coords           WarpCoords;
var transient WarpZoneInfo OtherSideActor;
var transient object       OtherSideLevel;
var() string[80]           Destinations[8];
var int                    numDestinations;

//-----------------------------------------------------------------------------
// Network replication.

replication
{
    reliable if( Role==ROLE_Authority )
        OtherSideURL, ThisTag, OtherSideActor;
}

//-----------------------------------------------------------------------------
// Functions.

// Warp coordinate system transformations.
intrinsic(314) final function Warp  ( out vector Loc, out vector Vel, out rotator R );
intrinsic(315) final function UnWarp( out vector Loc, out vector Vel, out rotator R );

function PreBeginPlay()
{
    Super.PreBeginPlay();

    // Generate the local connection.
    Generate();

    // Setup destination list.
    numDestinations = 0;
    While( numDestinations < 8 )
        if (Destinations[numDestinations] != "")
            numDestinations++;
        else
            numDestinations = 8;

    // Generate URL if necessary.
    if( numDestinations>0 && (OtherSideURL == "") )
        OtherSideURL = Destinations[0];
}

function Trigger( actor Other, pawn EventInstigator )
{
    local int nextPick;
    if (numDestinations == 0)
        return;
    
    nextPick = 0;
    While( (nextPick < 8) && (Destinations[nextPick] != OtherSideURL )  )
        nextPick++;

    nextPick++;
    if ( (nextPick > 7) || (Destinations[nextPick] == "") )
        nextPick = 0;
    
    OtherSideURL = Destinations[nextPick];
    ForceGenerate();
}

// Set up this warp zone's destination.
simulated event Generate()
{
    if( OtherSideLevel != None )
        return;
    ForceGenerate();
}

// Set up this warp zone's destination.
simulated event ForceGenerate()
{
    if( InStr(OtherSideURL,"/") >= 0 )
    {
        // Remote level.
        //log( "Warpzone " $ Self $ " remote" );
        OtherSideLevel = None;
        OtherSideActor = None;
    }
    else
    {
        // Local level.
        OtherSideLevel = XLevel;
        foreach AllActors( class 'WarpZoneInfo', OtherSideActor )
            if( string(OtherSideActor.ThisTag)~=OtherSideURL && OtherSideActor!=Self )
                break;
        //log( "Warpzone " $ Self $ " local, connected to " $ OtherSideActor );
    }
}

// When an actor enters this warp zone.
function ActorEntered( actor Other )
{
    local vector L;
    local rotator R;
    local Pawn P;

    Super.ActorEntered( Other );
    if( !Other.bJustTeleported )
    {
        Generate();

        if( OtherSideActor != None )
        {
            // This needs to also perform a coordinate system transformation,
            // in case the portals aren't directionally aligned. This is easy to
            // do but UnrealScript doesn't provide coordinate system operators yet.
            Other.Disable('Touch');
            Other.Disable('UnTouch');

            L = Other.Location;
            R = Other.Rotation;
            UnWarp( L, Other.Velocity, R );
            OtherSideActor.Warp( L, Other.Velocity, R );
            Other.SetLocation(L);
            if( Pawn(Other)!=None )
            {
                //tell enemies about teleport
                P = Level.PawnList;
                While ( P != None )
                {
                    if (P.Enemy == Other)
                        P.LastSeenPos = Other.Location; 
                    P = P.nextPawn;
                }
                //if ( Other.IsA('PlayerPawn') )
                //	PlayerPawn(Other).SetFOVAngle(150);
                R.Roll = 0;
                Pawn(Other).ClientSetRotation( R );
                Pawn(Other).MoveTimer = -1.0;
            }
            else
                Other.SetRotation( R );

            Other.Enable('Touch');
            Other.Enable('UnTouch');
            // Change rotation according to portal's rotational change.
        }
    }
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 12:52:32.000 - Creation time: za 22-4-2006 12:53:47.906 - Created with UnCodeX