22 float dotMultiplier =
vector.Dot(contact.VelocityAfter1.Normalized(), contact.VelocityBefore1.Normalized());
24 float momentumAfter = ownerMass * contact.VelocityAfter1.Length() * dotMultiplier;
25 float momentumA =
Math.AbsFloat(momentumBefore - momentumAfter);
27 dotMultiplier =
vector.Dot(contact.VelocityAfter2.Normalized(), contact.VelocityBefore2.Normalized());
29 momentumAfter = otherMass * contact.VelocityAfter2.Length() * dotMultiplier;
30 float momentumB =
Math.AbsFloat(momentumBefore - momentumAfter);
31 return momentumA + momentumB;
36 static void SpawnDestroyObjects(notnull
IEntity owner, notnull array<ref SCR_BaseSpawnable> spawnList, notnull SCR_DestructionHitInfo destructionHitInfo)
38 Physics physics = owner.GetPhysics();
44 spawnObject.Spawn(owner, physics, destructionHitInfo);
54 static void PlaySound(notnull
IEntity owner, SCR_EMaterialSoundTypeBreak materialSoundType,
int numDamagePhases,
int damagePhaseIndex)
61 if (!destructionManager)
65 if (!audioSourceConfiguration)
69 audioSourceConfiguration.m_sSoundEventName =
SCR_SoundEvent.SOUND_MPD_ + owner.Type().EnumToString(SCR_EMaterialSoundTypeBreak, materialSoundType);
74 owner.GetWorldBounds(mins, maxs);
82 audioSource.SetSignalValue(
SCR_AudioSource.PHASES_TO_DESTROYED_PHASE_SIGNAL_NAME, numDamagePhases - damagePhaseIndex - 1);
87 soundManager.PlayAudioSource(audioSource);
125 owner.SetObject(model,
string.Empty);
128 Physics phys = owner.GetPhysics();
133 if (!phys.UpdateGeometries())
143 owner.SetObject(model, remap);
146 Physics phys = owner.GetPhysics();
151 if (!phys.UpdateGeometries())
162 resource =
Resource.Load(modelName);
163 if (!resource.IsValid())
170 return resourceObject.ToVObject();
180 owner.GetBounds(mins, maxs);
181 return (maxs[0] - mins[0]) * (maxs[1] - mins[1]);
191 int responseIndex = physics.GetResponseIndex();
198 float healthPercentage = health / maxHealth;
202 physics.SetResponseIndex(responseIndex);
218 array<ref Tuple2<vector, vector>> areas = {};
219 array<bool> redoAreas = {};
233 if (!signalsManagerComponent)
237 signalsManagerComponent.SetSignalValue(signalsManagerComponent.AddOrFindSignal(
DAMAGE_PHASE_SIGNAL_NAME), damagePhaseIndex);
248 array<string> sanitizedEntries = {};
249 array<string> originalEntries = {};
250 array<string> originalSlots = {};
256 foreach (
string entry : originalEntries)
259 if (firstQuote == -1)
262 string remainingStr = entry.Substring(firstQuote + 1, entry.Length() - (firstQuote + 1));
264 if (secondQuote == -1)
267 string slot = entry.Substring(firstQuote + 1, secondQuote);
268 originalSlots.Insert(slot);
272 array<string> newEntries = {};
276 foreach (
string entry : newEntries)
279 if (firstQuote == -1)
282 string remainingStr = entry.Substring(firstQuote + 1, entry.Length() - (firstQuote + 1));
284 if (secondQuote == -1)
287 string slot = entry.Substring(firstQuote + 1, secondQuote);
290 if (originalSlots.Contains(slot))
291 sanitizedEntries.Insert(entry);
295 string sanitizedRemap;
296 foreach (
string entry : sanitizedEntries)
298 if (!sanitizedRemap.IsEmpty())
301 sanitizedRemap += entry;
304 return sanitizedRemap;
308#define ENABLE_BASE_DESTRUCTION
309enum SCR_EMaterialSoundTypeDebris
335enum SCR_EMaterialSoundTypeBreak
ArmaReforgerScripted GetGame()
void SCR_AudioSource(SCR_AudioSourceConfiguration audioSourceConfiguration, vector mat[4])
SCR_CommunicationSoundComponentClass MORTAR
class SCR_DestructionUtility BREAK_CERAMIC
class SCR_DestructionUtility CERAMIC
class SCR_DestructionUtility GLASS
class SCR_DestructionUtility BREAK_METAL_GENERATOR
class SCR_DestructionUtility WOOD_PLANK_SMALL
class SCR_DestructionUtility BREAK_ROCK
class SCR_DestructionUtility BREAK_HAYBALE
class SCR_DestructionUtility METAL_LIGHT
class SCR_DestructionUtility METAL_HUGE_LONG
class SCR_DestructionUtility BREAK_TENT
class SCR_DestructionUtility BREAK_PLASTIC
class SCR_DestructionUtility BREAK_MATRESS
class SCR_DestructionUtility ROCK_SMALL
class SCR_DestructionUtility HAYBALE
class SCR_DestructionUtility BREAK_MOIST
class SCR_DestructionUtility ROCK
class SCR_DestructionUtility BREAK_METAL
class SCR_DestructionUtility BREAK_METAL_HUGE
class SCR_DestructionUtility BREAK_GLASS_PANE
class SCR_DestructionUtility BREAK_PIANO
class SCR_DestructionUtility PLASTIC_SOLID
class SCR_DestructionUtility BREAK_SANDBAG
class SCR_DestructionUtility BELL_SMALL
class SCR_DestructionUtility METAL_POLE
class SCR_DestructionUtility MOIST
class SCR_DestructionUtility METAL_NETFENCE
class SCR_DestructionUtility BREAK_GLASS
class SCR_DestructionUtility MATRESS
class SCR_DestructionUtility BREAK_METAL_POLE
class SCR_DestructionUtility BREAK_GROUNDRADAR
class SCR_DestructionUtility BREAK_METAL_NETFENCE
class SCR_DestructionUtility METAL_HEAVY
class SCR_DestructionUtility BREAK_WATERHYDRANT
class SCR_DestructionUtility SANDBAG
class SCR_DestructionUtility METAL_HUGE
class SCR_DestructionUtility PLASTIC_HOLLOW
class SCR_DestructionUtility METAL_HUGE_SQUARE
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)
static string SanitizeRemapString(string originalRemap, string newRemap)
static void SetDamagePhaseSignal(notnull IEntity owner, int damagePhaseIndex=0)
static const int MIN_MOMENTUM_RESPONSE_INDEX
static float GetDestructibleSize(notnull IEntity owner)
static void SpawnDestroyObjects(notnull IEntity owner, notnull array< ref SCR_BaseSpawnable > spawnList, notnull SCR_DestructionHitInfo destructionHitInfo)
Spawns objects that are meant to be created when the object is destroyed (particles,...
static void SetModel(notnull IEntity owner, notnull VObject model, string remap)
static void PlaySound(notnull IEntity owner, SCR_EMaterialSoundTypeBreak materialSoundType, int numDamagePhases, int damagePhaseIndex)
static float CalculateMomentum(notnull Contact contact, float ownerMass, float otherMass)
static void UpdateResponseIndex(notnull Physics physics, float health, float maxHealth)
static void SetModel(notnull IEntity owner, ResourceName modelName)
static const float SIMULATION_IMPRECISION_MULTIPLIER
static const int MAX_MOMENTUM_RESPONSE_INDEX
static const int MAX_DESTRUCTION_RESPONSE_INDEX
static const int MIN_DESTRUCTION_RESPONSE_INDEX
static const string DAMAGE_PHASE_SIGNAL_NAME
static void RegenerateNavmeshDelayed(notnull IEntity owner)
static void SetModel(notnull IEntity owner, notnull VObject model)
static void SetModel(notnull IEntity owner, ResourceName modelName, string remap)
static VObject GetModel(ResourceName modelName, out Resource resource)
static SCR_MPDestructionManager GetInstance()
Returns the instance of the destruction manager.
SCR_AudioSourceConfiguration GetAudioSourceConfiguration()
@ NONE
When Shape is created and not initialized yet.