Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
bottle_base.c
Go to the documentation of this file.
2{
3 POURING = 1,
4 EMPTYING = 0,
5}
6
7class Bottle_Base extends Edible_Base
8{
9 //Particles
11 protected int m_ParticlePlaying = ParticleList.INVALID;
12 //Boiling
13 //waiting for proper particle effects
14 protected int PARTICLE_BOILING_EMPTY = ParticleList.COOKING_BOILING_EMPTY;
15 protected int PARTICLE_BOILING_START = ParticleList.COOKING_BOILING_START;
16 protected int PARTICLE_BOILING_DONE = ParticleList.COOKING_BOILING_DONE;
17 //Baking
18 protected int PARTICLE_BAKING_START = ParticleList.COOKING_BAKING_START;
19 protected int PARTICLE_BAKING_DONE = ParticleList.COOKING_BAKING_DONE;
20 //Drying
21 protected int PARTICLE_DRYING_START = ParticleList.COOKING_DRYING_START;
22 protected int PARTICLE_DRYING_DONE = ParticleList.COOKING_DRYING_DONE;
23 //Burning
24 protected int PARTICLE_BURNING_DONE = ParticleList.COOKING_BURNING_DONE;
25
26 //Sounds
29
30 //cooking data
32 protected bool m_CookingIsDone;
33 protected bool m_CookingIsEmpty;
34 protected bool m_CookingIsBurned;
35
36 //Boiling
37 const string SOUND_BOILING_EMPTY = "Boiling_SoundSet";
38
40 private const float QUANTITY_EMPTIED_PER_SEC_DEFAULT = 200; //default
41
42 void Bottle_Base()
43 {
44 RegisterNetSyncVariableInt("m_CookingMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
45 RegisterNetSyncVariableBool("m_CookingIsDone");
46 RegisterNetSyncVariableBool("m_CookingIsEmpty");
47 RegisterNetSyncVariableBool("m_CookingIsBurned");
48
49 m_LiquidEmptyRate = QUANTITY_EMPTIED_PER_SEC_DEFAULT;
50 }
51
52 void ~Bottle_Base()
53 {
56 }
57
58 override void EEDelete( EntityAI parent )
59 {
60 super.EEDelete( parent );
61
62 //remove audio visuals
63 RemoveAudioVisuals();
64 }
65
66 override void EECargoIn(EntityAI item)
67 {
68 super.EECargoIn(item);
69
70 MiscGameplayFunctions.SoakItemInsideParentContainingLiquidAboveThreshold(ItemBase.Cast(item), this);
71 }
72
73 override void OnFreezeStateChangeServer()
74 {
75 super.OnFreezeStateChangeServer();
76
77 //soak CARGO items on unfreeze
78 CargoBase cargo;
79 if (!GetIsFrozen() && GetLiquidType() != 0 && Class.CastTo(cargo,GetInventory().GetCargo()))
80 {
81 int count = cargo.GetItemCount();
82 for (int i = 0; i < count; ++i)
83 {
84 MiscGameplayFunctions.SoakItemInsideParentContainingLiquidAboveThreshold(ItemBase.Cast(cargo.GetItem(i)), this);
85 }
86 }
87 }
88
89 override int GetConsumptionPenaltyContext()
90 {
93 }
94
95 //================================================================
96 // PARTICLES & SOUNDS
97 //================================================================
98 //Refreshes the audio and partcile effects on cooking pot
99 //is_done - is the food baked, boiled, dried?
100 //is_empty - is cooking quipment (cargo) empty?
101 //is_burned - is any of the food items in the cargo in burned food stage?
102 override void Synchronize()
103 {
104 SetSynchDirty();
105 }
106
107 override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
108 {
109 super.OnRPC(sender, rpc_type, ctx);
110
111 Param1<bool> p = new Param1<bool>(false);
112
113 if (!ctx.Read(p))
114 return;
115
116 bool play = p.param1;
117 switch (rpc_type)
118 {
119 case SoundTypeBottle.POURING:
120 if (play)
121 PlayPouringLoopSound();
122 else
123 StopPouringLoopSound();
124
125 break;
126
127 case SoundTypeBottle.EMPTYING:
128 if (play)
129 PlayEmptyingLoopSound();
130 else
131 StopEmptyingLoopSound();
132
133 break;
134 }
135 }
136
137 override void OnVariablesSynchronized()
138 {
139 super.OnVariablesSynchronized();
140
142 {
144 }
145 else
146 {
147 RemoveAudioVisuals();
148 }
149 }
150
152 {
154
155 Synchronize();
156 }
157
158 override void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned )
159 {
160 m_CookingMethod = cooking_method;
161 m_CookingIsDone = is_done;
162 m_CookingIsEmpty = is_empty;
163 m_CookingIsBurned = is_burned;
164
165 Synchronize();
166 }
167
169 void RefreshAudioVisuals(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
170 {
171 string soundName = "";
172 int particleId;
173
174 switch (cooking_method)
175 {
176 case CookingMethodType.BOILING:
177 soundName = SOUND_BOILING_EMPTY;
178
179 if (is_empty)
180 {
181 particleId = PARTICLE_BOILING_EMPTY;
182 }
183 else
184 {
185 if (is_done)
186 particleId = PARTICLE_BOILING_DONE;
187 else
188 particleId = PARTICLE_BOILING_START;
189 }
190
191 break;
192
193 case CookingMethodType.BAKING:
194 if (is_done)
195 particleId = PARTICLE_BAKING_DONE;
196 else
197 particleId = PARTICLE_BAKING_START;
198
199 break;
200
201 case CookingMethodType.DRYING:
202 if (is_done)
203 particleId = PARTICLE_DRYING_DONE;
204 else
205 particleId = PARTICLE_DRYING_START;
206
207 break;
208
209 default:
210 soundName = "";
211 particleId = ParticleList.NONE;
212
213 break;
214 }
215
216 //if at least one of the food items is burned
217 if (is_burned)
218 {
219 particleId = PARTICLE_BURNING_DONE;
220 }
221
222 //play effects
223 ParticleCookingStart(particleId);
224 SoundCookingStart(soundName);
225 }
226
227 void RemoveAudioVisuals()
228 {
229 ParticleCookingStop();
231 }
232
233 //particles
234 void ParticleCookingStart(int particle_id)
235 {
236 #ifndef SERVER
238 {
239 //stop previous particles
240 ParticleCookingStop();
241
242 //create new
243 vector localPos = MiscGameplayFunctions.GetSteamPosition(GetHierarchyParent());
244 m_ParticleCooking = ParticleManager.GetInstance().PlayInWorld(particle_id, localPos);
246
247 }
248 #endif
249 }
250
251 void ParticleCookingStop()
252 {
253 if (m_ParticleCooking && GetGame() && !GetGame().IsDedicatedServer())
254 {
255 m_ParticleCooking.Stop();
256 m_ParticleCooking = null;
258 }
259 }
260
261 void PlayPouringLoopSound()
262 {
264 {
265 m_PouringLoopSound = SEffectManager.PlaySoundOnObject(GetPouringSoundset(), this, 0, 0, true);
266 }
267 }
268
269 void StopPouringLoopSound()
270 {
273 }
274
275 void PlayEmptyingLoopSound()
276 {
278 {
279 m_EmptyingLoopSound = SEffectManager.PlaySoundOnObject(GetEmptyingLoopSoundset(), this, 0, 0, true);
280 }
281 }
282
283 void StopEmptyingLoopSound()
284 {
287
288 EffectSound sound = SEffectManager.PlaySoundOnObject(GetEmptyingEndSoundset(), this);
289 sound.SetAutodestroy(true);
290 }
291
292 string GetEmptyingLoopSoundset()
293 {
294 vector pos = GetPosition();
295 string surfaceType = GetGame().GetPlayer().GetSurfaceType();
296 string soundSet = "";
297
298 bool diggable = GetGame().IsSurfaceDigable(surfaceType);
299
300 if (!diggable)
301 {
302 soundSet = GetEmptyingLoopSoundsetHard();
303 }
304 else if (diggable)
305 {
306 soundSet = GetEmptyingLoopSoundsetSoft();
307 }
308 else if (GetGame().SurfaceIsPond(pos[0], pos[2]) || GetGame().SurfaceIsSea(pos[0], pos[2]))
309 {
310 soundSet = GetEmptyingLoopSoundsetWater();
311 }
312
313 return soundSet;
314 }
315
316 string GetEmptyingEndSoundset()
317 {
318 vector pos = GetPosition();
319 string surfaceType = GetGame().GetPlayer().GetSurfaceType();
320 string soundSet = "";
321
322 bool diggable = GetGame().IsSurfaceDigable(surfaceType);
323
324 if (!diggable)
325 {
326 soundSet = GetEmptyingEndSoundsetHard();
327 }
328 else if (diggable)
329 {
330 soundSet = GetEmptyingEndSoundsetSoft();
331 }
332 else if (GetGame().SurfaceIsPond(pos[0], pos[2]) || GetGame().SurfaceIsSea(pos[0], pos[2]))
333 {
334 soundSet = GetEmptyingEndSoundsetWater();
335 }
336
337 return soundSet;
338 }
339
340 string GetPouringSoundset();
341 string GetEmptyingLoopSoundsetHard();
342 string GetEmptyingLoopSoundsetSoft();
343 string GetEmptyingLoopSoundsetWater();
344 string GetEmptyingEndSoundsetHard();
345 string GetEmptyingEndSoundsetSoft();
346 string GetEmptyingEndSoundsetWater();
347
349 float GetLiquidEmptyRate()
350 {
351 return m_LiquidEmptyRate;
352 }
353
354 override void SetActions()
355 {
356 super.SetActions();
357
372 }
373
374 override void OnDebugSpawn()
375 {
377 }
378}
ActionExtinguishFireplaceByLiquidCB ActionContinuousBaseCB ActionExtinguishFireplaceByLiquid()
void AddAction(typename actionName)
void SetActions()
int PARTICLE_BAKING_DONE
Definition bottle_base.c:19
SoundTypeBottle
Definition bottle_base.c:2
@ POURING
Definition bottle_base.c:3
@ EMPTYING
Definition bottle_base.c:4
EffectSound m_PouringLoopSound
Definition bottle_base.c:27
float m_LiquidEmptyRate
Definition bottle_base.c:39
int PARTICLE_DRYING_DONE
Definition bottle_base.c:22
bool m_CookingIsBurned
Definition bottle_base.c:34
bool m_CookingIsEmpty
Definition bottle_base.c:33
int PARTICLE_BOILING_DONE
Definition bottle_base.c:16
EffectSound m_EmptyingLoopSound
Definition bottle_base.c:28
int PARTICLE_DRYING_START
Definition bottle_base.c:21
int PARTICLE_BAKING_START
Definition bottle_base.c:18
int PARTICLE_BURNING_DONE
Definition bottle_base.c:24
bool m_CookingIsDone
Definition bottle_base.c:32
CookingMethodType m_CookingMethod
Definition bottle_base.c:31
int PARTICLE_BOILING_EMPTY
Definition bottle_base.c:14
enum SoundTypeBottle m_ParticleCooking
int m_ParticlePlaying
Definition bottle_base.c:11
int PARTICLE_BOILING_START
Definition bottle_base.c:15
const string SOUND_BOILING_EMPTY
Definition bottle_base.c:37
int GetLiquidType()
bool IsSurfaceDigable(string surface)
Checks if the surface is digable.
Definition game.c:1211
represents base for cargo storage for entities
Definition cargo.c:7
Super root of all classes in Enforce script.
Definition enscript.c:11
string GetSurfaceType(SurfaceAnimationBone limbType)
Wrapper class for managing sound through SEffectManager.
Definition effectsound.c:5
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
void SoundStop()
Stops sound.
Legacy way of using particles in the game.
Definition particle.c:7
The class that will be instanced (moddable)
Definition gameplay.c:389
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySoundOnObject(string sound_set, Object parent_object, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Serialization general interface. Serializer API works with:
Definition serializer.c:56
void Synchronize()
override void EEDelete(EntityAI parent)
override void OnVariablesSynchronized()
CookingMethodType
Definition cooking.c:2
void SoundCookingStop()
void SoundCookingStart(string sound_name)
int GetConsumptionPenaltyContext()
proto native CGame GetGame()
class JsonUndergroundAreaTriggerData GetPosition
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
void SetQuantityMax()
Definition itembase.c:8207
void RemoveAudioVisualsOnClient()
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
override void OnRPC(ParamsReadContext ctx)
int particle_id