Dayz Explorer 1.28.160049
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
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 SetRoofAbove(true);
32
33 m_UTSSettings.m_EnableOnTemperatureControl = true;
34 m_UTSSettings.m_ActiveTemperatureThreshold = 250.0;
35 m_UTSSettings.m_InactiveTemperatureThreshold = 975.0;
36 }
37
38 //================================================================
39 // ONSTORESAVE/LOAD/AFTERLOAD
40 //================================================================
41 override void OnStoreSave( ParamsWriteContext ctx )
42 {
43 super.OnStoreSave( ctx );
44
45 //fire point name
46 ctx.Write( m_FirePointIndex );
47
48 //smoke position
49 ctx.Write( m_SmokePosX );
50 ctx.Write( m_SmokePosY );
51 ctx.Write( m_SmokePosZ );
52 }
53
54 override bool OnStoreLoad( ParamsReadContext ctx, int version )
55 {
56 if ( !super.OnStoreLoad( ctx, version ) )
57 return false;
58
59 //--- Fireplace Indoor data ---
60 //fire point name
61 if ( !ctx.Read( m_FirePointIndex ) )
62 {
63 m_FirePointIndex = 1; //set default
64 return false;
65 }
66
67 //smoke position
68 if ( !ctx.Read( m_SmokePosX ) )
69 {
70 m_SmokePosX = 0; //set default
71 return false;
72 }
73 if ( !ctx.Read( m_SmokePosY ) )
74 {
75 m_SmokePosY = 0; //set default
76 return false;
77 }
78 if ( !ctx.Read( m_SmokePosZ ) )
79 {
80 m_SmokePosZ = 0; //set default
81 return false;
82 }
83 //---
84
85 return true;
86 }
87
88 //================================================================
89 // FIRE POINT (HOUSE)
90 // LIMITED TO 1 DECIMAL PLACE (0-9)
91 //================================================================
92 static int GetFirePointIndex( string action_selection )
93 {
94 int index_location = action_selection.Length() - 1;
95 return action_selection.Substring( index_location, 1 ).ToInt();
96 }
97
98 void SetFirePointIndex( int fire_point_index )
99 {
100 m_FirePointIndex = fire_point_index;
101 }
102
103 static bool CanPlaceFireplaceInSelectedSpot( Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world )
104 {
105 //Get fire point index position
106 vector fire_point_pos = building.GetSelectionPositionMS( OVENPOINT_FIRE_POSITION + fire_point_index.ToString() );
107 vector fire_point_rot = building.GetSelectionPositionMS( OVENPOINT_PLACE_ROT + fire_point_index.ToString() );
108 fire_point_pos_world = building.ModelToWorld( fire_point_pos );
109 fire_point_rot_world = building.ModelToWorld( fire_point_rot );
110
111 //check if there is any FireplaceIndoor objects near selected fire point
112 ref array<Object> nearest_objects = new array<Object>;
113 ref array<CargoBase> proxy_cargos = new array<CargoBase>;
114 GetGame().GetObjectsAtPosition3D( fire_point_pos_world, 1, nearest_objects, proxy_cargos );
115
116 for ( int i = 0; i < nearest_objects.Count(); ++i )
117 {
118 Object object = nearest_objects.Get( i );
119
120 if ( object.IsInherited( OvenIndoor ) )
121 {
122 return false;
123 }
124 }
125
126 return true;
127 }
128
129 void SetSmokePointPosition( vector smoke_point_pos )
130 {
131 m_SmokePosX = smoke_point_pos[0];
132 m_SmokePosY = smoke_point_pos[1];
133 m_SmokePosZ = smoke_point_pos[2];
134 }
135
136 //================================================================
137 // PARTICLES
138 //================================================================
139 override protected vector GetSmokeEffectPosition()
140 {
141 return Vector( m_SmokePosX, m_SmokePosY, m_SmokePosZ );
142 }
143
144 //small smoke
149
150 //normal smoke
155
156 //================================================================
157 // STATE
158 //================================================================
159 override bool IsIndoorOven()
160 {
161 return true;
162 }
163
164 override bool CanReleaseAttachment(EntityAI attachment)
165 {
166 if (!super.CanReleaseAttachment(attachment))
167 {
168 return false;
169 }
170
171 ItemBase item = ItemBase.Cast(attachment);
172 if (IsKindling(item) || IsFuel(item))
173 {
174 return !IsBurning();
175 }
176
177 return true;
178 }
179
180 override void EEItemAttached(EntityAI item, string slot_name)
181 {
182 super.EEItemAttached(item, slot_name);
183
184 ItemBase item_base = ItemBase.Cast(item);
185
186 if (IsKindling(item_base) || IsFuel(item_base))
187 {
188 AddToFireConsumables(item_base);
189 }
190
191 // direct cooking/smoking slots
192 bool edible_base_attached = false;
193 switch (slot_name)
194 {
195 case "DirectCookingA":
196 m_DirectCookingSlots[0] = item_base;
197 edible_base_attached = true;
198 break;
199 case "SmokingA":
200 m_SmokingSlots[0] = item_base;
201 edible_base_attached = true;
202 break;
203 case "SmokingB":
204 m_SmokingSlots[1] = item_base;
205 edible_base_attached = true;
206 break;
207 }
208
210 }
211
212 override void EEItemDetached(EntityAI item, string slot_name)
213 {
214 super.EEItemDetached(item, slot_name);
215
216 ItemBase item_base = ItemBase.Cast(item);
217
218 if (IsKindling(item_base) || IsFuel(item_base))
219 {
221 }
222
224
225 // direct cooking/smoking slots
226 switch (slot_name)
227 {
228 case "DirectCookingA":
229 m_DirectCookingSlots[0] = null;
230 break;
231 case "SmokingA":
232 m_SmokingSlots[0] = null;
233 break;
234
235 case "SmokingB":
236 m_SmokingSlots[1] = null;
237 break;
238 }
239
240 // cookware-specifics (remove audio visuals and clear references)
241 if (item_base.IsCookware())
242 {
243 ClearCookingEquipment(item_base);
244 item_base.RemoveAudioVisualsOnClient();
245 }
246
247 if (item_base.IsLiquidContainer()) //boiling bottle effects stop
248 item_base.RemoveAudioVisualsOnClient();
249
251 }
252
253 //================================================================
254 // CONDITIONS
255 //================================================================
256 //this into/outo parent.Cargo
257 override bool CanPutInCargo( EntityAI parent )
258 {
259 return false;
260 }
261
262 override bool CanRemoveFromCargo( EntityAI parent )
263 {
264 return true;
265 }
266
267 //hands
268 override bool CanPutIntoHands( EntityAI parent )
269 {
270 return false;
271 }
272
273 override bool CanRemoveFromHands( EntityAI parent )
274 {
275 return false;
276 }
277
278 // Item-to-item fire distribution
279 override bool HasFlammableMaterial()
280 {
281 return true;
282 }
283
284 override bool CanBeIgnitedBy( EntityAI igniter = NULL )
285 {
286 if ( HasAnyKindling() && !GetHierarchyParent() )
287 {
288 return true;
289 }
290
291 return false;
292 }
293
294 override bool CanIgniteItem( EntityAI ignite_target = NULL )
295 {
296 if ( IsBurning() )
297 {
298 return true;
299 }
300
301 return false;
302 }
303
304 override bool IsIgnited()
305 {
306 return IsBurning();
307 }
308
309 override void OnIgnitedTarget( EntityAI target_item )
310 {
311 }
312
313 override void OnIgnitedThis( EntityAI fire_source )
314 {
315 //start fire
316 StartFire();
317 }
318
319 override bool IsThisIgnitionSuccessful( EntityAI item_source = NULL )
320 {
321 //check kindling
322 if ( !HasAnyKindling() )
323 {
324 return false;
325 }
326
327 //check wetness
328 if ( IsWet() )
329 {
330 return false;
331 }
332
333 return true;
334 }
335}
ActionPlaceFireplaceIndoor m_FirePointIndex
void OvenIndoor()
Definition ovenindoor.c:13
void SetSmokePointPosition(vector smoke_point_pos)
Definition ovenindoor.c:129
override bool CanRemoveFromHands(EntityAI parent)
Definition ovenindoor.c:273
override bool CanIgniteItem(EntityAI ignite_target=NULL)
Definition ovenindoor.c:294
vector GetSmokeEffectPosition()
Definition ovenindoor.c:139
override void EEItemAttached(EntityAI item, string slot_name)
Definition ovenindoor.c:180
override void ParticleSmallSmokeStart()
Definition ovenindoor.c:145
float m_SmokePosX
Definition ovenindoor.c:3
override bool CanPutIntoHands(EntityAI parent)
Definition ovenindoor.c:268
override void ParticleNormalSmokeStart()
Definition ovenindoor.c:151
override bool IsIndoorOven()
Definition ovenindoor.c:159
float m_SmokePosZ
Definition ovenindoor.c:5
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
Definition ovenindoor.c:284
override bool HasFlammableMaterial()
Definition ovenindoor.c:279
float m_SmokePosY
Definition ovenindoor.c:4
override bool CanPutInCargo(EntityAI parent)
Definition ovenindoor.c:257
override void OnIgnitedTarget(EntityAI target_item)
Definition ovenindoor.c:309
override bool IsIgnited()
Definition ovenindoor.c:304
override void OnIgnitedThis(EntityAI fire_source)
Definition ovenindoor.c:313
static int GetFirePointIndex(string action_selection)
Definition ovenindoor.c:92
void SetFirePointIndex(int fire_point_index)
Definition ovenindoor.c:98
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
Definition ovenindoor.c:319
static bool CanPlaceFireplaceInSelectedSpot(Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world)
Definition ovenindoor.c:103
override bool OnStoreLoad(ParamsReadContext ctx, int version)
Definition ovenindoor.c:54
override void EEItemDetached(EntityAI item, string slot_name)
Definition ovenindoor.c:212
override bool CanRemoveFromCargo(EntityAI parent)
Definition ovenindoor.c:262
override void OnStoreSave(ParamsWriteContext ctx)
Definition ovenindoor.c:41
override bool CanReleaseAttachment(EntityAI attachment)
Definition ovenindoor.c:164
Serialization general interface. Serializer API works with:
Definition serializer.c:56
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void RefreshFireplaceVisuals()
void RemoveFromFireConsumables(FireConsumable fire_consumable)
ref UniversalTemperatureSourceSettings m_UTSSettings
bool HasAnyKindling()
override void CheckForDestroy()
Particle m_ParticleSmallSmoke
float m_LightDistance
void AddToFireConsumables(ItemBase item)
int PARTICLE_STEAM_END
int PARTICLE_NORMAL_FIRE
int PARTICLE_FIRE_START
bool IsFuel(ItemBase item)
Returns if item attached to fireplace is fuel.
int PARTICLE_NORMAL_SMOKE
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
proto native CGame GetGame()
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
void PlayParticle(int particle_id=-1)
Method to tell the particle to start playing.