diff --git a/Assets/GWConquest/Scripts/Formation.cs b/Assets/GWConquest/Scripts/Formation.cs index b362dc7..fa45d91 100644 --- a/Assets/GWConquest/Scripts/Formation.cs +++ b/Assets/GWConquest/Scripts/Formation.cs @@ -180,6 +180,14 @@ namespace GWConquest { if(entity.IsOwner && !state.IsInTransit) { + if(IsEmbarked) + { + if(ParentFormation != null && ParentFormation.entity.IsAttached) + { + ParentFormation.RemoveSubFormation(this); + } + } + state.CurrentTransition.OriginZone = Zone.GetZoneId(currentZone); state.CurrentTransition.TargetZone = Zone.GetZoneId(target); bool isGroundTransition = target.zoneType == ZoneType.Ground; @@ -251,7 +259,21 @@ namespace GWConquest public override void SimulateOwner() { - + if(IsEmbarked) + { + if(ParentFormation != null && ParentFormation.entity.IsAttached) + { + if(currentZone != ParentFormation.currentZone) + { + currentZone = ParentFormation.currentZone; + } + } + else { + BoltLog.Error("Formation {0} lost its parent formation {1}!", this, ParentFormation); + ParentFormation = null; + IsEmbarked = false; + } + } if(state.IsInTransit) { CoveredDistance += movementSpeed * BoltNetwork.FrameDeltaTime; diff --git a/Assets/GWConquest/Scripts/UI/TransportUIElement.cs b/Assets/GWConquest/Scripts/UI/TransportUIElement.cs index 1ec93c2..46cbf1b 100644 --- a/Assets/GWConquest/Scripts/UI/TransportUIElement.cs +++ b/Assets/GWConquest/Scripts/UI/TransportUIElement.cs @@ -227,17 +227,25 @@ namespace GWConquest { if(Formation.ZoneType == ZoneType.Ground) { - if (!Formation.IsEmbarked && ui.Type == ObjectType.District && ui.District.Zone.zoneType == ZoneType.Ground) + if (ui.Type == ObjectType.District && ui.District.Zone.zoneType == ZoneType.Ground) { - // Transition Boden -> Boden - var goalZone = ui.District.Zone; - var pathfinding = Formation.currentZone.planet.pathfindingGraph; - var shortestPath = pathfinding.FindShortestPath(Formation, Formation.currentZone, goalZone); - if (shortestPath != null) + if(!Formation.IsEmbarked) { - Formation.StartMovingOnPath(shortestPath.zones); + // Transition Boden -> Boden + var goalZone = ui.District.Zone; + var pathfinding = Formation.currentZone.planet.pathfindingGraph; + var shortestPath = pathfinding.FindShortestPath(Formation, Formation.currentZone, goalZone); + if (shortestPath != null) + { + Formation.StartMovingOnPath(shortestPath.zones); + } + } + else { + // Transition Weltall -> Boden + var goalZone = ui.District.Zone; + var path = new List() {Formation.currentZone, goalZone}; + Formation.StartMovingOnPath(path); } - } else if (ui.Type == ObjectType.Formation && ui.Formation.ZoneType == ZoneType.Space) { @@ -248,7 +256,7 @@ namespace GWConquest // Transition Boden -> Weltall var goalZone = ui.Formation.currentZone; var path = new List() {Formation.currentZone, goalZone}; - Formation.StartMovingOnPath(path, ui.Formation); + Formation.StartMovingOnPath(path, targetFormation: ui.Formation); } else { // Transition Weltall -> Weltall (Flottenwechsel)