1class PowerGeneratorBase
extends ItemBase
4 private static float m_FuelTankCapacity;
5 private static float m_FuelToEnergyRatio;
6 private int m_FuelPercentage;
9 static const string START_SOUND =
"powerGeneratorTurnOn_SoundSet";
10 static const string LOOP_SOUND =
"powerGeneratorLoop_SoundSet";
12 static const string STOP_SOUND =
"powerGeneratorTurnOff_SoundSet";
25 protected ref UniversalTemperatureSourceLambdaConstant
m_UTSLEngine;
32 m_FuelPercentage = 50;
33 RegisterNetSyncVariableInt(
"m_FuelPercentage");
54 m_UTSLEngine =
new UniversalTemperatureSourceLambdaConstant();
63 m_FuelPercentage = GetCompEM().GetEnergy0To100();
77 return "0.3 0.21 0.4";
90 if (GetCompEM().IsWorking())
107 if (!super.CanPutInCargo(parent))
118 if(!super.CanPutIntoHands(parent))
128 return GetCompEM().GetPluggedDevicesCount() == 0 && !GetCompEM().IsWorking();
138 m_FuelTankCapacity =
g_Game.ConfigGetFloat (
"CfgVehicles " +
GetType() +
" fuelTankCapacity");
139 m_FuelToEnergyRatio = GetCompEM().GetEnergyMax() / m_FuelTankCapacity;
172 override void OnWork(
float consumed_energy)
181 m_FuelPercentage = GetCompEM().GetEnergy0To100();
218 super.OnItemLocationChanged(old_owner, new_owner);
224 super.EEItemAttached(item, slot_name);
225 GetCompEM().InteractBranch(
this);
230 ShowSelection(
"sparkplug_installed");
236 super.EEItemDetached(item, slot_name);
237 GetCompEM().InteractBranch(
this);
240 if (item_IB.IsKindOf(
"Sparkplug"))
242 HideSelection(
"sparkplug_installed");
243 GetCompEM().SwitchOff();
266 SetAnimationPhase(
"dial_fuel", m_FuelPercentage * 0.01);
274 if (
GetFuel() == 0.0 && fuel_amount <= 0.0)
277 if (m_FuelTankCapacity > 0)
279 m_FuelToEnergyRatio = GetCompEM().GetEnergyMax() / m_FuelTankCapacity;
280 GetCompEM().SetEnergy(fuel_amount * m_FuelToEnergyRatio);
281 m_FuelPercentage = GetCompEM().GetEnergy0To100();
287 string error =
string.Format(
"ERROR! Item %1 has fuel tank with 0 capacity! Add parameter 'fuelTankCapacity' to its config and set it to more than 0!", this.
GetType());
296 if (available_fuel == 0.0)
299 GetCompEM().InteractBranch(
this);
302 if (needed_fuel > available_fuel)
305 return available_fuel;
320 int liquid_type = container.GetLiquidType();
323 if ( container.GetQuantity() > 0 && GetCompEM().
GetEnergy() < GetCompEM().GetEnergyMax() && (liquid_type &
LIQUID_GASOLINE))
341 return m_FuelTankCapacity;
346 return m_FuelPercentage;
353 EntityAI ent = GetInventory().FindAttachment(slot);
355 return ent && !ent.IsRuined();
360 super.OnVariablesSynchronized();
371 return "placePowerGenerator_SoundSet";
389 if (
Class.CastTo(entity,
this))
391 entity.GetInventory().CreateInInventory(
"SparkPlug");
406 super.GetDebugActions(outputList);
411 if (super.OnAction(action_id, player, ctx))
425 case EActions.GENERIC_FUEL_INCREASE:
428 case EActions.GENERIC_FUEL_DECREASE:
445class PowerGenerator
extends PowerGeneratorBase {}
Param4< int, int, string, int > TSelectableActionInfoWithColor
eBleedingSourceType GetType()
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
void AddAction(typename actionName)
Super root of all classes in Enforce script.
Wrapper class for managing sound through SEffectManager.
provides access to slot configuration
override void EEItemAttached(EntityAI item, string slot_name)
override void OnWork(float consumed_energy)
override void OnWorkStart()
ref UniversalTemperatureSource m_UTSource
DEPRECATED Attached spark plug item.
static const string STOP_SOUND
void SetFuel(float fuel_amount)
void PowerGeneratorBase()
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
override bool CanPutIntoHands(EntityAI parent)
override void SetActions()
override void OnInitEnergy()
EffectSound m_EngineStart
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
ref UniversalTemperatureSourceSettings m_UTSSettings
static const string START_SOUND
ref UniversalTemperatureSourceLambdaConstant m_UTSLEngine
override string GetDeploySoundset()
override void OnWorkStop()
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
float GetFuelPercentage()
override float GetLiquidThroughputCoef()
override void EEItemDetached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
override bool CanPutInCargo(EntityAI parent)
override void OnDebugSpawn()
vector GetSmokeParticleOrientation()
static const string LOOP_SOUND
ref Timer m_SoundLoopStartTimer
float AddFuel(float available_fuel)
vector GetSmokeParticlePosition()
const string LOOP_LOW_FUEL_SOUND
void ~PowerGeneratorBase()
void SetLowEnergyState(bool state)
const float LOW_ENERGY_FUEL_PERCENTAGE
override void EOnInit(IEntity other, int extra)
bool CanAddFuel(ItemBase container)
Manager class for managing Effect (EffectParticle, EffectSound).
static int PlayOnObject(notnull Effect eff, Object obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_relative_to_world=false)
Play an Effect.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
original Timer deletes m_params which is unwanted
override bool IsInitialized()
Serializer ParamsReadContext
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...
EntityEvent
Entity events for event-mask, or throwing event from code.
const float LIQUID_THROUGHPUT_GENERATOR
const int SAT_DEBUG_ACTION