DayZ 1.24
Loading...
Searching...
No Matches
OvenIndoor.c
Go to the documentation of this file.
1class OvenIndoor extends FireplaceBase
2{
3 protected float m_SmokePosX;
4 protected float m_SmokePosY;
5 protected float m_SmokePosZ;
6 protected int m_FirePointIndex = 1; //limited to 1 decimal place (1-9)
7
8 static const string OVENPOINT_ACTION_SELECTION = "oven_action";
9 static const string OVENPOINT_FIRE_POSITION = "oven_point";
10 static const string OVENPOINT_PLACE_ROT = "oven_rot";
11 static const string OVENPOINT_SMOKE_POSITION = "oven_smoke";
12
14 {
15 //Particles - default for FireplaceBase
23
24 //register sync variables
25 RegisterNetSyncVariableFloat("m_SmokePosX", 0, 0, 2);
26 RegisterNetSyncVariableFloat("m_SmokePosY", 0, 0, 2);
27 RegisterNetSyncVariableFloat("m_SmokePosZ", 0, 0, 2);
28 RegisterNetSyncVariableInt("m_FirePointIndex", 0, 9);
29
30 m_LightDistance = 50;
31 m_RoofAbove = true;
32 }
33
34 //================================================================
35 // ONSTORESAVE/LOAD/AFTERLOAD
36 //================================================================
38 {
39 super.OnStoreSave(ctx);
40
41 //fire point name
42 ctx.Write(m_FirePointIndex);
43
44 //smoke position
45 ctx.Write(m_SmokePosX);
46 ctx.Write(m_SmokePosY);
47 ctx.Write(m_SmokePosZ);
48 }
49
50 override bool OnStoreLoad(ParamsReadContext ctx, int version)
51 {
52 if (!super.OnStoreLoad(ctx, version))
53 return false;
54
55 //--- Fireplace Indoor data ---
56 //fire point name
57 if (!ctx.Read(m_FirePointIndex))
58 {
59 m_FirePointIndex = 1; //set default
60 return false;
61 }
62
63 //smoke position
64 if (!ctx.Read(m_SmokePosX))
65 {
66 m_SmokePosX = 0; //set default
67 return false;
68 }
69 if (!ctx.Read(m_SmokePosY))
70 {
71 m_SmokePosY = 0; //set default
72 return false;
73 }
74 if (!ctx.Read(m_SmokePosZ))
75 {
76 m_SmokePosZ = 0; //set default
77 return false;
78 }
79 //---
80
81 return true;
82 }
83
84 //================================================================
85 // FIRE POINT (HOUSE)
86 // LIMITED TO 1 DECIMAL PLACE (0-9)
87 //================================================================
89 {
90 int index_location = action_selection.Length() - 1;
91 return action_selection.Substring(index_location, 1).ToInt();
92 }
93
98
100 {
101 //Get fire point index position
102 vector fire_point_pos = building.GetSelectionPositionMS(OVENPOINT_FIRE_POSITION + fire_point_index.ToString());
103 vector fire_point_rot = building.GetSelectionPositionMS(OVENPOINT_PLACE_ROT + fire_point_index.ToString());
106
107 //check if there is any FireplaceIndoor objects near selected fire point
110 GetGame().GetObjectsAtPosition3D(fire_point_pos_world, 1, nearest_objects, proxy_cargos);
111
112 for (int i = 0; i < nearest_objects.Count(); ++i)
113 {
114 Object object = nearest_objects.Get(i);
115
116 if (object.IsInherited(OvenIndoor))
117 return false;
118 }
119
120 return true;
121 }
122
124 {
125 m_SmokePosX = smoke_point_pos[0];
126 m_SmokePosY = smoke_point_pos[1];
127 m_SmokePosZ = smoke_point_pos[2];
128 }
129
130 //================================================================
131 // PARTICLES
132 //================================================================
133 override protected vector GetSmokeEffectPosition()
134 {
135 return Vector(m_SmokePosX, m_SmokePosY, m_SmokePosZ);
136 }
137
138 //small smoke
143
144 //normal smoke
149
150 //================================================================
151 // STATE
152 //================================================================
153 override bool IsIndoorOven()
154 {
155 return true;
156 }
157
159 {
160 if (!super.CanReleaseAttachment(attachment))
161 return false;
162
164 if (IsKindling(item) || IsFuel(item))
165 return !IsBurning();
166
167 return true;
168 }
169
170 override void EEItemAttached(EntityAI item, string slot_name)
171 {
172 super.EEItemAttached(item, slot_name);
173
175
178
179 // direct cooking/smoking slots
180 bool edible_base_attached = false;
181 switch (slot_name)
182 {
183 case "DirectCookingA":
186 break;
187 case "SmokingA":
190 break;
191 case "SmokingB":
194 break;
195 }
196
197 // reset cooking time (to prevent the cooking exploit)
198 if (GetGame().IsServer() && edible_base_attached)
199 {
201 if (edBase)
202 {
203 if (edBase.GetFoodStage())
204 edBase.SetCookingTime(0);
205 }
206 }
207
209 }
210
211 override void EEItemDetached(EntityAI item, string slot_name)
212 {
213 super.EEItemDetached(item, slot_name);
214
216
219
220 CheckForDestroy();
221
222 // direct cooking/smoking slots
223 switch (slot_name)
224 {
225 case "DirectCookingA":
227 break;
228 case "SmokingA":
229 m_SmokingSlots[0] = null;
230 break;
231
232 case "SmokingB":
233 m_SmokingSlots[1] = null;
234 break;
235 }
236
237 // cookware-specifics (remove audio visuals)
238 if (item_base.Type() == ATTACHMENT_COOKING_POT)
239 {
242 cooking_pot.RemoveAudioVisualsOnClient();
243 }
244 if (item_base.Type() == ATTACHMENT_CAULDRON)
245 {
248 cauldron.RemoveAudioVisualsOnClient();
249 }
250 if (item_base.Type() == ATTACHMENT_FRYING_PAN)
251 {
253 FryingPan frying_pan = FryingPan.Cast(item);
254 frying_pan.RemoveAudioVisualsOnClient();
255 }
256
258 }
259
260 //================================================================
261 // CONDITIONS
262 //================================================================
263 //this into/outo parent.Cargo
264 override bool CanPutInCargo(EntityAI parent)
265 {
266 return false;
267 }
268
269 override bool CanRemoveFromCargo(EntityAI parent)
270 {
271 return true;
272 }
273
274 //hands
275 override bool CanPutIntoHands(EntityAI parent)
276 {
277 return false;
278 }
279
281 {
282 return false;
283 }
284
285 // Item-to-item fire distribution
286 override bool HasFlammableMaterial()
287 {
288 return true;
289 }
290
292 {
293 if (HasAnyKindling() && !GetHierarchyParent())
294 return true;
295
296 return false;
297 }
298
300 {
301 if (IsBurning())
302 return true;
303
304 return false;
305 }
306
307 override bool IsIgnited()
308 {
309 return IsBurning();
310 }
311
313 {
314 }
315
317 {
318 //start fire
319 StartFire();
320 }
321
323 {
324 //check kindling
325 if (!HasAnyKindling())
326 return false;
327
328 //check wetness
329 if (IsWet())
330 return false;
331
332 return true;
333 }
334}
ActionPlaceFireplaceIndoor m_FirePointIndex
void RefreshFireplaceVisuals()
void RemoveFromFireConsumables(FireConsumable fire_consumable)
bool HasAnyKindling()
Particle m_ParticleSmallSmoke
ATTACHMENT_FRYING_PAN
ATTACHMENT_CAULDRON
float m_LightDistance
void AddToFireConsumables(ItemBase item)
int PARTICLE_STEAM_END
int PARTICLE_NORMAL_FIRE
bool m_RoofAbove
int PARTICLE_FIRE_START
bool IsFuel(ItemBase item)
Returns if item attached to fireplace is fuel.
int PARTICLE_NORMAL_SMOKE
ATTACHMENT_COOKING_POT
bool IsBurning()
bool IsWet()
void StartFire(bool force_start=false)
ItemBase m_DirectCookingSlots[DIRECT_COOKING_SLOT_COUNT]
int PARTICLE_FIRE_END
int PARTICLE_SMALL_SMOKE
void ClearCookingEquipment()
DEPRECATED.
FireConsumable GetFireConsumableByItem(ItemBase item)
ItemBase m_SmokingSlots[SMOKING_SLOT_COUNT]
bool IsKindling(ItemBase item)
Returns if item attached to fireplace is kindling.
int PARTICLE_SMALL_FIRE
Particle m_ParticleNormalSmoke
void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
void OvenIndoor()
Definition OvenIndoor.c:13
void SetSmokePointPosition(vector smoke_point_pos)
Definition OvenIndoor.c:123
override bool CanIgniteItem(EntityAI ignite_target=NULL)
Definition OvenIndoor.c:299
vector GetSmokeEffectPosition()
Definition OvenIndoor.c:133
override void EEItemAttached(EntityAI item, string slot_name)
Definition OvenIndoor.c:170
override void ParticleSmallSmokeStart()
Definition OvenIndoor.c:139
override bool CanRemoveFromHands(EntityAI player)
Definition OvenIndoor.c:280
override bool CanPutIntoHands(EntityAI parent)
Definition OvenIndoor.c:275
override void ParticleNormalSmokeStart()
Definition OvenIndoor.c:145
override bool IsIndoorOven()
Definition OvenIndoor.c:153
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
Definition OvenIndoor.c:291
override void OnIgnitedTarget(EntityAI ignited_item)
Definition OvenIndoor.c:312
override bool HasFlammableMaterial()
Definition OvenIndoor.c:286
override bool CanPutInCargo(EntityAI parent)
Definition OvenIndoor.c:264
override bool IsIgnited()
Definition OvenIndoor.c:307
override void OnIgnitedThis(EntityAI fire_source)
Definition OvenIndoor.c:316
static int GetFirePointIndex(string action_selection)
Definition OvenIndoor.c:88
void SetFirePointIndex(int fire_point_index)
Definition OvenIndoor.c:94
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
Definition OvenIndoor.c:322
static bool CanPlaceFireplaceInSelectedSpot(Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world)
Definition OvenIndoor.c:99
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition OvenIndoor.c:50
override void EEItemDetached(EntityAI item, string slot_name)
Definition OvenIndoor.c:211
override bool CanRemoveFromCargo(EntityAI parent)
Definition OvenIndoor.c:269
override void OnStoreSave(ParamsWriteContext ctx)
Definition OvenIndoor.c:37
override bool CanReleaseAttachment(EntityAI attachment)
Definition OvenIndoor.c:158
static const int BARREL_FIRE_STEAM_2END
static const int OVEN_NORMAL_FIRE
static const int OVEN_SMALL_FIRE
static const int HOUSE_NORMAL_SMOKE
static const int HOUSE_SMALL_SMOKE
static const int OVEN_FIRE_START
static const int OVEN_FIRE_END
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.