Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
bottle_base.c
Go to the documentation of this file.
2 {
3  POURING = 1,
4  EMPTYING = 0,
5 }
6 
7 class Bottle_Base extends Edible_Base
8 {
9  //Particles
10  protected Particle m_ParticleCooking;
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  const string SOUND_BOILING_START = "Boiling_SoundSet";
39  const string SOUND_BOILING_DONE = "Boiling_Done_SoundSet";
40  const string SOUND_DRYING_START = "Drying_SoundSet";
41  const string SOUND_DRYING_DONE = "Drying_Done_SoundSet";
42 
44  private const float QUANTITY_EMPTIED_PER_SEC_DEFAULT = 200; //default
45 
46  void Bottle_Base()
47  {
48  RegisterNetSyncVariableInt("m_CookingMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
49  RegisterNetSyncVariableBool("m_CookingIsDone");
50  RegisterNetSyncVariableBool("m_CookingIsEmpty");
51  RegisterNetSyncVariableBool("m_CookingIsBurned");
52 
54  }
55 
56  void ~Bottle_Base()
57  {
58  SEffectManager.DestroyEffect(m_PouringLoopSound);
59  SEffectManager.DestroyEffect(m_EmptyingLoopSound);
60  }
61 
62  override void EEDelete( EntityAI parent )
63  {
64  super.EEDelete( parent );
65 
66  //remove audio visuals
68  }
69 
70  override void EECargoIn(EntityAI item)
71  {
72  super.EECargoIn(item);
73 
74  MiscGameplayFunctions.SoakItemInsideParentContainingLiquidAboveThreshold(ItemBase.Cast(item), this);
75  }
76 
77  //================================================================
78  // PARTICLES & SOUNDS
79  //================================================================
80  //Refreshes the audio and partcile effects on cooking pot
81  //is_done - is the food baked, boiled, dried?
82  //is_empty - is cooking quipment (cargo) empty?
83  //is_burned - is any of the food items in the cargo in burned food stage?
84  override void Synchronize()
85  {
86  SetSynchDirty();
87  }
88 
89  override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
90  {
91  super.OnRPC(sender, rpc_type, ctx);
92 
93  Param1<bool> p = new Param1<bool>(false);
94 
95  if (!ctx.Read(p))
96  return;
97 
98  bool play = p.param1;
99  switch (rpc_type)
100  {
101  case SoundTypeBottle.POURING:
102  if (play)
104  else
106 
107  break;
108 
109  case SoundTypeBottle.EMPTYING:
110  if (play)
112  else
114 
115  break;
116  }
117  }
118 
119  override void OnVariablesSynchronized()
120  {
121  super.OnVariablesSynchronized();
122 
124  {
126  }
127  else
128  {
130  }
131  }
132 
134  {
136 
137  Synchronize();
138  }
139 
140  void RefreshAudioVisualsOnClient( CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned )
141  {
142  m_CookingMethod = cooking_method;
143  m_CookingIsDone = is_done;
144  m_CookingIsEmpty = is_empty;
145  m_CookingIsBurned = is_burned;
146 
147  Synchronize();
148  }
149 
150  void RefreshAudioVisuals(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
151  {
152  string soundName;
153  int particleId;
154 
155  //if at least one of the food items is burned
156  if (is_burned)
157  {
158  soundName = SOUND_BURNING_DONE;
159  particleId = PARTICLE_BURNING_DONE;
160  }
161  //proper cooking methods
162  else
163  {
164  switch (cooking_method)
165  {
166  case CookingMethodType.BOILING:
167  if (is_empty)
168  {
169  soundName = SOUND_BOILING_EMPTY;
170  particleId = PARTICLE_BOILING_EMPTY;
171  }
172  else
173  {
174  if (is_done)
175  {
176  soundName = SOUND_BOILING_DONE;
177  particleId = PARTICLE_BOILING_DONE;
178  }
179  else
180  {
181  soundName = SOUND_BOILING_START;
182  particleId = PARTICLE_BOILING_START;
183  }
184  }
185 
186  break;
187 
188  case CookingMethodType.BAKING:
189  if (is_done)
190  {
191  soundName = SOUND_BAKING_DONE;
192  particleId = PARTICLE_BAKING_DONE;
193  }
194  else
195  {
196  soundName = SOUND_BAKING_START;
197  particleId = PARTICLE_BAKING_START ;
198  }
199 
200  break;
201 
202  case CookingMethodType.DRYING:
203  if (is_done)
204  {
205  soundName = SOUND_DRYING_DONE;
206  particleId = PARTICLE_DRYING_DONE;
207  }
208  else
209  {
210  soundName = SOUND_DRYING_START;
211  particleId = PARTICLE_DRYING_START;
212  }
213 
214  break;
215 
216  default:
217  soundName = "";
218  particleId = ParticleList.NONE;
219 
220  break;
221  }
222  }
223 
224  //play effects
225  ParticleCookingStart(particleId);
226  SoundCookingStart(soundName);
227  }
228 
230  {
233  }
234 
235  //particles
237  {
238  #ifndef SERVER
240  {
241  //stop previous particles
243 
244  //create new
245  vector localPos = MiscGameplayFunctions.GetSteamPosition(GetHierarchyParent());
246  m_ParticleCooking = ParticleManager.GetInstance().PlayInWorld(particle_id, localPos);
248 
249  }
250  #endif
251  }
252 
254  {
255  if (m_ParticleCooking && GetGame() && !GetGame().IsDedicatedServer())
256  {
257  m_ParticleCooking.Stop();
258  m_ParticleCooking = null;
260  }
261  }
262 
264  {
265  if (!m_PouringLoopSound || !m_PouringLoopSound.IsSoundPlaying())
266  {
267  m_PouringLoopSound = SEffectManager.PlaySoundOnObject(GetPouringSoundset(), this, 0, 0, true);
268  }
269  }
270 
272  {
273  if (m_PouringLoopSound)
274  m_PouringLoopSound.SoundStop();
275  }
276 
278  {
279  if (!m_EmptyingLoopSound || !m_EmptyingLoopSound.IsSoundPlaying())
280  {
281  m_EmptyingLoopSound = SEffectManager.PlaySoundOnObject(GetEmptyingLoopSoundset(), this, 0, 0, true);
282  }
283  }
284 
286  {
288  m_EmptyingLoopSound.SoundStop();
289 
290  EffectSound sound = SEffectManager.PlaySoundOnObject(GetEmptyingEndSoundset(), this);
291  sound.SetAutodestroy(true);
292  }
293 
295  {
296  vector pos = GetPosition();
297  string surfaceType = GetGame().GetPlayer().GetSurfaceType();
298  string soundSet = "";
299 
300  bool diggable = GetGame().IsSurfaceDigable(surfaceType);
301 
302  if (!diggable)
303  {
304  soundSet = GetEmptyingLoopSoundsetHard();
305  }
306  else if (diggable)
307  {
308  soundSet = GetEmptyingLoopSoundsetSoft();
309  }
310  else if (GetGame().SurfaceIsPond(pos[0], pos[2]) || GetGame().SurfaceIsSea(pos[0], pos[2]))
311  {
312  soundSet = GetEmptyingLoopSoundsetWater();
313  }
314 
315  return soundSet;
316  }
317 
319  {
320  vector pos = GetPosition();
321  string surfaceType = GetGame().GetPlayer().GetSurfaceType();
322  string soundSet = "";
323 
324  bool diggable = GetGame().IsSurfaceDigable(surfaceType);
325 
326  if (!diggable)
327  {
328  soundSet = GetEmptyingEndSoundsetHard();
329  }
330  else if (diggable)
331  {
332  soundSet = GetEmptyingEndSoundsetSoft();
333  }
334  else if (GetGame().SurfaceIsPond(pos[0], pos[2]) || GetGame().SurfaceIsSea(pos[0], pos[2]))
335  {
336  soundSet = GetEmptyingEndSoundsetWater();
337  }
338 
339  return soundSet;
340  }
341 
342  string GetPouringSoundset();
343  string GetEmptyingLoopSoundsetHard();
344  string GetEmptyingLoopSoundsetSoft();
345  string GetEmptyingLoopSoundsetWater();
346  string GetEmptyingEndSoundsetHard();
347  string GetEmptyingEndSoundsetSoft();
348  string GetEmptyingEndSoundsetWater();
349 
352  {
353  return m_LiquidEmptyRate;
354  }
355 
356  override void SetActions()
357  {
358  super.SetActions();
359 
373  }
374 
375  override void OnDebugSpawn()
376  {
377  SetQuantityMax();
378  }
379 }
ItemBase
Definition: inventoryitem.c:730
SOUND_BOILING_EMPTY
const string SOUND_BOILING_EMPTY
Definition: bottle_base.c:37
StopEmptyingLoopSound
void StopEmptyingLoopSound()
Definition: bottle_base.c:285
GetGame
proto native CGame GetGame()
PARTICLE_BAKING_DONE
protected int PARTICLE_BAKING_DONE
Definition: bottle_base.c:19
m_ParticlePlaying
protected int m_ParticlePlaying
Definition: bottle_base.c:11
RemoveAudioVisuals
void RemoveAudioVisuals()
Definition: bottle_base.c:229
POURING
@ POURING
Definition: bottle_base.c:3
m_CookingMethod
protected CookingMethodType m_CookingMethod
Definition: bottle_base.c:31
GetLiquidEmptyRate
float GetLiquidEmptyRate()
Returns base liquid empty rate (absolute)..preferrably use the 'GetLiquidThroughputCoef' instead.
Definition: bottle_base.c:351
particle_id
int particle_id
Definition: smokesimulation.c:3
PARTICLE_DRYING_DONE
protected int PARTICLE_DRYING_DONE
Definition: bottle_base.c:22
ActionPourLiquid
Definition: actionpourliquid.c:11
Particle
Legacy way of using particles in the game.
Definition: particle.c:6
PARTICLE_BAKING_START
protected int PARTICLE_BAKING_START
Definition: bottle_base.c:18
SOUND_BAKING_DONE
const string SOUND_BAKING_DONE
Definition: edible_base.c:5
m_LiquidEmptyRate
float m_LiquidEmptyRate
Definition: bottle_base.c:43
m_CookingIsEmpty
protected bool m_CookingIsEmpty
Definition: bottle_base.c:33
ActionFillGeneratorTank
Definition: actionfillgeneratortank.c:11
EEDelete
override void EEDelete(EntityAI parent)
Definition: bottle_base.c:62
QUANTITY_EMPTIED_PER_SEC_DEFAULT
const private float QUANTITY_EMPTIED_PER_SEC_DEFAULT
Definition: bottle_base.c:44
RefreshAudioVisualsOnClient
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
Definition: bottle_base.c:140
SOUND_BOILING_START
const string SOUND_BOILING_START
Definition: bottle_base.c:38
Bottle_Base
void Bottle_Base()
Definition: bottle_base.c:46
SOUND_DRYING_DONE
const string SOUND_DRYING_DONE
Definition: bottle_base.c:41
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: bottle_base.c:119
SoundCookingStart
protected void SoundCookingStart(string sound_name)
Definition: edible_base.c:514
PARTICLE_BOILING_START
protected int PARTICLE_BOILING_START
Definition: bottle_base.c:15
OnDebugSpawn
override void OnDebugSpawn()
Definition: bottle_base.c:375
SOUND_BOILING_DONE
const string SOUND_BOILING_DONE
Definition: bottle_base.c:39
Bottle_Base
Definition: canistergasoline.c:1
~Bottle_Base
void ~Bottle_Base()
Definition: bottle_base.c:56
ActionDrainLiquid
Definition: actiondrainliquid.c:11
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
PlayerIdentity
The class that will be instanced (moddable)
Definition: gameplay.c:377
PARTICLE_BOILING_DONE
protected int PARTICLE_BOILING_DONE
Definition: bottle_base.c:16
ActionDrink
Definition: actiondrink.c:9
ParticleCookingStop
void ParticleCookingStop()
Definition: bottle_base.c:253
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
ParticleList
Definition: particlelist.c:11
ParticleCookingStart
void ParticleCookingStart(int particle_id)
Definition: bottle_base.c:236
vector
Definition: enconvert.c:105
EECargoIn
override void EECargoIn(EntityAI item)
Definition: bottle_base.c:70
GetEmptyingLoopSoundset
string GetEmptyingLoopSoundset()
Definition: bottle_base.c:294
ActionWashHandsItemContinuous
Definition: actionwashhandsitemcontinuous.c:9
PARTICLE_DRYING_START
protected int PARTICLE_DRYING_START
Definition: bottle_base.c:21
PARTICLE_BOILING_EMPTY
protected int PARTICLE_BOILING_EMPTY
Definition: bottle_base.c:14
StopPouringLoopSound
void StopPouringLoopSound()
Definition: bottle_base.c:271
AddAction
void AddAction(typename actionName)
Definition: advancedcommunication.c:86
Synchronize
override void Synchronize()
Definition: bottle_base.c:84
ActionFillFuel
Definition: actionfillfuel.c:11
PlayEmptyingLoopSound
void PlayEmptyingLoopSound()
Definition: bottle_base.c:277
PlayPouringLoopSound
void PlayPouringLoopSound()
Definition: bottle_base.c:263
ActionWaterPlant
Definition: actionwaterplant.c:11
ActionFillBottleBase
Definition: actionfillbottlebase.c:22
ActionForceDrink
Definition: actionforcedrink.c:9
PARTICLE_BURNING_DONE
protected int PARTICLE_BURNING_DONE
Definition: bottle_base.c:24
RemoveAudioVisualsOnClient
void RemoveAudioVisualsOnClient()
Definition: bottle_base.c:133
SOUND_BAKING_START
const string SOUND_BAKING_START
Definition: edible_base.c:4
SoundTypeBottle
SoundTypeBottle
Definition: bottle_base.c:1
SoundCookingStop
protected void SoundCookingStop()
Definition: edible_base.c:527
SOUND_BURNING_DONE
const string SOUND_BURNING_DONE
Definition: edible_base.c:6
m_CookingIsBurned
protected bool m_CookingIsBurned
Definition: bottle_base.c:34
SetQuantityMax
void SetQuantityMax()
Definition: itembase.c:3226
m_CookingIsDone
protected bool m_CookingIsDone
Definition: bottle_base.c:32
CookingMethodType
CookingMethodType
Definition: cooking.c:1
OnRPC
override void OnRPC(PlayerIdentity sender, int rpc_type, ParamsReadContext ctx)
Definition: bottle_base.c:89
ActionExtinguishFireplaceByLiquid
ActionFertilizeSlotCB ActionExtinguishFireplaceByLiquid
ActionEmptyBottleBase
Definition: actionemptybottlebase.c:14
RefreshAudioVisuals
void RefreshAudioVisuals(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
Definition: bottle_base.c:150
ParticleManager
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor)
Definition: particlemanager.c:84
GetEmptyingEndSoundset
string GetEmptyingEndSoundset()
Definition: bottle_base.c:318
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
ActionWaterGardenSlot
Definition: actionwatergardenslot.c:11
EntityAI
Definition: building.c:5
m_ParticleCooking
enum SoundTypeBottle m_ParticleCooking
ActionFillCoolant
Definition: actionfillcoolant.c:11
m_EmptyingLoopSound
protected EffectSound m_EmptyingLoopSound
Definition: bottle_base.c:28
m_PouringLoopSound
protected EffectSound m_PouringLoopSound
Definition: bottle_base.c:27
Edible_Base
Definition: bearsteakmeat.c:1
EMPTYING
@ EMPTYING
Definition: bottle_base.c:4
SOUND_DRYING_START
const string SOUND_DRYING_START
Definition: bottle_base.c:40