Exemplo n.º 1
0
 protected void SetShipSpeed(Ship ship, ShipSpeedState sss)
 {
     if (ship == null)
     {
         return;
     }
     ship.Maneuvering.SpeedState = sss;
 }
Exemplo n.º 2
0
        public override bool OnEngineMessage(InteropMessageID messageId, ScriptMessageReader message)
        {
            switch (messageId)
            {
            case InteropMessageID.IMID_SCRIPT_OBJECT_SETPROP:
                string str = message.ReadString();
                if (str == "Position")
                {
                    this._position = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                    return(true);
                }
                if (str == "ShipSpeedScale")
                {
                    this._shipSpeedState = (ShipSpeedState)message.ReadInteger();
                    return(true);
                }
                if (str == "TargetFacingAngle")
                {
                    this._targetFacingAngle = (TargetFacingAngle)message.ReadInteger();
                    return(true);
                }
                break;

            case InteropMessageID.IMID_SCRIPT_MANEUVER_INFO:
                this._position    = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                this._rotation    = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                this._velocity    = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                this._destination = new Vector3(message.ReadSingle(), message.ReadSingle(), message.ReadSingle());
                return(true);

            default:
                App.Log.Warn("Unhandled message (id=" + (object)messageId + ").", "combat");
                break;
            }
            return(false);
        }
Exemplo n.º 3
0
        protected override void OnAttackUpdate(int framesElapsed)
        {
            if (this.m_TaskGroupObjective == null || this.m_TaskGroupObjective.m_Planet == null)
            {
                return;
            }
            foreach (Ship ship in this.m_Ships)
            {
                if (ship.Target != this.m_TaskGroupObjective.m_Planet)
                {
                    this.SetNewTarget(ship, (IGameObject)this.m_TaskGroupObjective.m_Planet);
                }
            }
            Vector3 currentPosition = this.GetCurrentPosition();
            Vector3 safeDestination = this.m_CommanderAI.GetSafeDestination(currentPosition, this.m_TaskGroupObjective.m_Planet.Parameters.Position);
            Vector3 destFacing      = safeDestination - currentPosition;

            destFacing.Y = 0.0f;
            double num1 = (double)destFacing.Normalize();

            this.SetFUP(safeDestination, destFacing);
            float num2 = 15000f;
            float num3 = !this.m_CommanderAI.EnemiesPresentInSystem ? 15000f : 100000f;
            float num4 = num2 * num2;
            float num5 = num3 * num3;

            foreach (Ship ship in this.m_Ships)
            {
                ShipSpeedState sss = (double)(ship.Position - safeDestination).LengthSquared > (double)num5 ? ShipSpeedState.Overthrust : ShipSpeedState.Normal;
                if (sss == ShipSpeedState.Overthrust && ship.TaskGroup != null && ship.TaskGroup.EnemyGroupInContact != null && (double)(ship.Position - ship.TaskGroup.EnemyGroupInContact.m_LastKnownPosition).LengthSquared < (double)num4)
                {
                    sss = ShipSpeedState.Normal;
                }
                this.SetShipSpeed(ship, sss);
            }
        }
Exemplo n.º 4
0
 public ShipManeuvering()
 {
     this._shipSpeedState = ShipSpeedState.Normal;
     this._retreatData    = new RetreatData();
 }