/// <summary> /// Positions the element in formation. This base class version simply places the /// element at the designated offset location from the HQElement. /// </summary> /// <param name="element">The element.</param> /// <param name="stationSlotInfo">The slot information.</param> public virtual void PositionElementInFormation(IUnitElement element, FormationStationSlotInfo stationSlotInfo) { (element as AUnitElementItem).transform.localPosition = stationSlotInfo.LocalOffset; //D.Log(ShowDebugLog, "{0} positioned at {1}, offset by {2} from {3} at {4}.", //element.DebugName, element.Position, stationSlotInfo.LocalOffset, HQElement.DebugName, HQElement.Position); }
/// <summary> /// Positions the element in formation. This FleetCmd version assigns a FleetFormationStation to the element (ship) after /// removing the existing station, if any. The ship will then assume its station by moving to its location when ordered. /// If this Cmd client is not yet operational meaning the fleet is being deployed for the first time, the ship will /// be placed at the station's location. /// </summary> /// <param name="element">The element.</param> /// <param name="stationSlotInfo">The station slot information.</param> public override void PositionElementInFormation(IUnitElement element, FormationStationSlotInfo stationSlotInfo) { ShipItem ship = element as ShipItem; if (!IsOperational) { // If not operational, this positioning is occurring during construction so place the ship now where it belongs base.PositionElementInFormation(element, stationSlotInfo); } FleetFormationStation station = ship.FormationStation; if (station != null) { // the ship already has a formation station so get rid of it D.Log(ShowDebugLog, "{0} is removing and despawning old {1}.", ship.DebugName, typeof(FleetFormationStation).Name); ship.FormationStation = null; station.AssignedShip = null; // FormationMgr will have already removed stationInfo from occupied list if present //FormationMgr.ReturnSlotAsAvailable(ship, station.StationInfo); MyPoolManager.Instance.DespawnFormationStation(station.transform); } //D.Log(ShowDebugLog, "{0} is adding a new {1} with SlotID {2}.", DebugName, typeof(FleetFormationStation).Name, stationSlotInfo.SlotID.GetValueName()); station = MyPoolManager.Instance.SpawnFormationStation(Position, Quaternion.identity, transform); station.StationInfo = stationSlotInfo; station.AssignedShip = ship; ship.FormationStation = station; }