(9a14162c6) Disabled spontaneous deterioration on items that are not being used. TODO: adjust all deterioration rates and delays

This commit is contained in:
Joonas Rikkonen
2019-04-07 21:43:35 +03:00
parent 3d3975e07c
commit be76bd53e9
9 changed files with 82 additions and 20 deletions
@@ -17,8 +17,8 @@ namespace Barotrauma.Items.Components
{
get { return outputContainer; }
}
public Deconstructor(Item item, XElement element)
public Deconstructor(Item item, XElement element)
: base(item, element)
{
InitProjSpecific(element);
@@ -53,7 +53,13 @@ namespace Barotrauma.Items.Components
return;
}
if (voltage < minVoltage) return;
if (voltage < minVoltage) { return; }
var repairable = item.GetComponent<Repairable>();
if (repairable != null)
{
repairable.LastActiveTime = (float)Timing.TotalTime + 10.0f;
}
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
@@ -73,8 +79,7 @@ namespace Barotrauma.Items.Components
float percentageHealth = targetItem.Condition / targetItem.Prefab.Health;
if (percentageHealth <= deconstructProduct.MinCondition || percentageHealth > deconstructProduct.MaxCondition) continue;
var itemPrefab = MapEntityPrefab.Find(null, deconstructProduct.ItemIdentifier) as ItemPrefab;
if (itemPrefab == null)
if (!(MapEntityPrefab.Find(null, deconstructProduct.ItemIdentifier) is ItemPrefab itemPrefab))
{
DebugConsole.ThrowError("Tried to deconstruct item \"" + targetItem.Name + "\" but couldn't find item prefab \"" + deconstructProduct.ItemIdentifier + "\"!");
continue;
@@ -113,7 +113,7 @@ namespace Barotrauma.Items.Components
#endif
}
voltage = 0.0f;
voltage -= deltaTime;
}
private void UpdatePropellerDamage(float deltaTime)
@@ -18,14 +18,14 @@ namespace Barotrauma.Items.Components
private FabricationRecipe fabricatedItem;
private float timeUntilReady;
private float requiredTime;
private Character user;
private ItemContainer inputContainer, outputContainer;
private float progressState;
public Fabricator(Item item, XElement element)
public Fabricator(Item item, XElement element)
: base(item, element)
{
foreach (XElement subElement in element.Elements())
@@ -174,6 +174,12 @@ namespace Barotrauma.Items.Components
if (voltage < minVoltage) { return; }
var repairable = item.GetComponent<Repairable>();
if (repairable != null)
{
repairable.LastActiveTime = (float)Timing.TotalTime + 10.0f;
}
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
if (powerConsumption <= 0) { voltage = 1.0f; }
@@ -81,7 +81,7 @@ namespace Barotrauma.Items.Components
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
}
voltage = 0.0f;
voltage -= deltaTime;
}
public override bool Pick(Character picker)
@@ -73,6 +73,7 @@ namespace Barotrauma.Items.Components
public override void UpdateBroken(float deltaTime, Camera cam)
{
powerDownTimer += deltaTime;
CurrFlow = 0.0f;
}
private void GetVents()
@@ -19,10 +19,10 @@ namespace Barotrauma.Items.Components
public float FlowPercentage
{
get { return flowPercentage; }
set
set
{
if (!MathUtils.IsValid(flowPercentage)) return;
flowPercentage = MathHelper.Clamp(value,-100.0f,100.0f);
flowPercentage = MathHelper.Clamp(value, -100.0f, 100.0f);
flowPercentage = MathUtils.Round(flowPercentage, 1.0f);
}
}
@@ -86,8 +86,8 @@ namespace Barotrauma.Items.Components
item.CurrentHull.WaterVolume += currFlow;
if (item.CurrentHull.WaterVolume > item.CurrentHull.Volume) { item.CurrentHull.Pressure += 0.5f; }
voltage = 0.0f;
voltage -= deltaTime;
}
partial void UpdateProjSpecific(float deltaTime);