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

@ -72,7 +72,9 @@ public class ActionGameManager : MonoBehaviour
public float DeathPPTransitionTime;
public PostProcessVolume DeathPP;
public PostProcessVolume HeatstrokePP;
public PostProcessVolume HypothermiaPP;
public PostProcessVolume SevereHeatstrokePP;
public PostProcessVolume SevereHypothermiaPP;
[Header("Scene Links")]
public Transform EffectManagerParent;
@ -173,6 +175,8 @@ public class ActionGameManager : MonoBehaviour
private void OnDisable()
{
Input.Dispose();
ConsoleController.ClearCommands();
EntityInstance.ClearWeaponManagers();
}
void Start()
@ -676,7 +680,10 @@ public class ActionGameManager : MonoBehaviour
PopulateLevel(CurrentSector.Zones[PlayerSettings.CurrentRun.CurrentZone]);
var targetEntity = Zone.Entities[PlayerSettings.CurrentRun.CurrentZoneEntity];
if (targetEntity is OrbitalEntity orbitalEntity)
{
CurrentEntity = targetEntity.Children.First(c => c is Ship {IsPlayerShip: true});
DoDock(orbitalEntity, orbitalEntity.DockingBays.First());
}
else
{
//StartCoroutine(IntroCutscene(targetEntity as Ship));
@ -730,7 +737,6 @@ public class ActionGameManager : MonoBehaviour
{
UnbindEntity();
DoDock(entity, bay);
TradeMenu.Inventory = entity.CargoBays.First();
AkSoundEngine.PostEvent("Dock", gameObject);
return;
}
@ -742,6 +748,7 @@ public class ActionGameManager : MonoBehaviour
private void DoDock(Entity entity, EquippedDockingBay dockingBay)
{
TradeMenu.Inventory = entity.CargoBays.First();
DockedEntity = entity;
ZoneRenderer.PerspectiveEntity = DockedEntity;
DockingBay = dockingBay;
@ -882,18 +889,20 @@ public class ActionGameManager : MonoBehaviour
var indicator = HostileTargetIndicator.Instantiate<VisibleHostileIndicator>();
_visibleHostileIndicators.Add(hostile, indicator);
}
_shipSubscriptions.Add(CurrentEntity.VisibleHostiles.ObserveAdd().Subscribe(addEvent =>
{
var indicator = HostileTargetIndicator.Instantiate<VisibleHostileIndicator>();
_visibleHostileIndicators.Add(addEvent.Value, indicator);
}));
_shipSubscriptions.Add(CurrentEntity.VisibleHostiles.ObserveRemove().Subscribe(removeEvent =>
{
_visibleHostileIndicators[removeEvent.Value].GetComponent<Prototype>().ReturnToPool();
_visibleHostileIndicators.Remove(removeEvent.Value);
}));
_shipSubscriptions.Add(CurrentEntity.Death.Subscribe(_ =>
_shipSubscriptions.Add(CurrentEntity.Death.Subscribe(cause =>
{
var deathTime = Time.time;
UnbindEntity();
@ -903,20 +912,29 @@ public class ActionGameManager : MonoBehaviour
Menu.gameObject.SetActive(false);
PlayerSettings.CurrentRun = null;
SavePlayerSettings();
SaveState();
Observable.EveryUpdate()
.Where(_ => Time.time - deathTime < DeathPPTransitionTime)
.Subscribe(_ =>
{
var t = (Time.time - deathTime) / DeathPPTransitionTime;
HeatstrokePP.weight = 1 - t;
SevereHeatstrokePP.weight = 1 - t;
if(cause==CauseOfDeath.Heatstroke)
{
HeatstrokePP.weight = 1 - t;
SevereHeatstrokePP.weight = 1 - t;
}
else if (cause == CauseOfDeath.Hypothermia)
{
HypothermiaPP.weight = 1 - t;
SevereHypothermiaPP.weight = 1 - t;
}
DeathPP.weight = t;
},
() =>
{
HeatstrokePP.weight = 0;
SevereHeatstrokePP.weight = 0;
HypothermiaPP.weight = 0;
SevereHypothermiaPP.weight = 0;
DeathPP.weight = 1;
});
}));

View file

@ -48,6 +48,12 @@ public class EntityInstance : MonoBehaviour
private static Dictionary<InstantWeaponData, InstantWeaponEffectManager> _instantWeaponManagers = new Dictionary<InstantWeaponData, InstantWeaponEffectManager>();
private static Dictionary<ConstantWeaponData, ConstantWeaponEffectManager> _constantWeaponManagers = new Dictionary<ConstantWeaponData, ConstantWeaponEffectManager>();
public static void ClearWeaponManagers()
{
_instantWeaponManagers.Clear();
_constantWeaponManagers.Clear();
}
public Dictionary<HardpointData, Transform[]> Barrels { get; private set; }
public Dictionary<HardpointData, int> BarrelIndices { get; private set; }
public Dictionary<Radiator, MeshRenderer> RadiatorMeshes { get; private set; }

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)

View file

@ -12,6 +12,14 @@ public enum ItemRotation
Clockwise = 3
}
public enum CauseOfDeath
{
HullDestroyed,
CockpitDestroyed,
Heatstroke,
Hypothermia
}
public enum HitType
{
Armor,

View file

@ -168,6 +168,11 @@ public class GameplaySettings
public float HeatstrokeExponent = 2;
public float HeatstrokeRecoverySpeed = .2f;
public float HeatstrokeControlLimit = .75f;
public float HypothermiaTemperature = 273;
public float HypothermiaMultiplier = .00001f;
public float HypothermiaExponent = 2;
public float HypothermiaRecoverySpeed = .2f;
public float HypothermiaControlLimit = .75f;
public float LockIndicatorNoiseAmplitude = 50f;
public ExponentialLerp LockIndicatorFrequency;
public ExponentialLerp LockSpinSpeed;

View file

@ -234,9 +234,9 @@ public class Ship : Entity
public override void Update(float delta)
{
foreach (var thruster in _allThrusters) thruster.Axis = 0;
if (_active && !_exitingWormhole && !_enteringWormhole)
{
foreach (var thruster in _allThrusters) thruster.Axis = 0;
var rightThrusterTorqueCompensation = abs(RightStrafeTotalTorque) / RightStrafeTorqueThrusters.Length;
foreach (var thruster in _rightThrusters)
{

View file

@ -27,7 +27,7 @@ public class ConfirmationDialog : PropertiesPanel
private void Start()
{
Cancel.onClick.AddListener(() => End());
Confirm.onClick.AddListener(() => End());
Confirm.onClick.AddListener(() => End(true));
if (CancelClickCatcher != null)
CancelClickCatcher.OnClick += data =>
{

View file

@ -29,6 +29,11 @@ public class ConsoleController
get => _instance ?? (_instance = new ConsoleController());
}
public static void ClearCommands()
{
_commands.Clear();
}
public static void AddCommand(string command, Action<string[]> action)
{
var lower = command.ToLowerInvariant();

View file

@ -62,6 +62,7 @@ public class InventoryMenu : MonoBehaviour
var cargo = GameManager.DockingBay ?? GameManager.CurrentEntity.CargoBays.FirstOrDefault();
if (cargo!=null)
InventoryPanels[0].Display(cargo);
else InventoryPanels[0].Clear();
if(GameManager.CurrentEntity != null)
InventoryPanels[1].Display(GameManager.CurrentEntity);
else InventoryPanels[1].Clear();
@ -285,14 +286,14 @@ public class InventoryMenu : MonoBehaviour
}
});
panel.OnClickAsObservable().Subscribe(data =>
panel.OnClickAsObservable().Subscribe(e =>
{
if (data is InventoryCargoEventData cargoEvent)
if (e.data is InventoryCargoEventData cargoEvent)
{
var item = cargoEvent.CargoBay.Occupancy[cargoEvent.Position.x, cargoEvent.Position.y];
if(item!=null)
{
if (Mouse.current.clickCount.ReadValue() == 2)
if (e.clickCount == 2)
{
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
if (otherPanel.CanDropItem(item))
@ -335,12 +336,12 @@ public class InventoryMenu : MonoBehaviour
}
}
}
else if (data is InventoryEntityEventData entityEvent)
else if (e.data is InventoryEntityEventData entityEvent)
{
var item = entityEvent.Entity.GearOccupancy[entityEvent.Position.x, entityEvent.Position.y];
if (item != null)
{
if (Mouse.current.clickCount.ReadValue() == 2)
if (e.clickCount == 2)
{
var otherPanel = panel == InventoryPanels[0] ? InventoryPanels[1] : InventoryPanels[0];
if (otherPanel.CanDropItem(item.EquippableItem))

View file

@ -20,7 +20,7 @@ using int2 = Unity.Mathematics.int2;
public class InventoryPanel : MonoBehaviour, IPointerClickHandler
{
[FormerlySerializedAs("ConfirmationDialog")] public ConfirmationDialog Dialog;
public ConfirmationDialog Dialog;
public bool Flip;
public GameSettings Settings;
public ActionGameManager GameManager;
@ -30,6 +30,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
public TextMeshProUGUI MaxTempLabel;
public GameObject TemperatureRange;
public Button Dropdown;
public Button EditName;
public Button Current;
public Button Thermal;
public GridLayoutGroup Grid;
@ -47,12 +48,13 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
public Color ToggleEnabledColor;
public Color ToggleDisabledColor;
public Color CellBackgroundColor = new Color(0, 0, 0, .75f);
public float MinTempRange;
public float MinTempRange = 1;
public float DoubleClickTime = .5f;
Subject<InventoryEventData> _onBeginDrag;
Subject<InventoryEventData> _onDrag;
Subject<InventoryEventData> _onEndDrag;
Subject<InventoryEventData> _onClick;
Subject<(InventoryEventData data, int clickCount)> _onClick;
Subject<InventoryEventData> _onPointerEnter;
Subject<InventoryEventData> _onPointerExit;
@ -72,6 +74,9 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
private Dictionary<int2, int> _cellAnimationSequence = new Dictionary<int2, int>();
private int _hitSequence = 0;
private bool _thermal = false;
private int _clickCount;
private InventoryCell _clickCell;
private float _clickTime;
private bool _hud;
@ -122,6 +127,23 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
}
});
}
if (EditName)
{
EditName.onClick.AddListener(() =>
{
Dialog.Clear();
var entityName = _displayedEntity.Name;
Dialog.AddField("Name", () => entityName, s => entityName = s);
Dialog.Show(() =>
{
_displayedEntity.Name = entityName;
Title.text = _displayedEntity.Name;
});
Dialog.MoveToCursor();
});
}
if(Dropdown)
{
Dropdown.onClick.AddListener(() =>
@ -134,7 +156,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
var options = entity.CargoBays
.Where(bay => bay != _displayedCargo)
.Select<EquippedCargoBay, (string text, Action action, bool enabled)>((bay, index) =>
($"Bay {index}", () => Display(bay), true));
($"Bay {index+1}", () => Display(bay), true));
if(entity != _displayedEntity) options = options.Prepend(("Equipment", () => Display(entity), true));
ContextMenu.AddDropdown(entity.Name, options);
}
@ -180,6 +202,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
{
if (_displayedEntity != null && TemperatureDisplay)
{
var tempRange = _displayedEntity.MaxTemp - _displayedEntity.MinTemp;
var opacity = smoothstep(0, MinTempRange, tempRange);
if(MinTempLabel)
{
MinTempLabel.text = $"{((int) (_displayedEntity.MinTemp - 273.15f)).ToString()}°C";
@ -194,7 +218,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
{
var temp = (_displayedEntity.Temperature[x - 1, y - 1] - _displayedEntity.MinTemp) / (_displayedEntity.MaxTemp-_displayedEntity.MinTemp);
var color = TemperatureColor.GetPixelBilinear(TemperatureColorCurve.Evaluate(temp), 0);
color.a = TemperatureAlphaCurve.Evaluate(temp);
color.a = TemperatureAlphaCurve.Evaluate(temp) * opacity;
_temperatureTexture.SetPixel(x,y,color);
}
else
@ -230,17 +254,12 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
_subscriptions.Clear();
if (Current)
Current.gameObject.SetActive(false);
if (Thermal)
Thermal.gameObject.SetActive(false);
if (Current) Current.gameObject.SetActive(false);
if (Thermal) Thermal.gameObject.SetActive(false);
if (TemperatureRange) TemperatureRange.SetActive(false);
if(TemperatureDisplay) TemperatureDisplay.gameObject.SetActive(false);
if (EditName) EditName.gameObject.SetActive(false);
if (TemperatureRange)
TemperatureRange.SetActive(false);
if(TemperatureDisplay)
TemperatureDisplay.gameObject.SetActive(false);
if(Title)
Title.text = "None";
}
@ -261,6 +280,11 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
if(Title)
Title.text = entity.Name;
if (EditName)
{
EditName.gameObject.SetActive(true);
}
var hullData = GameManager.ItemManager.GetData(entity.Hull) as HullData;
if (FitToContent)
@ -317,7 +341,15 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
if(cell.PointerClickTrigger)
{
cell.PointerClickTrigger.OnPointerClickAsObservable()
.Subscribe(data => _onClick?.OnNext(new InventoryEntityEventData(data, v, entity)));
.Subscribe(data =>
{
if (cell != _clickCell || Time.time - _clickTime > DoubleClickTime)
_clickCount = 0;
_clickCell = cell;
_clickTime = Time.time;
_clickCount++;
_onClick?.OnNext((new InventoryEntityEventData(data, v, entity), _clickCount));
});
cell.BeginDragTrigger.OnBeginDragAsObservable()
.Subscribe(data => _onBeginDrag?.OnNext(new InventoryEntityEventData(data, v, entity)));
cell.DragTrigger.OnDragAsObservable()
@ -436,7 +468,15 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
{
var cell = NodePrototype.Instantiate<InventoryCell>();
cell.PointerClickTrigger.OnPointerClickAsObservable()
.Subscribe(data => _onClick?.OnNext(new InventoryCargoEventData(data, v, cargo)));
.Subscribe(data =>
{
if (cell != _clickCell || Time.time - _clickTime > DoubleClickTime)
_clickCount = 0;
_clickCell = cell;
_clickTime = Time.time;
_clickCount++;
_onClick?.OnNext((new InventoryCargoEventData(data, v, cargo), _clickCount));
});
cell.BeginDragTrigger.OnBeginDragAsObservable()
.Subscribe(data => _onBeginDrag?.OnNext(new InventoryCargoEventData(data, v, cargo)));
cell.DragTrigger.OnDragAsObservable()
@ -676,7 +716,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
}
public Subject<PointerEventData> OnBackgroundClick = new Subject<PointerEventData>();
public UniRx.IObservable<InventoryEventData> OnClickAsObservable() => _onClick ?? (_onClick = new Subject<InventoryEventData>());
public Subject<(InventoryEventData data, int clickCount)> OnClickAsObservable() => _onClick ?? (_onClick = new Subject<(InventoryEventData data, int clickCount)>());
public UniRx.IObservable<InventoryEventData> OnBeginDragAsObservable() => _onBeginDrag ?? (_onBeginDrag = new Subject<InventoryEventData>());
public UniRx.IObservable<InventoryEventData> OnDragAsObservable() => _onDrag ?? (_onDrag = new Subject<InventoryEventData>());
public UniRx.IObservable<InventoryEventData> OnEndDragAsObservable() => _onEndDrag ?? (_onEndDrag = new Subject<InventoryEventData>());

View file

@ -36,6 +36,7 @@ public class SchematicDisplay : MonoBehaviour
public RectTransform EnergyFill;
public RectTransform HullDurabilityFill;
public RectTransform HeatstrokeMeterFill;
public RectTransform HypothermiaMeterFill;
public RectTransform HeatstrokeLimitFill;
public CanvasGroup TriggerGroups;
@ -249,7 +250,8 @@ public class SchematicDisplay : MonoBehaviour
CockpitTemperatureLabel.text = $"{((int) (_cockpit.Item.Temperature - 273.15f)).ToString()}°C";
HeatstrokeMeterFill.anchorMax = new Vector2(_entity.Heatstroke, 1);
HeatstrokeLimitFill.anchorMax = new Vector2(_cockpit.Item.Temperature / Settings.GameplaySettings.HeatstrokeTemperature, 1);
HypothermiaMeterFill.anchorMax = new Vector2(_entity.Hypothermia, 1);
HeatstrokeLimitFill.anchorMax = new Vector2(unlerp(Settings.GameplaySettings.HypothermiaTemperature, Settings.GameplaySettings.HeatstrokeTemperature, _cockpit.Item.Temperature), 1);
}
SensorCooldownFill.anchorMax = new Vector2(_entity.Sensor?.Cooldown ?? 0, 1);

View file

@ -69,7 +69,7 @@ public class TradeMenu : MonoBehaviour
ContextMenu.AddDropdown("Gear Type", hardpointTypes
.Select<HardpointType, (string, Action, bool)>(x => (Enum.GetName(typeof(HardpointType), x), () =>
{
if (_hardpointFilter.filter == null)
if (!_hardpointFilter.filter)
{
_hardpointFilter.filter = FilterPrototype.Instantiate<ItemFilter>();
_hardpointFilter.filter.OnDisable += () =>
@ -78,12 +78,12 @@ public class TradeMenu : MonoBehaviour
Populate();
};
}
if(_commodityFilter.filter != null)
if(_commodityFilter.filter)
{
_commodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_commodityFilter.filter = null;
}
if(_compoundCommodityFilter.filter != null)
if(_compoundCommodityFilter.filter)
{
_compoundCommodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_compoundCommodityFilter.filter = null;
@ -96,7 +96,7 @@ public class TradeMenu : MonoBehaviour
ContextMenu.AddDropdown("Simple Commodity", commodityTypes
.Select<SimpleCommodityCategory, (string, Action, bool)>(x => (Enum.GetName(typeof(SimpleCommodityCategory), x), () =>
{
if (_commodityFilter.filter == null)
if (!_commodityFilter.filter)
{
_commodityFilter.filter = FilterPrototype.Instantiate<ItemFilter>();
_commodityFilter.filter.OnDisable += () =>
@ -105,12 +105,12 @@ public class TradeMenu : MonoBehaviour
Populate();
};
}
if(_hardpointFilter.filter != null)
if(_hardpointFilter.filter)
{
_hardpointFilter.filter.GetComponent<Prototype>().ReturnToPool();
_hardpointFilter.filter = null;
}
if(_compoundCommodityFilter.filter != null)
if(_compoundCommodityFilter.filter)
{
_compoundCommodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_compoundCommodityFilter.filter = null;
@ -123,7 +123,7 @@ public class TradeMenu : MonoBehaviour
ContextMenu.AddDropdown("Compound Commodity", compoundCommodityTypes
.Select<CompoundCommodityCategory, (string, Action, bool)>(x => (Enum.GetName(typeof(CompoundCommodityCategory), x), () =>
{
if (_compoundCommodityFilter.filter == null)
if (!_compoundCommodityFilter.filter)
{
_compoundCommodityFilter.filter = FilterPrototype.Instantiate<ItemFilter>();
_compoundCommodityFilter.filter.OnDisable += () =>
@ -132,12 +132,12 @@ public class TradeMenu : MonoBehaviour
Populate();
};
}
if(_hardpointFilter.filter != null)
if(_hardpointFilter.filter)
{
_hardpointFilter.filter.GetComponent<Prototype>().ReturnToPool();
_hardpointFilter.filter = null;
}
if(_commodityFilter.filter != null)
if(_commodityFilter.filter)
{
_commodityFilter.filter.GetComponent<Prototype>().ReturnToPool();
_commodityFilter.filter = null;
@ -449,13 +449,19 @@ public class TradeMenu : MonoBehaviour
foreach (var ship in GameManager.CurrentEntity.Parent.Children.Where(e => e is Ship {IsPlayerShip: true}))
{
foreach (var bay in ship.CargoBays.Select((bay, index) => (bay, index)))
ContextMenu.AddOption($"{ship.Name} Bay {bay.index}",
() =>
{
_targetCargo = bay.bay;
TargetCargoLabel.text = $"{ship.Name} Bay {bay.index}";
});
{
if(_targetCargo != bay.bay)
{
ContextMenu.AddOption($"{ship.Name} Bay {bay.index+1}",
() =>
{
_targetCargo = bay.bay;
TargetCargoLabel.text = $"{ship.Name} Bay {bay.index+1}";
});
}
}
}
ContextMenu.Show();
});
}