Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
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
12 //Boiling
13 //waiting for proper particle effects
17 //Baking
20 //Drying
23 //Burning
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
43 {
44 RegisterNetSyncVariableInt("m_CookingMethod", CookingMethodType.NONE, CookingMethodType.COUNT);
45 RegisterNetSyncVariableBool("m_CookingIsDone");
46 RegisterNetSyncVariableBool("m_CookingIsEmpty");
47 RegisterNetSyncVariableBool("m_CookingIsBurned");
48
50 }
51
57
58 override void EEDelete( EntityAI parent )
59 {
60 super.EEDelete( parent );
61
62 //remove audio visuals
64 }
65
66 override void EECargoIn(EntityAI item)
67 {
68 super.EECargoIn(item);
69
70 MiscGameplayFunctions.SoakItemInsideParentContainingLiquidAboveThreshold(ItemBase.Cast(item), this);
71 }
72
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
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)
122 else
124
125 break;
126
127 case SoundTypeBottle.EMPTYING:
128 if (play)
130 else
132
133 break;
134 }
135 }
136
138 {
139 super.OnVariablesSynchronized();
140
142 {
144 }
145 else
146 {
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
232
233 //particles
235 {
236 #ifndef SERVER
238 {
239 //stop previous particles
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
252 {
253 if (m_ParticleCooking && g_Game && !g_Game.IsDedicatedServer())
254 {
255 m_ParticleCooking.Stop();
256 m_ParticleCooking = null;
258 }
259 }
260
262 {
263 if (!m_PouringLoopSound || !m_PouringLoopSound.IsSoundPlaying())
264 {
266 }
267 }
268
270 {
272 m_PouringLoopSound.SoundStop();
273 }
274
276 {
277 if (!m_EmptyingLoopSound || !m_EmptyingLoopSound.IsSoundPlaying())
278 {
280 }
281 }
282
284 {
286 m_EmptyingLoopSound.SoundStop();
287
289 sound.SetAutodestroy(true);
290 }
291
293 {
294 vector pos = GetPosition();
295 string surfaceType = g_Game.GetPlayer().GetSurfaceType();
296 string soundSet = "";
297
298 bool diggable = g_Game.IsSurfaceDigable(surfaceType);
299
300 if (!diggable)
301 {
302 soundSet = GetEmptyingLoopSoundsetHard();
303 }
304 else if (diggable)
305 {
306 soundSet = GetEmptyingLoopSoundsetSoft();
307 }
308 else if (g_Game.SurfaceIsPond(pos[0], pos[2]) || g_Game.SurfaceIsSea(pos[0], pos[2]))
309 {
310 soundSet = GetEmptyingLoopSoundsetWater();
311 }
312
313 return soundSet;
314 }
315
317 {
318 vector pos = GetPosition();
319 string surfaceType = g_Game.GetPlayer().GetSurfaceType();
320 string soundSet = "";
321
322 bool diggable = g_Game.IsSurfaceDigable(surfaceType);
323
324 if (!diggable)
325 {
326 soundSet = GetEmptyingEndSoundsetHard();
327 }
328 else if (diggable)
329 {
330 soundSet = GetEmptyingEndSoundsetSoft();
331 }
332 else if (g_Game.SurfaceIsPond(pos[0], pos[2]) || g_Game.SurfaceIsSea(pos[0], pos[2]))
333 {
334 soundSet = GetEmptyingEndSoundsetWater();
335 }
336
337 return soundSet;
338 }
339
347
350 {
351 return m_LiquidEmptyRate;
352 }
353
373
374 override void OnDebugSpawn()
375 {
377 }
378}
ActionExtinguishFireplaceByLiquidCB ActionContinuousBaseCB ActionExtinguishFireplaceByLiquid()
void AddAction(typename actionName)
void SetActions()
override void OnFreezeStateChangeServer()
Definition bottle_base.c:73
override void EECargoIn(EntityAI item)
Definition bottle_base.c:66
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
void StopEmptyingLoopSound()
void StopPouringLoopSound()
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
string GetEmptyingEndSoundset()
EffectSound m_EmptyingLoopSound
Definition bottle_base.c:28
int PARTICLE_DRYING_START
Definition bottle_base.c:21
void RemoveAudioVisuals()
int PARTICLE_BAKING_START
Definition bottle_base.c:18
const float QUANTITY_EMPTIED_PER_SEC_DEFAULT
Definition bottle_base.c:40
void ParticleCookingStart(int particle_id)
void PlayEmptyingLoopSound()
void RefreshAudioVisuals(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
Remnants of old, responsible for particles and some (empty) sounds. Cooked items take care of the res...
int PARTICLE_BURNING_DONE
Definition bottle_base.c:24
string GetEmptyingLoopSoundset()
bool m_CookingIsDone
Definition bottle_base.c:32
CookingMethodType m_CookingMethod
Definition bottle_base.c:31
void ~Bottle_Base()
Definition bottle_base.c:52
int PARTICLE_BOILING_EMPTY
Definition bottle_base.c:14
void Bottle_Base()
Definition bottle_base.c:42
float GetLiquidEmptyRate()
Returns base liquid empty rate (absolute)..preferrably use the 'GetLiquidThroughputCoef' instead.
enum SoundTypeBottle m_ParticleCooking
int m_ParticlePlaying
Definition bottle_base.c:11
void ParticleCookingStop()
void PlayPouringLoopSound()
int PARTICLE_BOILING_START
Definition bottle_base.c:15
const string SOUND_BOILING_EMPTY
Definition bottle_base.c:37
override string GetEmptyingEndSoundsetSoft()
Definition canteen.c:38
override void OnDebugSpawn()
Definition waterbottle.c:75
override string GetEmptyingEndSoundsetHard()
Definition canteen.c:33
override string GetPouringSoundset()
Definition canteen.c:13
override string GetEmptyingLoopSoundsetWater()
Definition canteen.c:28
override string GetEmptyingEndSoundsetWater()
Definition canteen.c:43
override string GetEmptyingLoopSoundsetSoft()
Definition canteen.c:23
override string GetEmptyingLoopSoundsetHard()
Definition canteen.c:18
represents base for cargo storage for entities
Definition cargo.c:7
proto native int GetItemCount()
proto native EntityAI GetItem(int index)
Super root of all classes in Enforce script.
Definition enscript.c:11
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.
Legacy way of using particles in the game.
Definition particle.c:7
static const int COOKING_BOILING_DONE
static const int NONE
static const int COOKING_BAKING_DONE
static const int COOKING_DRYING_START
static const int COOKING_BOILING_EMPTY
static const int INVALID
static const int COOKING_BURNING_DONE
static const int COOKING_DRYING_DONE
static const int COOKING_BAKING_START
static const int COOKING_BOILING_START
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.
proto bool Read(void value_in)
void Synchronize()
override void EEDelete(EntityAI parent)
override void OnVariablesSynchronized()
CookingMethodType
Definition cooking.c:2
DayZGame g_Game
Definition dayzgame.c:3942
void SoundCookingStop()
int GetConsumptionPenaltyContext()
void SoundCookingStart(string sound_name)
Serializer ParamsReadContext
Definition gameplay.c:15
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
vector GetPosition()
Get the world position of the Effect.
Definition effect.c:473
void RefreshAudioVisualsOnClient(CookingMethodType cooking_method, bool is_done, bool is_empty, bool is_burned)
cooking-related effect methods
void SetQuantityMax()
Definition itembase.c:8308
override int GetLiquidType()
Definition itembase.c:8794
void RemoveAudioVisualsOnClient()
void ParticleManager(ParticleManagerSettings settings)
Constructor (ctor).
override void OnRPC(ParamsReadContext ctx)
int particle_id