示例#1
0
        private static void CheckForDrownedVehicles()
        {
            var vehicles = VehicleManager.vehicles;

            for (var i = vehicles.Count - 1; i >= 0; i--)
            {
                if (!VehicleUtil.VehicleHasOwner(vehicles[i]))
                {
                    continue;
                }
                if (!vehicles[i].isDrowned)
                {
                    continue;
                }
                var vName        = vehicles[i].asset.vehicleName;
                var vId          = vehicles[i].asset.id;
                var vOwner       = vehicles[i].lockedOwner;
                var vehicleCount = DbManager.GetVehicleCount(vOwner.m_SteamID.ToString(), "Drown");
                if (vehicleCount >= Conf.DrownGarageSlot && Conf.DrownGarageSlot != -1)
                {
                    continue;
                }
                var drownedVehicleRegion = BarricadeManager.getRegionFromVehicle(vehicles[i]);
                GarageUtil.SaveVgVehicleToSql(vOwner.m_SteamID, "Drown", "Drowned", vehicles[i],
                                              drownedVehicleRegion);
                if (UnturnedPlayer.FromCSteamID(vOwner) != null)
                {
                    UnturnedPlayer.FromCSteamID(vOwner).SendChat(
                        Inst.Translate("rfgarage_autogarage_drown_success", vName, vId), MsgColor,
                        Conf.AnnouncerIconUrl);
                }
                Logger.LogWarning(
                    $"[RFGarage] {vName} [{vId}] has been added automatically to {vOwner.m_SteamID}'s garage due to Drown");
            }
        }
示例#2
0
        public static bool GetVehicleBySeat(UnturnedPlayer player, out InteractableVehicle currentVehicle, out BarricadeRegion vehicleBarricadeRegion)
        {
            currentVehicle         = player.CurrentVehicle;
            vehicleBarricadeRegion = null;
            if (currentVehicle == null)
            {
                return(false);
            }

            vehicleBarricadeRegion = BarricadeManager.getRegionFromVehicle(currentVehicle);
            return(true);
        }
示例#3
0
        public static bool GetVehicleByLook(UnturnedPlayer player, float distance, out InteractableVehicle lookVehicle, out BarricadeRegion lookVehicleBarricadeRegion)
        {
            lookVehicle = null;
            lookVehicleBarricadeRegion = null;
            var raycastInfo = DamageTool.raycast(new Ray(player.Player.look.aim.position, player.Player.look.aim.forward), distance, RayMasks.VEHICLE);

            if (raycastInfo.vehicle == null)
            {
                return(false);
            }

            lookVehicle = raycastInfo.vehicle;
            lookVehicleBarricadeRegion = BarricadeManager.getRegionFromVehicle(lookVehicle);
            return(true);
        }
示例#4
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            if (command.Length > 1)
            {
                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_invalid_parameter", Syntax), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;
            }

            var player = (UnturnedPlayer)caller;

            switch (command.Length)
            {
            case 0:
                Plugin.GarageAddAllQueueDict[player.CSteamID] = true;

                caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_ask_confirm"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                return;

            case 1:
                switch (command[0].ToLower())
                {
                case "confirm" when !Plugin.GarageAddAllQueueDict[player.CSteamID]:
                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_no_queue"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    return;

                case "confirm":
                {
                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_confirm"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    // Tuple < availableGarage, availableSlot >
                    var passedVehicles      = new List <InteractableVehicle>();
                    var blacklistedVehicles = new List <InteractableVehicle>();
                    var availableGarages    = GarageUtil.GetAllGarages(player);
                    foreach (var interactableVehicle in VehicleManager.vehicles.Where(interactableVehicle => interactableVehicle.lockedOwner.m_SteamID == player.CSteamID.m_SteamID))
                    {
                        GarageUtil.GarageAddAllChecks(player, interactableVehicle, out var response, out _);
                        switch (response)
                        {
                        case EResponseType.BLACKLIST_BARRICADE:
                        case EResponseType.BLACKLIST_TRUNK_ITEM:
                        case EResponseType.BLACKLIST_VEHICLE:
                            blacklistedVehicles.Add(interactableVehicle);
                            break;

                        case EResponseType.SUCCESS:
                            passedVehicles.Add(interactableVehicle);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }

                    var tupleGarages    = (from garage in availableGarages let garageOccupiedSlot = Plugin.DbManager.GetVehicleCount(player.CSteamID.m_SteamID.ToString(), garage.Name) where garage.Slot > garageOccupiedSlot select new Tuple <GarageModel, uint>(garage, garageOccupiedSlot)).ToList();
                    var vehicleIndex    = 0;
                    var successVehicles = new List <InteractableVehicle>();
                    foreach (var(garage, occupiedSlot) in tupleGarages)
                    {
                        var i = 0;
                        while (i < (garage.Slot - occupiedSlot) && vehicleIndex < passedVehicles.Count)
                        {
                            GarageUtil.SaveVgVehicleToSql(player.CSteamID.m_SteamID, garage.Name,
                                                          passedVehicles[vehicleIndex].asset.name, passedVehicles[vehicleIndex],
                                                          BarricadeManager.getRegionFromVehicle(passedVehicles[vehicleIndex]));
                            successVehicles.Add(passedVehicles[vehicleIndex]);
                            vehicleIndex++;
                            i++;
                        }
                    }

                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_success",
                                                          vehicleIndex, passedVehicles.Count - vehicleIndex), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    foreach (var vehicle in successVehicles)
                    {
                        caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_success_vehicle",
                                                              vehicle.asset.id, vehicle.asset.vehicleName), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    }
                    foreach (var vehicle in blacklistedVehicles)
                    {
                        caller.SendChat(Plugin.Inst.Translate("rfgarage_command_gadd_all_blacklist_vehicle",
                                                              vehicle.asset.id, vehicle.asset.vehicleName), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    }
                    passedVehicles.RemoveRange(0, vehicleIndex);
                    foreach (var vehicle in passedVehicles)
                    {
                        caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_fail_vehicle",
                                                              vehicle.asset.id, vehicle.asset.vehicleName), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    }
                    Plugin.GarageAddAllQueueDict[player.CSteamID] = false;
                    return;
                }

                case "abort":
                    Plugin.GarageAddAllQueueDict[player.CSteamID] = false;

                    caller.SendChat(Plugin.Inst.Translate("rfgarage_command_all_abort"), Plugin.MsgColor, Plugin.Conf.AnnouncerIconUrl);
                    return;
                }

                break;
            }
        }