Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
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 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 00241 00242 00243 00244 00245 00246 00247 00248 00249 00250 00251 00252 00253 00254 00255 00256 00257 00258 00259 00260 00261 00262 00263 00264 00265 00266 00267 00268 00269 00270 00271 00272 00273 00274 00275 00276 00277 00278 00279 00280 00281 00282 00283 00284 00285 00286 00287 00288 00289 00290 00291 00292 00293 00294 00295 00296 00297 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312 00313 00314 00315 00316 00317 00318 00319 00320 00321 00322 00323 00324 00325 00326 00327 00328 00329 00330 00331 00332 00333 00334 00335 00336 00337 00338 00339 00340 00341 00342 |
/** * Copyright 1998-2008 Epic Games, Inc. All Rights Reserved. */ class KActor extends DynamicSMActor native(Physics) nativereplication placeable showcategories(Navigation); // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) // (cpptext) var() bool bDamageAppliesImpulse; var() repnotify bool bWakeOnLevelStart; // Impact effects var ParticleSystemComponent ImpactEffectComponent; var AudioComponent ImpactSoundComponent; var AudioComponent ImpactSoundComponent2; // @TODO: This could be turned into a dynamic array; but for the moment just 2 will do. var float LastImpactTime; // Slide effects var ParticleSystemComponent SlideEffectComponent; var AudioComponent SlideSoundComponent; var bool bCurrentSlide; var bool bSlideActive; var float LastSlideTime; var native const RigidBodyState RBState; var native const float AngErrorAccumulator; /** replicated components of DrawScale3D */ var repnotify float DrawScaleX, DrawScaleY, DrawScaleZ; var vector InitialLocation; var rotator InitialRotation; replication { if ( Role == ROLE_Authority ) RBState; if (bNetInitial && Role == ROLE_Authority) bWakeOnLevelStart, DrawScaleX, DrawScaleY, DrawScaleZ; } /** Util for getting the PhysicalMaterial applied to this KActor's StaticMesh. */ native final function PhysicalMaterial GetKActorPhysMaterial(); /** Forces the resolve the RBState regardless of wether the actor is sleeping */ native final function ResolveRBState(); simulated event PostBeginPlay() { Super.PostBeginPlay(); if (bWakeOnLevelStart) { StaticMeshComponent.WakeRigidBody(); } DrawScaleX = DrawScale3D.X; DrawScaleY = DrawScale3D.Y; DrawScaleZ = DrawScale3D.Z; // Initialise impact/slide components (if we are being notified of physics events, and have sounds/effects set up // in PhysicalMaterial applied to our static mesh. if(StaticMeshComponent.bNotifyRigidBodyCollision) { SetPhysicalCollisionProperties(); } InitialLocation = Location; InitialRotation = Rotation; } /** called when the actor falls out of the world 'safely' (below KillZ and such) */ simulated event FellOutOfWorld(class<DamageType> dmgType) { ShutDown(); Super.FellOutOfWorld(dmgType); } simulated function SetPhysicalCollisionProperties() { local PhysicalMaterial PhysMat; PhysMat = GetKActorPhysMaterial(); if(PhysMat.ImpactEffect != None) { ImpactEffectComponent = new(Outer) class'ParticleSystemComponent'; AttachComponent(ImpactEffectComponent); ImpactEffectComponent.bAutoActivate = FALSE; ImpactEffectComponent.SetTemplate(PhysMat.ImpactEffect); } if(PhysMat.ImpactSound != None) { ImpactSoundComponent = new(Outer) class'AudioComponent'; ImpactSoundComponent.bAutoDestroy = TRUE; AttachComponent(ImpactSoundComponent); ImpactSoundComponent.SoundCue = PhysMat.ImpactSound; ImpactSoundComponent2 = new(Outer) class'AudioComponent'; ImpactSoundComponent2.bAutoDestroy = TRUE; AttachComponent(ImpactSoundComponent2); ImpactSoundComponent2.SoundCue = PhysMat.ImpactSound; } if(PhysMat.SlideEffect != None) { SlideEffectComponent = new(Outer) class'ParticleSystemComponent'; AttachComponent(SlideEffectComponent); SlideEffectComponent.bAutoActivate = FALSE; SlideEffectComponent.SetTemplate(PhysMat.SlideEffect); } if(PhysMat.SlideSound != None) { SlideSoundComponent = new(Outer) class'AudioComponent'; SlideSoundComponent.bAutoDestroy = TRUE; AttachComponent(SlideSoundComponent); SlideSoundComponent.SoundCue = PhysMat.SlideSound; } } simulated event ReplicatedEvent(name VarName) { local vector NewDrawScale3D; if (VarName == 'bWakeOnLevelStart') { if (bWakeOnLevelStart) { StaticMeshComponent.WakeRigidBody(); } } else if (VarName == 'DrawScaleX' || VarName == 'DrawScaleY' || VarName == 'DrawScaleZ') { NewDrawScale3D.X = DrawScaleX; NewDrawScale3D.Y = DrawScaleY; NewDrawScale3D.Z = DrawScaleZ; SetDrawScale3D(NewDrawScale3D); } else { Super.ReplicatedEvent(VarName); } } function ApplyImpulse( Vector ImpulseDir, float ImpulseMag, Vector HitLocation, optional TraceHitInfo HitInfo ) { local vector ApplyImpulse; ImpulseDir = Normal(ImpulseDir); ApplyImpulse = ImpulseDir * ImpulseMag; if( HitInfo.HitComponent != None ) { HitInfo.HitComponent.AddImpulse( ApplyImpulse, HitLocation, HitInfo.BoneName ); } else { // if no HitComponent is passed, default to our CollisionComponent CollisionComponent.AddImpulse( ApplyImpulse, HitLocation ); } } /** * Default behaviour when shot is to apply an impulse and kick the KActor. */ event TakeDamage(int Damage, Controller EventInstigator, vector HitLocation, vector Momentum, class<DamageType> DamageType, optional TraceHitInfo HitInfo, optional Actor DamageCauser) { local vector ApplyImpulse; // call Actor's version to handle any SeqEvent_TakeDamage for scripting Super.TakeDamage(Damage, EventInstigator, HitLocation, Momentum, DamageType, HitInfo, DamageCauser); if ( bDamageAppliesImpulse && damageType.default.KDamageImpulse > 0 ) { if ( VSize(momentum) < 0.001 ) { LogInternal("Zero momentum to KActor.TakeDamage"); return; } ApplyImpulse = Normal(momentum) * damageType.default.KDamageImpulse; if ( HitInfo.HitComponent != None ) { HitInfo.HitComponent.AddImpulse(ApplyImpulse, HitLocation, HitInfo.BoneName); } else { // if no HitComponent is passed, default to our CollisionComponent CollisionComponent.AddImpulse(ApplyImpulse, HitLocation); } } } /** * Respond to radial damage as well. */ simulated function TakeRadiusDamage ( Controller InstigatedBy, float BaseDamage, float DamageRadius, class<DamageType> DamageType, float Momentum, vector HurtOrigin, bool bFullDamage, Actor DamageCauser ) { local int Idx; local SeqEvent_TakeDamage DmgEvt; // search for any damage events for (Idx = 0; Idx < GeneratedEvents.Length; Idx++) { DmgEvt = SeqEvent_TakeDamage(GeneratedEvents[Idx]); if (DmgEvt != None) { // notify the event of the damage received DmgEvt.HandleDamage(self, InstigatedBy, DamageType, BaseDamage); } } if ( bDamageAppliesImpulse && damageType.default.RadialDamageImpulse > 0 && (Role == ROLE_Authority) ) { CollisionComponent.AddRadialImpulse(HurtOrigin, DamageRadius, damageType.default.RadialDamageImpulse, RIF_Linear, damageType.default.bRadialDamageVelChange); } } /** If this KActor receives a Toggle ON event from Kismet, wake the physics up. */ simulated function OnToggle(SeqAct_Toggle action) { if(action.InputLinks[0].bHasImpulse) { StaticMeshComponent.WakeRigidBody(); } } /** * Called upon receiving a SeqAct_Teleport action. Grabs * the first destination available and attempts to teleport * this actor. * * @param inAction - teleport action that was activated */ simulated function OnTeleport(SeqAct_Teleport inAction) { local array<Object> objVars; local int idx; local Actor destActor; // find the first supplied actor inAction.GetObjectVars(objVars,"Destination"); for (idx = 0; idx < objVars.Length && destActor == None; idx++) { destActor = Actor(objVars[idx]); } // and set to that actor's location if (destActor != None) { StaticMeshComponent.SetRBPosition(destActor.Location); StaticMeshComponent.SetRBRotation(destActor.Rotation); PlayTeleportEffect(false, true); } } simulated function Reset() { StaticMeshComponent.SetRBLinearVelocity( Vect(0,0,0) ); StaticMeshComponent.SetRBAngularVelocity( Vect(0,0,0) ); StaticMeshComponent.SetRBPosition( InitialLocation ); StaticMeshComponent.SetRBRotation( InitialRotation ); if (!bWakeOnLevelStart) { StaticMeshComponent.PutRigidBodyToSleep(); } else { StaticMeshComponent.WakeRigidBody(); } // Resolve the RBState and get all of the needed flags set ResolveRBState(); // Force replication bForceNetUpdate = TRUE; super.Reset(); } defaultproperties { bDamageAppliesImpulse=True Begin Object Class=StaticMeshComponent Name=StaticMeshComponent0 ObjName=StaticMeshComponent0 Archetype=StaticMeshComponent'Engine.Default__DynamicSMActor:StaticMeshComponent0' WireframeColor=(B=128,G=255,R=0,A=255) BlockRigidBody=True RBChannel=RBCC_GameplayPhysics RBCollideWithChannels=(Default=True,GameplayPhysics=True,EffectPhysics=True) ObjectArchetype=StaticMeshComponent'Engine.Default__DynamicSMActor:StaticMeshComponent0' End Object StaticMeshComponent=StaticMeshComponent0 Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment ObjName=MyLightEnvironment Archetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicSMActor:MyLightEnvironment' ObjectArchetype=DynamicLightEnvironmentComponent'Engine.Default__DynamicSMActor:MyLightEnvironment' End Object LightEnvironment=MyLightEnvironment bPawnCanBaseOn=False bSafeBaseIfAsleep=True Components(0)=MyLightEnvironment Components(1)=StaticMeshComponent0 Physics=PHYS_RigidBody TickGroup=TG_PostAsyncWork bNoDelete=True bAlwaysRelevant=True bUpdateSimulatedPosition=True bNetInitialRotation=True bBlocksNavigation=True bCollideActors=True bBlockActors=True bProjTarget=True bBlocksTeleport=True bNoEncroachCheck=True CollisionComponent=StaticMeshComponent0 CollisionType=COLLIDE_CustomDefault SupportedEvents(3)=Class'Engine.SeqEvent_RigidBodyCollision' Name="Default__KActor" ObjectArchetype=DynamicSMActor'Engine.Default__DynamicSMActor' } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |