Unstable 1.1.14.0

This commit is contained in:
Markus Isberg
2023-10-02 16:43:54 +03:00
parent 94f5a93a0c
commit cf8f0de659
606 changed files with 21906 additions and 11456 deletions
@@ -14,7 +14,11 @@ namespace Barotrauma.Items.Components
private readonly LocalizedString header;
private float deteriorationTimer;
private float deteriorateAlwaysResetTimer;
public float ForceDeteriorationTimer
{
get;
private set;
}
private int updateDeteriorationCounter;
private const int UpdateDeteriorationInterval = 10;
@@ -62,6 +66,13 @@ namespace Barotrauma.Items.Components
set;
}
[Serialize(60f, IsPropertySaveable.Yes, description: "How long will the item spontaneously deteriorate after being sabotaged.")]
public float SabotageDeteriorationDuration
{
get;
set;
}
[Serialize(80.0f, IsPropertySaveable.Yes, description: "The condition of the item has to be below this for it to become repairable. Percentages of max condition."), Editable(MinValueFloat = 0.0f, MaxValueFloat = 100.0f)]
public float RepairThreshold
{
@@ -83,13 +94,6 @@ namespace Barotrauma.Items.Components
set;
}
[Serialize(false, IsPropertySaveable.No, description: "If set to true, the deterioration timer will always run regardless if the item is being used or not.")]
public bool DeteriorateAlways
{
get;
set;
}
private float skillRequirementMultiplier;
[Serialize(1.0f, IsPropertySaveable.Yes)]
@@ -394,20 +398,19 @@ namespace Barotrauma.Items.Components
item.SendSignal(conditionSignal, "condition_out");
if (ForceDeteriorationTimer > 0.0f)
{
ForceDeteriorationTimer -= deltaTime;
if (ForceDeteriorationTimer <= 0.0f)
{
#if SERVER
//let the clients know the deterioration delay
item.CreateServerEvent(this);
#endif
}
}
if (CurrentFixer == null)
{
if (deteriorateAlwaysResetTimer > 0.0f)
{
deteriorateAlwaysResetTimer -= deltaTime;
if (deteriorateAlwaysResetTimer <= 0.0f)
{
DeteriorateAlways = false;
#if SERVER
//let the clients know the deterioration delay
item.CreateServerEvent(this);
#endif
}
}
updateDeteriorationCounter++;
if (updateDeteriorationCounter >= UpdateDeteriorationInterval)
{
@@ -534,8 +537,7 @@ namespace Barotrauma.Items.Components
}
deteriorationTimer = 0.0f;
deteriorateAlwaysResetTimer = item.Condition / DeteriorationSpeed;
DeteriorateAlways = true;
ForceDeteriorationTimer = SabotageDeteriorationDuration;
item.Condition = item.MaxCondition * (MinSabotageCondition / 100);
wasGoodCondition = false;
}
@@ -553,7 +555,8 @@ namespace Barotrauma.Items.Components
if (item.Condition <= 0.0f) { return; }
if (!ShouldDeteriorate()) { return; }
if (deteriorationTimer > 0.0f)
//forced deterioration doesn't tick down the timer for spontaneous deterioration
if (deteriorationTimer > 0.0f && ForceDeteriorationTimer <= 0.0f)
{
if (GameMain.NetworkMember == null || !GameMain.NetworkMember.IsClient)
{
@@ -568,6 +571,7 @@ namespace Barotrauma.Items.Components
if (item.ConditionPercentage > MinDeteriorationCondition)
{
float deteriorationSpeed = item.StatManager.GetAdjustedValue(ItemTalentStats.DetoriationSpeed, DeteriorationSpeed);
if (ForceDeteriorationTimer > 0.0f) { deteriorationSpeed = Math.Max(deteriorationSpeed, 1.0f); }
item.Condition -= deteriorationSpeed * deltaTime;
}
}
@@ -592,7 +596,7 @@ namespace Barotrauma.Items.Components
if (!character.HasAbilityFlag(AbilityFlags.CanTinker)) { return false; }
if (item.GetComponent<Engine>() != null) { return true; }
if (item.GetComponent<Pump>() != null) { return true; }
if (item.HasTag("turretammosource")) { return true; }
if (item.HasTag(Tags.TurretAmmoSource)) { return true; }
if (!character.HasAbilityFlag(AbilityFlags.CanTinkerFabricatorsAndDeconstructors)) { return false; }
if (item.GetComponent<Fabricator>() != null) { return true; }
if (item.GetComponent<Deconstructor>() != null) { return true; }
@@ -623,6 +627,8 @@ namespace Barotrauma.Items.Components
private bool ShouldDeteriorate()
{
if (ForceDeteriorationTimer > 0.0f) { return true; }
if (Level.IsLoadedFriendlyOutpost) { return false; }
#if CLIENT
if (GameMain.GameSession?.GameMode is TutorialMode) { return false; }
@@ -666,13 +672,13 @@ namespace Barotrauma.Items.Components
//oxygen generators don't deteriorate if they're not running
if (oxyGenerator.CurrFlow > 0.1f) { return true; }
}
else if (ic is Powered powered && !(powered is LightComponent))
else if (ic is Powered powered && powered is not LightComponent)
{
if (powered.Voltage >= powered.MinVoltage) { return true; }
}
}
return DeteriorateAlways;
return false;
}
private float GetDeteriorationDelayMultiplier()