Merge pull request #85 from GameCult/Gear-Damage

Add component to entity wear based on changes in temperature
This commit is contained in:
Reinier Vens 2021-06-12 18:52:17 +01:00 • committed by GitHub
commit f3df2ba4cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View file

@ -1157,6 +1157,7 @@ public class EquippedItem
public Subject<(uint id, float v)> AudioParameters { get; } = new Subject<(uint id, float v)>();
public Dictionary<uint, float> AudioParameterValues { get; } = new Dictionary<uint, float>();
private float oldTemperature;
public float Temperature
{
get
@ -1256,6 +1257,7 @@ public class EquippedItem
pow(item.Quality, ItemManager.GameplaySettings.DurabilityQualityExponent));
var hullData = itemManager.GetData(entity.Hull);
InsetShape = hullData.Shape.Inset(Data.Shape, position, item.Rotation);
if (Entity.Temperature != null) oldTemperature = Temperature;
Online = new ReadOnlyReactiveProperty<bool>(ThermalOnline
.CombineLatest(DurabilityOnline, (thermal, durability) => thermal && durability).DistinctUntilChanged());
@ -1310,17 +1312,20 @@ public class EquippedItem
}
public void UpdatePerformance()
{
{
var temp = Temperature;
ThermalPerformance = Data.Performance(temp);
var deltaTemp = math.abs(temp - oldTemperature);
DurabilityPerformance = EquippableItem.Durability / Data.Durability;
var performanceThreshold = Entity.Settings.ShutdownPerformance;
Wear = (1 - pow(ThermalPerformance,
(1 - pow(EquippableItem.Quality, ItemManager.GameplaySettings.QualityWearExponent)) *
ItemManager.GameplaySettings.ThermalWearExponent)
ItemManager.GameplaySettings.ThermalWearExponent) +
deltaTemp * ItemManager.GameplaySettings.DeltaTempWearExponent
) * Data.Durability / Data.ThermalResilience;
ThermalOnline.Value = ThermalPerformance > performanceThreshold || Entity.OverrideShutdown && EquippableItem.OverrideShutdown;
DurabilityOnline.Value = EquippableItem.Durability > .01f;
oldTemperature = temp;
}
public void Update(float delta)

View file

@ -172,6 +172,7 @@ public class GameplaySettings
public float WormholeAnimationDuration = 4;
public float WormholeExitCurveStart = .8f;
public float ThermalWearExponent = .01f;
public float DeltaTempWearExponent = .01f;
public float QualityWearExponent = 2;
public int WeaponGroupCount = 6;
public float WarpDistance = 25;