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

SideshowScript.Deco_AirShip


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
class Deco_AirShip extends Decoration;

#exec OBJ LOAD FILE=Pier_anim.ukx

var KFEventListener PlayLandEvent;
var KFEventListener PlayTakeOffEvent;

var name ClientAnim;

var() name LandEventName, TakeOffEventName;

struct AnimRepInfo
{
	var name    AnimName;	// The name of the animation to play
	var float	StartTime;	// The in game time that the animation first began playing
};

var AnimRepInfo AnimInfo;

replication
{
	reliable if( Role == ROLE_Authority )
		AnimInfo;
}

simulated function PostBeginPlay()
{
	// Starts the airship in the sky
	PlayAnim( 'Land', 1.0f );
	StopAnimating();
	SetUpListeners();
}

// Create actors to tell us when an event is called
function SetUpListeners()
{
	PlayLandEvent = Spawn( class 'KFEventListener' );
	PlayTakeOffEvent = Spawn( class 'KFEventListener' );

	PlayLandEvent.SetEventListenerInfo( self, LandEventName );
	PlayTakeOffEvent.SetEventListenerInfo( self, TakeOffEventName );
}

// Called when an event listener's tag is called on the server
function ReceivedEvent( name EventName )
{
	local AnimRepInfo TempRepInfo;
	local KFGameType KFGame;

	if ( EventName == LandEventName )
	{
		TempRepInfo.AnimName = 'Land';
	}
	else if ( EventName == TakeOffEventName )
	{
		TempRepInfo.AnimName = 'TakeOff';
	}

   	KFGame = KFGameType(Level.Game);

   	if ( KFGame != none )
   	{
   		// Get the elapsed time that the airship animation began playing
		TempRepInfo.StartTime = float( KFGame.ElapsedTime );
	}

	AnimInfo = TempRepInfo;	// Replicates AnimInfo To the client

	// Play animations if offline
	if ( Level.NetMode != NM_DedicatedServer )
	{
		ClientPlayAnim( AnimInfo.AnimName, 0 );
	}
}

simulated function PostNetReceive()
{
	local float CurrentAnimTime;
	local PlayerController PC;
	local GameReplicationInfo GRI;

   	if ( ClientAnim != AnimInfo.AnimName )
   	{
	   	ClientAnim = AnimInfo.AnimName;

   		PC = Level.GetLocalPlayerController();

   		if ( PC != none )
   		{
   			GRI = PC.GameReplicationInfo;

	   		if ( GRI != none )
	   		{
   		   		// Get the time elapsed upon receiving the newest animation
				//( This is done to play an animation part in synch with everyone else, if a player joins late )
		   		CurrentAnimTime = float( GRI.ElapsedTime ) - AnimInfo.StartTime;
	   		}
   		}

		ClientPlayAnim( AnimInfo.AnimName, CurrentAnimTime );
 	}
}

simulated function ClientPlayAnim( name AnimName, float CurrentAnimTime )
{
	local float CurrentAnimProgress; // Value from 0.0-1.0

	CurrentAnimProgress = CurrentAnimTime / GetAnimDuration( AnimName, 1.0f );

	PlayAnim( AnimName, 1.0f );
	SetAnimFrame( CurrentAnimProgress );
}

defaultproperties
{
     LandEventName="AirshipLandEvent"
     TakeOffEventName="AirshipTakeOffEvent"
     bStatic=False
     bNoDelete=True
     bStasis=False
     bAlwaysRelevant=True
     RemoteRole=ROLE_SimulatedProxy
     NetUpdateFrequency=1.000000
     Mesh=SkeletalMesh'Pier_anim.AirShip_Main'
     bNetNotify=True
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fri 13-10-2023 03:17:28.000 - Creation time: Fri 13-10-2023 03:19:01.231 - Created with UnCodeX