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";
25 protected ref UniversalTemperatureSourceLambdaConstant
m_UTSLEngine;
33 RegisterNetSyncVariableInt(
"m_FuelPercentage");
54 m_UTSLEngine =
new UniversalTemperatureSourceLambdaConstant();
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();
172 override void OnWork(
float consumed_energy)
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();
274 if (
GetFuel() == 0.0 && fuel_amount <= 0.0)
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))
353 EntityAI ent = GetInventory().FindAttachment(slot);
355 return ent && !ent.IsRuined();
360 super.OnVariablesSynchronized();
371 return "placePowerGenerator_SoundSet";
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.
Internal ancestor of all Entity implementations.
provides access to slot configuration
static proto native int GetSlotIdFromString(string slot_name)
override void OnDebugSpawn()
ref UniversalTemperatureSourceSettings m_UTSSettings
override void OnItemLocationChanged(EntityAI old_owner, EntityAI new_owner)
override string GetDeploySoundset()
static const string STOP_SOUND
override void OnInitEnergy()
void SetFuel(float fuel_amount)
void SetLowEnergyState(bool state)
void ~PowerGeneratorBase()
EffectSound m_EngineStart
static float m_FuelTankCapacity
void PowerGeneratorBase()
vector GetSmokeParticlePosition()
override bool CanPutInCargo(EntityAI parent)
override void OnWorkStop()
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
const float LOW_ENERGY_FUEL_PERCENTAGE
override void EEItemDetached(EntityAI item, string slot_name)
float AddFuel(float available_fuel)
override void OnWork(float consumed_energy)
ref Timer m_SoundLoopStartTimer
override bool CanPutIntoHands(EntityAI parent)
const string LOOP_LOW_FUEL_SOUND
ref UniversalTemperatureSourceLambdaConstant m_UTSLEngine
bool CanAddFuel(ItemBase container)
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
static const string LOOP_SOUND
override void EOnInit(IEntity other, int extra)
ref UniversalTemperatureSource m_UTSource
DEPRECATED Attached spark plug item.
override void OnWorkStart()
static const string START_SOUND
override void EEItemAttached(EntityAI item, string slot_name)
override void OnVariablesSynchronized()
static float m_FuelToEnergyRatio
float GetFuelPercentage()
override float GetLiquidThroughputCoef()
vector GetSmokeParticleOrientation()
override void SetActions()
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 ...
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