Heat Pipes

Thermal Layer Removed
Items can be destroyed from inventory menu via drag & drop
Trade menu contains only priced items
Trade menu has filters for commodities
Conductivity can be adjusted along schematic edges
Thermals rebalanced
This commit is contained in:
Reinier Vens 2021-01-17 02:45:52 +00:00
commit ebec68e7f0
28 changed files with 1706 additions and 322 deletions

View file

@ -50,7 +50,6 @@ public class ActionGameManager : MonoBehaviour
private float _time;
private AetheriaInput _input;
private int _zoomLevelIndex;
private Ship _currentShip;
// private ShipInput _shipInput;
private float2 _shipYawPitch;
@ -60,10 +59,7 @@ public class ActionGameManager : MonoBehaviour
public List<Ship> PlayerShips { get; } = new List<Ship>();
public EquippedDockingBay DockingBay { get; private set; }
public Ship CurrentShip
{
get => _currentShip;
}
public Ship CurrentShip { get; set; }
public DatabaseCache ItemData { get; private set; }
public ItemManager ItemManager { get; private set; }
public Zone Zone { get; private set; }
@ -123,12 +119,12 @@ public class ActionGameManager : MonoBehaviour
Cursor.lockState = CursorLockMode.Locked;
_input.Player.Enable();
Menu.gameObject.SetActive(false);
if (_currentShip != null && _currentShip.Parent == null)
if (CurrentShip != null && CurrentShip.Parent == null)
{
GameplayUI.SetActive(true);
SchematicDisplay.ShowShip(_currentShip);
ShipPanel.Display(_currentShip, true);
SchematicDisplay.ShowShip(CurrentShip);
ShipPanel.Display(CurrentShip, true);
}
return;
@ -138,7 +134,7 @@ public class ActionGameManager : MonoBehaviour
_input.Player.Disable();
GameplayUI.SetActive(false);
Menu.ShowTab(MenuTab.Map);
MenuMap.Position = _currentShip.Position.xz;
MenuMap.Position = CurrentShip.Position.xz;
};
_input.Global.Inventory.performed += context =>
@ -148,12 +144,12 @@ public class ActionGameManager : MonoBehaviour
Cursor.lockState = CursorLockMode.Locked;
_input.Player.Enable();
Menu.gameObject.SetActive(false);
if (_currentShip != null && _currentShip.Parent == null)
if (CurrentShip != null && CurrentShip.Parent == null)
{
GameplayUI.SetActive(true);
SchematicDisplay.ShowShip(_currentShip);
ShipPanel.Display(_currentShip, true);
SchematicDisplay.ShowShip(CurrentShip);
ShipPanel.Display(CurrentShip, true);
}
return;
}
@ -162,86 +158,79 @@ public class ActionGameManager : MonoBehaviour
_input.Player.Disable();
Menu.ShowTab(MenuTab.Inventory);
GameplayUI.SetActive(false);
var cargo = _currentShip.CargoBays.FirstOrDefault();
if (cargo != null)
{
Inventory.GetPanel.Display(cargo);
}
else Inventory.GetPanel.Clear();
Inventory.GetPanel.Display(_currentShip);
};
_input.Global.Dock.performed += context =>
{
if (_currentShip.Parent == null) Dock();
if (CurrentShip.Parent == null) Dock();
else Undock();
};
_input.Player.TargetReticle.performed += context =>
{
var underReticle = Zone.Entities.Where(x => x != _currentShip).MaxBy(x => dot(normalize(x.Position - _currentShip.Position), _currentShip.LookDirection));
_currentShip.Target.Value = _currentShip.Target.Value == underReticle ? null : underReticle;
var underReticle = Zone.Entities.Where(x => x != CurrentShip).MaxBy(x => dot(normalize(x.Position - CurrentShip.Position), CurrentShip.LookDirection));
CurrentShip.Target.Value = CurrentShip.Target.Value == underReticle ? null : underReticle;
};
_input.Player.TargetNearest.performed += context =>
{
_currentShip.Target.Value = Zone.Entities.Where(x=>x!=_currentShip).MaxBy(x => length(x.Position - _currentShip.Position));
CurrentShip.Target.Value = Zone.Entities.Where(x=>x!=CurrentShip).MaxBy(x => length(x.Position - CurrentShip.Position));
};
_input.Player.TargetNext.performed += context =>
{
var targets = Zone.Entities.Where(x => x != _currentShip).OrderBy(x => length(x.Position - _currentShip.Position)).ToArray();
var currentTargetIndex = Array.IndexOf(targets, _currentShip.Target.Value);
_currentShip.Target.Value = targets[(currentTargetIndex + 1) % targets.Length];
var targets = Zone.Entities.Where(x => x != CurrentShip).OrderBy(x => length(x.Position - CurrentShip.Position)).ToArray();
var currentTargetIndex = Array.IndexOf(targets, CurrentShip.Target.Value);
CurrentShip.Target.Value = targets[(currentTargetIndex + 1) % targets.Length];
};
_input.Player.TargetPrevious.performed += context =>
{
var targets = Zone.Entities.Where(x => x != _currentShip).OrderBy(x => length(x.Position - _currentShip.Position)).ToArray();
var currentTargetIndex = Array.IndexOf(targets, _currentShip.Target.Value);
_currentShip.Target.Value = targets[(currentTargetIndex + targets.Length - 1) % targets.Length];
var targets = Zone.Entities.Where(x => x != CurrentShip).OrderBy(x => length(x.Position - CurrentShip.Position)).ToArray();
var currentTargetIndex = Array.IndexOf(targets, CurrentShip.Target.Value);
CurrentShip.Target.Value = targets[(currentTargetIndex + targets.Length - 1) % targets.Length];
};
#region Trigger Groups
_input.Player.PreviousWeaponGroup.performed += context =>
{
if (_currentShip.Parent != null) return;
if (CurrentShip.Parent != null) return;
SchematicDisplay.SelectedGroupIndex--;
};
_input.Player.NextWeaponGroup.performed += context =>
{
if (_currentShip.Parent != null) return;
if (CurrentShip.Parent != null) return;
SchematicDisplay.SelectedGroupIndex++;
};
_input.Player.PreviousWeapon.performed += context =>
{
if (_currentShip.Parent != null) return;
if (CurrentShip.Parent != null) return;
SchematicDisplay.SelectedItemIndex--;
};
_input.Player.NextWeapon.performed += context =>
{
if (_currentShip.Parent != null) return;
if (CurrentShip.Parent != null) return;
SchematicDisplay.SelectedItemIndex++;
};
_input.Player.ToggleWeaponGroup.performed += context =>
{
if (_currentShip.Parent != null) return;
if (CurrentShip.Parent != null) return;
var item = SchematicDisplay.SchematicItems[SchematicDisplay.SelectedItemIndex];
if (_currentShip.TriggerGroups[SchematicDisplay.SelectedGroupIndex].Contains(item.Item))
_currentShip.TriggerGroups[SchematicDisplay.SelectedGroupIndex].Remove(item.Item);
else _currentShip.TriggerGroups[SchematicDisplay.SelectedGroupIndex].Add(item.Item);
if (CurrentShip.TriggerGroups[SchematicDisplay.SelectedGroupIndex].Contains(item.Item))
CurrentShip.TriggerGroups[SchematicDisplay.SelectedGroupIndex].Remove(item.Item);
else CurrentShip.TriggerGroups[SchematicDisplay.SelectedGroupIndex].Add(item.Item);
SchematicDisplay.UpdateTriggerGroups();
};
_input.Player.FireGroup1.started += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[0])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[0])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -254,8 +243,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup1.canceled += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[0])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[0])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -267,8 +256,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup2.started += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[1])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[1])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -281,8 +270,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup2.canceled += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[1])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[1])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -294,8 +283,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup3.started += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[2])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[2])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -308,8 +297,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup3.canceled += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[2])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[2])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -321,8 +310,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup4.started += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[3])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[3])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -335,8 +324,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup4.canceled += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[3])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[3])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -348,8 +337,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup5.started += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[4])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[4])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -362,8 +351,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup5.canceled += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[4])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[4])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -375,8 +364,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup6.started += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[5])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[5])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -389,8 +378,8 @@ public class ActionGameManager : MonoBehaviour
_input.Player.FireGroup6.canceled += context =>
{
if (_currentShip.Parent != null) return;
foreach (var item in _currentShip.TriggerGroups[5])
if (CurrentShip.Parent != null) return;
foreach (var item in CurrentShip.TriggerGroups[5])
{
foreach (var behaviors in item.BehaviorGroups)
{
@ -454,15 +443,15 @@ public class ActionGameManager : MonoBehaviour
var shipHull = ItemManager.CreateInstance(hullType, 0, 1) as EquippableItem;
var ship = new Ship(ItemManager, Zone, shipHull);
PlayerShips.Add(ship);
_currentShip = ship;
_currentShip.Target.Subscribe(target =>
CurrentShip = ship;
CurrentShip.Target.Subscribe(target =>
{
TargetIndicator.gameObject.SetActive(_currentShip.Target.Value != null);
TargetIndicator.gameObject.SetActive(CurrentShip.Target.Value != null);
TargetShipPanel.gameObject.SetActive(target != null);
if (target != null)
{
TargetShipPanel.Display(target, true);
TargetSchematicDisplay.ShowShip(target, _currentShip);
TargetSchematicDisplay.ShowShip(target, CurrentShip);
}
});
ship.ArmorDamage.Subscribe(hit =>
@ -478,7 +467,7 @@ public class ActionGameManager : MonoBehaviour
var data = ItemManager.GetData(hit.item.EquippableItem);
EventLog.LogMessage(
$"{hit.item.EquippableItem.Name} hit for {hit.damage} damage, currently {((int) (hit.item.EquippableItem.Durability / data.Durability * 100)).ToString()}%",
data.HardpointType == HardpointType.Thermal ? Settings.ThermalHitColor : Settings.GearHitColor);
Settings.GearHitColor);
});
ship.HardpointDamage.Subscribe(hit => EventLog.LogMessage(
$"{Enum.GetName(typeof(HardpointType), hit.hardpoint.Type)} hardpoint hit for {hit.damage} damage, currently {((int) (ship.HardpointArmor[hit.hardpoint] / hit.hardpoint.Armor * 100)).ToString()}%",
@ -524,27 +513,25 @@ public class ActionGameManager : MonoBehaviour
public void Dock()
{
if (_currentShip.Parent != null) return;
if (CurrentShip.Parent != null) return;
foreach (var entity in Zone.Entities.ToArray())
{
if (lengthsq(entity.Position.xz - _currentShip.Position.xz) <
if (lengthsq(entity.Position.xz - CurrentShip.Position.xz) <
Settings.GameplaySettings.DockingDistance * Settings.GameplaySettings.DockingDistance)
{
var bay = entity.TryDock(_currentShip);
var bay = entity.TryDock(CurrentShip);
if (bay != null)
{
DockingBay = bay;
DockCamera.enabled = true;
FollowCamera.enabled = false;
_currentShip.Active = false;
CurrentShip.Active = false;
var orbital = (OrbitalEntity) entity;
DockCamera.Follow = SectorRenderer.EntityInstances[orbital].Transform;
var parentOrbit = Zone.Orbits[orbital.OrbitData].Data.Parent;
var parentPlanet = SectorRenderer.Planets[Zone.Planets.FirstOrDefault(p => p.Value.Orbit == parentOrbit).Key];
DockCamera.LookAt = parentPlanet.Body.transform;
Menu.ShowTab(MenuTab.Inventory);
Inventory.GetPanel.Display(bay);
Inventory.GetPanel.Display(_currentShip);
Cursor.lockState = CursorLockMode.None;
_input.Player.Disable();
GameplayUI.SetActive(false);
@ -557,44 +544,44 @@ public class ActionGameManager : MonoBehaviour
public void Undock()
{
if (_currentShip.Parent == null) return;
if (_currentShip.GetBehavior<Cockpit>() == null)
if (CurrentShip.Parent == null) return;
if (CurrentShip.GetBehavior<Cockpit>() == null)
{
ConfirmationDialog.Clear();
ConfirmationDialog.Title.text = "Can't undock. Missing cockpit component!";
ConfirmationDialog.Show();
}
else if (_currentShip.GetBehavior<Thruster>() == null)
else if (CurrentShip.GetBehavior<Thruster>() == null)
{
ConfirmationDialog.Clear();
ConfirmationDialog.Title.text = "Can't undock. Missing thruster component!";
ConfirmationDialog.Show();
}
else if (_currentShip.GetBehavior<Reactor>() == null)
else if (CurrentShip.GetBehavior<Reactor>() == null)
{
ConfirmationDialog.Clear();
ConfirmationDialog.Title.text = "Can't undock. Missing reactor component!";
ConfirmationDialog.Show();
}
else if (_currentShip.Parent.TryUndock(_currentShip))
else if (CurrentShip.Parent.TryUndock(CurrentShip))
{
Menu.gameObject.SetActive(false);
DockingBay = null;
_currentShip.Active = true;
CurrentShip.Active = true;
//_shipInput = new ShipInput(_input.Player, _currentShip);
DockCamera.enabled = false;
FollowCamera.enabled = true;
FollowCamera.LookAt = SectorRenderer.EntityInstances[_currentShip].LookAtPoint;
FollowCamera.Follow = SectorRenderer.EntityInstances[_currentShip].Transform;
ArticulationGroups = _currentShip.Equipment
FollowCamera.LookAt = SectorRenderer.EntityInstances[CurrentShip].LookAtPoint;
FollowCamera.Follow = SectorRenderer.EntityInstances[CurrentShip].Transform;
ArticulationGroups = CurrentShip.Equipment
.Where(item => item.Behaviors.Any(x => x.Data is WeaponData && !(x.Data is LauncherData)))
.GroupBy(item => SectorRenderer.EntityInstances[_currentShip]
.GetBarrel(_currentShip.Hardpoints[item.Position.x, item.Position.y])
.GroupBy(item => SectorRenderer.EntityInstances[CurrentShip]
.GetBarrel(CurrentShip.Hardpoints[item.Position.x, item.Position.y])
.GetComponentInParent<ArticulationPoint>()?.Group ?? -1)
.Select((group, index) => {
return (
group.Select(item => _currentShip.Hardpoints[item.Position.x, item.Position.y]).ToArray(),
group.Select(item => SectorRenderer.EntityInstances[_currentShip].GetBarrel(_currentShip.Hardpoints[item.Position.x, item.Position.y])).ToArray(),
group.Select(item => CurrentShip.Hardpoints[item.Position.x, item.Position.y]).ToArray(),
group.Select(item => SectorRenderer.EntityInstances[CurrentShip].GetBarrel(CurrentShip.Hardpoints[item.Position.x, item.Position.y])).ToArray(),
Crosshairs[index]
);
}).ToArray();
@ -604,7 +591,7 @@ public class ActionGameManager : MonoBehaviour
foreach (var group in ArticulationGroups)
group.crosshair.gameObject.SetActive(true);
LockingIndicators = _currentShip.GetBehaviors<TargetLock>().Select(x =>
LockingIndicators = CurrentShip.GetBehaviors<TargetLock>().Select(x =>
{
var i = LockIndicator.Instantiate<PlaceUIElementWorldspace>();
return (x, i, i.GetComponent<Rotate>());
@ -614,8 +601,8 @@ public class ActionGameManager : MonoBehaviour
Cursor.lockState = CursorLockMode.Locked;
GameplayUI.SetActive(true);
_input.Player.Enable();
ShipPanel.Display(_currentShip, true);
SchematicDisplay.ShowShip(_currentShip);
ShipPanel.Display(CurrentShip, true);
SchematicDisplay.ShowShip(CurrentShip);
}
else
{
@ -636,9 +623,9 @@ public class ActionGameManager : MonoBehaviour
public IEnumerable<EquippedCargoBay> AvailableCargoBays()
{
if (_currentShip.Parent != null)
if (CurrentShip.Parent != null)
{
foreach (var bay in _currentShip.Parent.DockingBays)
foreach (var bay in CurrentShip.Parent.DockingBays)
{
if (PlayerShips.Contains(bay.DockedShip)) yield return bay;
}
@ -647,15 +634,15 @@ public class ActionGameManager : MonoBehaviour
public IEnumerable<Ship> AvailableShips()
{
if (_currentShip.Parent != null)
if (CurrentShip.Parent != null)
{
foreach (var ship in PlayerShips)
{
if (_currentShip.Parent.Children.Contains(ship)) yield return ship;
if (CurrentShip.Parent.Children.Contains(ship)) yield return ship;
}
}
else
yield return _currentShip;
yield return CurrentShip;
}
void Update()
@ -664,13 +651,13 @@ public class ActionGameManager : MonoBehaviour
{
_time += Time.deltaTime;
ItemManager.Time = Time.time;
if(_currentShip.Parent==null)
if(CurrentShip.Parent==null)
{
var look = _input.Player.Look.ReadValue<Vector2>();
_shipYawPitch = float2(_shipYawPitch.x + look.x * Sensitivity.x, clamp(_shipYawPitch.y + look.y * Sensitivity.y, -.45f * PI, .45f * PI));
_viewDirection = mul(float3(0, 0, 1), Unity.Mathematics.float3x3.Euler(float3(_shipYawPitch.yx, 0), RotationOrder.YXZ));
_currentShip.LookDirection = _viewDirection;
_currentShip.MovementDirection = _input.Player.Move.ReadValue<Vector2>();
CurrentShip.LookDirection = _viewDirection;
CurrentShip.MovementDirection = _input.Player.Move.ReadValue<Vector2>();
}
}
Zone.Update(_time, Time.deltaTime);
@ -684,12 +671,12 @@ public class ActionGameManager : MonoBehaviour
private void UpdateTargetIndicators()
{
if (_currentShip == null || _currentShip.Parent != null) return;
if (CurrentShip == null || CurrentShip.Parent != null) return;
ViewDot.Target = SectorRenderer.EntityInstances[_currentShip].LookAtPoint.position;
if (_currentShip.Target.Value != null)
TargetIndicator.Target = _currentShip.Target.Value.Position;
var distance = length((float3)ViewDot.Target - _currentShip.Position);
ViewDot.Target = SectorRenderer.EntityInstances[CurrentShip].LookAtPoint.position;
if (CurrentShip.Target.Value != null)
TargetIndicator.Target = CurrentShip.Target.Value.Position;
var distance = length((float3)ViewDot.Target - CurrentShip.Position);
foreach (var (_, barrels, crosshair) in ArticulationGroups)
{
var averagePosition = Vector3.zero;
@ -700,10 +687,10 @@ public class ActionGameManager : MonoBehaviour
}
foreach (var (targetLock, indicator, spin) in LockingIndicators)
{
var showLockingIndicator = targetLock.Lock > .01f && _currentShip.Target.Value != null;
var showLockingIndicator = targetLock.Lock > .01f && CurrentShip.Target.Value != null;
indicator.gameObject.SetActive(showLockingIndicator);
if(showLockingIndicator)
indicator.Target = _currentShip.Target.Value.Position;
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);