Esempio n. 1
0
 public void HandleBrokeOrbit(IShip_Ltd ship) {
     if (IsInHighOrbit(ship)) {
         var isRemoved = _shipsInHighOrbit.Remove(ship);
         D.Assert(isRemoved);
         D.Log(ShowDebugLog, "{0} has left high orbit around {1}.", ship.DebugName, DebugName);
         if (_emptySystemHighOrbitRigidbody != null) {
             if (_shipsInHighOrbit.Count == Constants.Zero) {
                 _emptySystemHighOrbitRigidbody.gameObject.SetActive(false);
             }
         }
         return;
     }
     if (IsInCloseOrbit(ship)) {
         D.AssertNotNull(_closeOrbitSimulator);
         var isRemoved = _shipsInCloseOrbit.Remove(ship);
         D.Assert(isRemoved);
         D.Log(ShowDebugLog, "{0} has left close orbit around {1}.", ship.DebugName, DebugName);
         float shipDistance = Vector3.Distance(ship.Position, Position);
         float minOutsideOfOrbitCaptureRadius = Data.CloseOrbitOuterRadius - ship.CollisionDetectionZoneRadius_Debug;
         if (shipDistance > minOutsideOfOrbitCaptureRadius) {
             D.Warn("{0} is leaving orbit of {1} but is not within {2:0.0000}. Ship's current orbit distance is {3:0.0000}.",
             ship.DebugName, DebugName, minOutsideOfOrbitCaptureRadius, shipDistance);
         }
         if (_shipsInCloseOrbit.Count == Constants.Zero) {
             // Choose either to deactivate the OrbitSimulator or destroy it, but not both
             CloseOrbitSimulator.IsActivated = false;
             //DestroyOrbitSimulator();
         }
         return;
     }
     D.Error("{0}.HandleBrokeOrbit() called, but {1} not in orbit.", DebugName, ship.DebugName);
 }
Esempio n. 2
0
    public void AssumeHighOrbit(IShip_Ltd ship, FixedJoint shipOrbitJoint) {
        if (_shipsInHighOrbit == null) {
            _shipsInHighOrbit = new List<IShip_Ltd>();
        }
        _shipsInHighOrbit.Add(ship);

        Rigidbody highOrbitRigidbody;
        if (_emptySystemHighOrbitRigidbody != null) {
            D.Assert(!ParentSystem.Planets.Any());
            if (!_emptySystemHighOrbitRigidbody.gameObject.activeSelf) {
                _emptySystemHighOrbitRigidbody.gameObject.SetActive(true);
            }
            highOrbitRigidbody = _emptySystemHighOrbitRigidbody;
        }
        else {
            if (ParentSystem.Planets.Any()) {
                // Use the existing rigidbody used by the inner planet's celestial orbit simulator
                PlanetItem innermostPlanet = ParentSystem.Planets.MinBy(p => Vector3.SqrMagnitude(p.Position - Position)) as PlanetItem;
                highOrbitRigidbody = innermostPlanet.CelestialOrbitSimulator.OrbitRigidbody;
            }
            else {
                highOrbitRigidbody = GeneralFactory.Instance.MakeShipHighOrbitAttachPoint(gameObject);
                _emptySystemHighOrbitRigidbody = highOrbitRigidbody;
            }
        }
        shipOrbitJoint.connectedBody = highOrbitRigidbody;
    }
Esempio n. 3
0
 public bool IsInHighOrbit(IShip_Ltd ship) {
     if (_shipsInHighOrbit == null || !_shipsInHighOrbit.Contains(ship)) {
         return false;
     }
     return true;
 }
Esempio n. 4
0
 public void AssumeCloseOrbit(IShip_Ltd ship, FixedJoint shipOrbitJoint) {
     if (_shipsInCloseOrbit == null) {
         _shipsInCloseOrbit = new List<IShip_Ltd>();
     }
     _shipsInCloseOrbit.Add(ship);
     shipOrbitJoint.connectedBody = CloseOrbitSimulator.OrbitRigidbody;
 }
Esempio n. 5
0
 public virtual void HandleBrokeOrbit(IShip_Ltd ship) {
     if (IsInHighOrbit(ship)) {
         var isRemoved = _shipsInHighOrbit.Remove(ship);
         D.Assert(isRemoved);
         D.Log(ShowDebugLog, "{0} has left high orbit around {1}.", ship.DebugName, DebugName);
         return;
     }
     D.Error("{0}.HandleBrokeOrbit() called, but {1} not in orbit.", DebugName, ship.DebugName);
 }
Esempio n. 6
0
 public void AssumeHighOrbit(IShip_Ltd ship, FixedJoint shipOrbitJoint) {
     if (_shipsInHighOrbit == null) {
         _shipsInHighOrbit = new List<IShip_Ltd>();
     }
     _shipsInHighOrbit.Add(ship);
     ConnectHighOrbitRigidbodyToShipOrbitJoint(shipOrbitJoint);
 }
Esempio n. 7
0
 public ShipReport(ShipData data, Player player, IShip_Ltd item) : base(data, player, item) { }
Esempio n. 8
0
    public void AssumeHighOrbit(IShip_Ltd ship, FixedJoint shipOrbitJoint) {
        if (_shipsInHighOrbit == null) {
            _shipsInHighOrbit = new List<IShip_Ltd>();
        }
        _shipsInHighOrbit.Add(ship);

        if (_highOrbitRigidbody == null) {
            //D.Log(ShowDebugLog, "{0} is adding high orbit rigidbody for {1}.", DebugName, ship.DebugName);
            _highOrbitRigidbody = GeneralFactory.Instance.MakeShipHighOrbitAttachPoint(gameObject);
        }
        if (!_highOrbitRigidbody.gameObject.activeSelf) {
            _highOrbitRigidbody.gameObject.SetActive(true);
        }
        shipOrbitJoint.connectedBody = _highOrbitRigidbody;
    }