Docking System

Entities now have dedicated docking bays with their own cargo area for loading/unloading
Inventory panel allows display of any ship or cargo bay at the currently docked station or within the current ship if undocked
This commit is contained in:
Reinier Vens 2020-12-19 02:37:13 +00:00
commit 2d9bec0e33
24 changed files with 553 additions and 465 deletions

View file

@ -32,12 +32,14 @@ public class ActionGameManager : MonoBehaviour
private float _time;
private AetheriaInput _input;
private int _zoomLevelIndex;
private Ship _currentShip;
public List<Ship> PlayerShips { get; } = new List<Ship>();
public DatabaseCache ItemData { get; private set; }
public ItemManager ItemManager { get; private set; }
public Zone Zone { get; private set; }
void Start()
{
ConsoleController.MessageReceiver = this;
@ -113,11 +115,17 @@ public class ActionGameManager : MonoBehaviour
var stationOrbit = Zone.CreateOrbit(parentOrbit, stationPos);
var station = new OrbitalEntity(ItemManager, Zone, stationHull, stationOrbit.ID);
Zone.Entities.Add(station);
var dockingBayData = ItemData.GetAll<DockingBayData>().First();
var dockingBay = ItemManager.CreateInstance(dockingBayData, 1, 1) as EquippableItem;
station.TryEquip(dockingBay);
var hullType = ItemData.GetAll<HullData>().First(x=>x.HullType==HullType.Ship);
var shipHull = ItemManager.CreateInstance(hullType, 0, 1) as EquippableItem;
var ship = new Ship(ItemManager, Zone, shipHull);
PlayerShips.Add(ship);
_currentShip = ship;
station.TryDock(ship);
// MapButton.onClick.AddListener(() =>
// {
// if (_currentMenuTabButton == MapPanel) return;
@ -138,6 +146,30 @@ public class ActionGameManager : MonoBehaviour
FollowCamera.gameObject.SetActive(!_editMode);
TopDownCamera.gameObject.SetActive(_editMode);
}
public IEnumerable<EquippedCargoBay> AvailableCargoBays()
{
if (_currentShip.Parent != null)
{
foreach (var bay in _currentShip.Parent.DockingBays)
{
if (PlayerShips.Contains(bay.DockedShip)) yield return bay;
}
}
}
public IEnumerable<Ship> AvailableShips()
{
if (_currentShip.Parent != null)
{
foreach (var ship in PlayerShips)
{
if (_currentShip.Parent.Children.Contains(ship)) yield return ship;
}
}
else
yield return _currentShip;
}
void Update()
{