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

@ -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