DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
EffectTrigger.c
См. документацию.
1// Base class for "Effect triggers"
2// Registers in TriggerEffectManager and handles parameter setting through cfgEffectArea.json file
4{
5 int m_AroundPartId; // The main particles spawned around player when in trigger
6 int m_TinyPartId; // The smaller particles spawned around player when in trigger
7 int m_PPERequester; // The Post Processing used when player is in trigger
12 EffectArea m_EffectArea;
14
15 #ifdef DIAG_DEVELOPER
16 Shape m_DbgShape;
17 bool m_DebugShapeActive;
18 #endif
19
21 {
22 RegisterNetSyncVariableInt("m_AroundPartId");
23 RegisterNetSyncVariableInt("m_TinyPartId");
24 RegisterNetSyncVariableInt("m_PPERequester");
25 RegisterNetSyncVariableInt("m_EffectsPriority");
26
28 m_Manager.RegisterTriggerType( this );
29 }
30
31 // ----------------------------------------------
32 // CUSTOM EVENTS
33 // ----------------------------------------------
34
35 void SetLocalEffects( int aroundPartId, int tinyPartId, int ppeRequesterIdx )
36 {
37 m_AroundPartId = aroundPartId;
38 m_TinyPartId = tinyPartId;
39 m_PPERequester = ppeRequesterIdx;
40
41 SetSynchDirty();
42 }
43
44 EffectArea GetEffectArea()
45 {
46 return m_EffectArea;
47 }
48
49 void Init(EffectArea area, int priority)
50 {
51 m_EffectArea = area;
52 m_EffectsPriority = priority;
53 }
54
56 {
57 return m_EffectsPriority;
58 }
59
61 {
62 return "";
63 }
64
65 void SetupClientEffects(bool enable, notnull PlayerBase player)
66 {
67 if ( !m_Manager.IsPlayerInTriggerType( player, this ) )
68 {
69 if (enable)
70 {
71 player.SetContaminatedEffectEx( true, m_PPERequester, m_AroundPartId, m_TinyPartId, GetAmbientSoundsetName() );
72 }
73 else
74 {
75 player.SetContaminatedEffectEx( false, m_PPERequester );
76 }
77 }
78 }
79
80
81 // ----------------------------------------------
82 // TRIGGER EVENTS
83 // ----------------------------------------------
84
85 override void EOnFrame(IEntity other, float timeSlice)
86 {
87 m_DeltaTime = timeSlice;
88 }
89
90 override bool CanAddObjectAsInsider(Object object)
91 {
92 #ifdef SERVER
93 DayZCreatureAI creature = DayZCreatureAI.Cast( object );
94 if(creature)
95 {
96 return !creature.ResistContaminatedEffect();
97 }
98 else
99 {
100 PlayerBase player = PlayerBase.Cast(object);
101 return player != null;
102 }
103 #else
104 PlayerBase player = PlayerBase.Cast(object);
105 return (player && player.IsControlledPlayer());
106 #endif
107 }
108
109 override protected void OnStayClientEvent(TriggerInsider insider, float deltaTime)
110 {
111 super.OnStayClientEvent(insider, deltaTime);
112 PlayerBase player = PlayerBase.Cast(insider.GetObject());
113 if (player)
114 player.RequestTriggerEffect(this, m_PPERequester, m_AroundPartId, m_TinyPartId, GetAmbientSoundsetName() );
115 }
116
117 override void OnEnterServerEvent( TriggerInsider insider )
118 {
119 super.OnEnterServerEvent( insider );
120
121 // We don't need to test the trigger count as Modifiers handle such cases already
122 if ( insider )
123 {
124 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
125
126 if(playerInsider)
127 {
128
129 m_Manager.OnPlayerEnter( playerInsider, this );
130 }
131
132 }
133
134 }
135
136 override void OnEnterClientEvent( TriggerInsider insider )
137 {
138 super.OnEnterClientEvent( insider );
139
140 if ( insider )
141 {
142 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
143
144 // We will only handle the controlled player, as effects are only relevant to this player instance
145 if (playerInsider && playerInsider.IsControlledPlayer() )
146 {
147 //SetupClientEffects(true, playerInsider);
148 // We then handle the update of player trigger state in manager
149 m_Manager.OnPlayerEnter( playerInsider, this );
150 }
151 }
152 }
153
154
155 override void OnLeaveServerEvent( TriggerInsider insider )
156 {
157 super.OnLeaveServerEvent( insider );
158
159 if ( insider )
160 {
161 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
162
163 if ( playerInsider )
164 m_Manager.OnPlayerExit( playerInsider, this );
165 }
166 }
167
168
169
170 override void OnLeaveClientEvent( TriggerInsider insider )
171 {
172 super.OnLeaveClientEvent( insider );
173
174 if ( insider )
175 {
176 // Make sure you pass the set variable for PPE effect
177 // It will not remove the correct one if START and STOP don't point to the same Requester
178 PlayerBase playerInsider = PlayerBase.Cast( insider.GetObject() );
179
180 // We will only handle the controlled player, as effects are only relevant to this player instance
181 if ( playerInsider && playerInsider.IsControlledPlayer() )
182 {
183 // We first handle the update of player trigger state in manager
184 m_Manager.OnPlayerExit( playerInsider, this );
185 //SetupClientEffects(false, playerInsider);
186 }
187 }
188 }
189
190 // We remove from trigger update DEAD or RESISTANT entities to limit the amount of entities to update
191 override bool ShouldRemoveInsider( TriggerInsider insider )
192 {
193 return !insider.GetObject().IsAlive();
194 }
195
196 // Used to apply the desired effect to all entities present in one trigger of the specified type
197 // NOTE : This is really not optimal, if you want to add new trigger types, you will have to test for them...
198 static void TriggerEffect( EntityAI insider, typename triggerType ) {}
199
200 #ifdef DIAG_DEVELOPER
201 // overriden so it doesnt refresh the shape every call while keeping the insider coloring functional
202 override void DebugDmgTrigger( vector pos, vector orientation, vector min, vector max, float radius, string dmgType, array<ref TriggerInsider> insiders)
203 {
204 bool enableDebug = DiagMenu.GetBool(DiagMenuIDs.TRIGGER_DEBUG);
205 if (enableDebug)
206 {
207 if (GetGame().IsMultiplayer() && GetGame().IsServer())
208 return;
209
210 if (!m_DebugShapeActive)
211 {
212 m_DbgShape = DrawDebugShape(pos, min, max, radius, COLOR_GREEN_A);
213 m_DebugShapeActive = true;
214 }
215
216 if (GetGame().IsMultiplayer() || GetGame().IsServer())
217 m_dbgInsiders = insiders;
218
219 if (m_dbgInsiders.Count() > 0)
220 m_DbgShape.SetColor(COLOR_YELLOW_A);
221 else
222 m_DbgShape.SetColor(COLOR_GREEN_A);
223 }
224 else if (m_DebugShapeActive)
225 {
226 CleanupDebugShapes(dbgTargets);
227 m_DebugShapeActive = false;
228 }
229 }
230 #endif
231
232}
void DrawDebugShape()
Определения BleedingSource.c:171
DiagMenuIDs
Определения EDiagMenuIDs.c:2
Trigger with cylinder shape.
Определения CylinderTrigger.c:3
do not process rotations !
Определения DayZAnimal.c:612
Определения EnDebug.c:233
int m_EffectsPriority
Определения EffectTrigger.c:13
float m_TimeAccuStay
Определения EffectTrigger.c:9
void SetLocalEffects(int aroundPartId, int tinyPartId, int ppeRequesterIdx)
Определения EffectTrigger.c:35
int m_PPERequester
Определения EffectTrigger.c:7
EffectArea GetEffectArea()
Определения EffectTrigger.c:44
void EffectTrigger()
Определения EffectTrigger.c:20
static void TriggerEffect(EntityAI insider, typename triggerType)
Определения EffectTrigger.c:198
override void EOnFrame(IEntity other, float timeSlice)
Определения EffectTrigger.c:85
override string GetAmbientSoundsetName()
Определения ContaminatedTrigger.c:84
void Init(EffectArea area, int priority)
Определения EffectTrigger.c:49
override bool CanAddObjectAsInsider(Object object)
Определения EffectTrigger.c:90
int GetEffectsPriority()
Определения EffectTrigger.c:55
override bool ShouldRemoveInsider(TriggerInsider insider)
Определения EffectTrigger.c:191
float m_DeltaTime
Определения EffectTrigger.c:8
EffectArea m_EffectArea
Определения EffectTrigger.c:12
void SetupClientEffects(bool enable, notnull PlayerBase player)
Определения EffectTrigger.c:65
int m_TinyPartId
Определения EffectTrigger.c:6
string GetAmbientSoundsetName()
Определения EffectTrigger.c:60
override void OnLeaveServerEvent(TriggerInsider insider)
Определения EffectTrigger.c:155
TriggerEffectManager m_Manager
Определения EffectTrigger.c:11
override void OnEnterClientEvent(TriggerInsider insider)
Определения EffectTrigger.c:136
int m_AroundPartId
Определения EffectTrigger.c:5
override void OnLeaveClientEvent(TriggerInsider insider)
Определения EffectTrigger.c:170
bool m_DealDamageFlag
Определения EffectTrigger.c:10
override void OnEnterServerEvent(TriggerInsider insider)
Определения EffectTrigger.c:117
void OnStayClientEvent(TriggerInsider insider, float deltaTime)
Определения EffectTrigger.c:109
Определения Building.c:6
Определения EnEntity.c:165
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
static TriggerEffectManager GetInstance()
Определения TriggerEffectManager.c:21
Object GetObject()
Определения Trigger.c:28
The object which is in a trigger and its metadata.
Определения Trigger.c:3
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения EnConvert.c:106
proto native CGame GetGame()
const int COLOR_YELLOW_A
Определения constants.c:72
const int COLOR_GREEN_A
Определения constants.c:70
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead