Heat System v2 + Lasers

Heat system remade, now guaranteed stable
Schematic heat texture is now
Radiators glow according to temperature
Added Laser weapons
Longinus has split weapon and radiator meshes, weapons can yaw 1 degree for target convergence
Articulation points can now handle 360 rotations properly
Fixed exception caused by hit spread on thin hull sections
Fixed loadout not restoring item rotation
Fixed exception in inventory panel selection
This commit is contained in:
Reinier Vens 2021-01-27 00:05:30 +00:00
commit b779d7c0af
43 changed files with 6898 additions and 227 deletions

View file

@ -56,6 +56,7 @@ public class ActionGameManager : MonoBehaviour
public List<EntityPack> Loadouts { get; set; } = new List<EntityPack>();
// private ShipInput _shipInput;
private IDisposable _shipTargetSubscription;
private float2 _shipYawPitch;
private float3 _viewDirection;
private (HardpointData[] hardpoints, Transform[] barrels, PlaceUIElementWorldspace crosshair)[] _articulationGroups;
@ -377,16 +378,6 @@ public class ActionGameManager : MonoBehaviour
var ship = new Ship(ItemManager, Zone, shipHull);
PlayerShips.Add(ship);
CurrentShip = ship;
CurrentShip.Target.Subscribe(target =>
{
TargetIndicator.gameObject.SetActive(CurrentShip.Target.Value != null);
TargetShipPanel.gameObject.SetActive(target != null);
if (target != null)
{
TargetShipPanel.Display(target, true);
TargetSchematicDisplay.ShowShip(target, CurrentShip);
}
});
ship.ArmorDamage.Subscribe(hit =>
{
var direction = _directions.MaxBy(d => dot(d.direction, normalize(hit.pos - hullType.Shape.CenterOfMass)));
@ -530,6 +521,22 @@ public class ActionGameManager : MonoBehaviour
return (x, i, i.GetComponent<Rotate>());
}).ToArray();
CurrentShip.HullDamage.Subscribe(f =>
{
if (float.IsNaN(CurrentShip.Hull.Durability))
Debug.Log("WTF!");
});
_shipTargetSubscription?.Dispose();
_shipTargetSubscription = CurrentShip.Target.Subscribe(target =>
{
TargetIndicator.gameObject.SetActive(CurrentShip.Target.Value != null);
TargetShipPanel.gameObject.SetActive(target != null);
if (target != null)
{
TargetShipPanel.Display(target, true);
TargetSchematicDisplay.ShowShip(target, CurrentShip);
}
});
Cursor.lockState = CursorLockMode.Locked;
GameplayUI.SetActive(true);
@ -623,10 +630,12 @@ public class ActionGameManager : MonoBehaviour
var showLockingIndicator = targetLock.Lock > .01f && CurrentShip.Target.Value != null;
indicator.gameObject.SetActive(showLockingIndicator);
if(showLockingIndicator)
indicator.Target = CurrentShip.Target.Value.Position;
indicator.NoiseAmplitude = Settings.GameplaySettings.LockIndicatorNoiseAmplitude * (1 - targetLock.Lock);
indicator.NoiseFrequency = Settings.GameplaySettings.LockIndicatorFrequency.Evaluate(targetLock.Lock);
spin.Speed = Settings.GameplaySettings.LockSpinSpeed.Evaluate(targetLock.Lock);
{
indicator.Target = CurrentShip.Target.Value.Position;
indicator.NoiseAmplitude = Settings.GameplaySettings.LockIndicatorNoiseAmplitude * (1 - targetLock.Lock);
indicator.NoiseFrequency = Settings.GameplaySettings.LockIndicatorFrequency.Evaluate(targetLock.Lock);
spin.Speed = Settings.GameplaySettings.LockSpinSpeed.Evaluate(targetLock.Lock);
}
}
}
}

View file

@ -25,18 +25,23 @@ public class ArticulationPoint : MonoBehaviour
{
if (Target)
{
var targetLocal = transform.parent.InverseTransformPoint(Target.position);
var targetLocal = transform.InverseTransformPoint(Target.position);
var yaw = Vector2.SignedAngle(new Vector2(0, 1), new Vector2(targetLocal.x, targetLocal.z));
var pitch = Vector2.SignedAngle(new Vector2(1, 0), new Vector2(targetLocal.z, targetLocal.y));
var targetYaw = clamp(-yaw, YawMin, YawMax);
var targetPitch = clamp(-pitch, PitchMin, PitchMax);
var targetYaw = clamp(_yaw - yaw, YawMin, YawMax);
var targetPitch = clamp(_pitch - pitch, PitchMin, PitchMax);
if (abs(targetYaw - _yaw) < Speed * Time.deltaTime)
_yaw = targetYaw;
else _yaw = _yaw + sign(targetYaw - _yaw) * Speed * Time.deltaTime;
if(_yaw < -360)
_yaw += 360;
if(_yaw > 360)
_yaw -= 360;
if (abs(targetPitch - _pitch) < Speed * Time.deltaTime)
_pitch = targetPitch;
else _pitch = _pitch + sign(targetPitch - _pitch) * Speed * Time.deltaTime;

View file

@ -7,6 +7,7 @@ public class EntityPrefab : MonoBehaviour
{
public HullCollider[] HullColliders;
public RadiatorHardpoint[] RadiatorHardpoints;
public ThrusterHardpoint[] ThrusterHardpoints;
public WeaponHardpoint[] WeaponHardpoints;
public ArticulationPoint[] ArticulationPoints;

View file

@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RadiatorHardpoint : MonoBehaviour
{
public MeshRenderer Mesh;
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d97beae3dbfd7514c94059c020f57c9d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -1,13 +1,56 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Laser : MonoBehaviour
{
public AnimationCurve IntensityCurve;
public float Duration;
public LineRenderer LineRenderer;
public float Damage { get; set; }
public float Penetration { get; set; }
public float Spread { get; set; }
public DamageType DamageType { get; set; }
public Entity SourceEntity { get; set; }
public float Range { get; set; }
private float _startTime;
private readonly Vector3[] _zeros = {Vector3.zero, Vector3.zero};
private void OnEnable()
{
_startTime = Time.time;
LineRenderer.SetPositions(_zeros);
}
private void Update()
{
var lerp = (Time.time - _startTime) / Duration;
if (lerp > 1)
{
GetComponent<Prototype>().ReturnToPool();
return;
}
LineRenderer.SetPosition(0, transform.position);
RaycastHit hit;
if (Physics.Raycast(new Ray(transform.position, transform.forward), out hit, Range, 1))
{
var hull = hit.collider.GetComponent<HullCollider>();
if (hull)
{
if (hull.Entity != SourceEntity)
{
hull.SendHit(Damage * (Time.deltaTime / Duration), Penetration, Spread, DamageType, SourceEntity, hit, transform.forward);
}
}
LineRenderer.SetPosition(1, hit.point);
}
else
LineRenderer.SetPosition(1, transform.position + transform.forward * Range);
LineRenderer.widthMultiplier = IntensityCurve.Evaluate(lerp);
}
}

View file

@ -4,7 +4,7 @@ MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
executionOrder: 80
icon: {instanceID: 0}
userData:
assetBundleName:

View file

@ -223,15 +223,27 @@ public class SectorRenderer : MonoBehaviour
}
}
}
instance.RadiatorMeshes = new Dictionary<HardpointData, MeshRenderer>();
instance.Barrels = new Dictionary<HardpointData, Transform[]>();
instance.BarrelIndices = new Dictionary<HardpointData, int>();
foreach (var hp in hullData.Hardpoints)
{
var whp = instance.Prefab.WeaponHardpoints.FirstOrDefault(x => x.name == hp.Transform);
if(whp)
if (hp.Type == HardpointType.Radiator)
{
instance.Barrels.Add(hp, whp.FiringPoint);
instance.BarrelIndices.Add(hp, 0);
var mesh = instance.Prefab.RadiatorHardpoints.FirstOrDefault(x => x.name == hp.Transform);
if (mesh)
{
instance.RadiatorMeshes.Add(hp, mesh.Mesh);
}
}
if(hp.Type == HardpointType.Ballistic || hp.Type == HardpointType.Energy || hp.Type == HardpointType.Launcher)
{
var whp = instance.Prefab.WeaponHardpoints.FirstOrDefault(x => x.name == hp.Transform);
if (whp)
{
instance.Barrels.Add(hp, whp.FiringPoint);
instance.BarrelIndices.Add(hp, 0);
}
}
}
@ -274,37 +286,47 @@ public class SectorRenderer : MonoBehaviour
// Spread damage is divided among components surrounding the hardpoint which has been hit
var spreadDamage = damage * spread;
// Find the cells surrounding the target cells
var surroundingCells = hitShape.Expand();
// Exclude cells contained by the original shape or not within the ship interior
foreach (var cell in surroundingCells.Coordinates.ToArray())
if (hitShape[cell] || !hullData.InteriorCells[cell])
surroundingCells[cell] = false;
// Find all equipment occupying surrounding cells
var surroundingEquipment = new List<EquippedItem>();
foreach (var hullCoord in surroundingCells.Coordinates)
if (spreadDamage > .01f)
{
if (entity.GearOccupancy[hullCoord.x, hullCoord.y] != null)
surroundingEquipment.Add(entity.GearOccupancy[hullCoord.x, hullCoord.y]);
// Find the cells surrounding the target cells
var surroundingCells = hitShape.Expand();
// Exclude cells contained by the original shape or not within the ship interior
foreach (var cell in surroundingCells.Coordinates.ToArray())
if (hitShape[cell] || !hullData.InteriorCells[cell])
surroundingCells[cell] = false;
if (surroundingCells.Coordinates.Length > 0)
{
// Find all equipment occupying surrounding cells
var surroundingEquipment = new List<EquippedItem>();
foreach (var hullCoord in surroundingCells.Coordinates)
{
if (entity.GearOccupancy[hullCoord.x, hullCoord.y] != null)
surroundingEquipment.Add(entity.GearOccupancy[hullCoord.x, hullCoord.y]);
}
// Divide spread damage among all surrounding cells
remainder = 0;
foreach (var e in surroundingEquipment)
{
remainder += max(spreadDamage / surroundingCells.Coordinates.Length - e.EquippableItem.Durability, 0);
e.EquippableItem.Durability = max(e.EquippableItem.Durability - spreadDamage / surroundingCells.Coordinates.Length, 0);
entity.ItemDamage.OnNext((e, spreadDamage / surroundingCells.Coordinates.Length));
}
// Remaining damage plus spread damage for empty cells is dealt to the hull
hullDamage += remainder + spreadDamage / surroundingCells.Coordinates.Length *
(surroundingCells.Coordinates.Length - surroundingEquipment.Count);
}
else hullDamage += spreadDamage;
}
// Divide spread damage among all surrounding cells
remainder = 0;
foreach (var e in surroundingEquipment)
if(hullDamage > .01f)
{
remainder += max(spreadDamage / surroundingCells.Coordinates.Length - e.EquippableItem.Durability, 0);
e.EquippableItem.Durability = max(e.EquippableItem.Durability - spreadDamage / surroundingCells.Coordinates.Length, 0);
entity.ItemDamage.OnNext((e, spreadDamage / surroundingCells.Coordinates.Length));
entity.Hull.Durability -= hullDamage;
entity.HullDamage.OnNext(hullDamage);
}
// Remaining damage plus spread damage for empty cells is dealt to the hull
hullDamage += remainder + spreadDamage / surroundingCells.Coordinates.Length *
(surroundingCells.Coordinates.Length - surroundingEquipment.Count);
entity.Hull.Durability -= hullDamage;
entity.HullDamage.OnNext(hullDamage);
}
foreach (var collider in instance.Prefab.HullColliders)
@ -599,6 +621,18 @@ public class SectorRenderer : MonoBehaviour
entity.Value.Transform.rotation = ((Ship) entity.Key).Rotation;
}
foreach (var x in entity.Value.RadiatorMeshes)
{
var temp = 0f;
foreach (var v in x.Key.Shape.Coordinates)
{
var v2 = v + x.Key.Position;
temp += entity.Key.Temperature[v2.x, v2.y];
}
temp /= x.Key.Shape.Coordinates.Length;
x.Value.material.SetFloat("_Emission", Settings.GameplaySettings.TemperatureEmissionCurve.Evaluate(temp));
}
foreach (var x in entity.Value.Barrels)
{
entity.Key.HardpointTransforms[x.Key] = (x.Value[0].position, x.Value[0].forward);
@ -613,7 +647,6 @@ public class SectorRenderer : MonoBehaviour
foreach(var e in hitList)
{
_zone.Entities.Remove(e);
}
var fogPos = FogCameraParent.position;
@ -639,6 +672,7 @@ public class EntityInstance
public EntityPrefab Prefab;
public Dictionary<HardpointData, Transform[]> Barrels;
public Dictionary<HardpointData, int> BarrelIndices;
public Dictionary<HardpointData, MeshRenderer> RadiatorMeshes;
public Transform LookAtPoint;
public Transform GetBarrel(HardpointData hardpoint)
{

View file

@ -43,7 +43,7 @@ public class Radiator : IBehavior
{
Emissivity = Context.Evaluate(_data.Emissivity, Item.EquippableItem, Entity);
var rad = pow(Item.Temperature, Context.GameplaySettings.HeatRadiationExponent) * Context.GameplaySettings.HeatRadiationMultiplier * Emissivity;
Item.AddHeat(-rad * delta);
Item.AddHeat(-rad * delta * Context.GetThermalMass(Item.EquippableItem));
Entity.VisibilitySources[this] = rad;
return true;
}

View file

@ -65,6 +65,8 @@ public abstract class Entity
private EquippedItem[] _orderedEquipment;
protected bool _active;
public float MaxTemp { get; private set; }
public float MinTemp { get; private set; }
public ItemManager ItemManager { get; }
public int AssignedPopulation => PopulationAssignments.Sum(pa => pa.AssignedPopulation);
public float Mass { get; private set; }
@ -537,50 +539,84 @@ public abstract class Entity
if (VisibilitySources[v] < 0.01f) VisibilitySources.Remove(v);
}
MaxTemp = Single.MinValue;
MinTemp = Single.MaxValue;
//float[,] newTemp = new float[hullData.Shape.Width,hullData.Shape.Height];
var radiation = 0f;
foreach (var v in hullData.Shape.Coordinates)
{
var temp = Temperature[v.x, v.y];
var heatTransfer = 0f;
var totalTemp = temp / ItemManager.GameplaySettings.HeatConductionMultiplier;
var totalConductivity = 1f / ItemManager.GameplaySettings.HeatConductionMultiplier;
if (hullData.Shape[int2(v.x - 1, v.y)])
heatTransfer += (Temperature[v.x - 1, v.y] - temp) *
(GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x - 1, v.y]?.Conductivity ?? 1) *
(HullConductivity[v.x - 1, v.y].x ? hullData.Conductivity : 1 / hullData.Conductivity);
{
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x - 1, v.y]?.Conductivity ?? 1) *
(HullConductivity[v.x - 1, v.y].x ? hullData.Conductivity : 1 / hullData.Conductivity) *
(ThermalMass[v.x - 1, v.y] / ThermalMass[v.x, v.y]);
totalConductivity += conductivity;
totalTemp += Temperature[v.x - 1, v.y] * conductivity;
}
if (hullData.Shape[int2(v.x + 1, v.y)])
heatTransfer += (Temperature[v.x + 1, v.y] - temp) *
(GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x + 1, v.y]?.Conductivity ?? 1) *
(HullConductivity[v.x, v.y].x ? hullData.Conductivity : 1 / hullData.Conductivity);
if (hullData.Shape[int2(v.x, v.y - 1)])
heatTransfer += (Temperature[v.x, v.y - 1] - temp) *
(GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x, v.y - 1]?.Conductivity ?? 1) *
(HullConductivity[v.x, v.y - 1].y ? hullData.Conductivity : 1 / hullData.Conductivity);
if (hullData.Shape[int2(v.x, v.y + 1)])
heatTransfer += (Temperature[v.x, v.y + 1] - temp) *
(GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x, v.y + 1]?.Conductivity ?? 1) *
(HullConductivity[v.x, v.y].y ? hullData.Conductivity : 1 / hullData.Conductivity);
{
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x + 1, v.y]?.Conductivity ?? 1) *
(HullConductivity[v.x, v.y].x ? hullData.Conductivity : 1 / hullData.Conductivity) *
(ThermalMass[v.x + 1, v.y] / ThermalMass[v.x, v.y]);
totalConductivity += conductivity;
totalTemp += Temperature[v.x + 1, v.y] * conductivity;
}
NewTemperature[v.x, v.y] = Temperature[v.x, v.y] + heatTransfer * min(ItemManager.GameplaySettings.HeatConductionMultiplier * delta,1) / ThermalMass[v.x,v.y];
if (hullData.Shape[int2(v.x, v.y - 1)])
{
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x, v.y - 1]?.Conductivity ?? 1) *
(HullConductivity[v.x, v.y - 1].y ? hullData.Conductivity : 1 / hullData.Conductivity) *
(ThermalMass[v.x, v.y - 1] / ThermalMass[v.x, v.y]);
totalConductivity += conductivity;
totalTemp += Temperature[v.x, v.y - 1] * conductivity;
}
if (hullData.Shape[int2(v.x, v.y + 1)])
{
var conductivity = (GearOccupancy[v.x, v.y]?.Conductivity ?? 1) *
(GearOccupancy[v.x, v.y + 1]?.Conductivity ?? 1) *
(HullConductivity[v.x, v.y].y ? hullData.Conductivity : 1 / hullData.Conductivity) *
(ThermalMass[v.x, v.y + 1] / ThermalMass[v.x, v.y]);
totalConductivity += conductivity;
totalTemp += Temperature[v.x, v.y + 1] * conductivity;
}
NewTemperature[v.x, v.y] = totalTemp / totalConductivity;
var r = 0f;
// For all cells on the border of the entity, radiate some heat into space, increasing the visibility of the ship
if (Parent==null && !hullData.InteriorCells[v])
{
var rad = pow(NewTemperature[v.x, v.y], ItemManager.GameplaySettings.HeatRadiationExponent) *
ItemManager.GameplaySettings.HeatRadiationMultiplier;
NewTemperature[v.x, v.y] -= rad * delta;
radiation += rad;
// for(int i = 0; i<4; i++)
// {
var rad = pow(NewTemperature[v.x, v.y], ItemManager.GameplaySettings.HeatRadiationExponent) *
ItemManager.GameplaySettings.HeatRadiationMultiplier;
NewTemperature[v.x, v.y] -= rad * delta / 4;
r += rad;
// }
}
radiation += r;
if(float.IsNaN(NewTemperature[v.x, v.y]) || NewTemperature[v.x, v.y] < 0)
if(float.IsNaN(NewTemperature[v.x, v.y]) || NewTemperature[v.x, v.y] < 0 || NewTemperature[v.x, v.y] > 600)
ItemManager.Log("HOUSTON, WE HAVE A PROBLEM!");
if (NewTemperature[v.x, v.y] < MinTemp)
MinTemp = NewTemperature[v.x, v.y];
if (NewTemperature[v.x, v.y] > MaxTemp)
MaxTemp = NewTemperature[v.x, v.y];
}
VisibilitySources[this] = radiation;

View file

@ -452,9 +452,17 @@ public class ItemManager
{
var data = GetData(item);
if(data is CraftedItemData c)
return CreateInstance(c, 0, 1);
{
var i = CreateInstance(c, 0, 1);
i.Rotation = item.Rotation;
return i;
}
if (item is SimpleCommodity s)
return CreateInstance(data as SimpleCommodityData, s.Quantity);
{
var i = CreateInstance(data as SimpleCommodityData, s.Quantity);
i.Rotation = item.Rotation;
return i;
}
return null;
}

View file

@ -99,6 +99,7 @@ public class GameplaySettings
public float HeatRadiationExponent = 1;
public float HeatRadiationMultiplier = 1;
public float HeatConductionMultiplier = 1;
public ExponentialCurve TemperatureEmissionCurve;
public float HeatstrokeTemperature = 330;
public float HeatstrokeMultiplier = .00001f;
public float HeatstrokeExponent = 2;

View file

@ -10,6 +10,7 @@ using UnityEngine;
using UniRx;
using UniRx.Triggers;
using Unity.Mathematics;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class InventoryMenu : MonoBehaviour
@ -304,10 +305,13 @@ public class InventoryMenu : MonoBehaviour
{
if (_selectedPanel != null)
{
foreach (var v in _selectedItemData.Shape.Coordinates)
if(_selectedPanel.CellInstances.ContainsKey(_selectedItemData.Shape.Coordinates.First()))
{
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2);
foreach (var v in _selectedItemData.Shape.Coordinates)
{
var v2 = _selectedItemData.Shape.Rotate(v, _selectedItem.Rotation) + _selectedPosition;
_selectedPanel.CellInstances[v2].Icon.color = _selectedPanel.GetColor(v2);
}
}
}
PropertiesPanel.Inspect(entityEvent.Entity, item);
@ -328,6 +332,13 @@ public class InventoryMenu : MonoBehaviour
void Update()
{
if (Keyboard.current.qKey.wasPressedThisFrame && _dragItem != null)
{
_dragItem.Rotation = (ItemRotation) (((int) _dragItem.Rotation + 1) % 4);
}
if (Keyboard.current.eKey.wasPressedThisFrame && _dragItem != null)
{
_dragItem.Rotation = (ItemRotation) (((int) _dragItem.Rotation + 3) % 4);
}
}
}

View file

@ -24,6 +24,8 @@ public class InventoryPanel : MonoBehaviour
public ActionGameManager GameManager;
public ContextMenu ContextMenu;
public TextMeshProUGUI Title;
public TextMeshProUGUI MinTempLabel;
public TextMeshProUGUI MaxTempLabel;
public Button Dropdown;
public Button Current;
public Button Thermal;
@ -153,8 +155,13 @@ public class InventoryPanel : MonoBehaviour
private void Update()
{
if (_displayedEntity != null)
if (_displayedEntity != null && TemperatureDisplay)
{
if(MinTempLabel)
{
MinTempLabel.text = $"Min: {((int) (_displayedEntity.MinTemp - 273.15f)).ToString()}°C";
MaxTempLabel.text = $"Max: {((int) (_displayedEntity.MaxTemp - 273.15f)).ToString()}°C";
}
var hullData = GameManager.ItemManager.GetData(_displayedEntity.Hull) as HullData;
for(var x = 0; x < _temperatureTexture.width; x++)
{
@ -162,7 +169,7 @@ public class InventoryPanel : MonoBehaviour
{
if (hullData.Shape[int2(x-1, y-1)])
{
var temp = _displayedEntity.Temperature[x - 1, y - 1] / MaxTemperature;
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);
_temperatureTexture.SetPixel(x,y,color);
@ -200,7 +207,8 @@ public class InventoryPanel : MonoBehaviour
_subscriptions.Clear();
TemperatureDisplay.gameObject.SetActive(false);
if(TemperatureDisplay)
TemperatureDisplay.gameObject.SetActive(false);
if(Title)
Title.text = "None";
@ -215,6 +223,12 @@ public class InventoryPanel : MonoBehaviour
_displayedEntity = entity;
_displayedCargo = null;
_firstRect = null;
if(MinTempLabel)
{
MinTempLabel.gameObject.SetActive(true);
MaxTempLabel.gameObject.SetActive(true);
}
if(Title)
Title.text = entity.Name;
@ -228,15 +242,19 @@ public class InventoryPanel : MonoBehaviour
Grid.cellSize = Vector2.one * (int) min(rect.width / (hullData.Shape.Width + 1), rect.height / (hullData.Shape.Height + 1));
}
_temperatureTexture = new Texture2D(
hullData.Shape.Width+2,
hullData.Shape.Height+2,
TextureFormat.RGBA32,
false, false);
TemperatureDisplay.gameObject.SetActive(true);
TemperatureDisplay.texture = _temperatureTexture;
var tempRect = TemperatureDisplay.rectTransform;
tempRect.sizeDelta = Grid.cellSize * new Vector2(hullData.Shape.Width + 2, hullData.Shape.Height + 2);
if(TemperatureDisplay)
{
_temperatureTexture = new Texture2D(
hullData.Shape.Width + 2,
hullData.Shape.Height + 2,
TextureFormat.RGBA32,
false,
false);
TemperatureDisplay.gameObject.SetActive(true);
TemperatureDisplay.texture = _temperatureTexture;
var tempRect = TemperatureDisplay.rectTransform;
tempRect.sizeDelta = Grid.cellSize * new Vector2(hullData.Shape.Width + 2, hullData.Shape.Height + 2);
}
if (Current)
{
@ -373,7 +391,11 @@ public class InventoryPanel : MonoBehaviour
_displayedCargo = cargo;
_displayedEntity = null;
TemperatureDisplay.gameObject.SetActive(false);
if(TemperatureDisplay)
TemperatureDisplay.gameObject.SetActive(false);
MinTempLabel.gameObject.SetActive(false);
MaxTempLabel.gameObject.SetActive(false);
if (Current)
Current.gameObject.SetActive(false);

View file

@ -211,27 +211,27 @@ public class SchematicDisplay : MonoBehaviour
{
if (_radiators.Length == 1)
RadiatorTemperatureLabel.text = $"{(_radiators[0].Item.Temperature - 273.15f).SignificantDigits(3)}°C";
RadiatorTemperatureLabel.text = $"{((int)(_radiators[0].Item.Temperature - 273.15f)).ToString()}°C";
else if (_radiators.Length > 1)
RadiatorTemperatureLabel.text =
$"{(_radiators.Min(r => r.Item.Temperature) - 273.15f).SignificantDigits(3)}-" +
$"{(_radiators.Max(r => r.Item.Temperature) - 273.15f).SignificantDigits(3)}°C";
$"{((int)(_radiators.Min(r => r.Item.Temperature) - 273.15f)).ToString()}-" +
$"{((int)(_radiators.Max(r => r.Item.Temperature) - 273.15f)).ToString()}°C";
if (_heatsinks.Length == 1)
HeatsinkTemperatureLabel.text = $"{(_heatsinks[0].Item.Temperature - 273.15f).SignificantDigits(3)}°C";
HeatsinkTemperatureLabel.text = $"{((int)(_heatsinks[0].Item.Temperature - 273.15f)).ToString()}°C";
else if (_heatsinks.Length > 1)
HeatsinkTemperatureLabel.text =
$"{(_heatsinks.Min(r => r.Item.Temperature) - 273.15f).SignificantDigits(3)}-" +
$"{(_heatsinks.Max(r => r.Item.Temperature) - 273.15f).SignificantDigits(3)}°C";
$"{((int)(_heatsinks.Min(r => r.Item.Temperature) - 273.15f)).ToString()}-" +
$"{((int)(_heatsinks.Max(r => r.Item.Temperature) - 273.15f)).ToString()}°C";
if (_cargoBays.Length == 1)
CargoTemperatureLabel.text = $"{(_cargoBays[0].Temperature - 273.15f).SignificantDigits(3)}°C";
CargoTemperatureLabel.text = $"{((int)(_cargoBays[0].Temperature - 273.15f)).ToString()}°C";
else if (_cargoBays.Length > 1)
CargoTemperatureLabel.text =
$"{(_cargoBays.Min(r => r.Temperature) - 273.15f).SignificantDigits(3)}-" +
$"{(_cargoBays.Max(r => r.Temperature) - 273.15f).SignificantDigits(3)}°C";
$"{((int)(_cargoBays.Min(r => r.Temperature) - 273.15f)).ToString()}-" +
$"{((int)(_cargoBays.Max(r => r.Temperature) - 273.15f)).ToString()}°C";
CockpitTemperatureLabel.text = $"{(_cockpit.Item.Temperature - 273.15f).SignificantDigits(3)}°C";
CockpitTemperatureLabel.text = $"{((int)(_cockpit.Item.Temperature - 273.15f)).ToString()}°C";
HeatstrokeMeterFill.anchorMax = new Vector2(_cockpit.Heatstroke, 1);
HeatstrokeLimitFill.anchorMax = new Vector2(_cockpit.Item.Temperature / Settings.GameplaySettings.HeatstrokeTemperature, 1);
@ -246,7 +246,7 @@ public class SchematicDisplay : MonoBehaviour
var charge = _capacitors.Sum(x => x.Charge);
var maxCharge = _capacitors.Sum(x => x.Capacity);
EnergyFill.anchorMax = new Vector2(charge / maxCharge, 1);
EnergyLabel.text = $"{charge.SignificantDigits(3)}/{maxCharge.SignificantDigits(3)} ({_reactor.Surplus.SignificantDigits(3)})";
EnergyLabel.text = $"{((int)charge).ToString()}/{((int)maxCharge).ToString()} + ({((int)_reactor.Surplus).ToString()})";
}
}
else