(9a14162c6) Disabled spontaneous deterioration on items that are not being used. TODO: adjust all deterioration rates and delays
This commit is contained in:
@@ -15,6 +15,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private float deteriorationTimer;
|
||||
|
||||
public float LastActiveTime;
|
||||
|
||||
[Serialize(0.0f, true), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f, DecimalCount = 2, ToolTip = "How fast the condition of the item deteriorates per second.")]
|
||||
public float DeteriorationSpeed
|
||||
{
|
||||
@@ -113,6 +115,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
UpdateProjSpecific(deltaTime);
|
||||
|
||||
if (!ShouldDeteriorate()) { return; }
|
||||
|
||||
if (CurrentFixer == null)
|
||||
{
|
||||
if (item.Condition > 0.0f)
|
||||
@@ -179,8 +183,48 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
partial void UpdateProjSpecific(float deltaTime);
|
||||
|
||||
private bool ShouldDeteriorate()
|
||||
{
|
||||
if (LastActiveTime > Timing.TotalTime) { return true; }
|
||||
foreach (ItemComponent ic in item.Components)
|
||||
{
|
||||
if (ic is PowerTransfer pt)
|
||||
{
|
||||
//power transfer items (junction boxes, relays) don't deteriorate if they're no carrying any power
|
||||
if (Math.Abs(pt.CurrPowerConsumption) < 0.1f) { return false; }
|
||||
}
|
||||
else if (ic is Engine engine)
|
||||
{
|
||||
//engines don't deteriorate if they're not running
|
||||
if (Math.Abs(engine.Force) < 1.0f) { return false; }
|
||||
}
|
||||
else if (ic is Pump pump)
|
||||
{
|
||||
//pumps don't deteriorate if they're not running
|
||||
if (Math.Abs(pump.FlowPercentage) < 1.0f) { return false; }
|
||||
}
|
||||
else if (ic is Reactor reactor)
|
||||
{
|
||||
//reactors don't deteriorate if they're not powered up
|
||||
if (reactor.Temperature < 0.1f) { return false; }
|
||||
}
|
||||
else if (ic is OxygenGenerator oxyGenerator)
|
||||
{
|
||||
//oxygen generators don't deteriorate if they're not running
|
||||
if (oxyGenerator.CurrFlow < 0.1f) { return false; }
|
||||
}
|
||||
else if (ic is Powered powered)
|
||||
{
|
||||
if (powered.Voltage < powered.MinVoltage) { return false; }
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdateFixAnimation(Character character)
|
||||
{
|
||||
character.AnimController.UpdateUseItem(false, item.WorldPosition + new Vector2(0.0f, 100.0f) * ((item.Condition / item.MaxCondition) % 0.1f));
|
||||
|
||||
Reference in New Issue
Block a user