From 19ae2fb90dcf1b7d54117a49fc52198f214e3258 Mon Sep 17 00:00:00 2001 From: Ferenc Fodor Date: Sun, 6 Jun 2021 16:54:01 +0200 Subject: [PATCH] Ship Towing Services Added functionality to tow ship to last visited station Added command "tow" Added property "CanTow" to ship --- Assets/Scripts/Gameplay/ActionGameManager.cs | 35 +++++++++++++++++++- Assets/Scripts/ServerShared/Ship.cs | 1 + 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/Gameplay/ActionGameManager.cs b/Assets/Scripts/Gameplay/ActionGameManager.cs index 9cc91decc..336f0b038 100644 --- a/Assets/Scripts/Gameplay/ActionGameManager.cs +++ b/Assets/Scripts/Gameplay/ActionGameManager.cs @@ -224,6 +224,8 @@ public class ActionGameManager : MonoBehaviour public AetheriaInput Input { get; private set; } public EquippedDockingBay DockingBay { get; private set; } public Entity DockedEntity { get; private set; } + //if better place, please move + public Entity TowingStation { get; private set; } public Entity CurrentEntity { @@ -561,7 +563,9 @@ public class ActionGameManager : MonoBehaviour Zone.Entities.Add(turret); turret.Activate(); }); - + //Temporary, or not + ConsoleController.AddCommand("tow", _ => TowShip()); + // ConsoleController.AddCommand("pingscene", // _ => // { @@ -770,6 +774,7 @@ public class ActionGameManager : MonoBehaviour true); // EntitySerializer.Unpack(ItemManager, Zone, Loadouts.First(x => x.Name == StarterShipTemplate), true); ((Ship) ship).IsPlayerShip = true; + ((Ship) ship).CanTow = true; ship.Position = float3.zero; ship.Zone = Zone; Zone.Entities.Add(ship); @@ -869,6 +874,8 @@ public class ActionGameManager : MonoBehaviour if (ZoneRenderer.Planets.ContainsKey(parentOrbitPlanet)) DockCamera.LookAt = ZoneRenderer.Planets[parentOrbitPlanet].Body.transform; else DockCamera.LookAt = ZoneRenderer.ZoneRoot; + if (dockingBay.DockedShip.CanTow) + TowingStation = entity; Menu.ShowTab(MenuTab.Inventory); } @@ -916,6 +923,32 @@ public class ActionGameManager : MonoBehaviour } } + public void TowShip() + { + if (CurrentEntity.Parent != null) return; + if (CurrentEntity is Ship ship) + { + if (Zone.Equals(TowingStation.Zone)) + { + var distance = (int)length(TowingStation.Position.xz - CurrentEntity.Position.xz); + CurrentEntity.Position.xz = TowingStation.Position.xz; + Dock(); + //Debug.Log($"${distance}"); + //payment = distance * TowingZoneRate; + } + else + { + var distance = Zone.GalaxyZone.Distance[TowingStation.Zone.GalaxyZone]; + PopulateLevel(TowingStation.Zone.GalaxyZone); + CurrentEntity.Zone = Zone; + CurrentEntity.Position.xz = TowingStation.Position.xz; + Dock(); + //Debug.Log($"${distance * 1000}"); + //payment = distance * TowingGalaxyRate; + } + } + } + private void UnbindEntity() { foreach (var indicator in _visibleHostileIndicators) Destroy(indicator.Value.gameObject); diff --git a/Assets/Scripts/ServerShared/Ship.cs b/Assets/Scripts/ServerShared/Ship.cs index 529c07b39..f806f8405 100644 --- a/Assets/Scripts/ServerShared/Ship.cs +++ b/Assets/Scripts/ServerShared/Ship.cs @@ -26,6 +26,7 @@ public class Ship : Entity public Entity HomeEntity; public float2 MovementDirection; public bool IsPlayerShip; + public bool CanTow; private HashSet _thrusterItems; private Thruster[] _allThrusters;