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

DeusEx.Shadow


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
//=============================================================================
// Shadow.
//=============================================================================
class Shadow extends Decal;

var vector lastLocation;
var bool   bHasDecal;

// the issue here is that we dont want to detach/attach the decal every frame
// given that often we are off screen and/or irrelevant
// however, the fact that we have 2 objects makes it all somewhat ugly
// i.e. we need to update the shadow whenever it should move
// now, if the owner moves, we have to move the shadow itself

function Tick(float deltaTime)
{
    local vector EndTrace, HitLocation, HitNormal;
    local Actor hit;
    local float dist;
    local ScriptedPawn pawnOwner;
    local bool recentlyDrewShadow, recentlyDrewOwner;
    local bool doDraw;
    
    Super.Tick(deltaTime);

    if (Owner == None)
    {
        Destroy();
        return;
    }

    // don't update if our owner is in stasis or isn't moving
    if (Owner.InStasis() || (VSize(Owner.Location - lastLocation) < 0.1))
        if (bHasDecal)   // we are doing nothing, we have a decal, we are fine
            return;

    // in our dream world, these two would be "last frame" not "recently"
    recentlyDrewShadow = (lastRendered()<1.0);
    recentlyDrewOwner  = (Owner.lastRendered()<1.0);
    doDraw             = recentlyDrewShadow || recentlyDrewOwner;

    if (bHasDecal)
    {
        DetachDecal();
        bHasDecal=False;
    }

    // temp until this works better
    if (Owner.IsA('DeusExPlayer'))
        doDraw = True;

    if (!doDraw)
        return;

    // save our location to check next frame - only if we move the shadow, however
    lastLocation = Owner.Location;

    // trace down about 30 feet
    EndTrace = Owner.Location - vect(0,0,480);
    hit = Trace(HitLocation, HitNormal, EndTrace, Owner.Location, True);

    if (hit != None)
    {
        dist = VSize(HitLocation - Owner.Location);
        DrawScale = (Owner.CollisionRadius / 15.0) - ((dist - Owner.CollisionHeight) / 130.0);
    
        pawnOwner = ScriptedPawn(Owner);
        if (pawnOwner != None)
            DrawScale *= pawnOwner.ShadowScale;

        if (DrawScale < 0)
            DrawScale = 0;
        SetLocation(HitLocation);
        SetRotation(Rotator(HitNormal));
    
        AttachDecal(32,vect(0.1,0.1,0));
        bHasDecal=True;
    }
}

defaultproperties
{
     bHasDecal=True
     Texture=Texture'DeusExItems.Skins.FlatFXTex40'
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mon 8/11/2021 16:22:52.000 - Creation time: Mon 8/11/2021 16:31:32.470 - Created with UnCodeX