Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
fireplaceindoor.c
Go to the documentation of this file.
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
16 PARTICLE_FIRE_START = ParticleList.HOUSE_FIRE_START;
17 PARTICLE_SMALL_FIRE = ParticleList.HOUSE_SMALL_FIRE;
18 PARTICLE_NORMAL_FIRE = ParticleList.HOUSE_NORMAL_FIRE;
19 PARTICLE_SMALL_SMOKE = ParticleList.HOUSE_SMALL_SMOKE;
20 PARTICLE_NORMAL_SMOKE = ParticleList.HOUSE_NORMAL_SMOKE;
21 PARTICLE_FIRE_END = ParticleList.HOUSE_FIRE_END;
22 PARTICLE_STEAM_END = ParticleList.HOUSE_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
42 override void OnStoreSave( ParamsWriteContext ctx )
43 {
44 super.OnStoreSave( ctx );
45
46 //fire point name
47 ctx.Write( m_FirePointIndex );
48
49 //smoke position
50 ctx.Write( m_SmokePosX );
51 ctx.Write( m_SmokePosY );
52 ctx.Write( m_SmokePosZ );
53 }
54
55 override bool OnStoreLoad( ParamsReadContext ctx, int version )
56 {
57 if ( !super.OnStoreLoad( ctx, version ) )
58 return false;
59
60 //--- Fireplace Indoor data ---
61 //fire point name
62 if ( !ctx.Read( m_FirePointIndex ) )
63 {
64 m_FirePointIndex = 1; //set default
65 return false;
66 }
67
68 //smoke position
69 if ( !ctx.Read( m_SmokePosX ) )
70 {
71 m_SmokePosX = 0; //set default
72 return false;
73 }
74 if ( !ctx.Read( m_SmokePosY ) )
75 {
76 m_SmokePosY = 0; //set default
77 return false;
78 }
79 if ( !ctx.Read( m_SmokePosZ ) )
80 {
81 m_SmokePosZ = 0; //set default
82 return false;
83 }
84 //---
85
86 return true;
87 }
88
89 //================================================================
90 // FIRE POINT (HOUSE)
91 // LIMITED TO 1 DECIMAL PLACE (0-9)
92 //================================================================
93 static int GetFirePointIndex( string action_selection )
94 {
95 int index_location = action_selection.Length() - 1;
96 return action_selection.Substring( index_location, 1 ).ToInt();
97 }
98
99 void SetFirePointIndex( int fire_point_index )
100 {
101 m_FirePointIndex = fire_point_index;
102 }
103
104 static bool CanPlaceFireplaceInSelectedSpot( Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world )
105 {
106 //Get fire point index position
107 vector fire_point_pos = building.GetSelectionPositionMS( FIREPOINT_FIRE_POSITION + fire_point_index.ToString() );
108 vector fire_point_rot = building.GetSelectionPositionMS( FIREPOINT_PLACE_ROT + fire_point_index.ToString() );
109 fire_point_pos_world = building.ModelToWorld( fire_point_pos );
110 fire_point_rot_world = building.ModelToWorld( fire_point_rot );
111
112 //check if there is any FireplaceIndoor objects near selected fire point
113 ref array<Object> nearest_objects = new array<Object>;
114 ref array<CargoBase> proxy_cargos = new array<CargoBase>;
115 GetGame().GetObjectsAtPosition3D( fire_point_pos_world, 0.25, nearest_objects, proxy_cargos );
116
117 for ( int i = 0; i < nearest_objects.Count(); ++i )
118 {
119 Object object = nearest_objects.Get( i );
120
121 if ( object.IsInherited( FireplaceIndoor ) )
122 {
123 return false;
124 }
125 }
126
127 return true;
128 }
129
130 void SetSmokePointPosition( vector smoke_point_pos )
131 {
132 m_SmokePosX = smoke_point_pos[0];
133 m_SmokePosY = smoke_point_pos[1];
134 m_SmokePosZ = smoke_point_pos[2];
135 }
136
137 //================================================================
138 // PARTICLES
139 //================================================================
140 override protected vector GetSmokeEffectPosition()
141 {
143 }
144
145 //small smoke
150
151 //normal smoke
156
157 //================================================================
158 // STATE
159 //================================================================
160 override bool IsFireplaceIndoor()
161 {
162 return true;
163 }
164
165 override void EEItemAttached(EntityAI item, string slot_name)
166 {
167 super.EEItemAttached(item, slot_name);
168
169 ItemBase item_base = ItemBase.Cast(item);
170 if ( IsKindling(item_base) || IsFuel(item_base))
171 {
172 AddToFireConsumables(item_base);
173 }
174
175 // direct cooking slots, smoking slots
176 bool edible_base_attached = false;
177 switch ( slot_name )
178 {
179 case "DirectCookingA":
180 m_DirectCookingSlots[0] = item_base;
181 edible_base_attached = true;
182 break;
183 case "DirectCookingB":
184 m_DirectCookingSlots[1] = item_base;
185 edible_base_attached = true;
186 break;
187 case "DirectCookingC":
188 m_DirectCookingSlots[2] = item_base;
189 edible_base_attached = true;
190 break;
191
192 case "SmokingA":
193 m_SmokingSlots[0] = item_base;
194 edible_base_attached = true;
195 break;
196 case "SmokingB":
197 m_SmokingSlots[1] = item_base;
198 edible_base_attached = true;
199 break;
200 case "SmokingC":
201 m_SmokingSlots[2] = item_base;
202 edible_base_attached = true;
203 break;
204 case "SmokingD":
205 m_SmokingSlots[3] = item_base;
206 edible_base_attached = true;
207 break;
208 }
209
211 }
212
213 override void EEItemDetached(EntityAI item, string slot_name)
214 {
215 super.EEItemDetached(item, slot_name);
216
217 ItemBase item_base = ItemBase.Cast(item);
218
219 if (IsKindling(item_base) || IsFuel(item_base))
220 {
222 }
223
225
226 // direct cooking/smoking slots
227 switch (slot_name)
228 {
229 case "DirectCookingA":
230 m_DirectCookingSlots[0] = null;
231 break;
232 case "DirectCookingB":
233 m_DirectCookingSlots[1] = null;
234 break;
235 case "DirectCookingC":
236 m_DirectCookingSlots[2] = null;
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 and clear references)
254 if (item_base.IsCookware())
255 {
256 ClearCookingEquipment(item_base);
257 item_base.RemoveAudioVisualsOnClient();
258 }
259
260 if (item_base.IsLiquidContainer()) //boiling bottle effects stop
261 item_base.RemoveAudioVisualsOnClient();
262
264 }
265
266 //================================================================
267 // CONDITIONS
268 //================================================================
269 //this into/outo parent.Cargo
270 override bool CanPutInCargo( EntityAI parent )
271 {
272 return false;
273 }
274
275 override bool CanRemoveFromCargo( EntityAI parent )
276 {
277 return true;
278 }
279
280 //cargo item into/outo this.Cargo
281 override bool CanReceiveItemIntoCargo( EntityAI item )
282 {
283 return super.CanReceiveItemIntoCargo( item );
284 }
285
286 //hands
287 override bool CanPutIntoHands( EntityAI parent )
288 {
289 return false;
290 }
291
292 override bool CanRemoveFromHands( EntityAI parent )
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 target_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 SetIgniteFailure( false );
341 Param1<bool> failure;
342
343 //check kindling
344 if ( !HasAnyKindling() )
345 {
346 return false;
347 }
348
349 //check wetness
350 if ( IsWet() )
351 {
352 SetIgniteFailure( true );
353
354 failure = new Param1<bool>( GetIgniteFailure() );
355 GetGame().RPCSingleParam( this, FirePlaceFailure.WET, failure, true );
356 return false;
357 }
358
359 return true;
360 }
361}
override bool CanReceiveItemIntoCargo(EntityAI item)
vector GetSmokeEffectPosition()
override void EEItemAttached(EntityAI item, string slot_name)
static bool CanPlaceFireplaceInSelectedSpot(Object building, int fire_point_index, out vector fire_point_pos_world, out vector fire_point_rot_world)
void SetSmokePointPosition(vector smoke_point_pos)
override bool IsIgnited()
override bool OnStoreLoad(ParamsReadContext ctx, int version)
override void EEItemDetached(EntityAI item, string slot_name)
override bool CanPutIntoHands(EntityAI parent)
static const string FIREPOINT_PLACE_ROT
static int GetFirePointIndex(string action_selection)
override void OnIgnitedTarget(EntityAI target_item)
static const string FIREPOINT_FIRE_POSITION
override void ParticleSmallSmokeStart()
static const string FIREPOINT_ACTION_SELECTION
override bool IsThisIgnitionSuccessful(EntityAI item_source=NULL)
override bool CanIgniteItem(EntityAI ignite_target=NULL)
void SetFirePointIndex(int fire_point_index)
override bool CanBeIgnitedBy(EntityAI igniter=NULL)
override bool HasFlammableMaterial()
override void ParticleNormalSmokeStart()
static const string FIREPOINT_SMOKE_POSITION
override bool CanRemoveFromCargo(EntityAI parent)
override void OnStoreSave(ParamsWriteContext ctx)
override bool CanRemoveFromHands(EntityAI parent)
override bool IsFireplaceIndoor()
override bool CanPutInCargo(EntityAI parent)
override void OnIgnitedThis(EntityAI fire_source)
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.
bool GetIgniteFailure()
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
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
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.