|
enum FireplaceFireState |
|
{ |
|
NO_FIRE = 1, |
|
START_FIRE = 2, |
|
SMALL_FIRE = 3, |
|
NORMAL_FIRE = 4, |
|
END_FIRE = 5, |
|
EXTINGUISHING_FIRE = 6, |
|
EXTINGUISHED_FIRE = 7, |
|
REIGNITED_FIRE = 8, |
|
|
|
COUNT = 9 |
|
} |
|
|
|
enum FirePlaceFailure |
|
{ |
|
WIND = 0, |
|
WET = 1, |
|
} |
|
|
|
class FireplaceBase extends ItemBase |
|
{ |
|
|
|
protected bool m_IsBurning = false; |
|
protected bool m_HasAshes = false; |
|
protected bool m_IsOven = false; |
|
protected bool m_HasStoneCircle = false; |
|
protected bool m_RoofAbove = false; |
|
protected bool m_NoIgnite = false; |
|
protected int m_OvenAttachmentsLockState = -1; |
|
protected FireplaceFireState m_FireState = FireplaceFireState.NO_FIRE; |
|
protected FireplaceFireState m_LastFireState = FireplaceFireState.NO_FIRE; |
|
protected vector m_HalfExtents; |
|
|
|
|
|
protected float m_TemperatureLossMP = 1.0; |
|
protected float m_FuelBurnRateMP = 1.0; |
|
|
|
|
|
protected ref Cooking m_CookingProcess; |
|
|
|
|
|
const float PARAM_SMALL_FIRE_TEMPERATURE = 150; |
|
const float PARAM_NORMAL_FIRE_TEMPERATURE = 1000; |
|
const float PARAM_MIN_FIRE_TEMPERATURE = 30; |
|
const float PARAM_TEMPERATURE_INCREASE = 3; |
|
const float PARAM_TEMPERATURE_DECREASE = 3; |
|
const float PARAM_MAX_WET_TO_IGNITE = 0.2; |
|
const float PARAM_MIN_TEMP_TO_REIGNITE = 30; |
|
const float PARAM_IGNITE_RAIN_THRESHOLD = 0.1; |
|
const float PARAM_BURN_WET_THRESHOLD = 0.40; |
|
const float PARAM_WET_INCREASE_COEF = 0.02; |
|
const float PARAM_WET_HEATING_DECREASE_COEF = 0.01; |
|
const float PARAM_WET_COOLING_DECREASE_COEF = 0.002; |
|
const float PARAM_FIRE_CONSUM_RATE_AMOUNT = 0.5; |
|
const float PARAM_BURN_DAMAGE_COEF = 5.0; |
|
const float PARAM_ITEM_HEAT_TEMP_INCREASE_COEF = 10; |
|
const float PARAM_ITEM_HEAT_MIN_TEMP = 40; |
|
const float PARAM_MAX_ITEM_HEAT_TEMP_INCREASE = 200; |
|
const float PARAM_FULL_HEAT_RADIUS = 2.0; |
|
const float PARAM_HEAT_RADIUS = 4.0; |
|
const float PARAM_HEAT_THROUGH_AIR_COEF = 0.1; |
|
const float PARAM_MAX_TRANSFERED_TEMPERATURE = 25; |
|
|
|
const int MIN_STONES_TO_BUILD_CIRCLE = 8; |
|
const int MIN_STONES_TO_BUILD_OVEN = 16; |
|
const int MAX_TEMPERATURE_TO_DISMANTLE_OVEN = 40; |
|
const float MIN_CEILING_HEIGHT = 5; |
|
|
|
const float TEMPERATURE_LOSS_MP_DEFAULT = 1.0; |
|
const float TEMPERATURE_LOSS_MP_STONES = 0.90; |
|
const float TEMPERATURE_LOSS_MP_OVEN = 0.75; |
|
|
|
const float FUEL_BURN_RATE_DEFAULT = 1.0; |
|
const float FUEL_BURN_RATE_STONES = 0.92; |
|
const float FUEL_BURN_RATE_OVEN = 0.85; |
|
|
|
|
|
const float PARAM_COOKING_TEMP_THRESHOLD = 100; |
|
const float PARAM_COOKING_EQUIP_MAX_TEMP = 250; |
|
const float PARAM_COOKING_EQUIP_TEMP_INCREASE = 10; |
|
|
|
const int TIMER_HEATING_UPDATE_INTERVAL = 3; |
|
const int TIMER_COOLING_UPDATE_INTERVAL = 2; |
|
|
|
const int DIRECT_COOKING_SLOT_COUNT = 3; |
|
const float DIRECT_COOKING_SPEED = 1.5; |
|
const int SMOKING_SLOT_COUNT = 4; |
|
const float SMOKING_SPEED = 1; |
|
|
|
|
|
const int LIFETIME_FIREPLACE_STONE_CIRCLE = 172800; |
|
const int LIFETIME_FIREPLACE_STONE_OVEN = 604800; |
|
|
|
const float IGNITE_WIND_THRESHOLD = 0.8; |
|
|
|
|
|
protected ref Timer m_HeatingTimer; |
|
protected ref Timer m_CoolingTimer; |
|
|
|
|
|
protected FireplaceLight m_Light; |
|
protected float m_LightDistance = 2000; |
|
|
|
|
|
protected ItemBase m_CookingEquipment; |
|
protected ItemBase m_DirectCookingSlots[DIRECT_COOKING_SLOT_COUNT]; |
|
protected ItemBase m_SmokingSlots[SMOKING_SLOT_COUNT]; |
|
protected ref FireConsumable m_ItemToConsume; |
|
|
|
|
|
protected int PARTICLE_FIRE_START = ParticleList.CAMP_FIRE_START; |
|
protected int PARTICLE_OVEN_FIRE_START = ParticleList.CAMP_STOVE_FIRE_START; |
|
protected int PARTICLE_SMALL_FIRE = ParticleList.CAMP_SMALL_FIRE; |
|
protected int PARTICLE_NORMAL_FIRE = ParticleList.CAMP_NORMAL_FIRE; |
|
protected int PARTICLE_OVEN_FIRE = ParticleList.CAMP_STOVE_FIRE; |
|
protected int PARTICLE_SMALL_SMOKE = ParticleList.CAMP_SMALL_SMOKE; |
|
protected int PARTICLE_NORMAL_SMOKE = ParticleList.CAMP_NORMAL_SMOKE; |
|
protected int PARTICLE_FIRE_END = ParticleList.CAMP_FIRE_END; |
|
protected int PARTICLE_OVEN_FIRE_END = ParticleList.CAMP_STOVE_FIRE_END; |
|
protected int PARTICLE_STEAM_END = ParticleList.CAMP_STEAM_2END; |
|
protected int PARTICLE_STEAM_EXTINGUISHING = ParticleList.CAMP_STEAM_EXTINGUISH_START; |
|
protected int PARTICLE_NO_IGNITE_WIND = ParticleList.CAMP_NO_IGNITE_WIND; |
|
|
|
protected Particle m_ParticleFireStart; |
|
protected Particle m_ParticleSmallFire; |
|
protected Particle m_ParticleNormalFire; |
|
protected Particle m_ParticleSmallSmoke; |
|
protected Particle m_ParticleNormalSmoke; |
|
protected Particle m_ParticleFireEnd; |
|
protected Particle m_ParticleSteamEnd; |
|
protected Particle m_ParticleSteamExtinguishing; |
|
|
|
|
|
const string SOUND_FIRE_HEAVY = "HeavyFire_SoundSet"; |
|
const string SOUND_FIRE_LIGHT = "LightFire_SoundSet"; |
|
const string SOUND_FIRE_NO_FIRE = "NoFuelFire_SoundSet"; |
|
const string SOUND_FIRE_EXTINGUISHING = "ExtinguishByWater_SoundSet"; |
|
const string SOUND_FIRE_EXTINGUISHED = "ExtinguishByWaterEnd_SoundSet"; |
|
|
|
|
|
protected EffectSound m_SoundFireLoop; |
|
protected EffectSound m_SoundFire; |
|
|
|
|
|
|
|
|
|
protected static ref map<typename, ref FireConsumableType> m_FireConsumableTypes; |
|
protected ref map<ItemBase, ref FireConsumable> m_FireConsumables; |
|
|
|
|
|
const string MESSAGE_IGNITE_IGNIT_ITEM_DAMAGED = "You cannot start fire. Fireplace is ruined."; |
|
const string MESSAGE_IGNITE_NO_KINDLING = "There needs to be some kindling to start a fire."; |
|
const string MESSAGE_IGNITE_TOO_WET = "The fireplace is too wet to be ignited."; |
|
const string MESSAGE_IGNITE_RAIN = "The fire went out because of the rain."; |
|
const string MESSAGE_IGNITE_WIND = "The fire went out because of the wind."; |
|
const string MESSAGE_IGNITE_IN_WATER = "I cannot ignite the fireplace in the water."; |
|
const string MESSAGE_IGNITE_UNDER_LOW_ROOF = "I cannot ignite the fireplace here, the is not enough room."; |
|
const string MESSAGE_REIGNITE_NO_KINDLING = "There needs to be some kindling to start a fire."; |
|
const string MESSAGE_REIGNITE_RAIN = "Cannot reignite fireplace in rain."; |
|
const string MESSAGE_REIGNITE_TOO_WET = "The fireplace is too wet to be reignited."; |
|
const string MESSAGE_BURY_ASHES_FAILED_NOT_EMPTY = "Cannot bury ashes. There are sill items in it."; |
|
const string MESSAGE_BURY_ASHES_FAILED_SURFACE = "Cannot bury ashes on hard surface."; |
|
const string MESSAGE_BURY_ASHES_FAILED_BURNING = "Cannot bury ashes, the fireplace is still burning."; |
|
const string MESSAGE_BURY_ASHES_FAILED_TOO_HOT = "Cannot bury ashes, the fireplace is too hot."; |
|
const string MESSAGE_CANNOT_BUILD_OVEN = "Cannot build oven."; |
|
const string MESSAGE_CANNOT_DISMANTLE_OVEN = "Cannot dismantle oven."; |
|
|
|
|
|
const string ANIMATION_ASHES = "Ashes"; |
|
const string ANIMATION_KINDLING = "Kindling"; |
|
const string ANIMATION_STICKS = "Sticks"; |
|
const string ANIMATION_WOOD = "Wood"; |
|
const string ANIMATION_BURNT_WOOD = "BurntWood"; |
|
const string ANIMATION_STONE = "Stone"; |
|
const string ANIMATION_STONES = "StonesCircle"; |
|
const string ANIMATION_TRIPOD = "Tripod"; |
|
const string ANIMATION_OVEN = "Oven"; |
|
const string ANIMATION_INVENTORY = "Inventory"; |
|
const string ANIMATION_COOKWARE_HANDLE = "handleRotate"; |
|
const string ANIMATION_CAULDRON_HANDLE = "handle1Rotate"; |
|
|
|
|
|
|
|
const string MATERIAL_FIREPLACE_GLOW = "dz\\gear\\cooking\\data\\stoneground.rvmat"; |
|
const string MATERIAL_FIREPLACE_NOGLOW = "dz\\gear\\cooking\\data\\stonegroundnoemit.rvmat"; |
|
|
|
|
|
|
|
typename ATTACHMENT_STICKS = WoodenStick; |
|
typename ATTACHMENT_FIREWOOD = Firewood; |
|
|
|
typename ATTACHMENT_RAGS = Rag; |
|
typename ATTACHMENT_BANDAGE = BandageDressing; |
|
typename ATTACHMENT_BOOK = ItemBook; |
|
typename ATTACHMENT_BARK_OAK = Bark_Oak; |
|
typename ATTACHMENT_BARK_BIRCH = Bark_Birch; |
|
typename ATTACHMENT_PAPER = Paper; |
|
typename ATTACHMENT_GIFTWRAP = GiftWrapPaper; |
|
typename ATTACHMENT_PUNCHEDCARD = PunchedCard; |
|
typename ATTACHMENT_EYEMASK_COLORBASE = EyeMask_ColorBase; |
|
|
|
typename ATTACHMENT_TRIPOD = Tripod; |
|
typename ATTACHMENT_COOKINGSTAND = CookingStand; |
|
typename ATTACHMENT_STONES = Stone; |
|
typename ATTACHMENT_COOKING_POT = Pot; |
|
typename ATTACHMENT_FRYING_PAN = FryingPan; |
|
typename ATTACHMENT_CAULDRON = Cauldron; |
|
|
|
const string OBJECT_CLUTTER_CUTTER = "ClutterCutterFireplace"; |
|
protected Object m_ClutterCutter; |
|
|
|
|
|
protected ref AreaDamageManager m_AreaDamage; |
|
|
|
|
|
protected float m_TotalEnergy; |
|
|
|
|
|
ref NoiseParams m_NoisePar; |
|
private bool m_CanNoise = true; |
|
|
|
|
|
protected ref UniversalTemperatureSource m_UTSource; |
|
protected ref UniversalTemperatureSourceSettings m_UTSSettings; |
|
protected ref UniversalTemperatureSourceLambdaFireplace m_UTSLFireplace; |
|
|
|
|
|
|
|
|
|
|
|
protected void FireplaceBase() |
|
{ |
|
|
|
if (!m_FireConsumableTypes) |
|
{ |
|
m_FireConsumableTypes = new ref map<typename, ref FireConsumableType>(); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_RAGS, new FireConsumableType(ATTACHMENT_RAGS, 14, true, "Rags")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_BANDAGE, new FireConsumableType(ATTACHMENT_BANDAGE, 14, true, "MedicalBandage")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_BOOK, new FireConsumableType(ATTACHMENT_BOOK, 36, true, "Book")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_BARK_OAK, new FireConsumableType(ATTACHMENT_BARK_OAK, 20, true, "OakBark")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_BARK_BIRCH, new FireConsumableType(ATTACHMENT_BARK_BIRCH, 14, true, "BirchBark")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_PAPER, new FireConsumableType(ATTACHMENT_PAPER, 10, true, "Paper")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_GIFTWRAP, new FireConsumableType(ATTACHMENT_GIFTWRAP, 10, true, "GiftWrapPaper")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_PUNCHEDCARD, new FireConsumableType(ATTACHMENT_PUNCHEDCARD, 10, true, "PunchedCard")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_EYEMASK_COLORBASE, new FireConsumableType(ATTACHMENT_EYEMASK_COLORBASE, 10, true, "EyeMask_ColorBase")); |
|
|
|
|
|
m_FireConsumableTypes.Insert(ATTACHMENT_STICKS, new FireConsumableType( ATTACHMENT_STICKS, 40, false, "WoodenStick")); |
|
m_FireConsumableTypes.Insert(ATTACHMENT_FIREWOOD, new FireConsumableType( ATTACHMENT_FIREWOOD, 100, false, "Firewood")); |
|
} |
|
|
|
|
|
CalcAndSetTotalEnergy(); |
|
|
|
|
|
m_FireConsumables = new ref map<ItemBase, ref FireConsumable>; |
|
|
|
|
|
SetTemperatureLossMP( TEMPERATURE_LOSS_MP_DEFAULT ); |
|
SetFuelBurnRateMP( FUEL_BURN_RATE_DEFAULT ); |
|
|
|
|
|
RegisterNetSyncVariableBool( "m_IsBurning" ); |
|
RegisterNetSyncVariableBool( "m_HasAshes" ); |
|
RegisterNetSyncVariableBool( "m_IsOven" ); |
|
RegisterNetSyncVariableBool( "m_HasStoneCircle" ); |
|
RegisterNetSyncVariableBool( "m_RoofAbove" ); |
|
RegisterNetSyncVariableInt( "m_FireState", FireplaceFireState.NO_FIRE, FireplaceFireState.COUNT ); |
|
RegisterNetSyncVariableBool( "m_IsSoundSynchRemote" ); |
|
RegisterNetSyncVariableBool( "m_IsPlaceSound" ); |
|
RegisterNetSyncVariableBool( "m_NoIgnite" ); |
|
|
|
m_HalfExtents = vector.Zero; |
|
} |
|
|
|
protected void ~FireplaceBase() |
|
{ |
|
DestroyAreaDamage(); |
|
|
|
if (GetLightEntity()) |
|
{ |
|
GetLightEntity().FadeOut(); |
|
} |
|
} |
|
|
|
override void EEInit() |
|
{ |
|
super.EEInit(); |
|
|
|
|
|
RefreshFireplaceVisuals(); |
|
|
|
if (GetGame().IsServer() || !GetGame().IsMultiplayer()) |
|
{ |
|
m_UTSSettings = new UniversalTemperatureSourceSettings(); |
|
m_UTSSettings.m_AffectStat = true; |
|
m_UTSSettings.m_ManualUpdate = true; |
|
m_UTSSettings.m_TemperatureMin = 0; |
|
m_UTSSettings.m_TemperatureMax = PARAM_NORMAL_FIRE_TEMPERATURE; |
|
m_UTSSettings.m_TemperatureCap = PARAM_MAX_TRANSFERED_TEMPERATURE; |
|
m_UTSSettings.m_RangeFull = PARAM_FULL_HEAT_RADIUS; |
|
m_UTSSettings.m_RangeMax = PARAM_HEAT_RADIUS; |
|
|
|
m_UTSLFireplace = new UniversalTemperatureSourceLambdaFireplace(); |
|
m_UTSLFireplace.SetSmallFireplaceTemperatureMax(PARAM_SMALL_FIRE_TEMPERATURE); |
|
m_UTSLFireplace.SetNormalFireplaceTemperatureMax(PARAM_NORMAL_FIRE_TEMPERATURE); |
|
|
|
m_UTSource = new UniversalTemperatureSource(this, m_UTSSettings, m_UTSLFireplace); |
|
} |
|
} |
|
|
|
override void EEItemAttached(EntityAI item, string slot_name) |
|
{ |
|
super.EEItemAttached(item, slot_name); |
|
|
|
|
|
switch (item.Type()) |
|
{ |
|
case ATTACHMENT_CAULDRON: |
|
case ATTACHMENT_COOKING_POT: |
|
case ATTACHMENT_FRYING_PAN: |
|
SetCookingEquipment(ItemBase.Cast(item)); |
|
break; |
|
} |
|
} |
|
|
|
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner) |
|
{ |
|
super.OnItemLocationChanged(old_owner, new_owner); |
|
|
|
|
|
GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(RefreshFireplacePhysics); |
|
} |
|
|
|
override void OnAttachmentRuined(EntityAI attachment) |
|
{ |
|
switch (attachment.Type()) |
|
{ |
|
case ATTACHMENT_TRIPOD: |
|
case ATTACHMENT_COOKINGSTAND: |
|
int slot = InventorySlots.GetSlotIdFromString("CookingEquipment"); |
|
EntityAI ent = GetInventory().FindAttachment(slot); |
|
if (ent) |
|
{ |
|
switch (ent.Type()) |
|
{ |
|
case ATTACHMENT_COOKING_POT: |
|
case ATTACHMENT_CAULDRON: |
|
case ATTACHMENT_FRYING_PAN: |
|
vector direction = ent.GetDirection(); |
|
float dot = vector.Dot(direction, vector.Forward); |
|
|
|
float angle = Math.Acos(dot); |
|
if (direction[0] < 0) |
|
{ |
|
angle = -angle; |
|
} |
|
|
|
float cos = Math.Cos(angle); |
|
float sin = Math.Sin(angle); |
|
GetInventory().DropEntityInBounds(InventoryMode.SERVER, this, ent, "2 0 2", angle, cos, sin); |
|
break; |
|
} |
|
} |
|
|
|
attachment.Delete(); |
|
break; |
|
} |
|
} |
|
|
|
override void EEDelete(EntityAI parent) |
|
{ |
|
super.EEDelete(parent); |
|
|
|
SetFireState(FireplaceFireState.NO_FIRE); |
|
|
|
|
|
#ifndef SERVER |
|
StopAllParticlesAndSounds(); |
|
#endif |
|
} |
|
|
|
|
|
override void OnStoreSave( ParamsWriteContext ctx ) |
|
{ |
|
super.OnStoreSave(ctx); |
|
|
|
|
|
ctx.Write( m_HasAshes ); |
|
|
|
|
|
ctx.Write( m_TemperatureLossMP ); |
|
|
|
|
|
ctx.Write( m_FuelBurnRateMP ); |
|
|
|
|
|
ctx.Write( m_IsBurning ); |
|
} |
|
|
|
override bool OnStoreLoad( ParamsReadContext ctx, int version ) |
|
{ |
|
if ( !super.OnStoreLoad(ctx, version) ) |
|
return false; |
|
|
|
|
|
|
|
if ( !ctx.Read( m_HasAshes ) ) |
|
{ |
|
m_HasAshes = false; |
|
return false; |
|
} |
|
|
|
|
|
if ( !ctx.Read( m_TemperatureLossMP ) ) |
|
{ |
|
m_TemperatureLossMP = 1.0; |
|
return false; |
|
} |
|
|
|
|
|
if ( !ctx.Read( m_FuelBurnRateMP ) ) |
|
{ |
|
m_FuelBurnRateMP = 1.0; |
|
return false; |
|
} |
|
|
|
|
|
if ( !ctx.Read( m_IsBurning ) ) |
|
{ |
|
m_IsBurning = false; |
|
return false; |
|
} |
|
|
|
|
|
return true; |
|
} |
|
|
|
override void AfterStoreLoad() |
|
{ |
|
super.AfterStoreLoad(); |
|
|
|
Synchronize(); |
|
|
|
|
|
if (IsBurning() ) |
|
{ |
|
if (GetGame() && GetGame().IsServer()) |
|
{ |
|
StartFire(true); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
void Synchronize() |
|
{ |
|
if ( GetGame() && GetGame().IsServer() ) |
|
{ |
|
SetSynchDirty(); |
|
|
|
if ( GetGame().IsMultiplayer() && GetGame().IsServer() ) |
|
{ |
|
|
|
GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).Call( RefreshFireplaceVisuals ); |
|
} |
|
} |
|
} |
|
|
|
override void OnVariablesSynchronized() |
|
{ |
|
super.OnVariablesSynchronized(); |
|
|
|
RefreshFireplaceVisuals(); |
|
RefreshFireParticlesAndSounds(false); |
|
|
|
if (IsPlaceSound()) |
|
{ |
|
PlayPlaceSound(); |
|
} |
|
|
|
if (IsBaseFireplace() && !IsOven()) |
|
{ |
|
if (m_IsBurning && !m_AreaDamage) |
|
{ |
|
CreateAreaDamage(); |
|
} |
|
else if (!m_IsBurning && m_AreaDamage) |
|
{ |
|
DestroyAreaDamage(); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override bool IsFireplace() |
|
{ |
|
return true; |
|
} |
|
|
|
bool IsBaseFireplace() |
|
{ |
|
return false; |
|
} |
|
|
|
bool IsBarrelWithHoles() |
|
{ |
|
return false; |
|
} |
|
|
|
bool IsFireplaceIndoor() |
|
{ |
|
return false; |
|
} |
|
|
|
bool IsIndoorOven() |
|
{ |
|
return false; |
|
} |
|
|
|
override bool CanHaveWetness() |
|
{ |
|
return true; |
|
} |
|
|
|
override bool CanHaveTemperature() |
|
{ |
|
return true; |
|
} |
|
|
|
|
|
ItemBase GetCookingEquipment() |
|
{ |
|
return m_CookingEquipment; |
|
} |
|
|
|
void SetCookingEquipment(ItemBase equipment) |
|
{ |
|
m_CookingEquipment = equipment; |
|
} |
|
|
|
void ClearCookingEquipment(ItemBase pItem) |
|
{ |
|
if (m_CookingProcess) |
|
{ |
|
m_CookingProcess.TerminateCookingSounds(pItem); |
|
} |
|
|
|
SetCookingEquipment(null); |
|
} |
|
|
|
|
|
void ClearCookingEquipment() |
|
{ |
|
SetCookingEquipment(null); |
|
} |
|
|
|
bool DirectCookingSlotsInUse() |
|
{ |
|
for (int i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++) |
|
{ |
|
if ( m_DirectCookingSlots[i] ) |
|
{ |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
bool SmokingSlotsInUse() |
|
{ |
|
for (int i = 0; i < SMOKING_SLOT_COUNT; i++) |
|
{ |
|
if ( m_SmokingSlots[i] ) |
|
{ |
|
return true; |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
|
|
void DestroyFireplace() |
|
{ |
|
DeleteSafe(); |
|
} |
|
|
|
override bool IsPrepareToDelete() |
|
{ |
|
return IsEmpty() && !IsBurning() && !HasAshes(); |
|
} |
|
|
|
override void EECargoOut(EntityAI item) |
|
{ |
|
super.EECargoOut(item); |
|
|
|
CheckForDestroy(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
void RefreshFireplaceVisuals() |
|
{ |
|
if (IsHologram()) |
|
{ |
|
return; |
|
} |
|
|
|
|
|
#ifndef SERVER |
|
if (IsBurning() ) |
|
{ |
|
|
|
if (!GetLightEntity()) |
|
{ |
|
SetLightEntity(FireplaceLight.Cast(ScriptedLightBase.CreateLight(FireplaceLight, GetPosition(), 20))); |
|
GetLightEntity().AttachOnMemoryPoint(this, "light"); |
|
} |
|
|
|
if (GetLightEntity() && GetLightEntity().GetBrightness() > 0) |
|
{ |
|
|
|
Object player = GetGame().GetPlayer(); |
|
float lightDist = m_LightDistance; |
|
|
|
if (IsOven()) |
|
{ |
|
lightDist = 50; |
|
} |
|
|
|
if (player) |
|
{ |
|
if (vector.DistanceSq(player.GetPosition(), this.GetPosition()) > lightDist * lightDist) |
|
{ |
|
GetLightEntity().FadeBrightnessTo(0, 5); |
|
} |
|
else |
|
{ |
|
GetLightEntity().FadeBrightnessTo(FireplaceLight.m_FireplaceBrightness, 5); |
|
} |
|
} |
|
|
|
|
|
if (IsItemTypeAttached(ATTACHMENT_STONES) || IsBarrelWithHoles() || IsFireplaceIndoor()) |
|
{ |
|
GetLightEntity().SetInteriorMode(); |
|
} |
|
else |
|
{ |
|
GetLightEntity().SetExteriorMode(); |
|
} |
|
} |
|
} |
|
else |
|
{ |
|
|
|
if (GetLightEntity()) |
|
{ |
|
GetLightEntity().FadeOut(); |
|
} |
|
} |
|
#endif |
|
|
|
|
|
if (IsBarrelWithHoles() || IsFireplaceIndoor() || IsIndoorOven() || IsOven()) |
|
{ |
|
SetFuelBurnRateMP(FUEL_BURN_RATE_OVEN); |
|
SetTemperatureLossMP(TEMPERATURE_LOSS_MP_OVEN); |
|
} |
|
else if (HasStoneCircle()) |
|
{ |
|
SetFuelBurnRateMP(FUEL_BURN_RATE_STONES); |
|
SetTemperatureLossMP(TEMPERATURE_LOSS_MP_STONES); |
|
} |
|
else |
|
{ |
|
SetFuelBurnRateMP(FUEL_BURN_RATE_DEFAULT); |
|
SetTemperatureLossMP(TEMPERATURE_LOSS_MP_DEFAULT); |
|
} |
|
|
|
|
|
if (IsOven()) |
|
{ |
|
|
|
if (!m_OvenAttachmentsLockState) |
|
{ |
|
LockOvenAttachments(true); |
|
} |
|
} |
|
else |
|
{ |
|
|
|
if (m_OvenAttachmentsLockState) |
|
{ |
|
LockOvenAttachments(false); |
|
} |
|
} |
|
|
|
|
|
|
|
if ( GetGame().IsServer() ) |
|
{ |
|
|
|
if ( IsItemTypeAttached( ATTACHMENT_STICKS ) ) |
|
SetAnimationPhase( ANIMATION_STICKS, 0 ); |
|
else |
|
SetAnimationPhase( ANIMATION_STICKS, 1 ); |
|
|
|
|
|
if ( IsItemTypeAttached( ATTACHMENT_FIREWOOD ) ) |
|
{ |
|
if ( IsBurning() && HasAshes() ) |
|
{ |
|
SetAnimationPhase( ANIMATION_BURNT_WOOD, 0 ); |
|
SetAnimationPhase( ANIMATION_WOOD, 1 ); |
|
} |
|
|
|
if ( IsWet() || !IsBurning() ) |
|
{ |
|
SetAnimationPhase( ANIMATION_BURNT_WOOD, 1 ); |
|
SetAnimationPhase( ANIMATION_WOOD, 0 ); |
|
} |
|
} |
|
else |
|
{ |
|
SetAnimationPhase( ANIMATION_WOOD, 1 ); |
|
SetAnimationPhase( ANIMATION_BURNT_WOOD, 1 ); |
|
} |
|
|
|
|
|
if ( GetKindlingCount() != 0 ) |
|
SetAnimationPhase( ANIMATION_KINDLING, 0 ); |
|
else |
|
SetAnimationPhase( ANIMATION_KINDLING, 1 ); |
|
|
|
|
|
if ( HasAshes() ) |
|
SetAnimationPhase( ANIMATION_ASHES, 0 ); |
|
else |
|
SetAnimationPhase( ANIMATION_ASHES, 1 ); |
|
|
|
|
|
if (HasStones()) |
|
{ |
|
if (HasStoneCircle()) |
|
{ |
|
SetAnimationPhase(ANIMATION_STONES, 0); |
|
SetAnimationPhase(ANIMATION_STONE, 1); |
|
} |
|
else if (IsOven()) |
|
{ |
|
SetAnimationPhase(ANIMATION_OVEN, 0); |
|
SetAnimationPhase(ANIMATION_STONE, 1); |
|
} |
|
else |
|
{ |
|
|
|
SetAnimationPhase(ANIMATION_STONES, 1); |
|
SetAnimationPhase(ANIMATION_OVEN, 1); |
|
SetAnimationPhase(ANIMATION_STONE, 0); |
|
} |
|
} |
|
else |
|
{ |
|
SetAnimationPhase(ANIMATION_STONE, 1); |
|
} |
|
} |
|
|
|
|
|
GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).Call(RefreshFireplacePhysics); |
|
} |
|
|
|
protected void SetBurntFirewood() |
|
{ |
|
if ( GetGame().IsServer() && IsInAnimPhase( ANIMATION_WOOD ) ) |
|
{ |
|
SetAnimationPhase( ANIMATION_WOOD, 1 ); |
|
SetAnimationPhase( ANIMATION_BURNT_WOOD, 0 ); |
|
} |
|
} |
|
|
|
|
|
void RefreshFireplacePhysics(); |
|
|
|
protected void RefreshFireParticlesAndSounds( bool force_refresh ) |
|
{ |
|
FireplaceFireState fire_state = GetFireState(); |
|
|
|
if ( m_LastFireState != fire_state || force_refresh ) |
|
{ |
|
switch ( fire_state ) |
|
{ |
|
case FireplaceFireState.START_FIRE: |
|
{ |
|
|
|
ParticleFireStartStart(); |
|
|
|
|
|
SoundFireStop(); |
|
SoundFireLightStart(); |
|
break; |
|
} |
|
case FireplaceFireState.SMALL_FIRE: |
|
{ |
|
|
|
ParticleFireStartStop(); |
|
|
|
ParticleSmallFireStart(); |
|
|
|
if ( CanShowSmoke() ) |
|
ParticleSmallSmokeStart(); |
|
else |
|
ParticleSmallSmokeStop(); |
|
|
|
ParticleNormalFireStop(); |
|
ParticleNormalSmokeStop(); |
|
|
|
ParticleSteamExtinguishingStop(); |
|
|
|
|
|
SoundFireStop(); |
|
SoundFireLightStart(); |
|
break; |
|
} |
|
case FireplaceFireState.NORMAL_FIRE: |
|
{ |
|
|
|
ParticleFireStartStop(); |
|
|
|
ParticleSmallFireStop(); |
|
ParticleSmallSmokeStop(); |
|
|
|
ParticleNormalFireStart(); |
|
|
|
if ( CanShowSmoke() ) |
|
ParticleNormalSmokeStart(); |
|
else |
|
ParticleNormalSmokeStop(); |
|
|
|
ParticleSteamExtinguishingStop(); |
|
|
|
|
|
SoundFireStop(); |
|
SoundFireHeavyStart(); |
|
break; |
|
} |
|
case FireplaceFireState.END_FIRE: |
|
{ |
|
|
|
ParticleFireStartStop(); |
|
|
|
ParticleSmallFireStop(); |
|
ParticleSmallSmokeStop(); |
|
|
|
ParticleNormalFireStop(); |
|
ParticleNormalSmokeStop(); |
|
|
|
ParticleFireEndStart(); |
|
|
|
|
|
SoundFireStop(); |
|
SoundFireNoFireStart(); |
|
break; |
|
} |
|
case FireplaceFireState.EXTINGUISHING_FIRE: |
|
{ |
|
|
|
ParticleFireStartStop(); |
|
|
|
ParticleSmallFireStop(); |
|
ParticleSmallSmokeStop(); |
|
|
|
ParticleNormalFireStop(); |
|
ParticleNormalSmokeStop(); |
|
|
|
ParticleFireEndStop(); |
|
|
|
ParticleSteamExtinguishingStart(); |
|
|
|
|
|
SoundFireStop(); |
|
SoundFireExtinguishingStart(); |
|
break; |
|
} |
|
case FireplaceFireState.EXTINGUISHED_FIRE: |
|
{ |
|
|
|
ParticleFireStartStop(); |
|
|
|
ParticleSmallFireStop(); |
|
ParticleSmallSmokeStop(); |
|
|
|
ParticleNormalFireStop(); |
|
ParticleNormalSmokeStop(); |
|
|
|
ParticleFireEndStop(); |
|
|
|
ParticleSteamExtinguishingStop(); |
|
|
|
if ( CanShowSmoke() ) |
|
ParticleSteamEndStart(); |
|
else |
|
ParticleSteamEndStop(); |
|
|
|
|
|
SoundFireStop(); |
|
SoundFireExtinguishedStart(); |
|
SoundFireNoFireStart(); |
|
break; |
|
} |
|
case FireplaceFireState.REIGNITED_FIRE: |
|
{ |
|
|
|
ParticleFireStartStart(); |
|
|
|
ParticleSmallFireStop(); |
|
ParticleSmallSmokeStop(); |
|
|
|
ParticleNormalFireStop(); |
|
ParticleNormalSmokeStop(); |
|
|
|
ParticleFireEndStop(); |
|
|
|
ParticleSteamEndStop(); |
|
|
|
|
|
SoundFireStop(); |
|
break; |
|
} |
|
case FireplaceFireState.NO_FIRE: |
|
{ |
|
|
|
ParticleFireStartStop(); |
|
|
|
ParticleSmallFireStop(); |
|
ParticleSmallSmokeStop(); |
|
|
|
ParticleNormalFireStop(); |
|
ParticleNormalSmokeStop(); |
|
|
|
ParticleFireEndStop(); |
|
|
|
ParticleSteamEndStop(); |
|
ParticleSteamExtinguishingStop(); |
|
|
|
|
|
SoundFireStop(); |
|
break; |
|
} |
|
} |
|
|
|
m_LastFireState = fire_state; |
|
} |
|
} |
|
|
|
protected void StopAllParticlesAndSounds() |
|
{ |
|
|
|
if ( m_ParticleFireStart ) |
|
StopParticle( m_ParticleFireStart ); |
|
if ( m_ParticleSmallFire ) |
|
StopParticle( m_ParticleSmallFire ); |
|
if ( m_ParticleNormalFire ) |
|
StopParticle( m_ParticleNormalFire ); |
|
if ( m_ParticleSmallSmoke ) |
|
StopParticle( m_ParticleSmallSmoke ); |
|
if ( m_ParticleNormalSmoke ) |
|
StopParticle( m_ParticleNormalSmoke ); |
|
if ( m_ParticleFireEnd ) |
|
StopParticle( m_ParticleFireEnd ); |
|
if ( m_ParticleSteamEnd ) |
|
StopParticle( m_ParticleSteamEnd ); |
|
if ( m_ParticleSteamExtinguishing ) |
|
StopParticle( m_ParticleSteamExtinguishing ); |
|
|
|
|
|
if ( m_SoundFireLoop ) |
|
StopSoundSet( m_SoundFireLoop ); |
|
if ( m_SoundFire ) |
|
StopSoundSet( m_SoundFire ); |
|
} |
|
|
|
bool CanShowSmoke() |
|
{ |
|
return true; |
|
} |
|
|
|
|
|
void RefreshFireState() |
|
{ |
|
float temperature = GetTemperature(); |
|
|
|
|
|
if (IsBurning()) |
|
{ |
|
|
|
if (temperature <= PARAM_MIN_FIRE_TEMPERATURE) |
|
{ |
|
if ( GetFireState() != FireplaceFireState.START_FIRE ) |
|
{ |
|
SetFireState( FireplaceFireState.START_FIRE ); |
|
} |
|
} |
|
|
|
else if (temperature <= PARAM_SMALL_FIRE_TEMPERATURE) |
|
{ |
|
if ( GetFireState() != FireplaceFireState.SMALL_FIRE ) |
|
{ |
|
SetFireState( FireplaceFireState.SMALL_FIRE ); |
|
} |
|
} |
|
|
|
else if (temperature > PARAM_SMALL_FIRE_TEMPERATURE) |
|
{ |
|
if ( GetFireState() != FireplaceFireState.NORMAL_FIRE ) |
|
{ |
|
SetFireState( FireplaceFireState.NORMAL_FIRE ); |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected bool PlayParticle( out Particle particle, int particle_type, vector pos, bool worldpos = false ) |
|
{ |
|
if ( !particle && GetGame() && ( !GetGame().IsDedicatedServer() ) ) |
|
{ |
|
if ( !worldpos ) |
|
{ |
|
particle = ParticleManager.GetInstance().PlayOnObject( particle_type, this, pos ); |
|
} |
|
else |
|
{ |
|
particle = ParticleManager.GetInstance().PlayInWorld( particle_type, pos ); |
|
} |
|
|
|
return true; |
|
} |
|
|
|
return false; |
|
} |
|
|
|
|
|
protected bool StopParticle( out Particle particle ) |
|
{ |
|
if ( particle && GetGame() && ( !GetGame().IsDedicatedServer() ) ) |
|
{ |
|
particle.Stop(); |
|
particle = NULL; |
|
|
|
return true; |
|
} |
|
|
|
return false; |
|
} |
|
|
|
|
|
protected void ParticleFireStartStart() |
|
{ |
|
if ( IsOven() ) |
|
{ |
|
PlayParticle( m_ParticleFireStart, PARTICLE_OVEN_FIRE_START, GetFireEffectPosition() ); |
|
} |
|
else |
|
{ |
|
PlayParticle( m_ParticleFireStart, PARTICLE_FIRE_START, GetFireEffectPosition() ); |
|
} |
|
} |
|
|
|
protected void ParticleFireStartStop() |
|
{ |
|
StopParticle( m_ParticleFireStart ); |
|
} |
|
|
|
|
|
protected void ParticleSmallFireStart() |
|
{ |
|
if ( IsOven() ) |
|
{ |
|
PlayParticle( m_ParticleSmallFire, PARTICLE_OVEN_FIRE, GetFireEffectPosition() ); |
|
} |
|
else |
|
{ |
|
PlayParticle( m_ParticleSmallFire, PARTICLE_SMALL_FIRE, GetFireEffectPosition() ); |
|
} |
|
} |
|
|
|
protected void ParticleSmallFireStop() |
|
{ |
|
StopParticle( m_ParticleSmallFire ); |
|
} |
|
|
|
|
|
protected void ParticleNormalFireStart() |
|
{ |
|
if ( IsOven() ) |
|
{ |
|
PlayParticle( m_ParticleNormalFire, PARTICLE_OVEN_FIRE, GetFireEffectPosition() ); |
|
} |
|
else |
|
{ |
|
PlayParticle( m_ParticleNormalFire, PARTICLE_NORMAL_FIRE, GetFireEffectPosition() ); |
|
} |
|
} |
|
|
|
protected void ParticleNormalFireStop() |
|
{ |
|
StopParticle( m_ParticleNormalFire ); |
|
} |
|
|
|
|
|
protected void ParticleSmallSmokeStart() |
|
{ |
|
PlayParticle( m_ParticleSmallSmoke, PARTICLE_SMALL_SMOKE, GetSmokeEffectPosition() ); |
|
|
|
|
|
float actual_height; |
|
if ( GetCeilingHeight( actual_height ) ) |
|
{ |
|
float air_resistance = GetAirResistanceForSmokeParticles( actual_height ); |
|
|
|
|
|
m_ParticleSmallSmoke.SetParameter( -1, EmitorParam.AIR_RESISTANCE, air_resistance ); |
|
} |
|
|
|
if ( IsRoofAbove() ) |
|
{ |
|
m_ParticleSmallSmoke.SetParameter( -1, EmitorParam.WIND, false ); |
|
} |
|
} |
|
|
|
protected void ParticleSmallSmokeStop() |
|
{ |
|
StopParticle( m_ParticleSmallSmoke ); |
|
} |
|
|
|
|
|
protected void ParticleNormalSmokeStart() |
|
{ |
|
PlayParticle( m_ParticleNormalSmoke, PARTICLE_NORMAL_SMOKE, GetSmokeEffectPosition() ); |
|
|
|
|
|
float actual_height; |
|
if ( GetCeilingHeight( actual_height ) ) |
|
{ |
|
float air_resistance = GetAirResistanceForSmokeParticles( actual_height ); |
|
|
|
|
|
m_ParticleNormalSmoke.SetParameter( -1, EmitorParam.AIR_RESISTANCE, air_resistance ); |
|
} |
|
|
|
if ( IsRoofAbove() ) |
|
{ |
|
m_ParticleNormalSmoke.SetParameter( -1, EmitorParam.WIND, false ); |
|
} |
|
} |
|
|
|
protected void ParticleNormalSmokeStop() |
|
{ |
|
StopParticle( m_ParticleNormalSmoke ); |
|
} |
|
|
|
|
|
protected void ParticleFireEndStart() |
|
{ |
|
if ( IsOven() ) |
|
{ |
|
PlayParticle( m_ParticleFireEnd, PARTICLE_OVEN_FIRE_END, GetFireEffectPosition() ); |
|
} |
|
else |
|
{ |
|
PlayParticle( m_ParticleFireEnd, PARTICLE_FIRE_END, GetFireEffectPosition() ); |
|
} |
|
} |
|
|
|
protected void ParticleFireEndStop() |
|
{ |
|
StopParticle( m_ParticleFireEnd ); |
|
} |
|
|
|
protected void ParticleFireWindyNoIgniteStart() |
|
{ |
|
if ( IsOven() ) |
|
{ |
|
PlayParticle( m_ParticleFireEnd, PARTICLE_OVEN_FIRE_END, GetFireEffectPosition() ); |
|
} |
|
else |
|
{ |
|
PlayParticle( m_ParticleFireEnd, PARTICLE_NO_IGNITE_WIND, GetFireEffectPosition() ); |
|
} |
|
} |
|
|
|
|
|
protected void ParticleSteamExtinguishingStart() |
|
{ |
|
PlayParticle( m_ParticleSteamExtinguishing, PARTICLE_STEAM_EXTINGUISHING, GetFireEffectPosition() ); |
|
} |
|
|
|
protected void ParticleSteamExtinguishingStop() |
|
{ |
|
StopParticle(m_ParticleSteamExtinguishing); |
|
} |
|
|
|
|
|
protected void ParticleSteamEndStart() |
|
{ |
|
PlayParticle( m_ParticleSteamEnd, PARTICLE_STEAM_END, GetFireEffectPosition() ); |
|
} |
|
|
|
protected void ParticleSteamEndStop() |
|
{ |
|
StopParticle( m_ParticleSteamEnd ); |
|
} |
|
|
|
protected void ParticleWetNoIgniteStart() |
|
{ |
|
PlayParticle( m_ParticleSteamEnd, PARTICLE_STEAM_END, GetFireEffectPosition() ); |
|
} |
|
|
|
protected void ParticleWetNoIgniteStop() |
|
{ |
|
StopParticle( m_ParticleSteamEnd ); |
|
} |
|
|
|
bool GetCeilingHeight( out float actual_height ) |
|
{ |
|
vector from = this.GetPosition(); |
|
vector to = this.GetPosition(); |
|
from[1] = from[1] + 1.0; |
|
to[1] = to[1] + MIN_CEILING_HEIGHT; |
|
vector contactPos; |
|
vector contactDir; |
|
int contactComponent; |
|
|
|
bool hit = DayZPhysics.RaycastRV( from, to, contactPos, contactDir, contactComponent, NULL, NULL, this ); |
|
actual_height = vector.Distance( from, contactPos ) + 1.0; |
|
|
|
return hit; |
|
} |
|
|
|
float GetAirResistanceForSmokeParticles( float actual_height ) |
|
{ |
|
float air_res; |
|
actual_height = Math.Clamp( actual_height, 0, 36 ); |
|
|
|
air_res = ( 6 - actual_height ) * 0.33; |
|
air_res = Math.Clamp( air_res, 0, 2 ); |
|
|
|
return air_res; |
|
} |
|
|
|
|
|
|
|
protected vector GetFireEffectPosition() |
|
{ |
|
return Vector( 0, 0.05, 0 ); |
|
} |
|
|
|
protected vector GetSmokeEffectPosition() |
|
{ |
|
return Vector( 0, 0.05, 0 ); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void SoundFireLightStart() |
|
{ |
|
PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_LIGHT, 1.0, 1.0 ); |
|
} |
|
|
|
protected void SoundFireHeavyStart() |
|
{ |
|
PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_HEAVY, 1.0, 2.0 ); |
|
} |
|
|
|
protected void SoundFireNoFireStart() |
|
{ |
|
PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_NO_FIRE, 2.0, 2.0 ); |
|
} |
|
|
|
protected void SoundFireExtinguishedStart() |
|
{ |
|
PlaySoundSet( m_SoundFire, SOUND_FIRE_EXTINGUISHED, 0.1, 0.1 ); |
|
} |
|
|
|
protected void SoundFireWetNoIgniteStart() |
|
{ |
|
PlaySoundSet( m_SoundFire, SOUND_FIRE_EXTINGUISHED, 0.1, 0.1 ); |
|
} |
|
|
|
protected void SoundFireExtinguishingStart() |
|
{ |
|
PlaySoundSetLoop( m_SoundFireLoop, SOUND_FIRE_EXTINGUISHING, 1.0, 0.5 ); |
|
} |
|
|
|
protected void SoundFireWindyNoIgniteStart() |
|
{ |
|
PlaySoundSet( m_SoundFire, "ExtinguishByWind_SoundSet", 0, 0 ); |
|
} |
|
|
|
|
|
protected void SoundFireStop() |
|
{ |
|
StopSoundSet( m_SoundFireLoop ); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void AddToFireConsumables(ItemBase item) |
|
{ |
|
m_FireConsumables.Insert(item, new FireConsumable(item, GetFireConsumableTypeEnergy(item))); |
|
CalcAndSetQuantity(); |
|
} |
|
|
|
protected float GetFireConsumableTypeEnergy(ItemBase item) |
|
{ |
|
FireConsumableType fireConsumableType = m_FireConsumableTypes.Get(item.Type()); |
|
if (!fireConsumableType) |
|
{ |
|
|
|
int count = m_FireConsumableTypes.Count(); |
|
for (int i = 0; i < count; ++i) |
|
{ |
|
if (item.IsInherited(m_FireConsumableTypes.GetKey(i))) |
|
fireConsumableType = m_FireConsumableTypes.GetElement(i); |
|
} |
|
} |
|
|
|
if (fireConsumableType) |
|
return fireConsumableType.GetEnergy(); |
|
|
|
return 0; |
|
} |
|
|
|
|
|
protected void RemoveFromFireConsumables(FireConsumable fire_consumable) |
|
{ |
|
if (fire_consumable) |
|
{ |
|
m_FireConsumables.Remove(fire_consumable.GetItem()); |
|
delete fire_consumable; |
|
} |
|
|
|
CalcAndSetQuantity(); |
|
} |
|
|
|
protected FireConsumable GetFireConsumableByItem( ItemBase item ) |
|
{ |
|
return m_FireConsumables.Get(item); |
|
} |
|
|
|
|
|
|
|
|
|
protected FireConsumable SetItemToConsume() |
|
{ |
|
if (m_FireConsumables.Count() == 0) |
|
{ |
|
m_ItemToConsume = null; |
|
} |
|
else |
|
{ |
|
for (int i = 0; i < m_FireConsumables.Count(); ++i) |
|
{ |
|
ItemBase key = m_FireConsumables.GetKey(i); |
|
FireConsumable fireConsumable = m_FireConsumables.Get(key); |
|
|
|
if (i == 0) |
|
{ |
|
m_ItemToConsume = fireConsumable; |
|
} |
|
else |
|
{ |
|
if (fireConsumable.GetEnergy() < m_ItemToConsume.GetEnergy()) |
|
{ |
|
m_ItemToConsume = fireConsumable; |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
RefreshFireplaceVisuals(); |
|
|
|
return m_ItemToConsume; |
|
} |
|
|
|
protected FireConsumable GetItemToConsume() |
|
{ |
|
return m_ItemToConsume; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void SpendFireConsumable(float amount) |
|
{ |
|
|
|
FireConsumable fireConsumable = GetItemToConsume(); |
|
|
|
if (!fireConsumable) |
|
{ |
|
|
|
fireConsumable = SetItemToConsume(); |
|
} |
|
|
|
if (fireConsumable) |
|
{ |
|
ItemBase item = fireConsumable.GetItem(); |
|
fireConsumable.SetRemainingEnergy(fireConsumable.GetRemainingEnergy() - amount); |
|
|
|
if (fireConsumable.GetRemainingEnergy() <= 0 || amount == 0) |
|
{ |
|
|
|
if (!HasAshes()) |
|
{ |
|
SetAshesState(true); |
|
} |
|
|
|
if (item.IsAnyInherited({ItemBook, Paper, GiftWrapPaper, EyeMask_ColorBase})) |
|
{ |
|
RemoveFromFireConsumables(fireConsumable); |
|
item.Delete(); |
|
} |
|
else |
|
{ |
|
|
|
if (item.GetQuantity() <= 1) |
|
{ |
|
|
|
RemoveFromFireConsumables(fireConsumable); |
|
} |
|
else |
|
{ |
|
fireConsumable.SetRemainingEnergy(fireConsumable.GetEnergy()); |
|
} |
|
|
|
item.AddQuantity(-1); |
|
SetItemToConsume(); |
|
} |
|
} |
|
} |
|
|
|
CalcAndSetQuantity(); |
|
} |
|
|
|
|
|
protected int GetKindlingCount() |
|
{ |
|
int attachmentsCount = GetInventory().AttachmentCount(); |
|
int kindlingCount = 0; |
|
|
|
for (int i = 0; i < attachmentsCount; ++i) |
|
{ |
|
ItemBase item = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(i)); |
|
|
|
if (IsKindling(item)) |
|
kindlingCount++; |
|
} |
|
|
|
return kindlingCount; |
|
} |
|
|
|
|
|
protected int GetFuelCount() |
|
{ |
|
int attachmentsCount = GetInventory().AttachmentCount(); |
|
int fuelCount = 0; |
|
|
|
for (int i = 0; i < attachmentsCount; ++i) |
|
{ |
|
ItemBase item = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(i)); |
|
if (IsFuel(item)) |
|
fuelCount++; |
|
} |
|
|
|
return fuelCount; |
|
} |
|
|
|
|
|
protected bool IsKindling(ItemBase item) |
|
{ |
|
FireConsumableType fireConsumableType = m_FireConsumableTypes.Get(item.Type()); |
|
if (!fireConsumableType) |
|
{ |
|
|
|
int count = m_FireConsumableTypes.Count(); |
|
for (int i = 0; i < count; ++i) |
|
{ |
|
if (item.IsInherited(m_FireConsumableTypes.GetKey(i))) |
|
fireConsumableType = m_FireConsumableTypes.GetElement(i); |
|
} |
|
} |
|
|
|
return fireConsumableType && fireConsumableType.IsKindling(); |
|
} |
|
|
|
|
|
protected bool IsFuel(ItemBase item) |
|
{ |
|
FireConsumableType fireConsumableType = m_FireConsumableTypes.Get(item.Type()); |
|
if (!fireConsumableType) |
|
{ |
|
|
|
int count = m_FireConsumableTypes.Count(); |
|
for (int i = 0; i < count; ++i) |
|
{ |
|
if (item.IsInherited(m_FireConsumableTypes.GetKey(i))) |
|
fireConsumableType = m_FireConsumableTypes.GetElement(i); |
|
} |
|
} |
|
|
|
return fireConsumableType && !fireConsumableType.IsKindling(); |
|
} |
|
|
|
|
|
bool IsItemTypeAttached(typename item_type) |
|
{ |
|
return GetAttachmentByType(item_type) != null; |
|
} |
|
|
|
|
|
bool IsItemAttachedQuantity(typename item_type, float quantity) |
|
{ |
|
ItemBase item = ItemBase.Cast(GetAttachmentByType(item_type)); |
|
|
|
return item.GetQuantity() >= quantity; |
|
} |
|
|
|
|
|
bool HasLastAttachment() |
|
{ |
|
return GetInventory().AttachmentCount() == 1; |
|
} |
|
|
|
|
|
bool HasLastFuelKindlingAttached() |
|
{ |
|
return (GetFuelCount() + GetKindlingCount()) == 1; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
bool IsBurning() |
|
{ |
|
return m_IsBurning; |
|
} |
|
|
|
|
|
protected void SetBurningState(bool is_burning) |
|
{ |
|
m_IsBurning = is_burning; |
|
} |
|
|
|
|
|
bool HasAshes() |
|
{ |
|
return m_HasAshes; |
|
} |
|
|
|
|
|
protected void SetAshesState(bool has_ashes) |
|
{ |
|
m_HasAshes = has_ashes; |
|
|
|
if (m_HasAshes) |
|
{ |
|
SetBurntFirewood(); |
|
} |
|
} |
|
|
|
|
|
bool IsOven() |
|
{ |
|
return m_IsOven; |
|
} |
|
bool HasStoneCircle() |
|
{ |
|
return m_HasStoneCircle; |
|
} |
|
|
|
bool HasStones() |
|
{ |
|
EntityAI attached_item = GetAttachmentByType(ATTACHMENT_STONES); |
|
|
|
return attached_item && attached_item.GetQuantity() > 0; |
|
} |
|
|
|
int GetAttachedStonesCount() |
|
{ |
|
if (HasStones()) |
|
{ |
|
return GetAttachmentByType(ATTACHMENT_STONES).GetQuantity(); |
|
} |
|
|
|
return 0; |
|
} |
|
|
|
void SetOvenState( bool is_oven ) |
|
{ |
|
if ( m_IsOven != is_oven ) |
|
{ |
|
m_IsOven = is_oven; |
|
m_RoofAbove = is_oven; |
|
|
|
GetInventory().SetSlotLock( InventorySlots.GetSlotIdFromString("Stones") , is_oven); |
|
|
|
Synchronize(); |
|
} |
|
} |
|
void SetStoneCircleState( bool has_stonecircle ) |
|
{ |
|
if ( m_HasStoneCircle != has_stonecircle ) |
|
{ |
|
m_HasStoneCircle = has_stonecircle; |
|
|
|
GetInventory().SetSlotLock( InventorySlots.GetSlotIdFromString("Stones") , has_stonecircle); |
|
|
|
Synchronize(); |
|
} |
|
} |
|
|
|
|
|
protected float GetTemperatureLossMP() |
|
{ |
|
return m_TemperatureLossMP; |
|
} |
|
|
|
protected void SetTemperatureLossMP( float value ) |
|
{ |
|
m_TemperatureLossMP = value; |
|
} |
|
|
|
|
|
protected float GetFuelBurnRateMP() |
|
{ |
|
return m_FuelBurnRateMP; |
|
} |
|
|
|
protected void SetFuelBurnRateMP( float value ) |
|
{ |
|
m_FuelBurnRateMP = value; |
|
} |
|
|
|
|
|
protected int GetFireState() |
|
{ |
|
return m_FireState; |
|
} |
|
|
|
|
|
protected void SetFireState( FireplaceFireState state ) |
|
{ |
|
if ( m_FireState != state ) |
|
{ |
|
m_FireState = state; |
|
|
|
Synchronize(); |
|
} |
|
} |
|
|
|
void SetExtinguishingState() |
|
{ |
|
SetFireState( FireplaceFireState.EXTINGUISHING_FIRE ); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void StartFire(bool force_start = false) |
|
{ |
|
|
|
if (m_CoolingTimer) |
|
{ |
|
m_CoolingTimer.Stop(); |
|
m_CoolingTimer = null; |
|
} |
|
|
|
|
|
if (MiscGameplayFunctions.IsUnderRoof(this)) |
|
m_RoofAbove = true; |
|
|
|
|
|
if (!IsBurning() || force_start) |
|
{ |
|
SetItemToConsume(); |
|
SetBurningState(true); |
|
m_UTSource.SetActive(true); |
|
StartHeating(); |
|
|
|
|
|
if (!IsFireplaceIndoor()) |
|
{ |
|
SetAffectPathgraph(false, true); |
|
GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, this); |
|
} |
|
} |
|
|
|
Synchronize(); |
|
} |
|
|
|
|
|
protected void StartHeating() |
|
{ |
|
|
|
SetObjectMaterial(0, MATERIAL_FIREPLACE_GLOW); |
|
|
|
if (IsWindy() && !IsRoofAbove() && !IsOven() && !IsBarrelWithHoles()) |
|
{ |
|
StopFire(); |
|
return; |
|
} |
|
|
|
if (GetWet() > PARAM_BURN_WET_THRESHOLD) |
|
{ |
|
StopFire(FireplaceFireState.EXTINGUISHED_FIRE); |
|
return; |
|
} |
|
|
|
|
|
if (IsBaseFireplace() && !IsOven()) |
|
CreateAreaDamage(); |
|
|
|
m_HeatingTimer = new Timer(CALL_CATEGORY_GAMEPLAY); |
|
m_HeatingTimer.Run(TIMER_HEATING_UPDATE_INTERVAL, this, "Heating", null, true); |
|
|
|
|
|
m_NoisePar = new NoiseParams(); |
|
if (IsRoofAbove() || IsOven() || IsFireplaceIndoor()) |
|
m_NoisePar.LoadFromPath("CfgVehicles FireplaceBase NoiseFireplaceSpecial"); |
|
else |
|
m_NoisePar.LoadFromPath("CfgVehicles FireplaceBase NoiseFireplaceBase"); |
|
} |
|
|
|
|
|
protected void Heating() |
|
{ |
|
float temperature = GetTemperature(); |
|
float temperature_modifier = 0; |
|
|
|
|
|
if (GetWet() > PARAM_BURN_WET_THRESHOLD) |
|
{ |
|
StopFire(FireplaceFireState.EXTINGUISHED_FIRE); |
|
return; |
|
} |
|
else |
|
{ |
|
if (m_FireConsumables.Count() == 0) |
|
{ |
|
StopFire(); |
|
return; |
|
} |
|
} |
|
|
|
|
|
float amount = PARAM_FIRE_CONSUM_RATE_AMOUNT * GetFuelBurnRateMP() * TIMER_HEATING_UPDATE_INTERVAL; |
|
SpendFireConsumable(amount); |
|
|
|
|
|
float rain = GetGame().GetWeather().GetRain().GetActual(); |
|
if (rain >= PARAM_BURN_WET_THRESHOLD && !IsRoofAbove()) |
|
{ |
|
|
|
AddWetnessToFireplace(PARAM_WET_INCREASE_COEF * rain); |
|
|
|
|
|
temperature_modifier = PARAM_TEMPERATURE_INCREASE * rain; |
|
} |
|
|
|
else |
|
{ |
|
AddWetnessToFireplace(-PARAM_WET_HEATING_DECREASE_COEF); |
|
} |
|
|
|
|
|
m_UTSLFireplace.SetFuelCount(GetFuelCount()); |
|
temperature = GetTemperature() + (PARAM_TEMPERATURE_INCREASE * TIMER_HEATING_UPDATE_INTERVAL) - temperature_modifier; |
|
m_UTSLFireplace.SetCurrentTemperature(temperature); |
|
m_UTSource.Update(m_UTSSettings, m_UTSLFireplace); |
|
|
|
|
|
if ( GetFireState() != FireplaceFireState.EXTINGUISHING_FIRE ) |
|
{ |
|
RefreshFireState(); |
|
} |
|
|
|
|
|
BurnItemsInFireplace(); |
|
|
|
|
|
if (HasCookingStand() && m_CookingEquipment) |
|
{ |
|
float cook_equip_temp = m_CookingEquipment.GetTemperature(); |
|
|
|
if ( cook_equip_temp >= PARAM_COOKING_TEMP_THRESHOLD ) |
|
{ |
|
|
|
CookWithEquipment(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cook_equip_temp = cook_equip_temp + PARAM_COOKING_EQUIP_TEMP_INCREASE; |
|
if ( temperature <= PARAM_SMALL_FIRE_TEMPERATURE ) |
|
{ |
|
cook_equip_temp = Math.Clamp ( cook_equip_temp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_SMALL_FIRE_TEMPERATURE ); |
|
} |
|
else |
|
{ |
|
cook_equip_temp = Math.Clamp ( cook_equip_temp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_COOKING_EQUIP_MAX_TEMP ); |
|
} |
|
|
|
m_CookingEquipment.SetTemperature( cook_equip_temp ); |
|
} |
|
|
|
float cook_item_temp; |
|
int i; |
|
|
|
if ( DirectCookingSlotsInUse() ) |
|
{ |
|
for ( i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++ ) |
|
{ |
|
if ( m_DirectCookingSlots[i] ) |
|
{ |
|
cook_item_temp = m_DirectCookingSlots[i].GetTemperature(); |
|
if ( cook_item_temp >= PARAM_COOKING_TEMP_THRESHOLD ) |
|
{ |
|
CookOnDirectSlot( m_DirectCookingSlots[i], cook_item_temp, temperature ); |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
if ( SmokingSlotsInUse() ) |
|
{ |
|
for ( i = 0; i < SMOKING_SLOT_COUNT; i++ ) |
|
{ |
|
if ( m_SmokingSlots[i] ) |
|
{ |
|
SmokeOnSmokingSlot( m_SmokingSlots[i], cook_item_temp, temperature ); |
|
} |
|
} |
|
} |
|
|
|
|
|
if ( GetGame().GetWorld().IsNight() && m_CanNoise ) |
|
{ |
|
NoiseSystem noise = GetGame().GetNoiseSystem(); |
|
if ( noise && m_NoisePar ) |
|
{ |
|
noise.AddNoisePos( this, GetPosition(), m_NoisePar); |
|
} |
|
m_CanNoise = false; |
|
} |
|
else |
|
m_CanNoise = true; |
|
|
|
Synchronize(); |
|
} |
|
|
|
|
|
|
|
|
|
|
|
void StopFire( FireplaceFireState fire_state = FireplaceFireState.END_FIRE ) |
|
{ |
|
StopHeating(); |
|
SpendFireConsumable(0); |
|
SetBurningState(false); |
|
StartCooling(); |
|
SetFireState(fire_state); |
|
|
|
|
|
if (!IsFireplaceIndoor()) |
|
{ |
|
SetAffectPathgraph(false, false); |
|
GetGame().GetCallQueue(CALL_CATEGORY_SYSTEM).CallLater(GetGame().UpdatePathgraphRegionByObject, 100, false, this); |
|
} |
|
|
|
Synchronize(); |
|
} |
|
|
|
protected void StopHeating() |
|
{ |
|
if (!m_HeatingTimer) |
|
return; |
|
|
|
m_HeatingTimer.Stop(); |
|
m_HeatingTimer = null; |
|
} |
|
|
|
protected void StartCooling() |
|
{ |
|
if (m_HeatingTimer) |
|
{ |
|
m_HeatingTimer.Stop(); |
|
m_HeatingTimer = null; |
|
} |
|
|
|
|
|
m_CoolingTimer = new Timer(CALL_CATEGORY_GAMEPLAY); |
|
m_CoolingTimer.Run(TIMER_COOLING_UPDATE_INTERVAL, this, "Cooling", null, true); |
|
} |
|
|
|
protected void Cooling() |
|
{ |
|
float wetness = GetWet(); |
|
float temperature = GetTemperature(); |
|
float temperature_modifier = 0; |
|
|
|
if (!IsBurning() && temperature >= 10) |
|
{ |
|
|
|
|
|
float rain = GetGame().GetWeather().GetRain().GetActual(); |
|
if (IsRainingAbove() && !IsRoofAbove()) |
|
{ |
|
|
|
AddWetnessToFireplace(PARAM_WET_INCREASE_COEF * rain); |
|
|
|
|
|
temperature_modifier = temperature_modifier + ( PARAM_TEMPERATURE_DECREASE * rain ); |
|
} |
|
else |
|
{ |
|
AddWetnessToFireplace(-PARAM_WET_COOLING_DECREASE_COEF); |
|
} |
|
|
|
|
|
temperature_modifier = temperature_modifier + ( PARAM_TEMPERATURE_DECREASE * wetness ); |
|
|
|
|
|
m_UTSLFireplace.SetFuelCount(GetFuelCount()); |
|
temperature = GetTemperature() - (PARAM_TEMPERATURE_DECREASE * TIMER_COOLING_UPDATE_INTERVAL) - temperature_modifier; |
|
m_UTSLFireplace.SetCurrentTemperature(temperature); |
|
m_UTSource.Update(m_UTSSettings, m_UTSLFireplace); |
|
|
|
|
|
BurnItemsInFireplace(); |
|
|
|
|
|
if ( m_CookingEquipment ) |
|
{ |
|
float cook_equip_temp = m_CookingEquipment.GetTemperature(); |
|
|
|
if ( cook_equip_temp >= PARAM_COOKING_TEMP_THRESHOLD ) |
|
{ |
|
|
|
CookWithEquipment(); |
|
} |
|
} |
|
|
|
float cook_item_temp; |
|
int i; |
|
|
|
|
|
if ( DirectCookingSlotsInUse() ) |
|
{ |
|
for ( i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++ ) |
|
{ |
|
if ( m_DirectCookingSlots[i] ) |
|
{ |
|
cook_item_temp = m_DirectCookingSlots[i].GetTemperature(); |
|
if ( cook_item_temp >= PARAM_COOKING_TEMP_THRESHOLD ) |
|
{ |
|
CookOnDirectSlot( m_DirectCookingSlots[i], cook_item_temp, temperature ); |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
if ( SmokingSlotsInUse() ) |
|
{ |
|
for ( i = 0; i < SMOKING_SLOT_COUNT; i++ ) |
|
{ |
|
if ( m_SmokingSlots[i] ) |
|
{ |
|
SmokeOnSmokingSlot( m_SmokingSlots[i], cook_item_temp, temperature ); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
} |
|
else |
|
{ |
|
|
|
if (Math.AbsFloat(temperature) < 10) |
|
{ |
|
StopCooling(); |
|
m_UTSource.SetActive(false); |
|
} |
|
} |
|
} |
|
|
|
protected void StopCooling() |
|
{ |
|
|
|
SetFireState(FireplaceFireState.NO_FIRE); |
|
SetObjectMaterial(0, MATERIAL_FIREPLACE_NOGLOW); |
|
|
|
|
|
m_CoolingTimer.Stop(); |
|
m_CoolingTimer = NULL; |
|
|
|
|
|
DestroyAreaDamage(); |
|
|
|
|
|
if (GetCookingEquipment()) |
|
{ |
|
Bottle_Base cooking_pot = Bottle_Base.Cast(GetCookingEquipment()); |
|
if ( cooking_pot ) |
|
cooking_pot.RemoveAudioVisualsOnClient(); |
|
} |
|
|
|
if (DirectCookingSlotsInUse()) |
|
{ |
|
for ( int i = 0; i < DIRECT_COOKING_SLOT_COUNT; i++ ) |
|
{ |
|
if ( m_DirectCookingSlots[i] ) |
|
{ |
|
Bottle_Base cookingpot = Bottle_Base.Cast( m_DirectCookingSlots[i] ); |
|
if ( cookingpot ) |
|
cookingpot.RemoveAudioVisualsOnClient(); |
|
|
|
FryingPan fryingpan = FryingPan.Cast( m_DirectCookingSlots[i] ); |
|
if ( fryingpan ) |
|
fryingpan.RemoveAudioVisualsOnClient(); |
|
|
|
Edible_Base itsfood = Edible_Base.Cast( m_DirectCookingSlots[i] ); |
|
if ( itsfood ) |
|
itsfood.MakeSoundsOnClient( false ); |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
protected void CookWithEquipment() |
|
{ |
|
if (m_CookingProcess == null) |
|
{ |
|
m_CookingProcess = new Cooking(); |
|
} |
|
|
|
m_CookingProcess.CookWithEquipment(m_CookingEquipment); |
|
} |
|
|
|
Cooking GetCookingProcess() |
|
{ |
|
if (m_CookingProcess == null) |
|
{ |
|
m_CookingProcess = new Cooking(); |
|
} |
|
|
|
return m_CookingProcess; |
|
} |
|
|
|
protected void CookOnDirectSlot(ItemBase slot_item, float temp_equip, float temp_ext) |
|
{ |
|
if (m_CookingProcess == null) |
|
{ |
|
m_CookingProcess = new Cooking(); |
|
} |
|
|
|
m_CookingProcess.CookWithEquipment(slot_item); |
|
|
|
switch (slot_item.Type()) |
|
{ |
|
case ATTACHMENT_CAULDRON: |
|
case ATTACHMENT_COOKING_POT: |
|
case ATTACHMENT_FRYING_PAN: |
|
float cookEquipTemp = temp_equip + PARAM_COOKING_EQUIP_TEMP_INCREASE; |
|
if ( temp_ext <= PARAM_SMALL_FIRE_TEMPERATURE ) |
|
{ |
|
cookEquipTemp = Math.Clamp(cookEquipTemp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_SMALL_FIRE_TEMPERATURE); |
|
} |
|
else |
|
{ |
|
cookEquipTemp = Math.Clamp(cookEquipTemp, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_COOKING_EQUIP_MAX_TEMP); |
|
} |
|
slot_item.SetTemperature(cookEquipTemp); |
|
break; |
|
} |
|
} |
|
|
|
protected void SmokeOnSmokingSlot( ItemBase slot_item, float temp_equip, float temp_ext ) |
|
{ |
|
if ( m_CookingProcess == NULL ) |
|
{ |
|
m_CookingProcess = new Cooking(); |
|
} |
|
|
|
|
|
Edible_Base ingr = Edible_Base.Cast( slot_item ); |
|
if ( ingr ) |
|
{ |
|
m_CookingProcess.SmokeItem( ingr, FireplaceBase.TIMER_HEATING_UPDATE_INTERVAL * FireplaceBase.SMOKING_SPEED ); |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void BurnItemsInFireplace() |
|
{ |
|
|
|
CargoBase cargo = GetInventory().GetCargo(); |
|
for (int i = 0; i < cargo.GetItemCount(); i++) |
|
{ |
|
ItemBase item = ItemBase.Cast(cargo.GetItem(i)); |
|
|
|
|
|
AddDamageToItemByFireEx(item, false, false); |
|
|
|
if (item.GetHealth("", "Health") <= 0 && !item.IsKindOf("Grenade_Base")) |
|
{ |
|
item.Delete(); |
|
} |
|
|
|
|
|
AddTemperatureToItemByFire(item); |
|
|
|
|
|
AddWetnessToItem(item, -PARAM_WET_HEATING_DECREASE_COEF); |
|
} |
|
|
|
|
|
for (int j = 0; j < GetInventory().AttachmentCount(); ++j) |
|
{ |
|
ItemBase attachment = ItemBase.Cast(GetInventory().GetAttachmentFromIndex(j)); |
|
|
|
|
|
AddDamageToItemByFireEx(attachment, false, true); |
|
|
|
|
|
AddTemperatureToItemByFire(attachment); |
|
|
|
|
|
AddWetnessToItem(attachment, -PARAM_WET_HEATING_DECREASE_COEF); |
|
} |
|
} |
|
|
|
|
|
protected void AddTemperatureToItemByFire(ItemBase item) |
|
{ |
|
if (item.GetTemperatureMax() >= PARAM_ITEM_HEAT_MIN_TEMP) |
|
{ |
|
float temperature = item.GetTemperature() + PARAM_ITEM_HEAT_TEMP_INCREASE_COEF; |
|
temperature = Math.Clamp(temperature, PARAM_ITEM_HEAT_MIN_TEMP, PARAM_MAX_ITEM_HEAT_TEMP_INCREASE); |
|
item.SetTemperature(temperature); |
|
} |
|
} |
|
|
|
|
|
protected void AddTemperatureToFireplace(float amount) {}; |
|
|
|
|
|
protected void AddDamageToItemByFireEx(ItemBase item, bool can_be_ruined, bool pAttachment) |
|
{ |
|
if (!item) |
|
{ |
|
return; |
|
} |
|
|
|
if (GetTemperature() <= PARAM_ITEM_HEAT_MIN_TEMP) |
|
{ |
|
return; |
|
} |
|
|
|
|
|
if (!pAttachment) |
|
{ |
|
|
|
GameInventory itemInventory = item.GetInventory(); |
|
if (itemInventory) |
|
{ |
|
for (int i = 0; i < itemInventory.AttachmentCount(); ++i) |
|
{ |
|
itemInventory.GetAttachmentFromIndex(i).AddHealth("", "", -PARAM_BURN_DAMAGE_COEF); |
|
} |
|
} |
|
|
|
item.AddHealth("", "", -PARAM_BURN_DAMAGE_COEF); |
|
} |
|
else |
|
{ |
|
float timerCoef = 1.0; |
|
if (m_HeatingTimer && m_HeatingTimer.IsRunning()) |
|
{ |
|
timerCoef = TIMER_HEATING_UPDATE_INTERVAL; |
|
} |
|
else if (m_CoolingTimer && m_CoolingTimer.IsRunning()) |
|
{ |
|
timerCoef = TIMER_COOLING_UPDATE_INTERVAL; |
|
} |
|
|
|
switch (item.Type()) |
|
{ |
|
case ATTACHMENT_TRIPOD: |
|
case ATTACHMENT_COOKINGSTAND: |
|
case ATTACHMENT_COOKING_POT: |
|
case ATTACHMENT_CAULDRON: |
|
case ATTACHMENT_FRYING_PAN: |
|
item.DecreaseHealth(GameConstants.FIRE_ATTACHMENT_DAMAGE_PER_SECOND * timerCoef, false); |
|
break; |
|
} |
|
|
|
|
|
if (IsFuel(item) || IsKindling(item)) |
|
{ |
|
if (item.GetHealthLevel() < GameConstants.STATE_BADLY_DAMAGED) |
|
{ |
|
item.DecreaseHealth(PARAM_BURN_DAMAGE_COEF, false); |
|
} |
|
} |
|
|
|
|
|
if (item.CanBeCooked() && item.GetHealthLevel() >= GameConstants.STATE_BADLY_DAMAGED) |
|
{ |
|
Edible_Base edible_item = Edible_Base.Cast( item ); |
|
edible_item.ChangeFoodStage(FoodStageType.BURNED); |
|
} |
|
} |
|
} |
|
|
|
|
|
protected void AddDamageToItemByFire(ItemBase item, bool can_be_ruined) |
|
{ |
|
item.DecreaseHealth( PARAM_BURN_DAMAGE_COEF, false ); |
|
|
|
if ( item.CanBeCooked() & item.GetHealthLevel() >= GameConstants.STATE_BADLY_DAMAGED ) |
|
{ |
|
Edible_Base edible_item = Edible_Base.Cast( item ); |
|
edible_item.ChangeFoodStage( FoodStageType.BURNED ); |
|
} |
|
} |
|
|
|
|
|
protected void AddWetnessToItem(ItemBase item, float amount) |
|
{ |
|
float wetness = item.GetWet(); |
|
wetness = wetness + amount; |
|
wetness = Math.Clamp(wetness, 0, 1); |
|
item.SetWet(wetness); |
|
} |
|
|
|
|
|
void AddWetnessToFireplace(float amount) |
|
{ |
|
|
|
float wetness = GetWet(); |
|
wetness = wetness + amount; |
|
wetness = Math.Clamp(wetness, 0, 1); |
|
SetWet(wetness); |
|
|
|
|
|
if (amount > 0) |
|
{ |
|
float temperature = GetTemperature(); |
|
temperature = temperature * ( 1 - ( wetness * 0.5 ) ); |
|
temperature = Math.Clamp( temperature, PARAM_MIN_FIRE_TEMPERATURE, PARAM_NORMAL_FIRE_TEMPERATURE ); |
|
|
|
m_UTSLFireplace.SetFuelCount(GetFuelCount()); |
|
m_UTSLFireplace.SetCurrentTemperature(temperature); |
|
} |
|
} |
|
|
|
|
|
protected void TransferHeatToNearPlayers() {} |
|
|
|
|
|
void CreateAreaDamage() |
|
{ |
|
|
|
DestroyAreaDamage(); |
|
|
|
|
|
m_AreaDamage = new AreaDamageLoopedDeferred( this ); |
|
m_AreaDamage.SetDamageComponentType(AreaDamageComponentTypes.HITZONE); |
|
m_AreaDamage.SetExtents("-0.30 0 -0.30", "0.30 0.75 0.30"); |
|
m_AreaDamage.SetLoopInterval( 0.5 ); |
|
m_AreaDamage.SetDeferDuration( 0.5 ); |
|
m_AreaDamage.SetHitZones( { "Head","Torso","LeftHand","LeftLeg","LeftFoot","RightHand","RightLeg","RightFoot" } ); |
|
m_AreaDamage.SetAmmoName( "FireDamage" ); |
|
m_AreaDamage.Spawn(); |
|
} |
|
|
|
void DestroyAreaDamage() |
|
{ |
|
if ( m_AreaDamage ) |
|
{ |
|
m_AreaDamage.Destroy(); |
|
} |
|
} |
|
|
|
|
|
bool IsFacingFireplace(PlayerBase player) |
|
{ |
|
ErrorEx("Deprecated method", ErrorExSeverity.INFO); |
|
|
|
return false; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
bool HasAnyKindling() |
|
{ |
|
return GetKindlingCount() > 0; |
|
} |
|
|
|
|
|
static bool IsWindy() |
|
{ |
|
|
|
float wind_speed = GetGame().GetWeather().GetWindSpeed(); |
|
float wind_speed_threshold = GetGame().GetWeather().GetWindMaximumSpeed() * FireplaceBase.IGNITE_WIND_THRESHOLD; |
|
|
|
return ( wind_speed >= wind_speed_threshold ); |
|
} |
|
|
|
bool GetIgniteFailure() |
|
{ |
|
return m_NoIgnite; |
|
} |
|
|
|
void SetIgniteFailure( bool failure ) |
|
{ |
|
m_NoIgnite = failure; |
|
} |
|
|
|
|
|
static bool IsEntityWet( notnull EntityAI entity_ai ) |
|
{ |
|
return ( entity_ai.GetWet() >= FireplaceBase.PARAM_MAX_WET_TO_IGNITE ); |
|
} |
|
|
|
bool IsWet() |
|
{ |
|
return FireplaceBase.IsEntityWet( this ); |
|
} |
|
|
|
|
|
bool IsRoofAbove() |
|
{ |
|
return m_RoofAbove; |
|
} |
|
|
|
|
|
override bool IsOpen() |
|
{ |
|
return true; |
|
} |
|
|
|
|
|
bool IsCeilingHighEnoughForSmoke() |
|
{ |
|
return !MiscGameplayFunctions.IsUnderRoof( this, FireplaceBase.MIN_CEILING_HEIGHT ); |
|
} |
|
|
|
|
|
static bool IsRainingAboveEntity( notnull EntityAI entity_ai ) |
|
{ |
|
return ( GetGame() && ( GetGame().GetWeather().GetRain().GetActual() >= FireplaceBase.PARAM_IGNITE_RAIN_THRESHOLD ) ); |
|
} |
|
|
|
bool IsRainingAbove() |
|
{ |
|
return FireplaceBase.IsRainingAboveEntity( this ); |
|
} |
|
|
|
|
|
static bool IsEntityOnWaterSurface(notnull EntityAI entity_ai) |
|
{ |
|
vector fireplacePosition = entity_ai.GetPosition(); |
|
string surfaceType; |
|
g_Game.SurfaceGetType3D(fireplacePosition[0], fireplacePosition[1] + g_Game.SurfaceGetSeaLevel(), fireplacePosition[2], surfaceType); |
|
if (!surfaceType) |
|
{ |
|
float waterLevelDiff = fireplacePosition[1] - g_Game.SurfaceGetSeaLevel(); |
|
return waterLevelDiff < 0.5; |
|
} |
|
else if (surfaceType.Contains("water")) |
|
{ |
|
return true; |
|
} |
|
|
|
return false; |
|
} |
|
bool IsOnWaterSurface() |
|
{ |
|
return FireplaceBase.IsEntityOnWaterSurface(this); |
|
} |
|
|
|
|
|
static bool IsEntityOnInteriorSurface(notnull EntityAI entity_ai) |
|
{ |
|
string surfaceType; |
|
vector fireplacePosition = entity_ai.GetPosition(); |
|
GetGame().SurfaceGetType3D(fireplacePosition[0], fireplacePosition[1] + 1.0, fireplacePosition[2], surfaceType); |
|
return (GetGame().ConfigGetInt("CfgSurfaces " + surfaceType + " interior") == 1); |
|
} |
|
bool IsOnInteriorSurface() |
|
{ |
|
return FireplaceBase.IsEntityOnInteriorSurface( this ); |
|
} |
|
|
|
|
|
override bool IsEmpty() |
|
{ |
|
return ( GetInventory().GetCargo().GetItemCount() == 0 && GetInventory().AttachmentCount() == 0 ); |
|
} |
|
|
|
|
|
bool IsCargoEmpty() |
|
{ |
|
return ( GetInventory().GetCargo().GetItemCount() == 0 ); |
|
} |
|
|
|
bool HasCookingStand() |
|
{ |
|
return GetInventory().FindAttachment(InventorySlots.GetSlotIdFromString("CookingTripod")) != null; |
|
} |
|
|
|
|
|
bool IsInAnimPhase( string anim_phase ) |
|
{ |
|
return GetAnimationPhase(anim_phase) == 0; |
|
} |
|
|
|
bool IsSpaceFor(vector size) |
|
{ |
|
array<Object> objs = {}; |
|
if (GetGame().IsBoxCollidingGeometry(GetWorldPosition() + Vector(0, size[1] * 0.5 + 0.1, 0), GetDirection().VectorToAngles(), size, ObjIntersect.View, ObjIntersect.Geom, {this}, objs)) |
|
{ |
|
foreach (Object obj : objs) |
|
{ |
|
if (dBodyGetInteractionLayer(obj) == PhxInteractionLayers.ITEM_LARGE) |
|
return false; |
|
} |
|
} |
|
return true; |
|
} |
|
|
|
|
|
override bool CanSwapEntities(EntityAI otherItem, InventoryLocation otherDestination, InventoryLocation destination) |
|
{ |
|
if (!otherDestination || otherDestination.GetParent() == this) |
|
{ |
|
return false; |
|
} |
|
return true; |
|
} |
|
|
|
|
|
bool CanBuildOven() |
|
{ |
|
return !IsOven() && !IsBurning() && (GetAttachedStonesCount() >= MIN_STONES_TO_BUILD_OVEN) && !FindAttachmentBySlotName("CookingTripod") && !HasStoneCircle() && IsSpaceForOven(); |
|
} |
|
|
|
bool IsSpaceForOven() |
|
{ |
|
const float size = 0.6; |
|
return IsSpaceFor(Vector(size, size, size)); |
|
} |
|
|
|
|
|
bool CanBuildStoneCircle() |
|
{ |
|
return !HasStoneCircle() && !IsOven() && !IsBurning() && (GetAttachedStonesCount() >= MIN_STONES_TO_BUILD_CIRCLE) && IsSpaceForCircle(); |
|
} |
|
|
|
bool IsSpaceForCircle() |
|
{ |
|
return IsSpaceFor(Vector(0.9, 0.1, 0.9)); |
|
} |
|
|
|
|
|
bool CanDismantleOven() |
|
{ |
|
return ( IsOven() && !IsBurning() && !DirectCookingSlotsInUse() && !SmokingSlotsInUse() && GetTemperature() <= MAX_TEMPERATURE_TO_DISMANTLE_OVEN ); |
|
} |
|
|
|
bool CanDismantleStoneCircle() |
|
{ |
|
return ( HasStoneCircle() && !IsOven() && !IsBurning() ); |
|
} |
|
|
|
bool CanCookOnStick() |
|
{ |
|
return ( GetTemperature() >= PARAM_COOKING_TEMP_THRESHOLD ); |
|
} |
|
|
|
|
|
bool CanExtinguishFire() |
|
{ |
|
return IsBurning(); |
|
} |
|
|
|
FireplaceLight GetLightEntity() |
|
{ |
|
return m_Light; |
|
} |
|
|
|
void SetLightEntity( FireplaceLight light ) |
|
{ |
|
m_Light = light; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
override void OnPlacementComplete( Man player, vector position = "0 0 0", vector orientation = "0 0 0" ) |
|
{ |
|
super.OnPlacementComplete( player, position, orientation ); |
|
|
|
if ( GetGame().IsServer() ) |
|
{ |
|
|
|
Object cc_object = GetGame().CreateObjectEx( OBJECT_CLUTTER_CUTTER , position, ECE_PLACE_ON_SURFACE ); |
|
cc_object.SetOrientation( orientation ); |
|
GetGame().GetCallQueue( CALL_CATEGORY_GAMEPLAY ).CallLater( GetGame().ObjectDelete, 1000, false, cc_object ); |
|
|
|
SetIsPlaceSound( true ); |
|
} |
|
} |
|
|
|
override string GetPlaceSoundset() |
|
{ |
|
return "placeFireplace_SoundSet"; |
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void CalcAndSetTotalEnergy() |
|
{ |
|
if ( GetGame() && GetGame().IsServer() ) |
|
{ |
|
m_TotalEnergy = 0; |
|
|
|
foreach (FireConsumableType fireConsumableType : m_FireConsumableTypes) |
|
{ |
|
string quantityConfigPath = string.Format("CfgVehicles %1 varQuantityMax", fireConsumableType.GetItemType().ToString()); |
|
string stackMaxConfigPath = string.Format("CfgSlots Slot_%1 stackMax", fireConsumableType.GetAttSlot()); |
|
if (GetGame().ConfigIsExisting(quantityConfigPath)) |
|
{ |
|
float quantityMax = GetGame().ConfigGetFloat(quantityConfigPath); |
|
} |
|
|
|
if (GetGame().ConfigIsExisting(stackMaxConfigPath)) |
|
{ |
|
float stackMax = GetGame().ConfigGetFloat(stackMaxConfigPath); |
|
} |
|
|
|
|
|
|
|
|
|
if (stackMax > 0) |
|
{ |
|
m_TotalEnergy += stackMax * fireConsumableType.GetEnergy(); |
|
} |
|
else |
|
{ |
|
m_TotalEnergy += quantityMax * fireConsumableType.GetEnergy(); |
|
} |
|
} |
|
|
|
|
|
|
|
} |
|
} |
|
|
|
|
|
protected void CalcAndSetQuantity() |
|
{ |
|
if (GetGame() && GetGame().IsServer()) |
|
{ |
|
float remainingEnergy; |
|
|
|
foreach (FireConsumable fireConsumable : m_FireConsumables) |
|
{ |
|
float quantity = fireConsumable.GetItem().GetQuantity(); |
|
if (quantity > 0) |
|
{ |
|
remainingEnergy += ((quantity - 1) * fireConsumable.GetEnergy()) + fireConsumable.GetRemainingEnergy(); |
|
|
|
} |
|
else |
|
{ |
|
remainingEnergy += fireConsumable.GetRemainingEnergy(); |
|
|
|
} |
|
} |
|
|
|
SetQuantity(remainingEnergy / m_TotalEnergy * GetQuantityMax()); |
|
} |
|
} |
|
|
|
override void OnAttachmentQuantityChanged(ItemBase item) |
|
{ |
|
super.OnAttachmentQuantityChanged(item); |
|
|
|
CalcAndSetQuantity(); |
|
} |
|
|
|
override bool CanReleaseAttachment(EntityAI attachment) |
|
{ |
|
if (!super.CanReleaseAttachment(attachment)) |
|
return false; |
|
|
|
ItemBase item = ItemBase.Cast(attachment); |
|
if (IsKindling(item) || IsFuel(item)) |
|
{ |
|
return !IsBurning(); |
|
} |
|
|
|
return true; |
|
} |
|
|
|
void LockOvenAttachments(bool lock) |
|
{ |
|
|
|
|
|
string path_cooking_equipment = string.Format("%1 %2 GUIInventoryAttachmentsProps CookingEquipment attachmentSlots", CFG_VEHICLESPATH, GetType()); |
|
|
|
string path_direct_cooking = string.Format("%1 %2 GUIInventoryAttachmentsProps DirectCooking attachmentSlots", CFG_VEHICLESPATH, GetType()); |
|
if ( GetGame().ConfigIsExisting(path_cooking_equipment) && GetGame().ConfigIsExisting(path_direct_cooking) ) |
|
{ |
|
array<string> arr_cooking_equipment = new array<string>; |
|
array<string> arr_direct_cooking = new array<string>; |
|
GetGame().ConfigGetTextArray(path_cooking_equipment,arr_cooking_equipment); |
|
GetGame().ConfigGetTextArray(path_direct_cooking,arr_direct_cooking); |
|
for ( int i = 0; i < arr_cooking_equipment.Count(); i++ ) |
|
{ |
|
if ( lock != GetInventory().GetSlotLock(InventorySlots.GetSlotIdFromString(arr_cooking_equipment[i])) ) |
|
{ |
|
GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(arr_cooking_equipment[i]),lock); |
|
|
|
} |
|
} |
|
|
|
for ( i = 0; i < arr_direct_cooking.Count(); i++ ) |
|
{ |
|
if ( lock == GetInventory().GetSlotLock(InventorySlots.GetSlotIdFromString(arr_direct_cooking[i])) ) |
|
{ |
|
GetInventory().SetSlotLock(InventorySlots.GetSlotIdFromString(arr_direct_cooking[i]),!lock); |
|
|
|
} |
|
} |
|
} |
|
m_OvenAttachmentsLockState = lock; |
|
} |
|
override bool DisassembleOnLastDetach() |
|
{ |
|
return true; |
|
} |
|
|
|
override void OnRPC( PlayerIdentity sender, int rpc_type, ParamsReadContext ctx ) |
|
{ |
|
super.OnRPC( sender, rpc_type, ctx ); |
|
|
|
ref Param1<bool> p = new Param1<bool>(false); |
|
|
|
if (ctx.Read(p)) |
|
{ |
|
bool failure = p.param1; |
|
} |
|
|
|
switch ( rpc_type ) |
|
{ |
|
case FirePlaceFailure.WIND: |
|
|
|
if ( failure ) |
|
{ |
|
ParticleFireWindyNoIgniteStart(); |
|
SoundFireStop(); |
|
SoundFireWindyNoIgniteStart(); |
|
} |
|
|
|
break; |
|
|
|
case FirePlaceFailure.WET: |
|
|
|
if ( failure ) |
|
{ |
|
ParticleWetNoIgniteStart(); |
|
SoundFireStop(); |
|
SoundFireWetNoIgniteStart(); |
|
} |
|
|
|
break; |
|
} |
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override void OnDebugSpawn() |
|
{ |
|
ItemBase firewood = ItemBase.Cast(GetInventory().CreateInInventory("Firewood")); |
|
firewood.SetQuantity(firewood.GetQuantityMax()); |
|
|
|
ItemBase sticks = ItemBase.Cast(GetInventory().CreateInInventory("WoodenStick")); |
|
sticks.SetQuantity(sticks.GetQuantityMax()); |
|
|
|
ItemBase stone = ItemBase.Cast(GetInventory().CreateInInventory("Stone")); |
|
stone.SetQuantity(stone.GetQuantityMax()); |
|
|
|
GetInventory().CreateInInventory("Rag"); |
|
|
|
SpawnEntityOnGroundPos("PetrolLighter", GetPosition()); |
|
} |
|
|
|
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList) |
|
{ |
|
outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.ACTIVATE_ENTITY, "Ignite", FadeColors.LIGHT_GREY)); |
|
outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DEACTIVATE_ENTITY, "Extinguish", FadeColors.LIGHT_GREY)); |
|
outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.LIGHT_GREY)); |
|
|
|
super.GetDebugActions(outputList); |
|
} |
|
|
|
override bool OnAction(int action_id, Man player, ParamsReadContext ctx) |
|
{ |
|
if (super.OnAction(action_id, player, ctx)) |
|
return true; |
|
if (GetGame().IsServer() || !GetGame().IsMultiplayer()) |
|
{ |
|
if (action_id == EActions.ACTIVATE_ENTITY) |
|
{ |
|
OnIgnitedThis(null); |
|
} |
|
else if (action_id == EActions.DEACTIVATE_ENTITY) |
|
{ |
|
StopFire(); |
|
} |
|
} |
|
return false; |
|
} |
|
|
|
|
|
} |
|
|