Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
BaseDebrisSmallEntity.c
Go to the documentation of this file.
1#define DEBUG
2#define ENABLE_BASE_DESTRUCTION
3[EntityEditorProps(category: "GameScripted/Debris", description: "Entity used to represent small chunks of debris. Automatically managed.", dynamicBox: true)]
4class SCR_BaseDebrisSmallEntityClass: GenericEntityClass
5{
6}
7
13{
14#ifdef ENABLE_BASE_DESTRUCTION
16 bool m_bDelete = false;
17
19 [Attribute(defvalue:"30", params:"0 inf", desc:"How long until the debris despawns (seconds)")]
21
24
26 protected static const float MINIMAL_DISTANCE_SQ = 0.25;
27
29 protected static const float MINIMAL_AGE = 0.25;
30
32 protected static const float KINETIC_ENERGY_THRESHOLD = 15;
33
34#ifdef ENABLE_DIAG
36 float m_fdVelocity;
37
39 protected ref DebugTextWorldSpace m_Text;
40
42 protected float m_fdVelocityPeak;
43
45 protected float m_fdVelocityPeakAgeTime;
46#endif // ENABLE_DIAG
47
48 //------------------------------------------------------------------------------------------------
51 protected bool IsGamePlaying()
52 {
53 return GetGame().GetWorldEntity() != null;
54 }
55
56 //------------------------------------------------------------------------------------------------
57 protected static float GetDistanceToCamera(BaseWorld world, vector position)
58 {
59 vector cameraMat[4];
60 world.GetCurrentCamera(cameraMat);
61 return vector.Distance(cameraMat[3], position);
62 }
63
64 //------------------------------------------------------------------------------------------------
65 override void EOnFrame(IEntity owner, float timeSlice)
66 {
67 // Get debris age
68 m_fAgeTime += timeSlice;
69
70 // Delete this debris. (automatically unregisters)
73
74 // If debris should be deleted then delete it.
75 if (m_bDelete)
76 {
77 Physics entityPhysics = GetPhysics();
78 if (entityPhysics)
79 entityPhysics.Destroy();
80
81 delete this;
82 }
83 }
84
85 //------------------------------------------------------------------------------------------------
86#ifdef ENABLE_DIAG
87 void SoundDebugOnFrame(float soundThreshold)
88 {
89 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SOUNDS_MPDESTRUCTION_SHOW_IMPULSEVALUES))
90 {
91 // Get center of entity
92 vector minsDebug;
93 vector maxsDebug;
94 GetWorldBounds(minsDebug, maxsDebug);
95 const vector centerDebug = vector.Lerp(minsDebug, maxsDebug, 0.5);
96
97 // Hold peak value for 1s
98 if (m_fAgeTime - m_fdVelocityPeakAgeTime > 1 || m_fdVelocity > m_fdVelocityPeak)
99 {
100 m_Text = DebugTextWorldSpace.Create(GetWorld(), m_fdVelocity.ToString(1, 2) + "/" + soundThreshold.ToString(1, 2) + "/" + GetPhysics().GetMass().ToString(), DebugTextFlags.FACE_CAMERA, centerDebug[0], centerDebug[1], centerDebug[2], 20);
101 m_fdVelocityPeak = m_fdVelocity;
102 m_fdVelocityPeakAgeTime = m_fAgeTime;
103 }
104 }
105 }
106
107 void SoundDebugPlaySound(float soundThreshold, float dVelocity, vector pos)
108 {
109 if (DiagMenu.GetBool(SCR_DebugMenuID.DEBUGUI_SOUNDS_MPDESTRUCTION_SHOW_IMPULSEVALUES))
110 {
111 m_Text = DebugTextWorldSpace.Create(GetWorld(), dVelocity.ToString(1, 2) + "/" + soundThreshold.ToString(1, 2) + "/" + GetPhysics().GetMass().ToString(), DebugTextFlags.FACE_CAMERA, pos[0], pos[1], pos[2], 20, COLOR_BLUE);
112 m_fdVelocityPeakAgeTime = m_fAgeTime + 1;
113 }
114 }
115
116#endif // ENABLE_DIAG
117
118 //------------------------------------------------------------------------------------------------
121 {
122 m_bDelete = true;
124 }
125
126 //------------------------------------------------------------------------------------------------
128 {
130 SetFlags(EntityFlags.ACTIVE, true);
131 }
132
133#endif // ENABLE_BASE_DESTRUCTION
134}
bool IsGamePlaying()
SCR_BaseDebrisSmallEntityClass m_bDelete
Whether this debris has reached end of its lifetime and should be deleted.
void SCR_BaseDebrisSmallEntity(IEntitySource src, IEntity parent)
float m_fLifeTime
The lifetime in seconds.
float m_fAgeTime
Entity age in seconds. After this time is bigger thatn m_fLifeTime, debris will despawn.
void DeleteDebris()
Delete debris - unregisters it from the list and makes it scale down and delete.
SCR_DebugMenuID
This enum contains all IDs for DiagMenu entries added in script.
Definition DebugMenuID.c:4
ArmaReforgerScripted GetGame()
Definition game.c:1398
enum SCR_ECompassType EntityEditorProps(category:"GameScripted/Gadgets", description:"Compass", color:"0 0 255 255")
Prefab data class for compass component.
vector position
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
proto external EntityEvent SetEventMask(EntityEvent e)
proto external Physics GetPhysics()
void EOnFrame(IEntity owner, float timeSlice)
proto external EntityEvent ClearEventMask(EntityEvent e)
proto external BaseWorld GetWorld()
proto external EntityFlags SetFlags(EntityFlags flags, bool recursively=false)
proto external void GetWorldBounds(out vector mins, out vector maxs)
const int COLOR_BLUE
Definition constants.c:23
DebugTextFlags
SCR_FieldOfViewSettings Attribute
EntityEvent
Various entity events.
Definition EntityEvent.c:14
EntityFlags
Various entity flags.
Definition EntityFlags.c:14
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.