Hypothermia & UI Fixes

Implemented hypothermia death, with associated postprocessing and HUD UI
Fixed heatstroke and hypothermia not triggering death events
Fixed target inventory dropdown not working in trade menu
Added ability to rename ship
Added player death on cockpit destruction
Fixed confirmation dialog not using onconfirm callback
Fixed faulty double click in inventory panel
Fading out heat texture when ship has uniform temperature
Fixed inventory panel displaying incorrect default when no cargo bay equipped
Fixed incorrect state for console and weapon effect managers when restarting from in-game menu
Fixed save/reload when ship is docked at a station
This commit is contained in:
Reinier Vens 2021-04-10 01:47:16 +01:00
commit 62d4221958
26 changed files with 867 additions and 138 deletions

View file

@ -98,6 +98,7 @@ public abstract class Entity
public Cockpit Cockpit { get; private set; }
public Sensor Sensor { get; private set; }
public float Heatstroke { get; private set; }
public float Hypothermia { get; private set; }
public float TargetRange { get; private set; }
public float MaxTemp { get; private set; }
@ -115,12 +116,14 @@ public abstract class Entity
public Subject<Entity> Docked = new Subject<Entity>();
public Subject<Unit> HeatstrokeRisk = new Subject<Unit>();
public Subject<Unit> HeatstrokeDeath = new Subject<Unit>();
public Subject<Unit> HypothermiaRisk = new Subject<Unit>();
public Subject<Unit> HypothermiaDeath = new Subject<Unit>();
public UniRx.IObservable<EquippedItem> ItemDestroyed;
public UniRx.IObservable<int2> HullArmorDepleted;
public UniRx.IObservable<HardpointData> HardpointArmorDepleted;
public UniRx.IObservable<Weapon> WeaponDestroyed;
public UniRx.IObservable<Unit> Death;
public UniRx.IObservable<CauseOfDeath> Death;
private List<IDisposable> _subscriptions = new List<IDisposable>();
@ -178,7 +181,10 @@ public abstract class Entity
ItemDestroyed = ItemDamage.Where(x => x.item.EquippableItem.Durability < .01f).Select(x=>x.item);
WeaponDestroyed = ItemDestroyed.Select(x => x.Behaviors.FirstOrDefault(b => b is Weapon) as Weapon).Where(x => x != null);
HullArmorDepleted = ArmorDamage.Where(x => Armor[x.pos.x, x.pos.y] < .01f).Select(x => x.pos);
Death = HullDamage.Select(_ => Unit.Default).Where(_ => Hull.Durability < .01f).Merge(HeatstrokeDeath);
Death = HullDamage.Where(_ => Hull.Durability < .01f).Select(_ => CauseOfDeath.HullDestroyed)
.Merge(HeatstrokeDeath.Select(_ => CauseOfDeath.Heatstroke))
.Merge(HypothermiaDeath.Select(_ => CauseOfDeath.Hypothermia))
.Merge(ItemDestroyed.Where(i=>i.GetBehavior<Cockpit>()!=null).Select(_ => CauseOfDeath.CockpitDestroyed));
EntityInfoGathered.ObserveReplace().Subscribe(replace =>
{
@ -779,7 +785,7 @@ public abstract class Entity
ItemManager.GameplaySettings.HeatstrokeMultiplier * delta);
if(previous < ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold && Heatstroke > ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold)
HeatstrokeRisk.OnNext(Unit.Default);
if(Heatstroke > 1)
if(Heatstroke > .99)
{
HeatstrokeDeath.OnNext(Unit.Default);
Deactivate();
@ -789,6 +795,25 @@ public abstract class Entity
{
Heatstroke = saturate(Heatstroke - ItemManager.GameplaySettings.HeatstrokeRecoverySpeed * delta);
}
if (Cockpit.Item.Temperature < ItemManager.GameplaySettings.HypothermiaTemperature)
{
var previous = Hypothermia;
Hypothermia = saturate(
Hypothermia +
pow(ItemManager.GameplaySettings.HypothermiaTemperature - Cockpit.Item.Temperature, ItemManager.GameplaySettings.HypothermiaExponent) *
ItemManager.GameplaySettings.HypothermiaMultiplier * delta);
if(previous < ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold && Heatstroke > ItemManager.GameplaySettings.SevereHeatstrokeRiskThreshold)
HypothermiaRisk.OnNext(Unit.Default);
if(Hypothermia > .99)
{
HypothermiaDeath.OnNext(Unit.Default);
Deactivate();
}
}
else
{
Hypothermia = saturate(Hypothermia - ItemManager.GameplaySettings.HypothermiaRecoverySpeed * delta);
}
}
foreach (var equippedItem in _orderedEquipment)