Exemplo n.º 1
0
        public override void Move()
        {
            if (!m_weaponArmed)
            {
                m_mover.StopMove();
                return;
            }

            if (m_weapon_primary == null || m_weapon_primary.CubeBlock.Closed)
            {
                Log.DebugLog("no primary weapon");
                m_mover.StopMove();
                return;
            }

            if (m_currentTarget == null)
            {
                m_mover.StopMove();
                return;
            }

            if (m_orbiter == null)
            {
                if (m_navSet.DistanceLessThan(m_weaponRange_min * 2f))
                {
                    // we give orbiter a lower distance, so it will calculate orbital speed from that
                    m_orbiter = new Orbiter(m_pathfinder, m_navSet, m_currentTarget.Entity, m_weaponRange_min + FinalAltitude, m_currentTarget.HostileName());
                    // start further out so we can spiral inwards
                    m_finalOrbitAltitude = m_orbiter.Altitude;
                    m_orbiter.Altitude   = m_finalOrbitAltitude + InitialAltitude - FinalAltitude;
                    Log.DebugLog("weapon range: " + m_weaponRange_min + ", final orbit altitude: " + m_finalOrbitAltitude + ", initial orbit altitude: " + m_orbiter.Altitude, Logger.severity.DEBUG);
                }
                else
                {
                    m_mover.Thrust.Update();
                    Vector3 direction = m_mover.SignificantGravity() ?
                                        (Vector3)m_mover.Thrust.WorldGravity / -m_mover.Thrust.GravityStrength :
                                        Vector3.CalculatePerpendicularVector(Vector3.Normalize(m_weapon_primary_pseudo.WorldPosition - m_currentTarget.GetPosition()));
                    Vector3 offset = direction * (m_weaponRange_min + InitialAltitude);

                    m_pathfinder.MoveTo(m_currentTarget, offset);
                    return;
                }
            }

            Target current = m_weapon_primary.CurrentTarget;

            if ((current == null || current.Entity == null) && m_orbiter.Altitude > m_finalOrbitAltitude && m_navSet.DistanceLessThan(m_orbiter.OrbitSpeed * 0.5f))
            {
                Log.DebugLog("weapon range: " + m_weaponRange_min + ", final orbit altitude: " + m_finalOrbitAltitude + ", initial orbit altitude: " + m_orbiter.Altitude +
                             ", dist: " + m_navSet.Settings_Current.Distance + ", orbit speed: " + m_orbiter.OrbitSpeed, Logger.severity.TRACE);
                m_orbiter.Altitude -= 10f;
            }

            m_orbiter.Move();

            ////Log.DebugLog("moving to " + (m_currentTarget.predictPosition() + m_currentOffset), "Move()");
            //m_mover.CalcMove(m_weapon_primary_pseudo, m_currentTarget.GetPosition() + m_currentOffset, m_currentTarget.GetLinearVelocity());
        }
Exemplo n.º 2
0
        public void UpdateTarget(LastSeen enemy)
        {
            if (enemy == null)
            {
                Log.DebugLog("lost target", Logger.severity.DEBUG, condition: m_currentTarget != null);
                m_currentTarget = null;
                m_orbiter       = null;
                return;
            }

            if (m_currentTarget == null || m_currentTarget.Entity != enemy.Entity)
            {
                Log.DebugLog("new target: " + enemy.Entity.getBestName(), Logger.severity.DEBUG);
                m_currentTarget = enemy;
                m_navSet.Settings_Task_NavEngage.DestinationEntity = m_currentTarget.Entity;
            }
        }
Exemplo n.º 3
0
        public void UpdateTarget(LastSeen enemy)
        {
            if (enemy == null)
            {
                m_logger.debugLog(m_currentTarget != null, "lost target", Logger.severity.DEBUG);
                m_currentTarget = null;
                m_orbiter = null;
                return;
            }

            if (m_currentTarget == null || m_currentTarget.Entity != enemy.Entity)
            {
                m_logger.debugLog("new target: " + enemy.Entity.getBestName(), Logger.severity.DEBUG);
                m_currentTarget = enemy;
                m_navSet.Settings_Task_NavEngage.DestinationEntity = m_currentTarget.Entity;
            }
        }
Exemplo n.º 4
0
        public override void Move()
        {
            if (!m_weaponArmed)
            {
                m_mover.StopMove();
                return;
            }

            if (m_weapon_primary == null || m_weapon_primary.CubeBlock.Closed)
            {
                m_logger.debugLog("no primary weapon");
                m_mover.StopMove();
                return;
            }

            if (m_currentTarget == null)
            {
                m_mover.StopMove();
                return;
            }

            if (m_orbiter == null)
            {
                if (m_navSet.DistanceLessThan(m_weaponRange_min * 2f))
                {
                    // we give orbiter a lower distance, so it will calculate orbital speed from that
                    m_orbiter = new Orbiter(m_mover, m_navSet, m_weapon_primary_pseudo, m_currentTarget.Entity, m_weaponRange_min - 50f, m_currentTarget.HostileName());
                    // start further out so we can spiral inwards
                    m_finalOrbitAltitude = m_orbiter.Altitude;
                    m_orbiter.Altitude = m_finalOrbitAltitude + 250f;
                    m_logger.debugLog("weapon range: " + m_weaponRange_min + ", final orbit altitude: " + m_finalOrbitAltitude + ", initial orbit altitude: " + m_orbiter.Altitude, Logger.severity.DEBUG);
                }
                else
                {
                    Vector3D targetPosition = m_currentTarget.GetPosition();
                    Vector3D direction = Vector3D.Normalize(m_weapon_primary_pseudo.WorldPosition - targetPosition);
                    targetPosition += direction * m_weaponRange_min * 1.9f;

                    m_mover.CalcMove(m_weapon_primary_pseudo, targetPosition, m_currentTarget.Entity.Physics.LinearVelocity);
                    return;
                }
            }

            Target current = m_weapon_primary.CurrentTarget;
            if ((current == null || current.Entity == null) && m_orbiter.Altitude > m_finalOrbitAltitude && m_navSet.DistanceLessThan(m_orbiter.OrbitSpeed * 0.5f))
            {
                m_logger.debugLog("weapon range: " + m_weaponRange_min + ", final orbit altitude: " + m_finalOrbitAltitude + ", initial orbit altitude: " + m_orbiter.Altitude +
                    ", dist: " + m_navSet.Settings_Current.Distance + ", orbit speed: " + m_orbiter.OrbitSpeed, Logger.severity.TRACE);
                m_orbiter.Altitude -= 10f;
            }

            m_orbiter.Move();

            ////m_logger.debugLog("moving to " + (m_currentTarget.predictPosition() + m_currentOffset), "Move()");
            //m_mover.CalcMove(m_weapon_primary_pseudo, m_currentTarget.GetPosition() + m_currentOffset, m_currentTarget.GetLinearVelocity());
        }