DayZ 1.24
Loading...
Searching...
No Matches
FireplaceIndoor.c
Go to the documentation of this file.
1class FireplaceIndoor 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 FIREPOINT_ACTION_SELECTION = "fireplace_action";
9 static const string FIREPOINT_FIRE_POSITION = "fireplace_point";
10 static const string FIREPOINT_PLACE_ROT = "fireplace_rot";
11 static const string FIREPOINT_SMOKE_POSITION = "fireplace_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(FIREPOINT_FIRE_POSITION + fire_point_index.ToString());
103 vector fire_point_rot = building.GetSelectionPositionMS(FIREPOINT_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, 0.25, 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(FireplaceIndoor))
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 IsFireplaceIndoor()
154 {
155 return true;
156 }
157
158 override void EEItemAttached(EntityAI item, string slot_name)
159 {
160 super.EEItemAttached(item, slot_name);
161
165
166 // direct cooking slots, smoking slots
167 bool edible_base_attached = false;
168 switch (slot_name)
169 {
170 case "DirectCookingA":
173 break;
174 case "DirectCookingB":
177 break;
178 case "DirectCookingC":
181 break;
182
183 case "SmokingA":
186 break;
187 case "SmokingB":
190 break;
191 case "SmokingC":
194 break;
195 case "SmokingD":
198 break;
199 }
200
201 // reset cooking time (to prevent the cooking exploit)
202 if (GetGame().IsServer() && edible_base_attached)
203 {
205 if (edBase)
206 {
207 if (edBase.GetFoodStage())
208 edBase.SetCookingTime(0);
209 }
210 }
211
213 }
214
215 override void EEItemDetached(EntityAI item, string slot_name)
216 {
217 super.EEItemDetached(item, slot_name);
218
220
223
224 CheckForDestroy();
225
226 // direct cooking/smoking slots
227 switch (slot_name)
228 {
229 case "DirectCookingA":
231 break;
232 case "DirectCookingB":
234 break;
235 case "DirectCookingC":
237 break;
238
239 case "SmokingA":
240 m_SmokingSlots[0] = null;
241 break;
242 case "SmokingB":
243 m_SmokingSlots[1] = null;
244 break;
245 case "SmokingC":
246 m_SmokingSlots[2] = null;
247 break;
248 case "SmokingD":
249 m_SmokingSlots[3] = null;
250 break;
251 }
252
253 // cookware-specifics (remove audio visuals)
254 if (item_base.Type() == ATTACHMENT_COOKING_POT)
255 {
258 cooking_pot.RemoveAudioVisualsOnClient();
259 }
260 if (item_base.Type() == ATTACHMENT_CAULDRON)
261 {
264 cauldron.RemoveAudioVisualsOnClient();
265 }
266 if (item_base.Type() == ATTACHMENT_FRYING_PAN)
267 {
269 FryingPan frying_pan = FryingPan.Cast(item);
270 frying_pan.RemoveAudioVisualsOnClient();
271 }
272
274 }
275
276 //================================================================
277 // CONDITIONS
278 //================================================================
279 //this into/outo parent.Cargo
280 override bool CanPutInCargo(EntityAI parent)
281 {
282 return false;
283 }
284
285 override bool CanRemoveFromCargo(EntityAI parent)
286 {
287 return true;
288 }
289
290 //cargo item into/outo this.Cargo
292 {
293 return super.CanReceiveItemIntoCargo(item);
294 }
295
296 //hands
297 override bool CanPutIntoHands(EntityAI parent)
298 {
299 return false;
300 }
301
303 {
304 return false;
305 }
306
307 // Item-to-item fire distribution
308 override bool HasFlammableMaterial()
309 {
310 return true;
311 }
312
314 {
315 if (HasAnyKindling() && !GetHierarchyParent())
316 return true;
317
318 return false;
319 }
320
322 {
323 if (IsBurning())
324 return true;
325
326 return false;
327 }
328
329 override bool IsIgnited()
330 {
331 return IsBurning();
332 }
333
335 {
336 }
337
339 {
340 //start fire
341 StartFire();
342 }
343
345 {
346 SetIgniteFailure(false);
348
349 //check kindling
350 if (!HasAnyKindling())
351 return false;
352
353 //check wetness
354 if (IsWet())
355 {
356 SetIgniteFailure(true);
357
359 GetGame().RPCSingleParam(this, FirePlaceFailure.WET, failure, true);
360 return false;
361 }
362
363 return true;
364 }
365}
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.
bool GetIgniteFailure()
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
void SetIgniteFailure(bool failure)
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 SetSmokePointPosition(vector smoke_point_pos)
override bool CanIgniteItem(EntityAI ignite_target=NULL)
vector GetSmokeEffectPosition()
override void EEItemAttached(EntityAI item, string slot_name)
override void ParticleSmallSmokeStart()
override bool CanRemoveFromHands(EntityAI player)
override bool CanPutIntoHands(EntityAI parent)
override void ParticleNormalSmokeStart()
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
override bool IsFireplaceIndoor()
override void OnIgnitedTarget(EntityAI ignited_item)
override bool HasFlammableMaterial()
override bool CanPutInCargo(EntityAI parent)
override bool IsIgnited()
override void OnIgnitedThis(EntityAI fire_source)
static int GetFirePointIndex(string action_selection)
override bool CanReceiveItemIntoCargo(EntityAI item)
void SetFirePointIndex(int fire_point_index)
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
static bool CanPlaceFireplaceInSelectedSpot(Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world)
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override void EEItemDetached(EntityAI item, string slot_name)
override bool CanRemoveFromCargo(EntityAI parent)
override void OnStoreSave(ParamsWriteContext ctx)
static const int HOUSE_NORMAL_FIRE
static const int HOUSE_FIRE_STEAM_2END
static const int HOUSE_NORMAL_SMOKE
static const int HOUSE_SMALL_FIRE
static const int HOUSE_FIRE_END
static const int HOUSE_FIRE_START
static const int HOUSE_SMALL_SMOKE
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.