5 ref array<ref SCR_TimedEffect> m_aEffects;
7 [
Attribute(
desc:
"Useful for complex buildings. Leave empty to use entity's bounding box.")]
8 ref array<ref SCR_InteriorBoundingBox> m_aInteriorQueryBoundingBoxes;
10 [
Attribute(defvalue:
"0",
desc:
"Delay in seconds between damage and the beginning of the building transition")]
14 float m_fSinkingSpeed;
16 [
Attribute(defvalue:
"150",
desc:
"This speeds up the sinking gradually % per second.",
params:
"0 10000 1")]
17 float m_fSinkingSpeedGradualMultiplier;
20 float m_fRotationSpeed;
22 [
Attribute(defvalue:
"0.8",
desc:
"Time between rotation changes when building is collapsing in seconds")]
23 float m_fRotationTime;
25 [
Attribute(defvalue:
"50",
desc:
"Rotation time randomizer in % - can both shorten/prolong the time",
params:
"0 10000 1")]
26 float m_fRotationTimeRandom;
28 [
Attribute(defvalue:
"1",
desc:
"Max rotations count while sinking")]
31 [
Attribute(defvalue :
vector.Zero.ToString(),
desc:
"This vector defines offset for the final position after destruction.")]
35 ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration;
38 ref
Curve m_CameraShakeCurve;
40 [
Attribute(uiwidget:
UIWidgets.Flags, enums: ParamEnumArray.FromEnum(SCR_EDestructionRotationEnum))]
41 SCR_EDestructionRotationEnum m_eAllowedRotations;
55 [
Attribute(defvalue:
"1 1 1",
params:
"inf inf purpose=sizes space=custom", uiwidget:
UIWidgets.BoundingVolumeEditor)]
68 m_vCenter.GetTransform(centerTransform);
70 center = centerTransform[3];
98 vector points[8] = {{-halfScale[0], -halfScale[1], -halfScale[2]} + center,
99 {halfScale[0], halfScale[1], halfScale[2]} + center,
100 {halfScale[0], -halfScale[1], -halfScale[2]} + center,
101 {-halfScale[0], halfScale[1], halfScale[2]} + center,
102 {-halfScale[0], halfScale[1], -halfScale[2]} + center,
103 {halfScale[0], -halfScale[1], halfScale[2]} + center,
104 {-halfScale[0], -halfScale[1], halfScale[2]} + center,
105 {halfScale[0], halfScale[1], -halfScale[2]} + center};
108 vector p0[] = {points[0].Multiply4(ownerTransform), points[4].Multiply4(ownerTransform)};
109 vector p1[] = {points[2].Multiply4(ownerTransform), points[7].Multiply4(ownerTransform)};
110 vector p2[] = {points[5].Multiply4(ownerTransform), points[1].Multiply4(ownerTransform)};
111 vector p3[] = {points[6].Multiply4(ownerTransform), points[3].Multiply4(ownerTransform)};
113 vector p4[] = {points[0].Multiply4(ownerTransform), points[2].Multiply4(ownerTransform)};
114 vector p5[] = {points[2].Multiply4(ownerTransform), points[5].Multiply4(ownerTransform)};
115 vector p6[] = {points[5].Multiply4(ownerTransform), points[6].Multiply4(ownerTransform)};
116 vector p7[] = {points[6].Multiply4(ownerTransform), points[0].Multiply4(ownerTransform)};
118 vector p8[] = {points[4].Multiply4(ownerTransform), points[7].Multiply4(ownerTransform)};
119 vector p9[] = {points[7].Multiply4(ownerTransform), points[1].Multiply4(ownerTransform)};
120 vector p10[] = {points[1].Multiply4(ownerTransform), points[3].Multiply4(ownerTransform)};
121 vector p11[] = {points[3].Multiply4(ownerTransform), points[4].Multiply4(ownerTransform)};
127 int color =
m_Color.PackToInt();
130 Shape.CreateLines(color, shapeFlags, p0, 2);
131 Shape.CreateLines(color, shapeFlags, p1, 2);
132 Shape.CreateLines(color, shapeFlags, p2, 2);
133 Shape.CreateLines(color, shapeFlags, p3, 2);
135 Shape.CreateLines(color, shapeFlags, p4, 2);
136 Shape.CreateLines(color, shapeFlags, p5, 2);
137 Shape.CreateLines(color, shapeFlags, p6, 2);
138 Shape.CreateLines(color, shapeFlags, p7, 2);
140 Shape.CreateLines(color, shapeFlags, p8, 2);
141 Shape.CreateLines(color, shapeFlags, p9, 2);
142 Shape.CreateLines(color, shapeFlags, p10, 2);
143 Shape.CreateLines(color, shapeFlags, p11, 2);
146 vector mins = {center[0] - halfScale[0], center[1] - halfScale[1], center[2] - halfScale[2]};
147 vector maxs = {center[0] + halfScale[0], center[1] + halfScale[1], center[2] + halfScale[2]};
151 SCR_DebugShapeHelperComponent.AddBoxWithTransform(mins, maxs, ownerTransform, color,
ShapeFlags.ONCE |
ShapeFlags.TRANSP |
ShapeFlags.DOUBLESIDE);
157enum SCR_EDestructionRotationEnum
168 protected const float MAX_MULTIPLIER = 1.5;
169 protected float m_fMaxDistance = 50;
172 protected ref Curve m_CameraShakeCurve;
173 protected vector m_vStartOrigin;
181 super.Update(owner, timeSlice);
183 CameraBase camera =
GetGame().GetCameraManager().CurrentCamera();
187 float distanceSq = vector.DistanceSqXZ(m_vStartOrigin, camera.GetOrigin());
188 float multiplier = 1 - Math.Clamp(distanceSq / (m_fMaxDistance * m_fMaxDistance *
m_fSizeMultiplier), 0, 1);
189 float curveMultiplier = LegacyCurve.Curve(
ECurveType.CatmullRom, 1 - multiplier, m_CameraShakeCurve)[1];
191 m_vTranslation *= Math.Min(multiplier *
m_fSizeMultiplier * curveMultiplier, MAX_MULTIPLIER);
192 m_vRotation *= Math.Min(multiplier *
m_fSizeMultiplier * curveMultiplier, MAX_MULTIPLIER);
196 void SetStartOrigin(vector startOrigin)
198 m_vStartOrigin = startOrigin
204 m_CameraShakeCurve = curve;
208 void SetSizeMultiplier(
float sizeMultiplier)
216class SCR_TimedDebris : SCR_TimedEffect
218 [
Attribute(
"0 0 0", UIWidgets.Coords,
desc:
"Positional offset (in local space to the destructible)")]
221 [
Attribute(
"0 0 0", UIWidgets.Coords,
desc:
"Yaw, pitch & roll offset (in local space to the destructible)")]
224 [
Attribute(ResourceName.Empty, UIWidgets.ResourcePickerThumbnail,
"Debris model prefabs to spawn (spawns ALL of them)",
"et xob")]
225 ref array<ResourceName> m_ModelPrefabs;
227 [
Attribute(
"10", UIWidgets.Slider,
"Mass of the debris",
"0.01 1000 0.01")]
230 [
Attribute(
"5", UIWidgets.Slider,
"Minimum lifetime value for the debris (in s)",
"0 3600 0.5")]
233 [
Attribute(
"10", UIWidgets.Slider,
"Maximum lifetime value for the debris (in s)",
"0 3600 0.5")]
236 [
Attribute(
"200", UIWidgets.Slider,
"Maximum distance from camera above which the debris is not spawned (in m)",
"0 3600 0.5")]
239 [
Attribute(
"0", UIWidgets.Slider,
"Higher priority overrides lower priority if at or over debris limit",
"0 100 1")]
242 [
Attribute(
"0.1", UIWidgets.Slider,
"Damage received to physics impulse (speed / mass) multiplier",
"0 10000 0.01")]
245 [
Attribute(
"2", UIWidgets.Slider,
"Damage to speed multiplier, used when objects get too much damage to impulse",
"0 10000 0.01")]
246 float m_fMaxDamageToSpeedMultiplier;
248 [
Attribute(
"0.5", UIWidgets.Slider,
"Random linear velocity multiplier (m/s)",
"0 200 0.1")]
251 [
Attribute(
"180", UIWidgets.Slider,
"Random angular velocity multiplier (deg/s)",
"0 3600 0.1")]
254 [
Attribute(
"0", uiwidget: UIWidgets.ComboBox,
"Type of material for debris sound",
"", ParamEnumArray.FromEnum(SCR_EMaterialSoundTypeDebris))]
255 SCR_EMaterialSoundTypeDebris m_eMaterialSoundType;
266 outMat[3] = vector.Up * 0.001;
272 vector localMat[4], parentMat[4];
277 Math3D.MatrixMultiply4(parentMat, localMat, outMat);
283 override void ExecuteEffect(
IEntity owner, SCR_HitInfo hitInfo, inout notnull SCR_BuildingDestructionData
data)
285 int numModelPrefabs = 0;
287 numModelPrefabs = m_ModelPrefabs.Count();
289 for (
int i = 0; i < numModelPrefabs; i++)
291 ResourceName prefabPath = m_ModelPrefabs[i];
293 ResourceName modelPath;
295 SCR_Global.GetModelAndRemapFromResource(prefabPath, modelPath, remap);
297 if (modelPath == ResourceName.Empty)
303 SCR_DestructionDamageManagerComponent destructionComponent = SCR_DestructionDamageManagerComponent.Cast(owner.
FindComponent(SCR_DestructionDamageManagerComponent));
307 vector linearVelocity = hitInfo.m_HitDirection * Math.RandomFloat(0, 1);
309 linearVelocity *= dmgSpeed;
310 vector angularVelocity =
Vector(Math.RandomFloat(-1, 1), Math.RandomFloat(-1, 1), Math.RandomFloat(-1, 1)) * Math.RandomFloat(0.25, 4) *
m_fRandomVelocityAngular;
311 angularVelocity *= dmgSpeed;
313 SCR_DebrisSmallEntity.SpawnDebris(owner.
GetWorld(), spawnMat, modelPath,
m_fMass, Math.RandomFloat(
m_fLifetimeMin,
m_fLifetimeMax),
m_fDistanceMax,
m_fPriority, linearVelocity, angularVelocity, remap,
false, m_eMaterialSoundType);
320class SCR_TimedEffect : Managed
322 [
Attribute(
"0", UIWidgets.Slider,
"Set time in % of sinking the building. 0 = Immediately, can happen before the sinking starts if delay is used",
"0 1 0.01")]
326 bool m_bSnapToTerrain;
329 bool m_bAttachToParent;
331 [
Attribute(
"0",
desc:
"Does this effect remain after destruction? F. E. ruins.")]
336 void SnapToTerrain(inout vector origin,
IEntity owner)
338 if (!m_bSnapToTerrain)
341 float y = SCR_TerrainHelper.GetTerrainY(origin, owner.
GetWorld());
347 void ExecuteEffect(
IEntity owner, SCR_HitInfo hitInfo, inout notnull SCR_BuildingDestructionData
data)
363 super.ExecuteEffect(owner, hitInfo,
data);
365 if (!
System.IsConsoleApp())
372 if (!destructibleComponent)
381 soundManager.PlayAudioSource(audioSource);
401 [
Attribute(
"1",
desc:
"If this prefab has an RplComponent then it should be only spawned by the server")]
408 super.ExecuteEffect(owner, hitInfo,
data);
415 if (!resource || !resource.IsValid())
419 mat =
data.m_vStartMatrix;
421 if (m_bSnapToTerrain)
424 SnapToTerrain(origin, owner);
430 params.TransformMode = ETransformMode.WORLD;
432 if (m_bAttachToParent)
438 Debug.Error(
string.Format(
"Could not spawn prefab %1 in SCR_TimedPrefab.ExecuteEffect()",
m_sRuinsPrefab));
444 persistence.StartTracking(spawnedEntity);
446 data.m_aExcludeList.Insert(spawnedEntity);
457 [
Attribute(
"1",
desc:
"Overall multiplier for particle effect intensity. Higher values multiplies particle count (Birt Rate + Birth Rate RND), size (Size Multiplier and Size RND) , and velocity (Velocity and Velocity RND).")]
464 Print(
"No SCR_ParticleSpawnable defined on SCR_TimedParticle",
LogLevel.WARNING);
472 super.ExecuteEffect(owner, hitInfo,
data);
478 if (m_bAttachToParent)
479 emitter =
m_Particle.SpawnAsChild(owner, hitInfo, m_bSnapToTerrain);
485 Debug.Error(
"No emitter was spawned in SCR_TimedParticle.ExecuteEffect()");
491 data.m_aExcludeList.Insert(emitter);
497 Particles particles = emitter.GetParticles();
517 float GetParticlesMultiplier()
533 private int m_iDataIndex = -1;
541 protected SCR_BuildingDestructionData
GetData()
546 Print(
"SCR_BuildingDestructionManagerComponent not found! Building destruction won't work.",
LogLevel.ERROR);
550 return manager.
GetData(m_iDataIndex);
560 Print(
"SCR_BuildingDestructionManagerComponent not found! Building destruction won't work.",
LogLevel.ERROR);
564 manager.FreeData(m_iDataIndex);
576 if (!sharedInstigator)
577 sharedInstigator =
Instigator.CreateInstigator(null);
606 if (childDestructibleComp)
608 defaultHitZone = childDestructibleComp.GetDefaultHitZone();
611 owner.RemoveChild(child,
true);
613 damageContext.damageValue = defaultHitZone.GetMaxHealth();
614 damageContext.struckHitZone = defaultHitZone;
615 damageContext.hitEntity = child;
617 childDestructibleComp.HandleDamage(damageContext);
725 if (
data.m_AudioSource)
730 soundManager.TerminateAudioSource(
data.m_AudioSource);
733 data.m_AudioSource = audioSource;
746 return data.m_AudioSource;
756 data.m_RandomGenerator.SetSeed(seed);
763 super.OnDamageStateChanged(newState, previousDamageState, isJIP);
775 int seed =
Math.RandomInt(0, 10000);
812 data.m_aQueriedEntities = {};
830 if (!boundingBoxes || boundingBoxes.IsEmpty())
838 SCR_DestructionManager destrManager = SCR_DestructionManager.GetDestructionManagerInstance();
839 SCR_RegionalDestructionManager regionalManager;
841 regionalManager = SCR_RegionalDestructionManager.Cast(destrManager.GetOrCreateRegionalDestructionManager(
GetOwner().
GetOrigin()));
843 RplComponent rplComponent = RplComponent.Cast(owner.
FindComponent(RplComponent));
845 ref array<ref vector> boxesPositions =
new array<ref vector>;
850 if (!boundingBox || !boundingBox.GetCenter(center) || boundingBox.GetScale() ==
vector.One)
852 Print(
"SCR_DestructibleBuildingComponent: Interior Bounding Box has been added but not set up!",
LogLevel.WARNING);
856 boundingBox.GetBounds(mins, maxs);
857 if (regionalManager && !rplComponent.IsProxy())
858 regionalManager.RegisterInteriorBoundingBox(
data.m_vStartMatrix, mins, maxs, center);
862 if (rplComponent.IsProxy() && regionalManager)
864 if (destrManager.m_RegionalManagerHandledBoxes.Find(regionalManager.GetRplID(), boxesPositions))
866 boxesPositions.Insert(
data.m_vStartMatrix[3]+center);
870 boxesPositions =
new array<ref vector>;
871 boxesPositions.Insert(
data.m_vStartMatrix[3]+center);
872 destrManager.m_RegionalManagerHandledBoxes.Insert(regionalManager.GetRplID(), boxesPositions);
888 int count =
data.m_aQueriedEntities.Count();
890 SCR_DestructionDamageManagerComponent destructionComponent;
893 RplComponent rplComponent;
895 array<IEntity> handledEntities = {};
896 for (
int i = count - 1; i >= 0; i--)
899 if (!
data.m_aQueriedEntities[i])
901 data.m_aQueriedEntities.Remove(i);
906 childEntity =
data.m_aQueriedEntities[i].GetChildren();
909 bool wasHandled = handledEntities.Contains(childEntity);
912 if (!wasHandled && !
data.m_aQueriedEntities.Contains(childEntity))
914 data.m_aQueriedEntities.Insert(childEntity);
928 handledEntities.Insert(
data.m_aQueriedEntities[i]);
931 data.m_iChecksThisFrame++;
934 data.m_iChecksThisFrame = 0;
952 destructionComponent = SCR_DestructionDamageManagerComponent.Cast(
data.m_aQueriedEntities[i].FindComponent(SCR_DestructionDamageManagerComponent));
956 if (!destructibleEntity && !destructionComponent && !editableEntity)
957 RplComponent.DeleteRplEntity(
data.m_aQueriedEntities[i],
false);
960 if (destructibleEntity)
961 destructibleEntity.HandleDamage(
EDamageType.TRUE, destructibleEntity.GetCurrentHealth() * 11, hitPosDirNorm);
964 if (destructionComponent)
965 destructionComponent.DeleteDestructibleDelayed();
971 data.m_aQueriedEntities.Remove(i);
988 RplComponent.DeleteRplEntity(
GetOwner(),
false);
1000 if (
data.m_CameraShake != null)
1003 data.m_CameraShake.SetParams(0.15, 0.15, 0.01, 0.3, 0.24);
1004 data.m_CameraShake = null;
1007 data.m_aQueriedEntities = null;
1014 param.Start = start -
direction * lengthMultiplier;
1015 param.End = start +
direction * lengthMultiplier;
1018 return param.TraceEnt != null;
1027 vector start = entity.GetOrigin();
1031 param.LayerMask = EPhysicsLayerDefs.Projectile;
1032 param.Include = owner;
1035 for (
int i = 0; i < 3; i++)
1037 float lengthMultiplier = 1;
1039 lengthMultiplier = 100;
1083 entity == ownerParent ||
1085 (entityParent && entityParent != owner)
1102 SCR_DamageManagerComponent damageManager = character.GetDamageManager();
1103 if (damageManager && damageManager.GetState() !=
EDamageState.DESTROYED)
1119 SCR_BaseCompartmentManagerComponent baseCompartmentManagerComp = SCR_BaseCompartmentManagerComponent.Cast(e.FindComponent(SCR_BaseCompartmentManagerComponent));
1120 if (baseCompartmentManagerComp)
1122 array<IEntity> turretOccupants = {};
1123 baseCompartmentManagerComp.GetOccupants(turretOccupants);
1124 foreach (
IEntity occupant : turretOccupants)
1139 if (
data.m_aQueriedEntities.Contains(e))
1150 foreach (
typename typeName : manager.GetExcludedQueryTypes())
1152 if (e.IsInherited(typeName))
1154 if (!e.Type().IsInherited(
SCR_PowerPole) && !e.Type().IsInherited(SCR_JunctionPowerPole))
1168 if (!prefabData || !prefabData.m_aCableSlotGroups)
1178 if (!slotGroup || !slotGroup.m_aSlots)
1182 int validSlotCount = 0;
1190 avgLocalPos += slot.m_vPosition;
1195 if (validSlotCount > 0)
1197 avgLocalPos = avgLocalPos / validSlotCount;
1198 vector avgWorldPos = powerPole.CoordToParent(avgLocalPos);
1211 SCR_EditorLinkComponent linkComp = SCR_EditorLinkComponent.Cast(e.FindComponent(SCR_EditorLinkComponent));
1225 if(e.GetParent() != owner)
1236 data.m_aQueriedEntities.Insert(e);
1253 headHitzone.HandleDamage(1000,
EDamageType.TRUE, null);
1266 HitZone defaultHitzone = damageManager.GetDefaultHitZone();
1267 defaultHitzone.HandleDamage(defaultHitzone.GetMaxHealth(),
EDamageType.TRUE, null);
1284 if (e.Type() != PowerlineEntity)
1308 float x =
Math.AbsFloat(mins[0]) + maxs[0];
1309 float y =
Math.AbsFloat(mins[1]) + maxs[1];
1310 float z =
Math.AbsFloat(mins[2]) + maxs[2];
1312 float buildingVolume = x * y * z;
1314 data.m_fBuildingVolume = buildingVolume;
1339 persistence.StartTracking(owner,
false);
1348 if (sinkVector ==
vector.Zero)
1354 StaticModelEntity.Cast(owner).DestroyOccluders();
1360 FinishLerp(owner, immediate,
true, spawnEffects);
1366 auto shake =
data.m_CameraShake;
1369 shake.SetParams(0.15, 0.15, 0.01, 400, 0.24);
1371 shake.SetStartOrigin(
data.m_vStartMatrix[3]);
1372 shake.SetSizeMultiplier(
data.m_fSizeMultiplier);
1375 if (character && character.IsInVehicle())
1381 if (simulation && simulation.HasAnyGroundContact())
1382 SCR_CameraShakeManagerComponent.AddCameraShake(shake);
1387 SCR_CameraShakeManagerComponent.AddCameraShake(shake);
1394 EnableDamageSystemOnFrame();
1408 if (!
data.m_aExcludeList)
1409 data.m_aExcludeList = {};
1414 array<ref SCR_TimedEffect> effects =
GetEffects();
1415 SCR_TimedEffect currentEffect;
1416 for (
int i = effects.Count() - 1; i >= 0; i--)
1418 if (
data.m_aExecutedEffectIndices &&
data.m_aExecutedEffectIndices.Contains(i))
1421 currentEffect = effects[i];
1423 if (immediateDestruction && !currentEffect.m_bPersistent)
1426 if (currentEffect.m_fSpawnTime <= percentDone)
1428 currentEffect.ExecuteEffect(owner, hitInfo,
data);
1431 if (!
data.m_aExecutedEffectIndices)
1433 data.m_aExecutedEffectIndices =
new set<int>();
1435 data.m_aExecutedEffectIndices.Reserve(effects.Count());
1438 data.m_aExecutedEffectIndices.Insert(i);
1448 protected void FinishLerp(
IEntity owner,
bool immediate,
bool updateEntity,
bool spawnEffects =
true)
1450 owner.SetObject(null,
"");
1452 DisableDamageSystemOnFrame();
1509 data.m_aNavmeshAreas = {};
1510 data.m_aRedoRoads = {};
1518 for (
int i = 0; i < 3; i++)
1520 targetSmaller = endOrigin[i] < startOrigin[i];
1523 if (currentOrigin[i] < endOrigin[i])
1524 currentOrigin[i] = endOrigin[i];
1528 if (currentOrigin[i] > endOrigin[i])
1529 currentOrigin[i] = endOrigin[i];
1552 data.m_iRotationTime =
GetRotationTime() * (1 +
data.m_RandomGenerator.RandFloatXY(0, rotationTimeRandomizer)) * 1000;
1555 data.m_fSpeedMultiplier *= 0.05;
1558 if (
data.m_iRotatedTimes != 0)
1566 vector newTargetAngles =
Vector(
data.m_RandomGenerator.RandFloatXY(5, 20) * allowRotationX *
data.m_iRotationMultiplier +
data.m_vStartAngles[0]
1567 ,
data.m_RandomGenerator.RandFloatXY(5, 20) * allowRotationY *
data.m_iRotationMultiplier +
data.m_vStartAngles[1]
1568 ,
data.m_RandomGenerator.RandFloatXY(5, 20) * allowRotationZ *
data.m_iRotationMultiplier +
data.m_vStartAngles[2]);
1571 data.m_iRotationMultiplier *= -1;
1574 data.m_fRotationSpeedMultiplier = 0.5;
1577 data.m_vTargetAngles = newTargetAngles;
1582 int pauseTime =
data.m_RandomGenerator.RandIntInclusive(0, 500);
1586 data.m_iRotationStart = world.GetWorldTime() + pauseTime;
1589 data.m_iPauseTime = world.GetWorldTime() + pauseTime;
1591 data.m_iRotatedTimes++;
1595 data.m_fRotationSpeedMultiplier += timeSlice;
1610 if (!audioSourceConfiguration || !audioSourceConfiguration.IsValid())
1619 soundManager.PlayAudioSource(audioSource);
1631 if (target ==
vector.Zero)
1634 float percent = timeSlice / (
data.m_iRotationTime * 0.001);
1635 vector diff = target - start;
1636 vector nextRotation = current + percent * diff * rotationSpeed *
data.m_fRotationSpeedMultiplier;
1639 return nextRotation;
1668 float.AlmostEqual(newOrigin[0],
data.m_vTargetOrigin[0]) &&
1669 float.AlmostEqual(newOrigin[1],
data.m_vTargetOrigin[1]) &&
1670 float.AlmostEqual(newOrigin[2],
data.m_vTargetOrigin[2]);
1672 float difY =
data.m_vTargetOrigin[1] -
data.m_vStartMatrix[3][1];
1673 float curY = newOrigin[1] -
data.m_vStartMatrix[3][1];
1674 float percentDone = curY/difY;
1685 worldMat[3] = newOrigin;
1714 protected override event bool OnRplSave(ScriptBitWriter writer)
1716 super.OnRplSave(writer);
1727 super.OnRplLoad(reader);
1751 if (other && other.IsInherited(SCR_DebrisSmallEntity))
1755 Physics physics = contact.Physics1;
1756 int responseIndex = physics.GetResponseIndex();
1757 float ownerMass = physics.GetMass();
1759 if (!physics.IsDynamic())
1761 physics = contact.Physics2;
1765 otherMass = physics.GetMass();
1773 otherMass = otherPhysics.GetMass();
1779 vector relVel = contact.VelocityBefore2 - contact.VelocityBefore1;
1780 outMat[0] = contact.Position;
1781 outMat[1] = relVel.Normalized();
1782 outMat[2] = contact.Normal;
1784 float damage = momentum * 0.05;
1805 super.OnPostInit(owner);
1811 override array<ref WB_UIMenuItem> _WB_GetContextMenuItems(
IEntity owner)
1813 array<ref WB_UIMenuItem> items = {
new WB_UIMenuItem(
"Toggle Interior Bounding Box Debug", 0) };
1819 override void _WB_OnContextMenu(
IEntity owner,
int id)
1831 protected override void _WB_AfterWorldUpdate(
IEntity owner,
float timeSlice)
1833 super._WB_AfterWorldUpdate(owner, timeSlice);
1835 if (!DiagMenu.GetBool(
SCR_DebugMenuID.DEBUGUI_SHOW_INTERIOR_BOUNDING_BOX))
1838 GenericEntity entity = GenericEntity.Cast(owner);
1843 if (!api || !api.IsEntitySelected(api.EntityToSource(owner)))
1847 vector ownerTransform[4];
1853 boundingBox.DrawDebug(ownerTransform);
1858 protected override event bool _WB_GetKeySpaceMatrixWorld(
IEntity owner, BaseContainer src,
string key, BaseContainerList ownerContainers,
IEntity parent, out vector transformSpaceWorld[4])
1860 if(src.GetClassName() ==
"SCR_InteriorBoundingBox" && key ==
"m_vScale")
1865 BaseContainer ownerCont = null;
1866 if(ownerContainers.Count() > 0)
1867 ownerCont = ownerContainers[ownerContainers.Count() - 1];
1869 if(ownerCont && ownerCont.GetClassName() ==
"SCR_DestructibleBuildingComponent")
1874 BaseContainerList bboxes = ownerCont.GetObjectArray(
"m_aInteriorQueryBoundingBoxes");
1879 for (
int i = 0; i < bboxes.Count(); i++)
1881 BaseContainer box = bboxes.Get(i);
1894 SCR_InteriorBoundingBox intBox = null;
1898 intBox = boundingBoxes[bboxIndex];
1903 vector boxLocalTransform[4];
1904 intBox.m_vCenter.GetTransform(boxLocalTransform);
1907 vector entityWorldTransform[4];
1911 vector boxTransform[4];
1912 Math3D.MatrixMultiply4(entityWorldTransform, boxLocalTransform, boxTransform);
1914 transformSpaceWorld = boxTransform;
1921 return super._WB_GetKeySpaceMatrixWorld(owner, src, key, ownerContainers, parent, transformSpaceWorld);
1930 RplComponent rplComponent = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
1931 return rplComponent && rplComponent.IsProxy();
1937 RplComponent rplComponent = RplComponent.Cast(
GetOwner().FindComponent(RplComponent));
1938 return rplComponent && rplComponent.IsMaster();
ArmaReforgerScripted GetGame()
SCR_HybridPhysicsComponentClass m_fMass
Class for storing physics setup info for SCR_HybridPhysicsComponent.
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
void SCR_AudioSource(SCR_AudioSourceConfiguration audioSourceConfiguration, vector mat[4])
void GetSpawnTransform(IEntity owner, out vector outMat[4], bool localCoords=false)
Calculates the spawn tranformation matrix for the object.
override bool HandleDamage(BaseDamageContext damageContext, IEntity owner)
SCR_CharacterSoundComponentClass GetComponentData()
SCR_InteriorBoundingBox ROTATION_Z
SCR_InteriorBoundingBox ROTATION_Y
SCR_InteriorBoundingBox ROTATION_X
void SCR_DestructibleEntity(IEntitySource src, IEntity parent)
float m_fRandomVelocityLinear
float m_fRandomVelocityAngular
Get all prefabs that have the spawner data
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
void SCR_PowerPole(IEntitySource src, IEntity parent)
void ParticleEffectEntity(IEntitySource src, IEntity parent)
SCR_AudioSourceConfiguration GetAudioSourceConfiguration()
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
void SCR_VehicleDamageManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
enum EVehicleType IEntity
proto external WorldEditorAPI _WB_GetEditorAPI()
This returns world editor API, which is safe to use from editor events bellow.
proto external Managed FindComponent(typename typeName)
proto external void SetAngles(vector angles)
Same as SetYawPitchRoll(), but sets rotation around X, Y and Z axis.
proto external vector GetLocalAngles()
Same as GetLocalYawPitchRoll(), but returns rotation vector around X, Y and Z axis.
proto external void SetOrigin(vector orig)
proto external vector GetOrigin()
proto external Physics GetPhysics()
proto external int AddChild(notnull IEntity child, TNodeId pivot, EAddChildFlags flags=EAddChildFlags.AUTO_TRANSFORM)
Add Entity to hierarchy. Pivot is pivot index, or -1 for center of parent.
proto external void GetBounds(out vector mins, out vector maxs)
proto external IEntity GetChildren()
proto external void GetWorldTransform(out vector mat[])
See IEntity::GetTransform.
proto external int Update()
proto external BaseWorld GetWorld()
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external bool SetWorldTransform(vector mat[4])
See IEntity::SetTransform. Returns false, if there is no change in transformation.
proto external void GetTransform(out vector mat[])
proto external IEntity GetParent()
proto external IEntity GetSibling()
PointInfo - allows to define position.
Object holding reference to resource. In destructor release the resource.
void GetNavmeshRebuildAreas(IEntity entity, out notnull array< ref Tuple2< vector, vector > > outAreas, out notnull array< bool > redoRoads)
void RequestNavmeshRebuildAreas(notnull array< ref Tuple2< vector, vector > > areas, notnull array< bool > redoRoads)
notnull SCR_BuildingDestructionData GetData(inout int index)
SCR_CharacterHeadHitZone GetHeadHitZone()
void ClampVector(inout vector currentOrigin, vector startOrigin, vector endOrigin)
override void OnFrame(IEntity owner, float timeSlice)
Handles per-frame operations, only enabled while the building is sinking.
void SpawnEffects(float percentDone, IEntity owner, bool immediateDestruction)
bool HasPhysicalChildren(notnull IEntity e)
override bool HasDataToReplicate()
void StoreNavmeshData()
Stores navmesh data to regenerate navmesh later.
void SetAudioSource(SCR_AudioSource audioSource)
void CalculateAndStoreVolume()
void FreeData()
Frees the data stored in building destruction manager.
ref array< ref SCR_InteriorBoundingBox > GetInteriorBoundingBoxes()
override void OnFilteredContact(IEntity owner, IEntity other, Contact contact)
Contact to deal damage.
float GetSpeed()
Returns prefab data stored speed.
void DestroyChildDestructibles(notnull IEntity owner)
void GoToDestroyedState(bool immediate, bool spawnEffects=true)
const float BUILDING_SIZE
bool AddEntityCallback(notnull IEntity e)
Used by Query in DestroyInterior.
float GetSpeedGradualMultiplier()
Returns prefab data stored speed gradual multiplier.
void DeleteBuilding()
Handles the destruction of building itself after interior is handled.
override event bool OnRplLoad(ScriptBitReader reader)
Loads serialized state on client.
void RegenerateNavmesh()
Regenerates navmesh using previously stored data.
void DamageOccupantsDelayed(IEntity targetEntity)
void RPC_GoToDestroyedState(int seed)
Used to do runtime synchronization of state.
void DestroyInteriorInit(bool immediate)
Handles destruction of interior by gathering objects using AABB (will probably use OBB) and deleting ...
float GetRotationTimeRandomizer()
void FinishLerp(IEntity owner, bool immediate, bool updateEntity, bool spawnEffects=true)
SCR_AudioSource GetAudioSource()
vector LerpAngles(vector start, vector current, vector target, float rotationSpeed, float timeSlice, notnull SCR_BuildingDestructionData data)
ref array< vector > m_aPowerPolePositions
const vector TRACE_DIRECTIONS[3]
float GetDelay()
Returns prefab data stored delay.
bool ProcessFoundPowerline(notnull IEntity e)
void LerpPosition(IEntity owner, float timeSlice)
void HandleConnectedPowerlines()
override event bool OnRplSave(ScriptBitWriter writer)
Serializes state over network.
const int NO_COLLISION_RESPONSE_INDEX
override void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
Called when damage state is changed.
SCR_BuildingDestructionData GetData()
Returns centrally stored data from building destruction manager.
override void OnPostInit(IEntity owner)
bool TraceFilter(notnull IEntity e, vector start="0 0 0", vector dir="0 0 0")
Filters out unwanted entities.
bool IsInside(notnull IEntity entity)
Checks whether or not an entity is inside of the building, using a trace in each world axis.
void DestroyInterior(bool immediate)
void FinishDestruction()
Last method to be called after destruction happens, data is cleared.
bool QueryFilterCallback(notnull IEntity entity)
Used to filter out entities that are not meant to be handled in AddEntityCallback.
void GoToDestroyedStateLoad(bool spawnEffects=true)
Curve GetCameraShakeCurve()
void LerpRotation(IEntity owner, float timeSlice)
bool IsProxy()
Returns true if local instance is proxy (not the authority).
override bool HijackDamageHandling(notnull BaseDamageContext damageContext)
void HandleVehicle(IEntity targetEntity)
bool PerformTrace(notnull TraceParam param, vector start, vector direction, notnull BaseWorld world, float lengthMultiplier=1)
SCR_AudioSourceConfiguration GetSlowDownAudioSourceConfiguration()
array< ref SCR_TimedEffect > GetEffects()
Returns pointer to prefab data stored array of effects, do not modify the array!
const int MAX_CHECKS_PER_FRAME
static float CalculateMomentum(notnull Contact contact, float ownerMass, float otherMass)
void SetEntityState(EEditableEntityState state, bool toSet)
bool Delete(bool changedByUser=false, bool updateNavmesh=false)
static RplComponent GetEntityRplComponent(notnull IEntity entity)
override bool IsRunning()
Class to temporarily store information about the last hit that dealt damage.
void GetBounds(out vector mins, out vector maxs)
bool GetCenter(out vector center)
static IEntity GetLocalControlledEntity()
void SetParticleParams(ParticleEffectEntity emitter, inout notnull SCR_BuildingDestructionData data)
override void ExecuteEffect(IEntity owner, SCR_HitInfo hitInfo, inout notnull SCR_BuildingDestructionData data)
Plays particles.
float m_fParticlesMultiplier
ref SCR_ParticleSpawnable m_Particle
bool m_bSpawnedByTheServer
ResourceName m_sRuinsPrefab
override void ExecuteEffect(IEntity owner, SCR_HitInfo hitInfo, inout notnull SCR_BuildingDestructionData data)
Spawns prefab.
ref SCR_AudioSourceConfiguration m_AudioSourceConfiguration
override void ExecuteEffect(IEntity owner, SCR_HitInfo hitInfo, inout notnull SCR_BuildingDestructionData data)
Plays effects.
enum EPhysicsLayerPresets Vehicle
IEntity GetOwner()
Owner entity of the fuel tank.
proto void Print(void var, LogLevel level=LogLevel.NORMAL)
Prints content of variable to console/log.
LogLevel
Enum with severity of the logging message.
@ NONE
When Shape is created and not initialized yet.
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
EntityFlags
Various entity flags.
BaseProjectileComponentClass GameComponentClass GetInstigator()
void RplRpc(RplChannel channel, RplRcver rcver, RplCondition condition=RplCondition.None, string customConditionName="")
RplChannel
Communication channel. Reliable is guaranteed to be delivered. Unreliable not.
proto native vector Vector(float x, float y, float z)