Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
underobjectdecalspawncomponent.c
Go to the documentation of this file.
2{
3 bool m_RandomizeRotation = true;
4
5 float m_ScaleMin = 0.1;
6 float m_ScaleMax = 1.0;
7
8 vector m_PositionOffset = vector.Zero;
9}
10
11class UnderObjectDecalSpawnComponent
12{
13 private const string SURFACE_PARAM_DECAL_NAME = "underObjectDecal";
14
16
17 protected Object m_Parent;
18 protected Object m_Decal;
19
20 private float m_LastScaleValue;
21
22 void UnderObjectDecalSpawnComponent(notnull UnderObjectDecalSpawnSettings pSettings, notnull Object pParent)
23 {
24 m_Settings = pSettings;
25 m_Parent = pParent;
26 }
27
28 private string GetObjectNameFromSurfaceConfig(string surfaceParamName = SURFACE_PARAM_DECAL_NAME)
29 {
30 string surfaceType
31 int liquidType;
32 g_Game.SurfaceUnderObjectCorrectedLiquid(m_Parent, surfaceType, liquidType);
33
34 return Surface.GetParamText(surfaceType, surfaceParamName);
35 }
36
37 void SpawnDecal()
38 {
39 if (m_Decal)
40 return;
41
42 #ifndef SERVER
43 m_Decal = g_Game.CreateObjectEx(
44 GetObjectNameFromSurfaceConfig(),
45 m_Parent.GetPosition() + m_Settings.m_PositionOffset,
47 );
48
49 if (m_Decal)
50 {
51 if (m_Settings.m_RandomizeRotation)
52 {
53 vector v;
54 v[0] = Math.RandomFloat(-Math.PI, Math.PI);
55 m_Decal.SetOrientation(v * Math.RAD2DEG);
56 }
57
58 m_Decal.SetScale(m_Settings.m_ScaleMin);
59 }
60 #endif
61 }
62
63 void RemoveDecal()
64 {
65 #ifndef SERVER
66 if (m_Decal)
67 m_Decal.Delete();
68 #endif
69 }
70
71 void UpdateSize(float pScaleValue)
72 {
73 #ifndef SERVER
74 if (m_Decal)
75 {
76 if (pScaleValue != m_LastScaleValue)
77 {
78 m_LastScaleValue = m_Decal.GetScale();
79 m_Decal.SetScale(Math.Clamp(pScaleValue, m_Settings.m_ScaleMin, m_Settings.m_ScaleMax));
80 }
81 }
82 #endif
83 }
84}
const int ECE_LOCAL
const int ECE_PLACE_ON_SURFACE
Definition enmath.c:7
DayZGame g_Game
Definition dayzgame.c:3868
proto native void RemoveDecal(hDecal decal)
Widget m_Parent
Definition sizetochild.c:92
ref UnderObjectDecalSpawnSettings m_Settings
class UnderObjectDecalSpawnSettings SURFACE_PARAM_DECAL_NAME