5 class SCR_RotorDamageManagerComponent : SCR_DamageManagerComponent
34 [
Attribute(
"{4AAF69CCD1AEA70E}Particles/Vehicle/Helicopter/Rotor Collision Effects/Helicopter_Rotor_Collision_Main_Solid.ptc")]
54 protected void DamageOther(notnull IEntity other,
float damage)
56 ChimeraCharacter character = ChimeraCharacter.Cast(other);
57 SCR_DamageManagerComponent characterDamageManager;
59 characterDamageManager = character.GetDamageManager();
61 if (!characterDamageManager || characterDamageManager.IsDestroyed())
66 Physics otherPhysics = other.GetPhysics();
67 array<HitZone> characterHitZones = {};
68 characterDamageManager.GetAllHitZones(characterHitZones);
70 foreach (
HitZone characterHitZone : characterHitZones)
72 if (!characterHitZone.HasColliderNodes() || characterHitZone.GetDamageState() ==
EDamageState.DESTROYED)
75 array<int> colliderIDs = {};
76 characterHitZone.GetColliderIDs(colliderIDs);
78 foreach (
int colliderID : colliderIDs)
80 if (
m_RotorHitZone.HasCollision(otherPhysics.GetGeomWorldPosition(colliderID)))
82 characterHitZone.HandleDamage(damage,
EDamageType.COLLISION,
null);
94 vector ownerTransform[4];
97 vector rotorTransformLocal[4];
101 float rotorRadiusSq = rotorRadius * rotorRadius;
103 vector rotorEdge = vector.Right * rotorRadius;
104 vector contactPositionLocal = contactPos.InvMultiply4(ownerTransform).InvMultiply4(rotorTransformLocal).Normalized() * rotorRadius;
106 float distanceEdgeToContactSq = vector.DistanceSq(rotorEdge, contactPositionLocal);
107 float rotorContactAngle = Math.RAD2DEG * Math.Acos((2 * rotorRadiusSq - distanceEdgeToContactSq) / (2 * rotorRadiusSq));
108 if (contactPositionLocal[1] < 0)
109 rotorContactAngle = 360 - rotorContactAngle;
111 vector rotationMatrix[3];
113 Math3D.AnglesToMatrix({180, 0, rotorContactAngle}, rotationMatrix);
115 Math3D.AnglesToMatrix({180, 0, rotorContactAngle + 180}, rotationMatrix);
117 vector resultRotation[3];
118 Math3D.MatrixMultiply3(rotorTransformLocal, rotationMatrix, resultRotation);
120 vector translatedTransform[4];
121 Math3D.MatrixMultiply3(ownerTransform, resultRotation, translatedTransform);
122 translatedTransform[3] = contactPos;
128 ResourceName resource = effectInfo.GetVehicleDustResource(
m_iEffectIndex);
129 if (!resource || resource.IsEmpty())
155 int shapeIndex1 = contactShapeIndex1;
164 Math3D.MatrixIdentity4(mat);
173 super.OnDamageStateChanged(state);
177 SetEventMask(
GetOwner(), EntityEvent.CONTACT);
179 ClearEventMask(
GetOwner(), EntityEvent.CONTACT);
190 [
RplRpc(RplChannel.Unreliable, RplRcver.Broadcast)]
193 TraceParam trace =
new TraceParam();
194 trace.Start = contactPos + contactNormal;
195 trace.End = contactPos - contactNormal;
196 trace.Flags = TraceFlags.WORLD | TraceFlags.ENTS;
207 override bool OnContact(IEntity owner, IEntity other, Contact contact)
214 vector rotorTransform[4];
219 float rotorCenterToContact = vector.Distance(rotorTransform[3], contact.Position);
220 float rotorRPMMultiplier = Math.Clamp(rotorCenterToContact / rotorRadius, 0, 1);
223 if (rotorRadius <= 0)
225 if (rotorBladeCount <= 0)
230 ChimeraCharacter character = ChimeraCharacter.Cast(other);
245 return super.OnContact(owner, other, contact);
251 IEntity root =
GetOwner().GetRootParent();
253 m_HelicopterSimulation = VehicleHelicopterSimulation.Cast(root.FindComponent(VehicleHelicopterSimulation));
274 RplComponent rplComp = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
275 if (!rplComp || rplComp.IsProxy())
278 SetEventMask(
GetOwner(), EntityEvent.CONTACT);