Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_WindowHitZone.c
Go to the documentation of this file.
2{
3 override protected void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
4 {
5 super.OnDamageStateChanged(newState, previousDamageState, isJIP);
6
7 if (!GetGame().InPlayMode())
8 return;
9
10 // Update the associated portal when the window is destroyed / restored
11 if (newState == EDamageState.DESTROYED)
12 SetSoundPassing(true);
13 else if (newState == EDamageState.UNDAMAGED)
14 SetSoundPassing(false);
15 }
16
17 private void SetSoundPassing(bool value)
18 {
19 HitZoneContainerComponent container = GetHitZoneContainer();
20 if (container == null)
21 return;
22
23 IEntity owner = container.GetOwner();
24
25 // Find the entity with the subscene
27 IEntity parent = owner;
28 while (parent != null)
29 {
31 if (subscene != null)
32 break;
33
34 parent = parent.GetParent();
35 }
36
37 if (subscene == null)
38 return;
39
40 // window world position
41 vector posHZ[4];
42 owner.GetWorldTransform(posHZ);
43 // subscene entity world position
44 vector matWS[4];
45 parent.GetWorldTransform(matWS);
46
47 // Invert the transform so we get the local position of the window within the parent
48 vector matLS[4];
49 Math3D.MatrixInvMultiply4(matWS, posHZ, matLS);
50
51 // Find the portal and update the sound passing flag as necessary
52 vector mins = matLS[3] - { 0.2, 0.2, 0.2 };
53 vector maxs = matLS[3] + { 0.2, 0.2, 0.2 };
54 int portalIdx = subscene.FindPortalByOBB(mins, maxs, matWS);
55 if (portalIdx < 0 || portalIdx >= 0xFFFF)
56 return;
57
58 subscene.SetPortalPassingSound(portalIdx, value);
59 }
60}
ArmaReforgerScripted GetGame()
Definition game.c:1398
proto external Managed FindComponent(typename typeName)
proto external void GetWorldTransform(out vector mat[])
See IEntity::GetTransform.
proto external IEntity GetParent()
void OnDamageStateChanged(EDamageState newState, EDamageState previousDamageState, bool isJIP)
EDamageState