1class PowerGeneratorBase
extends ItemBase
8 static const string START_SOUND =
"powerGeneratorTurnOn_SoundSet";
9 static const string LOOP_SOUND =
"powerGeneratorLoop_SoundSet";
10 static const string STOP_SOUND =
"powerGeneratorTurnOff_SoundSet";
11 static const string SPARKPLUG_ATTACH_SOUND =
"sparkplug_attach_SoundSet";
12 static const string SPARKPLUG_DETACH_SOUND =
"sparkplug_detach_SoundSet";
31 m_FuelPercentage = 50;
32 RegisterNetSyncVariableInt(
"m_FuelPercentage");
33 RegisterNetSyncVariableBool(
"m_IsSoundSynchRemote");
34 RegisterNetSyncVariableBool(
"m_IsPlaceSound");
65 m_FuelPercentage = GetCompEM().GetEnergy0To100();
82 if (GetCompEM().IsWorking())
84 PlaySoundSetLoop(m_EngineLoop, LOOP_SOUND, 0, 0);
98 if (!
super.CanPutInCargo(parent))
107 if (!
super.CanPutIntoHands(parent))
115 return GetCompEM().GetPluggedDevicesCount() == 0 && !GetCompEM().IsWorking();
125 m_FuelTankCapacity =
GetGame().ConfigGetFloat(
"CfgVehicles " +
GetType() +
" fuelTankCapacity");
137 PlaySoundSet(m_EngineStart, START_SOUND, 0, 0);
139 if (!m_SoundLoopStartTimer)
142 if (!m_SoundLoopStartTimer.IsRunning())
143 m_SoundLoopStartTimer.Run(1.5,
this,
"StartLoopSound",
NULL,
false);
158 m_FuelPercentage = GetCompEM().GetEnergy0To100();
171 PlaySoundSet(m_EngineStop, STOP_SOUND, 0, 0);
172 StopSoundSet(m_EngineLoop);
195 GetCompEM().InteractBranch(
this);
201 ShowSelection(
"sparkplug_installed");
205 sound.SetAutodestroy(
true);
214 GetCompEM().InteractBranch(
this);
218 if (
item_IB.IsKindOf(
"Sparkplug"))
220 HideSelection(
"sparkplug_installed");
221 GetCompEM().SwitchOff();
225 sound.SetAutodestroy(
true);
237 SetAnimationPhase(
"dial_fuel", m_FuelPercentage * 0.01);
243 if (m_FuelTankCapacity > 0)
246 GetCompEM().SetEnergy(
fuel_amount * m_FuelToEnergyRatio);
247 m_FuelPercentage = GetCompEM().GetEnergy0To100();
253 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());
264 GetCompEM().InteractBranch(
this);
311 EntityAI ent = GetInventory().FindAttachment(slot);
313 return ent && !
ent.IsRuined();
318 super.OnVariablesSynchronized();
339 return "placePowerGenerator_SoundSet";
358 entity.GetInventory().CreateInInventory(
"SparkPlug");
eBleedingSourceType GetType()
void AddAction(typename actionName)
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
override bool IsInitialized()
ref UniversalTemperatureSourceSettings m_UTSSettings
ref UniversalTemperatureSource m_UTSource
void SetIsPlaceSound(bool is_place_sound)
class JsonUndergroundAreaTriggerData GetPosition
Super root of all classes in Enforce script.
Wrapper class for managing sound through SEffectManager.
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
override void EEItemAttached(EntityAI item, string slot_name)
override bool CanPutIntoHands(EntityAI player)
override void OnWork(float consumed_energy)
override void OnWorkStart()
ref UniversalTemperatureSource m_UTSource
DEPRECATED Attached spark plug item.
void SetFuel(float fuel_amount)
void PowerGeneratorBase()
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
static float m_FuelTankCapacity
override void SetActions()
override void OnInitEnergy()
EffectSound m_EngineStart
ref UniversalTemperatureSourceSettings m_UTSSettings
override void OnWorkStop()
override string GetPlaceSoundset()
override float GetLiquidThroughputCoef()
static float m_FuelToEnergyRatio
override void EEItemDetached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
override bool CanPutInCargo(EntityAI parent)
override void OnDebugSpawn()
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
ref Timer m_SoundLoopStartTimer
ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine
float AddFuel(float available_fuel)
void ~PowerGeneratorBase()
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 EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
original Timer deletes m_params which is unwanted
proto native CGame GetGame()
proto void DPrint(string var)
Prints content of variable to console/log. Should be used for critical messages so it will appear in ...
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
EntityEvent
Entity events for event-mask, or throwing event from code.
const float LIQUID_THROUGHPUT_GENERATOR
const int LIQUID_GASOLINE