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;
31 static protected float m_BlinkingStatusLightInterval = 0.4;
33 protected bool m_BlinkingStatusLightIsOn =
false;
37 m_ChargeEnergyPerSecond =
GetGame().ConfigGetFloat (
"CfgVehicles " +
GetType() +
" ChargeEnergyPerSecond");
40 RegisterNetSyncVariableInt(
"m_BatteryEnergy0To100");
48 override void OnWork(
float consumed_energy )
57 float battery_capacity = battery.GetCompEM().GetEnergyMax();
59 if ( battery.GetCompEM().GetEnergy() < battery_capacity )
61 float charger_health = GetHealth(
"",
"");
62 float energy_add = m_ChargeEnergyPerSecond * ( consumed_energy / GetCompEM().GetEnergyUsage() );
65 if (FeatureTimeAccel.GetFeatureTimeAccelEnabled(ETimeAccelCategories.ENERGY_RECHARGE))
67 float timeAccel = FeatureTimeAccel.GetFeatureTimeAccelValue();
68 energy_add *= timeAccel;
72 if ( GetCompEM().ConsumeEnergy(energy_add) )
75 energy_add = energy_add * ( 0.5 + charger_health*0.005 );
83 battery.GetCompEM().AddEnergy( energy_add );
87 battery.GetCompEM().SetEnergy( battery_capacity );
89 m_BatteryEnergy0To100 = battery.GetCompEM().GetEnergy0To100();
100 m_UpdateStatusLightsTimer.Run( m_BlinkingStatusLightInterval/2 ,
this,
"UpdateStatusLights", NULL,
true);
109 m_UpdateStatusLightsTimer.Stop();
117 if (GetCompEM().IsWorking())
126 if (m_BatteryEnergy0To100 <= 33)
130 if (m_BlinkingStatusLightIsOn)
137 else if (m_BatteryEnergy0To100 > 33 && m_BatteryEnergy0To100 <= 66)
143 else if (m_BatteryEnergy0To100 > 66 && m_BatteryEnergy0To100 < 100)
149 if (m_BlinkingStatusLightIsOn)
156 else if (m_BatteryEnergy0To100 >= 100)
165 if (m_BlinkingStatusLightIsOn)
188 if( !super.CanPutInCargo(parent) ) {
return false;}
190 if ( !GetCompEM().IsPlugged() && !GetCompEM().GetPluggedDevice() )
200 if( !super.CanPutIntoHands( parent ) )
205 if ( !GetCompEM().IsPlugged() && !GetCompEM().GetPluggedDevice() )
215 string att_type = device.GetType();
217 if ( att_type ==
"CarBattery" )
220 ShowSelection(SEL_CLIPS_CAR);
223 if ( att_type ==
"TruckBattery" )
226 ShowSelection(SEL_CLIPS_TRUCK);
229 HideSelection(SEL_CLIPS_DETACHED);
230 HideSelection(SEL_CLIPS_FOLDED);
236 ShowSelection(SEL_CLIPS_DETACHED);
241 if ( !super.CanReceiveAttachment(attachment, slotId) )
245 Class.CastTo(ibase, attachment);
253 if ( GetCompEM().GetPluggedDevice() )
256 if ( ibase.HasEnergyManager() && ibase.GetCompEM().GetPluggedDevicesCount() >= 1 )
264 if ( !super.CanLoadAttachment(attachment) )
268 Class.CastTo(ibase, attachment);
271 if ( GetCompEM().GetPluggedDevice() )
274 if ( ibase.HasEnergyManager() && ibase.GetCompEM().GetPluggedDevicesCount() >= 1 )
284 string selection = ATTACHED_CLIPS_STATES[i];
285 HideSelection(selection);
295 SetObjectMaterial( 0, RED_LIGHT_GLOW );
299 SetObjectMaterial( 2, GREEN_LIGHT_GLOW );
303 SetObjectMaterial( 1, YELLOW_LIGHT_GLOW );
307 SetObjectMaterial( 3, SWITCH_LIGHT_GLOW );
312 SetObjectMaterial( 0, DEFAULT_MATERIAL );
316 SetObjectMaterial( 2, DEFAULT_MATERIAL );
320 SetObjectMaterial( 1, DEFAULT_MATERIAL );
324 SetObjectMaterial( 3, DEFAULT_MATERIAL );
330 HideSelection(SEL_SWITCH_OFF);
331 ShowSelection(SEL_SWITCH_ON);
336 HideSelection(SEL_SWITCH_ON);
337 ShowSelection(SEL_SWITCH_OFF);
343 super.OnInventoryExit(player);
346 HideSelection(SEL_CLIPS_FOLDED);
347 ShowSelection(SEL_CLIPS_DETACHED);
352 super.OnInventoryEnter(player);
355 HideSelection(SEL_CLIPS_DETACHED);
356 ShowSelection(SEL_CLIPS_FOLDED);
361 super.RefreshPhysics();
365 RemoveProxyPhysics(
"battery" );
366 AddProxyPhysics(
"battery" );
369 RemoveProxyPhysics(
"battery" );
378 super.OnPlacementStarted(player);
380 SetAnimationPhase(SEL_CLIPS_DETACHED, 0);
381 SetAnimationPhase(SEL_CLIPS_FOLDED, 1);
382 SetAnimationPhase(SEL_SWITCH_ON, 1);
383 SetAnimationPhase(SEL_SWITCH_OFF, 1);
384 SetAnimationPhase(SEL_LIGHT_STATE_1, 1);
385 SetAnimationPhase(SEL_LIGHT_STATE_2, 1);
386 SetAnimationPhase(SEL_LIGHT_STATE_3, 1);
396 foreach (
string selection : selections)
399 playerPB.GetHologramServer().SetSelectionToRefresh(selection);
401 playerPB.GetHologramLocal().SetSelectionToRefresh(selection);
412 return "placeBatteryCharger_SoundSet";
eBleedingSourceType GetType()
ActionPlaceObjectCB ActiondeployObjectCB ActionPlaceObject()
void AddAction(typename actionName)
Super root of all classes in Enforce script.
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 CanPutIntoHands(EntityAI parent)
override bool IsElectricAppliance()
override void SetActions()
override bool CanLoadAttachment(EntityAI attachment)
const string SEL_CORD_PLUGGED
override string GetDeploySoundset()
void UpdateStatusLights()
override void OnWorkStop()
int m_BatteryEnergy0To100
void HideAttachedClipsStates()
ref Timer m_UpdateStatusLightsTimer
float m_ChargeEnergyPerSecond
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 OnInventoryExit(Man player)
const string SEL_CLIPS_CAR
override bool IsDeployable()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()