## Engine
Class SMActorRotating

source: C:\XIII\Engine\Classes\SMActorRotating.uc

    Core.Object
       |
       +--Engine.Actor
          |
          +--Engine.SMActorRotating

Direct Known Subclasses:None

class SMActorRotating
extends Engine.Actor

    //=============================================================================
    // SMActorRotating.
    //=============================================================================

Variables
`float` | `TimeStamp,TimeStart`
`bool` | `bOpen,bOpening,bClosing`
`vector` | `vSpeed`

States
Closing, Opening, Open, Closed

Function Summary
`vector` | `vLerp(float Alpha, vector vA, vector vB)`

State Closing Function Summary

State Opening Function Summary

State Open Function Summary

State Closed Function Summary

Source Code

    00001	//=============================================================================
    00002	// SMActorRotating.
    00003	//=============================================================================
    00004
    00005	class SMActorRotating extends Actor
    00006		placeable;
    00007	VAR(Rotating) bool bInitiallyOn;
    00008	VAR(Rotating) StaticMesh smRotatingMesh;
    00009	VAR(Rotating) StaticMesh smStaticMesh;
    00010
    00011	VAR(Scaling) bool bInitiallyOpen;
    00012	VAR(Scaling) float OpeningDelay;
    00013	VAR(Scaling) float ClosingDelay;
    00014	VAR(Scaling) float OpeningTime;
    00015	VAR(Scaling) vector OpenScale3D;
    00016	VAR(Scaling) vector ClosedScale3D;
    00017	VAR TRANSIENT float TimeStamp,TimeStart;
    00018	VAR bool bOpen,bOpening,bClosing;
    00019	VAR TRANSIENT vector vSpeed;
    00020
    00021	Function vector vLerp(float Alpha,vector vA, vector vB)
    00022	{
    00023		return Alpha*vA+(1-Alpha)*vB;
    00024	}
    00025
    00026	State() ScalingTriggerToggle
    00027	{
    00028		EVENT BeginState()
    00029		{
    00030			bOpen=bInitiallyOpen;
    00031			SetPhysics(PHYS_None);
    00032			if (bOpen)
    00033				GotoState('Open');
    00034			else
    00035				GotoState('Closed');
    00036
    00037			TimeStamp=0.0;
    00038		}
    00039	}
    00040
    00041	State Closed
    00042	{
    00043		EVENT BeginState()
    00044		{
    00045			SetDrawScale3D(ClosedScale3D);
    00046			DebugLog(name@"enter Closed state");
    00047		}
    00048
    00049		EVENT Trigger(actor Other,pawn EventInstigator)
    00050		{
    00051			TimeStart=TimeStamp+OpeningDelay;
    00052			GotoState('Opening');
    00053		}
    00054
    00055	}
    00056
    00057	State Open
    00058	{
    00059		EVENT BeginState()
    00060		{
    00061			SetDrawScale3D(OpenScale3D);
    00062			DebugLog(name@"Open");
    00063		}
    00064
    00065		EVENT Trigger(actor Other,pawn EventInstigator)
    00066		{
    00067			TimeStart=TimeStamp+ClosingDelay;
    00068			GotoState('Closing');
    00069		}
    00070	}
    00071
    00072	State Opening
    00073	{
    00074		EVENT BeginState()
    00075		{
    00076			DebugLog(name@"Opening");
    00077			enable('Tick');
    00078		}
    00079
    00080		EVENT EndState()
    00081		{
    00082			disable('Tick');
    00083		}
    00084
    00085		EVENT Tick(float dt)
    00086		{
    00087			LOCAL float relativetime;
    00088			TimeStamp+=dt;
    00089			relativetime=(TimeStamp-TimeStart)/OpeningTime;
    00090			if (relativetime<0)
    00091				return;
    00092			if (relativetime<1)
    00093			{
    00094				SetDrawScale3D(vLerp(relativetime,OpenScale3D,ClosedScale3D));
    00095			}
    00096			else
    00097			{
    00098				SetDrawScale3D(OpenScale3D);
    00099				bOpen=true;
    00100				GotoState('Open');
    00101			}
    00102
    00103		}
    00104		EVENT Trigger(actor Other,pawn EventInstigator)
    00105		{
    00106	//		TimeStart=2*TimeStamp-OpeningTime+TimeStamp;
    00107	//		TimeStart=TimeStamp+ClosingDelay;
    00108			TimeStart = 2 * TimeStamp - OpeningTime - TimeStart;
    00109
    00110			GotoState('Closing');
    00111		}
    00112
    00113	}
    00114
    00115	State Closing
    00116	{
    00117		EVENT BeginState()
    00118		{
    00119			DebugLog(name@"Closing");
    00120			enable('Tick');
    00121		}
    00122
    00123		EVENT EndState()
    00124		{
    00125			disable('Tick');
    00126		}
    00127
    00128		EVENT Tick(float dt)
    00129		{
    00130			LOCAL float relativetime;
    00131			TimeStamp+=dt;
    00132			relativetime=(TimeStamp-TimeStart)/OpeningTime;
    00133			if (relativetime<0)
    00134				return;
    00135			if (relativetime<1)
    00136			{
    00137				SetDrawScale3D(vLerp(relativetime,ClosedScale3D,OpenScale3D));
    00138			}
    00139			else
    00140			{
    00141				SetDrawScale3D(ClosedScale3D);
    00142				bOpen=false;
    00143				GotoState('Closed');
    00144			}
    00145		}
    00146		EVENT Trigger(actor Other,pawn EventInstigator)
    00147		{
    00148			TimeStart = 2 * TimeStamp - OpeningTime - TimeStart;
    00149
    00150			GotoState('Opening');
    00151		}
    00152	}
    00153
    00154	State() TriggerToggle
    00155	{
    00156		EVENT BeginState()
    00157		{
    00158
    00159			if (bInitiallyOn)
    00160			{
    00161				if (smRotatingMesh!=none)
    00162					StaticMesh=smRotatingMesh;
    00163				SetPhysics(PHYS_Rotating);
    00164			}
    00165			else
    00166			{
    00167				if (smStaticMesh!=none)
    00168					StaticMesh=smStaticMesh;
    00169				SetPhysics(PHYS_None);
    00170			}
    00171		}
    00172
    00173		EVENT Trigger(actor Other,pawn EventInstigator)
    00174		{
    00175			if (Physics==PHYS_None)
    00176			{
    00177				if (smRotatingMesh!=none)
    00178					StaticMesh=smRotatingMesh;
    00179				SetPhysics(PHYS_Rotating);
    00180			}
    00181			else
    00182			{
    00183				if (smStaticMesh!=none)
    00184					StaticMesh=smStaticMesh;
    00185				SetPhysics(PHYS_None);
    00186			}
    00187		}
    00188	}
    00189
    00190	State() TriggerControl
    00191	{
    00192		EVENT BeginState()
    00193		{
    00194			if (bInitiallyOn)
    00195			{
    00196				if (smRotatingMesh!=none)
    00197					StaticMesh=smRotatingMesh;
    00198				SetPhysics(PHYS_Rotating);
    00199			}
    00200			else
    00201			{
    00202				if (smStaticMesh!=none)
    00203					StaticMesh=smStaticMesh;
    00204				SetPhysics(PHYS_None);
    00205			}
    00206		}
    00207
    00208		EVENT Trigger(actor Other,pawn EventInstigator)
    00209		{
    00210			if (smRotatingMesh!=none)
    00211				StaticMesh=smRotatingMesh;
    00212			SetPhysics(PHYS_Rotating);
    00213		}
    00214
    00215		EVENT Untrigger(actor Other,pawn EventInstigator)
    00216		{
    00217			if (smStaticMesh!=none)
    00218				StaticMesh=smStaticMesh;
    00219			SetPhysics(PHYS_None);
    00220		}
    00221	}
    00222
    00223	defaultproperties
    00224	{
    00225	     OpeningDelay=3.500000
    00226	     ClosingDelay=1.500000
    00227	     OpeningTime=16.000000
    00228	     OpenScale3D=(X=1.000000,Y=1.000000,Z=1.000000)
    00229	     ClosedScale3D=(Z=1.000000)
    00230	     bWorldGeometry=True
    00231	     bShadowCast=True
    00232	     bIgnoreDynLight=False
    00233	     bBlockActors=True
    00234	     bBlockPlayers=True
    00235
bFixedRotationDir=True 00236 Physics=PHYS_Rotating 00237 DrawType=DT_StaticMesh 00238 CollisionRadius=1.000000 00239 CollisionHeight=1.000000 00240 RotationRate=(Pitch=5000) 00241 bEdShouldSnap=True 00242 }

End Source Code