4 static protected const string SEL_CLIPS_CAR =
"clips_car_battery";
5 static protected const string SEL_CLIPS_TRUCK =
"clips_truck_battery";
6 static protected const string SEL_CLIPS_DETACHED =
"clips_detached";
7 static protected const string SEL_CLIPS_FOLDED =
"clips_folded";
8 static protected const string SEL_SWITCH_ON =
"switch_on";
9 static protected const string SEL_SWITCH_OFF =
"switch_off";
10 static protected const string SEL_CORD_PLUGGED =
"cord_plugged";
11 static protected const string SEL_CORD_FOLDED =
"cord_folded";
12 static protected const string SEL_LIGHT_STATE_1 =
"light_stand_by";
13 static protected const string SEL_LIGHT_STATE_2 =
"light_charging";
14 static protected const string SEL_LIGHT_STATE_3 =
"light_charged";
17 static protected const string RED_LIGHT_GLOW =
"dz\\gear\\camping\\data\\battery_charger_light_r.rvmat";
18 static protected const string GREEN_LIGHT_GLOW =
"dz\\gear\\camping\\data\\battery_charger_light_g.rvmat";
19 static protected const string YELLOW_LIGHT_GLOW =
"dz\\gear\\camping\\data\\battery_charger_light_y.rvmat";
20 static protected const string SWITCH_LIGHT_GLOW =
"dz\\gear\\camping\\data\\battery_charger_light_switch_on.rvmat";
21 static protected const string DEFAULT_MATERIAL =
"dz\\gear\\camping\\data\\battery_charger.rvmat";
23 protected const string ATTACHED_CLIPS_STATES[] = {
SEL_CLIPS_CAR, SEL_CLIPS_TRUCK};
24 protected const int ATTACHED_CLIPS_STATES_COUNT = 2;
30 static protected float m_BlinkingStatusLightInterval = 0.4;
32 protected bool m_BlinkingStatusLightIsOn =
false;
36 m_ChargeEnergyPerSecond =
GetGame().ConfigGetFloat(
"CfgVehicles " +
GetType() +
" ChargeEnergyPerSecond");
39 RegisterNetSyncVariableInt(
"m_BatteryEnergy0To100");
40 RegisterNetSyncVariableBool(
"m_IsSoundSynchRemote");
41 RegisterNetSyncVariableBool(
"m_IsPlaceSound");
64 battery.SetTemperature(60);
92 m_BatteryEnergy0To100 =
battery.GetCompEM().GetEnergy0To100();
103 m_UpdateStatusLightsTimer.Run(m_BlinkingStatusLightInterval / 2,
this,
"UpdateStatusLights",
NULL,
true);
112 m_UpdateStatusLightsTimer.Stop();
120 if (GetCompEM().IsWorking())
129 if (m_BatteryEnergy0To100 <= 33)
133 if (m_BlinkingStatusLightIsOn)
140 else if (m_BatteryEnergy0To100 > 33 && m_BatteryEnergy0To100 <= 66)
146 else if (m_BatteryEnergy0To100 > 66 && m_BatteryEnergy0To100 < 100)
152 if (m_BlinkingStatusLightIsOn)
159 else if (m_BatteryEnergy0To100 >= 100)
168 if (m_BlinkingStatusLightIsOn)
191 if (!
super.CanPutInCargo(parent))
return false;
193 if (!GetCompEM().IsPlugged() && !GetCompEM().GetPluggedDevice())
201 if (!
super.CanPutIntoHands(parent))
204 if (!GetCompEM().IsPlugged() && !GetCompEM().GetPluggedDevice())
217 ShowSelection(SEL_CLIPS_CAR);
223 ShowSelection(SEL_CLIPS_TRUCK);
226 HideSelection(SEL_CLIPS_DETACHED);
227 HideSelection(SEL_CLIPS_FOLDED);
233 ShowSelection(SEL_CLIPS_DETACHED);
250 if (GetCompEM().GetPluggedDevice())
253 if (
ibase.HasEnergyManager() &&
ibase.GetCompEM().GetPluggedDevicesCount() >= 1)
268 if (GetCompEM().GetPluggedDevice())
271 if (
ibase.HasEnergyManager() &&
ibase.GetCompEM().GetPluggedDevicesCount() >= 1)
281 string selection = ATTACHED_CLIPS_STATES[
i];
282 HideSelection(selection);
291 SetObjectMaterial(0, RED_LIGHT_GLOW);
295 SetObjectMaterial(2, GREEN_LIGHT_GLOW);
299 SetObjectMaterial(1, YELLOW_LIGHT_GLOW);
303 SetObjectMaterial(3, SWITCH_LIGHT_GLOW);
308 SetObjectMaterial(0, DEFAULT_MATERIAL);
312 SetObjectMaterial(2, DEFAULT_MATERIAL);
316 SetObjectMaterial(1, DEFAULT_MATERIAL);
320 SetObjectMaterial(3, DEFAULT_MATERIAL);
326 HideSelection(SEL_SWITCH_OFF);
327 ShowSelection(SEL_SWITCH_ON);
332 HideSelection(SEL_SWITCH_ON);
333 ShowSelection(SEL_SWITCH_OFF);
342 HideSelection(SEL_CLIPS_FOLDED);
343 ShowSelection(SEL_CLIPS_DETACHED);
351 HideSelection(SEL_CLIPS_DETACHED);
352 ShowSelection(SEL_CLIPS_FOLDED);
357 super.OnVariablesSynchronized();
365 super.RefreshPhysics();
369 RemoveProxyPhysics(
"battery");
370 AddProxyPhysics(
"battery");
373 RemoveProxyPhysics(
"battery");
384 SetAnimationPhase(SEL_CLIPS_DETACHED, 0);
385 SetAnimationPhase(SEL_CLIPS_FOLDED, 1);
386 SetAnimationPhase(SEL_SWITCH_ON, 1);
387 SetAnimationPhase(SEL_SWITCH_OFF, 1);
388 SetAnimationPhase(SEL_LIGHT_STATE_1, 1);
389 SetAnimationPhase(SEL_LIGHT_STATE_2, 1);
390 SetAnimationPhase(SEL_LIGHT_STATE_3, 1);
403 playerPB.GetHologramServer().SetSelectionToRefresh(selection);
405 playerPB.GetHologramLocal().SetSelectionToRefresh(selection);
423 return "placeBatteryCharger_SoundSet";
eBleedingSourceType GetType()
void AddAction(typename actionName)
override void SetTemperature(float value, bool allow_client=false)
void SetIsPlaceSound(bool is_place_sound)
Super root of all classes in Enforce script.
override bool CanPutIntoHands(EntityAI player)
override void OnSwitchOn()
override void OnInventoryEnter(Man player)
override void OnWork(float consumed_energy)
override void OnWorkStart()
override void OnOwnSocketReleased(EntityAI device)
override void OnOwnSocketTaken(EntityAI device)
override void OnPlacementStarted(Man player)
override bool IsElectricAppliance()
override void SetActions()
override bool CanLoadAttachment(EntityAI attachment)
const string SEL_CORD_PLUGGED
void UpdateStatusLights()
override void OnWorkStop()
int m_BatteryEnergy0To100
override string GetPlaceSoundset()
void HideAttachedClipsStates()
ref Timer m_UpdateStatusLightsTimer
float m_ChargeEnergyPerSecond
override void OnVariablesSynchronized()
override void RefreshPhysics()
bool m_BlinkingStatusLightIsOn
override void OnSwitchOff()
const int ATTACHED_CLIPS_STATES_COUNT
const string SEL_CORD_FOLDED
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
override bool CanPutInCargo(EntityAI parent)
const string SEL_CLIPS_DETACHED
override void OnPlacementComplete(Man player, vector position="0 0 0", vector orientation="0 0 0")
override void OnInventoryExit(Man player)
const string SEL_CLIPS_CAR
override bool IsDeployable()
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.