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)
override bool IsInitialized()
Super root of all classes in Enforce script.
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)
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
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 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 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