3 override bool CanPutAsAttachment(
EntityAI parent)
5 if (!super.CanPutAsAttachment(parent))
8 if (parent.IsInherited(BatteryCharger))
10 BatteryCharger charger = BatteryCharger.Cast(parent);
14 if (GetCompEM().GetPluggedDevice())
20 override bool CanDetachAttachment(
EntityAI parent)
25 override bool CanReceiveAttachment(
EntityAI attachment,
int slotId)
27 if (GetCompEM().IsPlugged())
30 return super.CanReceiveAttachment(attachment, slotId);
33 override bool CanPutIntoHands(
EntityAI player)
35 if (!super.CanPutIntoHands(parent))
40 if (HasEnergyManager())
43 if (poweredDevice && poweredDevice.IsInherited(MetalWire))
47 else if (poweredDevice)
56 override bool CanPutInCargo(
EntityAI parent)
58 if (!super.CanPutInCargo(parent))
65 return !(poweredDevice && poweredDevice.IsInherited(MetalWire));
68 override void OnInventoryEnter(Man player)
70 super.OnInventoryEnter(player);
72 if (GetHierarchyParent() == player || (GetHierarchyParent() && GetHierarchyParent().GetInventory().GetCargo()))
74 if (HasEnergyManager())
80 if (poweredDevice.IsInherited(MetalWire))
83 if (poweredDevice.GetCompEM().IsPlugged())
84 poweredDevice.GetCompEM().UnplugDevice(poweredDevice.GetCompEM().GetPluggedDevice());
88 this.GetCompEM().UnplugAllDevices();
95 override void OnMovedInsideCargo(
EntityAI container)
97 super.OnMovedInsideCargo(container);
99 if (HasEnergyManager())
106 if (poweredDevice.IsInherited(MetalWire))
108 poweredDevice.GetCompEM().UnplugAllDevices();
112 this.GetCompEM().UnplugAllDevices();
118 override bool CanDisplayAttachmentSlot(
int slot_id)
120 if (GetCompEM().IsPlugged())
123 return super.CanDisplayAttachmentSlot(slot_id);
126 override bool DisplayNameRuinAttach()
131 override bool ShowZonesHealth()
136 override void SetActions()
149 private int m_Efficiency0To10;
150 static private float m_EfficiencyDecayStart = 0.1;
154 m_Efficiency0To10 = 10;
155 RegisterNetSyncVariableInt(
"m_Efficiency0To10");
160 float GetEfficiency0To1()
162 return m_Efficiency0To10 * 0.1;
166 float GetEfficiencyDecayStart()
168 return m_EfficiencyDecayStart;
171 override void OnEnergyConsumed()
173 super.OnEnergyConsumed();
176 float energyCoef = GetCompEM().GetEnergy0To1();
178 if (energyCoef < m_EfficiencyDecayStart && m_EfficiencyDecayStart > 0)
180 m_Efficiency0To10 =
Math.Round((energyCoef / m_EfficiencyDecayStart) * 10);
188 override void OnEnergyAdded()
190 super.OnEnergyAdded();
193 float energyCoef = GetCompEM().GetEnergy0To1();
195 if (energyCoef < m_EfficiencyDecayStart && m_EfficiencyDecayStart > 0)
197 m_Efficiency0To10 =
Math.Round((energyCoef / m_EfficiencyDecayStart) * 10);
201 m_Efficiency0To10 = 10;