コード例 #1
0
    private void AutopilotGoTo()
    {
        if (SelectedObject != null)
        {
            Vector3 gotoDest = Vector3.zero;
            if (SelectedObjectType == SelectedObjectType.Planet)
            {
                Planet  planet   = (Planet)SelectedObject;
                Vector3 distance = planet.transform.position - PlayerShip.transform.position;
                gotoDest = planet.transform.position - distance.normalized * (40f + planet.OriginalScale.x / 2f);
            }
            else if (SelectedObjectType == SelectedObjectType.Station)
            {
                StationBase station  = (StationBase)SelectedObject;
                Vector3     distance = station.transform.position - PlayerShip.transform.position;
                gotoDest = PlayerShip.transform.position + distance.normalized * (distance.magnitude - 20f);
            }

            if (gotoDest != Vector3.zero)
            {
                MacroAITask task = new MacroAITask();
                task.TaskType           = MacroAITaskType.Travel;
                task.TravelDestSystemID = GameManager.Inst.WorldManager.CurrentSystem.ID;
                task.TravelDestNodeID   = "";
                task.IsDestAStation     = false;
                Transform origin = GameObject.Find("Origin").transform;
                task.TravelDestCoord = new RelLoc(origin.position, gotoDest, origin);

                IsAutopilot             = true;
                PlayerParty.WaitTimer   = 0;
                PlayerParty.CurrentTask = task;

                PlayerParty.HasReachedDestNode = false;
                PlayerParty.DestNode           = GameManager.Inst.NPCManager.MacroAI.GetClosestNodeToLocation(task.TravelDestCoord.RealPos, GameManager.Inst.WorldManager.AllSystems[task.TravelDestSystemID]);
                Debug.Log("Autopilot dest node " + PlayerParty.DestNode.ID);
                PlayerAutopilot.Activate();
                _isMouseFlight = false;

                InputEventHandler.Instance.InputState = InputState.Autopilot;
            }
        }
    }
コード例 #2
0
        public static async Task RappelFromHeli()
        {
            var player = API.GetPlayerPed(-1);

            if (API.IsPedInAnyHeli(player))
            {
                var heli = API.GetVehiclePedIsIn(player, false);
                if (!Vehicles.GetPedSeat(heli, player, out int seat))
                {
                    return;
                }

                switch (seat)
                {
                case -1:
                    if (API.AreAnyVehicleSeatsFree(heli))
                    {
                        await Autopilot.Activate();

                        API.TaskRappelFromHeli(player, 0);
                    }
                    break;

                case 0:
                    if (Vehicles.GetFreeSeat(heli, out int goodSeat, true))
                    {
                        API.SetPedIntoVehicle(player, heli, goodSeat);
                        API.TaskRappelFromHeli(player, 0);
                    }
                    break;

                default:
                    API.TaskRappelFromHeli(player, 0);
                    break;
                }
            }
            else
            {
                Common.Notification("Player is not in a heli");
            }
        }