Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ovenindoor.c
Go to the documentation of this file.
1 class 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 
13  void OvenIndoor()
14  {
15  //Particles - default for FireplaceBase
16  PARTICLE_FIRE_START = ParticleList.OVEN_FIRE_START;
17  PARTICLE_SMALL_FIRE = ParticleList.OVEN_SMALL_FIRE;
18  PARTICLE_NORMAL_FIRE = ParticleList.OVEN_NORMAL_FIRE;
19  PARTICLE_SMALL_SMOKE = ParticleList.HOUSE_SMALL_SMOKE;
20  PARTICLE_NORMAL_SMOKE = ParticleList.HOUSE_NORMAL_SMOKE;
21  PARTICLE_FIRE_END = ParticleList.OVEN_FIRE_END;
22  PARTICLE_STEAM_END = ParticleList.BARREL_FIRE_STEAM_2END;
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  //================================================================
37  override void OnStoreSave( ParamsWriteContext ctx )
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  //================================================================
88  static int GetFirePointIndex( string action_selection )
89  {
90  int index_location = action_selection.Length() - 1;
91  return action_selection.Substring( index_location, 1 ).ToInt();
92  }
93 
94  void SetFirePointIndex( int fire_point_index )
95  {
96  m_FirePointIndex = fire_point_index;
97  }
98 
99  static bool CanPlaceFireplaceInSelectedSpot( Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world )
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() );
104  fire_point_pos_world = building.ModelToWorld( fire_point_pos );
105  fire_point_rot_world = building.ModelToWorld( fire_point_rot );
106 
107  //check if there is any FireplaceIndoor objects near selected fire point
108  ref array<Object> nearest_objects = new array<Object>;
109  ref array<CargoBase> proxy_cargos = new array<CargoBase>;
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  {
118  return false;
119  }
120  }
121 
122  return true;
123  }
124 
125  void SetSmokePointPosition( vector smoke_point_pos )
126  {
127  m_SmokePosX = smoke_point_pos[0];
128  m_SmokePosY = smoke_point_pos[1];
129  m_SmokePosZ = smoke_point_pos[2];
130  }
131 
132  //================================================================
133  // PARTICLES
134  //================================================================
135  override protected vector GetSmokeEffectPosition()
136  {
137  return Vector( m_SmokePosX, m_SmokePosY, m_SmokePosZ );
138  }
139 
140  //small smoke
141  override void ParticleSmallSmokeStart()
142  {
144  }
145 
146  //normal smoke
147  override void ParticleNormalSmokeStart()
148  {
150  }
151 
152  //================================================================
153  // STATE
154  //================================================================
155  override bool IsIndoorOven()
156  {
157  return true;
158  }
159 
160  override bool CanReleaseAttachment(EntityAI attachment)
161  {
162  if (!super.CanReleaseAttachment(attachment))
163  {
164  return false;
165  }
166 
167  ItemBase item = ItemBase.Cast(attachment);
168  if (IsKindling(item) || IsFuel(item))
169  {
170  return !IsBurning();
171  }
172 
173  return true;
174  }
175 
176  override void EEItemAttached(EntityAI item, string slot_name)
177  {
178  super.EEItemAttached(item, slot_name);
179 
180  ItemBase item_base = ItemBase.Cast(item);
181 
182  if (IsKindling(item_base) || IsFuel(item_base))
183  {
184  AddToFireConsumables(item_base);
185  }
186 
187  // direct cooking/smoking slots
188  bool edible_base_attached = false;
189  switch (slot_name)
190  {
191  case "DirectCookingA":
192  m_DirectCookingSlots[0] = item_base;
193  edible_base_attached = true;
194  break;
195  case "SmokingA":
196  m_SmokingSlots[0] = item_base;
197  edible_base_attached = true;
198  break;
199  case "SmokingB":
200  m_SmokingSlots[1] = item_base;
201  edible_base_attached = true;
202  break;
203  }
204 
205  // reset cooking time (to prevent the cooking exploit)
206  if (GetGame().IsServer() && edible_base_attached)
207  {
208  Edible_Base edBase = Edible_Base.Cast(item_base);
209  if (edBase)
210  {
211  if ( edBase.GetFoodStage())
212  {
213  edBase.SetCookingTime(0);
214  }
215  }
216  }
217 
219  }
220 
221  override void EEItemDetached(EntityAI item, string slot_name)
222  {
223  super.EEItemDetached(item, slot_name);
224 
225  ItemBase item_base = ItemBase.Cast(item);
226 
227  if (IsKindling(item_base) || IsFuel(item_base))
228  {
230  }
231 
232  CheckForDestroy();
233 
234  // direct cooking/smoking slots
235  switch (slot_name)
236  {
237  case "DirectCookingA":
238  m_DirectCookingSlots[0] = null;
239  break;
240  case "SmokingA":
241  m_SmokingSlots[0] = null;
242  break;
243 
244  case "SmokingB":
245  m_SmokingSlots[1] = null;
246  break;
247  }
248 
249  // cookware-specifics (remove audio visuals)
250  if (item_base.Type() == ATTACHMENT_COOKING_POT)
251  {
252  ClearCookingEquipment(item_base);
253  Bottle_Base cooking_pot = Bottle_Base.Cast(item);
254  cooking_pot.RemoveAudioVisualsOnClient();
255  }
256  if (item_base.Type() == ATTACHMENT_CAULDRON)
257  {
258  ClearCookingEquipment(item_base);
259  Bottle_Base cauldron = Bottle_Base.Cast(item);
260  cauldron.RemoveAudioVisualsOnClient();
261  }
262  if (item_base.Type() == ATTACHMENT_FRYING_PAN)
263  {
264  ClearCookingEquipment(item_base);
265  FryingPan frying_pan = FryingPan.Cast(item);
266  frying_pan.RemoveAudioVisualsOnClient();
267  }
268 
270  }
271 
272  //================================================================
273  // CONDITIONS
274  //================================================================
275  //this into/outo parent.Cargo
276  override bool CanPutInCargo( EntityAI parent )
277  {
278  return false;
279  }
280 
281  override bool CanRemoveFromCargo( EntityAI parent )
282  {
283  return true;
284  }
285 
286  //hands
287  override bool CanPutIntoHands( EntityAI parent )
288  {
289  return false;
290  }
291 
292  override bool CanRemoveFromHands( EntityAI player )
293  {
294  return false;
295  }
296 
297  // Item-to-item fire distribution
298  override bool HasFlammableMaterial()
299  {
300  return true;
301  }
302 
303  override bool CanBeIgnitedBy( EntityAI igniter = NULL )
304  {
305  if ( HasAnyKindling() && !GetHierarchyParent() )
306  {
307  return true;
308  }
309 
310  return false;
311  }
312 
313  override bool CanIgniteItem( EntityAI ignite_target = NULL )
314  {
315  if ( IsBurning() )
316  {
317  return true;
318  }
319 
320  return false;
321  }
322 
323  override bool IsIgnited()
324  {
325  return IsBurning();
326  }
327 
328  override void OnIgnitedTarget( EntityAI ignited_item )
329  {
330  }
331 
332  override void OnIgnitedThis( EntityAI fire_source )
333  {
334  //start fire
335  StartFire();
336  }
337 
338  override bool IsThisIgnitionSuccessful( EntityAI item_source = NULL )
339  {
340  //check kindling
341  if ( !HasAnyKindling() )
342  {
343  return false;
344  }
345 
346  //check wetness
347  if ( IsWet() )
348  {
349  return false;
350  }
351 
352  return true;
353  }
354 }
ItemBase
Definition: inventoryitem.c:730
GetGame
proto native CGame GetGame()
ATTACHMENT_CAULDRON
ATTACHMENT_CAULDRON
Definition: fireplacebase.c:208
GetSmokeEffectPosition
protected vector GetSmokeEffectPosition()
Definition: fireplacebase.c:1272
OnIgnitedThis
override void OnIgnitedThis(EntityAI fire_source)
Executed on Server when some item ignited this one.
Definition: fireworksbase.c:96
ClearCookingEquipment
void ClearCookingEquipment(ItemBase pItem)
Definition: fireplacebase.c:550
AddToFireConsumables
protected void AddToFireConsumables(ItemBase item)
Definition: fireplacebase.c:1327
m_DirectCookingSlots
protected ItemBase m_DirectCookingSlots[DIRECT_COOKING_SLOT_COUNT]
Definition: fireplacebase.c:107
PARTICLE_NORMAL_SMOKE
protected int PARTICLE_NORMAL_SMOKE
Definition: fireplacebase.c:118
PARTICLE_SMALL_SMOKE
protected int PARTICLE_SMALL_SMOKE
Definition: fireplacebase.c:117
CanReleaseAttachment
override bool CanReleaseAttachment(EntityAI attachment)
Definition: fireplacebase.c:2654
m_FirePointIndex
ActionPlaceFireplaceIndoor m_FirePointIndex
m_ParticleSmallSmoke
protected Particle m_ParticleSmallSmoke
Definition: fireplacebase.c:128
IsIndoorOven
bool IsIndoorOven()
Definition: fireplacebase.c:524
m_RoofAbove
protected bool m_RoofAbove
Definition: fireplacebase.c:28
Bottle_Base
Definition: canistergasoline.c:1
FireplaceBase
Definition: barrelholes_colorbase.c:1
IsFuel
protected bool IsFuel(ItemBase item)
Returns if item attached to fireplace is fuel.
Definition: fireplacebase.c:1518
m_ParticleNormalSmoke
protected Particle m_ParticleNormalSmoke
Definition: fireplacebase.c:129
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
IsWet
bool IsWet()
Definition: fireplacebase.c:2383
PlayParticle
void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.
Definition: particlebase.c:96
ParticleList
Definition: particlelist.c:11
CanPutIntoHands
override bool CanPutIntoHands(EntityAI parent)
Definition: explosivesbase.c:257
vector
Definition: enconvert.c:105
CanPutInCargo
override bool CanPutInCargo(EntityAI parent)
Definition: explosivesbase.c:247
HasFlammableMaterial
override bool HasFlammableMaterial()
Definition: fireworksbase.c:41
CanRemoveFromHands
override bool CanRemoveFromHands(EntityAI parent)
Definition: explosivesbase.c:267
Object
Definition: objecttyped.c:1
PARTICLE_STEAM_END
protected int PARTICLE_STEAM_END
Definition: fireplacebase.c:121
m_SmokingSlots
protected ItemBase m_SmokingSlots[SMOKING_SLOT_COUNT]
Definition: fireplacebase.c:108
m_LightDistance
protected float m_LightDistance
Definition: fireplacebase.c:103
ATTACHMENT_FRYING_PAN
ATTACHMENT_FRYING_PAN
Definition: fireplacebase.c:207
CanRemoveFromCargo
override bool CanRemoveFromCargo(EntityAI parent)
Definition: basebuildingbase.c:927
GetFireConsumableByItem
protected FireConsumable GetFireConsumableByItem(ItemBase item)
Definition: fireplacebase.c:1365
PARTICLE_FIRE_START
protected int PARTICLE_FIRE_START
Definition: fireplacebase.c:112
IsKindling
protected bool IsKindling(ItemBase item)
Returns if item attached to fireplace is kindling.
Definition: fireplacebase.c:1500
array< Object >
OnStoreSave
void OnStoreSave(ParamsWriteContext ctx)
Definition: modifierbase.c:229
PARTICLE_SMALL_FIRE
protected int PARTICLE_SMALL_FIRE
Definition: fireplacebase.c:114
ParticleSmallSmokeStart
protected void ParticleSmallSmokeStart()
Definition: fireplacebase.c:1125
StartFire
void StartFire(bool force_start=false)
Definition: fireplacebase.c:1697
PARTICLE_NORMAL_FIRE
protected int PARTICLE_NORMAL_FIRE
Definition: fireplacebase.c:115
ATTACHMENT_COOKING_POT
ATTACHMENT_COOKING_POT
Definition: fireplacebase.c:206
PARTICLE_FIRE_END
protected int PARTICLE_FIRE_END
Definition: fireplacebase.c:119
EEItemAttached
override void EEItemAttached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:520
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
EEItemDetached
override void EEItemDetached(EntityAI item, string slot_name)
Definition: basebuildingbase.c:529
CanBeIgnitedBy
override protected bool CanBeIgnitedBy(EntityAI igniter=NULL)
Definition: fireworksbase.c:102
OnStoreLoad
bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition: modifiersmanager.c:270
EntityAI
Definition: building.c:5
HasAnyKindling
bool HasAnyKindling()
Definition: fireplacebase.c:2352
RemoveFromFireConsumables
protected void RemoveFromFireConsumables(FireConsumable fire_consumable)
Definition: fireplacebase.c:1354
Edible_Base
Definition: bearsteakmeat.c:1
ParticleNormalSmokeStart
protected void ParticleNormalSmokeStart()
Definition: fireplacebase.c:1151
IsBurning
bool IsBurning()
Definition: fireplacebase.c:1566
RefreshFireplaceVisuals
void RefreshFireplaceVisuals()
Definition: fireplacebase.c:612