Пример #1
0
        private void ShortDistanceNavigate(PlayerMove_Sail __instance)
        {
            VectorLF3 dir = target.GetDirection(__instance.player);

            Sail.SetDir(__instance, dir);

            VectorLF3 advisePoint = VectorLF3.zero;

            if (AdvisePointIfOcclusion(__instance, ref advisePoint, shortNavUncoverRange))
            {
#if DEBUG
                ModDebug.Log("Planet Navigate ToAdvisePoint:" + advisePoint);
#endif
                dir = (advisePoint - __instance.player.uPosition).normalized;
                Sail.SetDir(__instance, dir);
                Sail.TrySpeedUp(this, __instance);
            }
            else
            {
                if (Target.IsFocusingNormalized(dir, __instance.player.uVelocity.normalized))
                {
#if DEBUG
                    ModDebug.Log("Short Navigate - Speed Up");
#endif
                    Sail.TrySpeedUp(this, __instance);
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Short Navigate - No Speed Up");
#endif
                }
            }
        }
Пример #2
0
        public void PlanetNavigation(PlayerMove_Sail __instance)
        {
            ModDebug.Assert(IsCurNavPlanet());
            player = __instance.player;

            if (IsCurNavPlanet())
            {
                double distance = (target.TargetPlanet.uPosition - __instance.player.uPosition).magnitude;

                if ((enableLocalWrap &&
                     distance > localWrapMinDistance &&
                     distance > (target.TargetPlanet.realRadius + longNavUncoverRange))
                    ||
                    target.IsLocalStarPlanet() == false)
                {
                    PlanetData localPlanet = GameMain.localPlanet;
                    if (localPlanet != null &&
                        target.TargetPlanet != null &&
                        localPlanet.id != target.TargetPlanet.id)
                    {
#if DEBUG
                        ModDebug.Log("Leave Local Planet");
#endif
                        VectorLF3 dir = (__instance.player.uPosition - localPlanet.uPosition).normalized;
                        Sail.SetDir(__instance, dir);
                    }
                    else
                    {
#if DEBUG
                        ModDebug.Log("Local Long Distance Navigation");
#endif
                        LongDistanceNavigate(__instance);
                    }
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Local Short Distance Navigation");
#endif
                    ShortDistanceNavigate(__instance);
                }
            }
            else
            {
                Arrive();
#if DEBUG
                ModDebug.Error("PlanetNavigation - No Target");
#endif
            }
        }
Пример #3
0
        public void PlanetNavigation(PlayerMove_Sail __instance)
        {
            ModDebug.Assert(IsCurNavPlanet);
            player = __instance.player;

            if (!IsCurNavPlanet)
            {
                Arrive();
#if DEBUG
                ModDebug.Error("Planet navigation - Error target");
#endif
                return;
            }

            if (NeedLocalLongDistanceNavigate(__instance))
            {
                PlanetData localPlanet = GameMain.localPlanet;
                if (localPlanet != null &&
                    target.TargetPlanet != null &&
                    localPlanet.id != target.TargetPlanet.id)
                {
#if DEBUG
                    ModDebug.Log("Leave Local Planet");
#endif
                    VectorLF3 dir = (__instance.player.uPosition - localPlanet.uPosition).normalized;
                    Sail.SetDir(__instance, dir);
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Local Long Distance Navigation");
#endif
                    LongDistanceNavigate(__instance);
                }

                return;
            }

#if DEBUG
            ModDebug.Log("Local Short Distance Navigation");
#endif
            ShortDistanceNavigate(__instance);
        }
Пример #4
0
        public void StarNavigation(PlayerMove_Sail __instance)
        {
            ModDebug.Assert(IsCurNavStar());
            player = __instance.player;

            if (IsCurNavStar())
            {
                PlanetData localPlanet = GameMain.localPlanet;
                if (localPlanet != null)
                {
#if DEBUG
                    ModDebug.Log("Leave Local Planet");
#endif
                    VectorLF3 dir = (__instance.player.uPosition - localPlanet.uPosition).normalized;
                    Sail.SetDir(__instance, dir);
                    return;
                }
                else
                {
                    if (DetermineArrive() && IsCloseToNearStar(__instance))
                    {
#if DEBUG
                        ModDebug.Log("StarNavigation Arrive");
#endif
                        Arrive();
                        Warp.TryLeaveWarp(__instance);
                        return;
                    }
                    else
                    {
                        LongDistanceNavigate(__instance);
                        return;
                    }
                }
            }
            else
            {
                Arrive();
#if DEBUG
                ModDebug.Error("StarNavigation - No Target");
#endif
            }
        }
Пример #5
0
        private void LongDistanceNavigate(PlayerMove_Sail __instance)
        {
            VectorLF3 dir = target.GetDirection(__instance.player);

            Sail.SetDir(__instance, dir);

            VectorLF3 advisePoint = VectorLF3.zero;

            if (AdvisePointIfOcclusion(__instance, ref advisePoint, longNavUncoverRange))
            {
#if DEBUG
                ModDebug.Log("LongDistanceNavigate - ToAdvisePoint:" + advisePoint);
#endif

                dir = (advisePoint - __instance.player.uPosition).normalized;
                Sail.SetDir(__instance, dir);
                Sail.TrySpeedUp(this, __instance);
            }
            else if (Target.IsFocusingNormalized(dir, __instance.player.uVelocity.normalized) && !__instance.player.warping)
            {
                if (__instance.player.mecha.coreEnergy >= wrapEnergylimit && Warp.TryWrap(this, __instance))
                {
#if DEBUG
                    ModDebug.Log("Enter Wrap");
#endif
                    return;
                }
                else if (IsCurNavPlanet && target.IsLocalStarPlanet == true)
                {
#if DEBUG
                    ModDebug.Log("Local Planet Navigate No Wrap Chance SpeedUp");
#endif
                    Sail.TrySpeedUp(this, __instance);
                    return;
                }
                else if (LongDistanceNavigateNeedSpeedUp())
                {
#if DEBUG
                    ModDebug.Log("Long Distance Navigate Need SpeedUp");
#endif
                    Sail.TrySpeedUp(this, __instance);
                }
                else
                {
#if DEBUG
                    ModDebug.Log("Long Distance Navigate No SpeedUp And Warp");
#endif
                }
            }

            bool LongDistanceNavigateNeedSpeedUp()
            {
                if (__instance.player.mecha.coreEnergy >= speedUpEnergylimit)
                {
                    if (__instance.player.mecha.thrusterLevel < THRUSTER_LEVEL_WARP)
                    {
                        return(true);
                    }
                    //else if (Warp.GetWarperCount(__instance) <= 0)
                    else if (!Warp.HasWarper(__instance))
                    {
                        return(true);
                    }
                    return(true);
                }
                //Prepare warp
                if (__instance.player.mecha.coreEnergy < wrapEnergylimit)
                {
                    return(false);
                }
                return(false);
            }
        }