1class PowerGeneratorBase
extends ItemBase
9 static const string START_SOUND =
"powerGeneratorTurnOn_SoundSet";
10 static const string LOOP_SOUND =
"powerGeneratorLoop_SoundSet";
12 static const string STOP_SOUND =
"powerGeneratorTurnOff_SoundSet";
27 protected ref UniversalTemperatureSourceLambdaConstant
m_UTSLEngine;
35 RegisterNetSyncVariableInt(
"m_FuelPercentage");
56 m_UTSLEngine =
new UniversalTemperatureSourceLambdaConstant();
79 return "0.3 0.21 0.4";
92 if (GetCompEM().IsWorking())
109 if (!super.CanPutInCargo(parent))
120 if(!super.CanPutIntoHands(parent))
130 return GetCompEM().GetPluggedDevicesCount() == 0 && !GetCompEM().IsWorking();
174 override void OnWork(
float consumed_energy)
220 super.OnItemLocationChanged(old_owner, new_owner);
226 super.EEItemAttached(item, slot_name);
227 GetCompEM().InteractBranch(
this);
233 ShowSelection(
"sparkplug_installed");
244 super.EEItemDetached(item, slot_name);
246 GetCompEM().InteractBranch(
this);
250 if (item_IB.IsKindOf(
"Sparkplug"))
252 HideSelection(
"sparkplug_installed");
253 GetCompEM().SwitchOff();
289 if (
GetFuel() == 0.0 && fuel_amount <= 0.0)
302 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());
311 if (available_fuel == 0.0)
314 GetCompEM().InteractBranch(
this);
317 if (needed_fuel > available_fuel)
320 return available_fuel;
335 int liquid_type = container.GetLiquidType();
338 if ( container.GetQuantity() > 0 && GetCompEM().
GetEnergy() < GetCompEM().GetEnergyMax() && (liquid_type &
LIQUID_GASOLINE))
368 EntityAI ent = GetInventory().FindAttachment(slot);
370 return ent && !ent.IsRuined();
375 super.OnVariablesSynchronized();
386 return "placePowerGenerator_SoundSet";
406 entity.GetInventory().CreateInInventory(
"SparkPlug");
421 super.GetDebugActions(outputList);
426 if (super.OnAction(action_id, player, ctx))
440 case EActions.GENERIC_FUEL_INCREASE:
443 case EActions.GENERIC_FUEL_DECREASE:
458class PowerGenerator
extends PowerGeneratorBase {}
Param4< int, int, string, int > TSelectableActionInfoWithColor
eBleedingSourceType GetType()
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
void AddAction(typename actionName)
override bool IsInitialized()
proto native float ConfigGetFloat(string path)
Get float value from config on path.
Super root of all classes in Enforce script.
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Wrapper class for managing sound through SEffectManager.
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
provides access to slot configuration
override void EEItemAttached(EntityAI item, string slot_name)
static const string SPARKPLUG_ATTACH_SOUND
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)
static float m_FuelTankCapacity
override void SetActions()
override void OnInitEnergy()
EffectSound m_EngineStart
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
ref UniversalTemperatureSourceSettings m_UTSSettings
static const string START_SOUND
static const string SPARKPLUG_DETACH_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()
static float m_FuelToEnergyRatio
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)
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.
Manager class for managing Effect (EffectParticle, EffectSound)
original Timer deletes m_params which is unwanted
Serializer ParamsReadContext
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.
static const float ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE
const float LIQUID_THROUGHPUT_GENERATOR
const int LIQUID_GASOLINE
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
const int SAT_DEBUG_ACTION
class JsonUndergroundAreaTriggerData GetPosition