Esempio n. 1
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length > 1)
            {
                throw new CommandWrongUsageException(Context);
            }

            ushort amount = 10;

            if (Context.Parameters.Length == 1)
            {
                amount = await Context.Parameters.GetAsync <ushort>(0);
            }

            UnturnedUser    uPlayer   = (UnturnedUser)Context.Actor;
            PlayerEquipment equipment = uPlayer.Player.Player.equipment;

            if (equipment.itemID == 0)
            {
                throw new UserFriendlyException(m_StringLocalizer["more:none"]);
            }

            Item item = new Item(equipment.itemID, EItemOrigin.ADMIN);

            await UniTask.SwitchToMainThread();

            for (int i = 0; i < amount; i++)
            {
                uPlayer.Player.Player.inventory.forceAddItem(item, true);
            }

            await PrintAsync(m_StringLocalizer["more:success",
                                               new { Amount = amount, Item = equipment.asset.itemName }]);
        }
        protected override async UniTask OnUnloadAsync()
        {
            await UniTask.SwitchToMainThread();

            PlayerInput.onPluginKeyTick -= OnKeyPressed;
            ro_Logger.LogInformation("Plugin unloaded correctly!");
        }
Esempio n. 3
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 1)
            {
                throw new CommandWrongUsageException(Context);
            }

            var searchTerm = Context.Parameters[0];
            var user       = await Context.Parameters.GetAsync <UnturnedUser>(0);

            if (user == null)
            {
                throw new UserFriendlyException(m_StringLocalizer["general:invalid_player", new { Player = searchTerm }]);
            }

            var callingPlayer = (UnturnedUser)Context.Actor;

            await UniTask.SwitchToMainThread();

            await user.Player.Player.TeleportToLocationAsync(callingPlayer.Player.Transform.Position.ToUnityEngineVector3());

            await user.PrintMessageAsync(m_StringLocalizer["tphere:successful_tp", new { Player = user.DisplayName }]);

            await user.PrintMessageAsync(m_StringLocalizer["tphere:successful_tp_other", new { Player = user.DisplayName }]);
        }
        private async UniTask RequestExpirationThread(ulong recipientID, ulong requesterID, int lifetime)
        {
            await UniTask.Delay(TimeSpan.FromMilliseconds(lifetime));

            if (!m_OpenRequests[recipientID].Contains(requesterID))
            {
                return;
            }

            m_OpenRequests[recipientID].Remove(requesterID);

            SteamPlayer requester = PlayerTool.getSteamPlayer(requesterID);

            if (requester == null)
            {
                return;
            }

            SteamPlayer recipient = PlayerTool.getSteamPlayer(recipientID);

            if (recipient == null)
            {
                return;
            }

            await UniTask.SwitchToMainThread();

            ChatManager.serverSendMessage(m_StringLocalizer["tpa:expired", new { Recipient = recipient.playerID.characterName }], Color.red, toPlayer: requester);
        }
Esempio n. 5
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 2)
            {
                throw new CommandWrongUsageException(Context);
            }

            string playerSearchTerm = Context.Parameters[0];

            if (!PlayerTool.tryGetSteamPlayer(playerSearchTerm, out SteamPlayer recipient))
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:invalid_player", new { Player = playerSearchTerm }]);
            }

            string vehicleSearchTerm = Context.Parameters[1];

            if (!UnturnedAssetHelper.GetVehicle(vehicleSearchTerm, out VehicleAsset vehicle))
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:invalid",
                                                                  new { Vehicle = vehicleSearchTerm }]);
            }

            await UniTask.SwitchToMainThread();

            if (VehicleTool.giveVehicle(recipient.player, vehicle.id))
            {
                await Context.Actor.PrintMessageAsync(m_StringLocalizer["vehicle:success_given",
                                                                        new { Vehicle = vehicle.vehicleName, Player = recipient.playerID.characterName }]);
            }
            else
            {
                throw new UserFriendlyException(m_StringLocalizer["vehicle:failure"]);
            }
        }
Esempio n. 6
0
        public async UniTask <Result> InvokeAsync(Texture inputTex, PoseDetect.Result pose, CancellationToken cancellationToken, PlayerLoopTiming timing)
        {
            cropMatrix = CalcCropMatrix(ref pose, ref resizeOptions);
            RenderTexture rt = resizer.Resize(
                inputTex, resizeOptions.width, resizeOptions.height, true,
                cropMatrix,
                TextureResizer.GetTextureST(inputTex, resizeOptions));

            await ToTensorAsync(rt, input0, false, cancellationToken);

            await UniTask.SwitchToThreadPool();

            interpreter.SetInputTensorData(0, input0);
            interpreter.Invoke();
            interpreter.GetOutputTensorData(0, output0);
            interpreter.GetOutputTensorData(1, output1);
            if (options.useWorldLandmarks)
            {
                interpreter.GetOutputTensorData(3, output3);
                interpreter.GetOutputTensorData(4, output4);
            }
            var result = GetResult();
            await UniTask.SwitchToMainThread(timing, cancellationToken);

            return(result);
        }
Esempio n. 7
0
        protected override async UniTask OnExecuteAsync()
        {
            var targetActor = Context.Parameters.Count == 2
                ? await Context.Parameters.GetAsync <UnturnedUser>(0)
                : Context.Actor as UnturnedUser;

            if (targetActor != Context.Actor && await CheckPermissionAsync("other") != PermissionGrantResult.Grant)
            {
                throw new NotEnoughPermissionException(Context, "other");
            }

            if (targetActor == null)
            {
                return;
            }

            var speed = await Context.Parameters.GetAsync <float>(Context.Parameters.Count - 1);

            await UniTask.SwitchToMainThread();

            targetActor.Player.Player.movement.sendPluginSpeedMultiplier(speed);

            if (Context.Actor != targetActor)
            {
                await PrintAsync(m_StringLocalizer["speed:instigator", new
                                                   {
                                                       User = targetActor,
                                                       Speed = speed
                                                   }]);
            }
            await targetActor.PrintMessageAsync(m_StringLocalizer["speed:target", new { Speed = speed }]);
        }
Esempio n. 8
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length < 1)
            {
                throw new CommandWrongUsageException(Context, m_StringLocalizer);
            }

            await UniTask.SwitchToMainThread();

            StringBuilder playersNotFound = new StringBuilder();

            for (int i = 0; i < Context.Parameters.Length; i++)
            {
                var user = await Context.Parameters.GetAsync <UnturnedUser>(i);

                if (user == null)
                {
                    playersNotFound.Append($"{Context.Parameters[i]}, ");
                    continue;
                }

                user.Player.Player.skills.ServerUnlockAllSkills();
                await Context.Actor.PrintMessageAsync(m_StringLocalizer["maxskills:granted_other", new { Player = user.DisplayName }]);
            }

            if (playersNotFound.Length != 0)
            {
                playersNotFound.Remove(playersNotFound.Length - 2, 2);
                throw new UserFriendlyException(m_StringLocalizer["commands:failed_players", new { Players = playersNotFound.ToString() }]);
            }
        }
Esempio n. 9
0
        public async UniTask Listen(int port)
        {
            try
            {
                listener = TcpListener.Create(port);
                listener.Start();

                listenCompletion = AutoResetUniTaskCompletionSource.Create();
                var acceptThread = new Thread(AcceptLoop)
                {
                    IsBackground = true
                };
                acceptThread.Start();

                Started.Invoke();

                await listenCompletion.Task;

                await UniTask.SwitchToMainThread();
            }
            finally
            {
                listener?.Stop();
            }
        }
Esempio n. 10
0
        public Task <IVehicle> SpawnVehicleAsync(Vector3 position, string vehicleId, IVehicleState state = null)
        {
            async UniTask <IVehicle> VehicleSpawnTask()
            {
                await UniTask.SwitchToMainThread();

                if (!ushort.TryParse(vehicleId, out var parsedVehicleId))
                {
                    throw new Exception($"Invalid vehicle id: {vehicleId}");
                }

                var vehicleAsset = (ItemAsset)Assets.find(EAssetType.ITEM, parsedVehicleId);

                if (vehicleAsset == null || vehicleAsset.isPro)
                {
                    return(null);
                }

                if (state != null)
                {
                    // todo: use state like VehicleManager.load() does
                }

                var vehicle = VehicleManager.spawnVehicleV2(vehicleAsset.id, position.ToUnityVector(), Quaternion.identity);

                return(new UnturnedVehicle(vehicle));
            }

            return(VehicleSpawnTask().AsTask());
        }
Esempio n. 11
0
    async UniTaskVoid DownloadLanguage()
    {
        if (Directory.Exists(data.saveFilePath))
        {
            Directory.Delete(data.saveFilePath, true);
        }
        Directory.CreateDirectory(data.saveFilePath);

        await UniTask.SwitchToMainThread();

        for (int i = 0; i < data.itemList.Count; i++)
        {
            var languageItem = data.itemList[i];
            if (languageItem.download)
            {
                var path    = $"{data.downloadPath}/export?format=csv&gid={languageItem.sheetId}";
                var request = await UnityWebRequest.Get(path).SendWebRequest().ToUniTask(Progress.CreateOnlyValueChanged <float>((percent) =>
                {
                    contentDownloading = $"{languageItem.sheetName} => {percent* 100}%";
                }));

                TextProcessing(request.downloadHandler.text, i);
            }
        }

        contentDownloading = string.Empty;

        EditorUtility.DisplayDialog("Download language",
                                    "Download language finish", "OK");
        AssetDatabase.Refresh();
    }
Esempio n. 12
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 0)
            {
                throw new CommandWrongUsageException(Context);
            }

            UnturnedUser uPlayer        = (UnturnedUser)Context.Actor;
            var          currentVehicle = uPlayer.Player.Player.movement.getVehicle();

            if (currentVehicle != null)
            {
                await UniTask.SwitchToMainThread();

                RepairVehicle(currentVehicle);
                await uPlayer.PrintMessageAsync(m_StringLocalizer["repair:vehicle:current"]);
            }
            else
            {
                PlayerLook  look    = uPlayer.Player.Player.look;
                RaycastInfo raycast = DamageTool.raycast(new Ray(look.aim.position, look.aim.forward),
                                                         100f, RayMasks.VEHICLE);

                if (raycast.vehicle == null)
                {
                    throw new UserFriendlyException(m_StringLocalizer["repair:vehicle:none"]);
                }

                await UniTask.SwitchToMainThread();

                RepairVehicle(raycast.vehicle);
                await uPlayer.PrintMessageAsync(m_StringLocalizer["repair:vehicle:looking"]);
            }
        }
        public Task <IReadOnlyCollection <IBuildable> > GetBuildablesAsync()
        {
            async UniTask <IReadOnlyCollection <IBuildable> > GetBuildablesTask()
            {
                await UniTask.SwitchToMainThread();

                var barricadeRegions = BarricadeManager.regions.Cast <BarricadeRegion>()
                                       .Concat(BarricadeManager.vehicleRegions)
                                       .ToList();

                var structureRegions = StructureManager.regions.Cast <StructureRegion>()
                                       .ToList();

                var barricadeDrops = barricadeRegions.SelectMany(brd => brd.drops).ToList();
                var structureDrops = structureRegions.SelectMany(str => str.drops).ToList();

                return(barricadeDrops
                       .Select(d => new UnturnedBarricadeBuildable(d))
                       .Cast <UnturnedBuildable>()
                       .Concat(structureDrops.Select(d => new UnturnedStructureBuildable(d)))
                       .Select(d => d !)
                       .ToList());
            }

            return(GetBuildablesTask().AsTask());
        }
        protected override async Task OnExecuteAsync()
        {
            var unturnedUser = (UnturnedUser)Context.Actor;
            await UniTask.SwitchToMainThread();

            Provider.kick(unturnedUser.SteamId, m_StringLocalizer["ldm_cmds:success:exit"]);
        }
Esempio n. 15
0
        public virtual Task <bool> SetRotationAsync(Vector3 rotation)
        {
            async UniTask <bool> RotationTask()
            {
                if (!ValidationHelper.IsValid(rotation))
                {
                    return(false);
                }

                await UniTask.SwitchToMainThread();

                var unityRotation = Quaternion.Euler(rotation.ToUnityVector());

                if (m_Rigidbody != null)
                {
                    m_Rigidbody.rotation = unityRotation;
                }
                else
                {
                    m_Transform.rotation = unityRotation;
                }

                return(true);
            }

            return(RotationTask().AsTask());
        }
Esempio n. 16
0
        protected override async Task OnExecuteAsync()
        {
            UnturnedUser user = (UnturnedUser)Context.Actor;
            uint         id   = await Context.Parameters.GetAsync <uint>(0);

            PlayerBunch?pBunch = await m_KeysManager.TryGetPlayerBunch(user.SteamId.ToString());

            if (pBunch == null || pBunch.VehiclesKey.Count == 0)
            {
                await user.PrintMessageAsync(m_StringLocalizer["translations:no_key"], System.Drawing.Color.Red, false, "");
            }
            else if (!pBunch.VehiclesKey.Any(v => v.InstanceId == id))
            {
                InteractableVehicle vehicle = VehicleManager.findVehicleByNetInstanceID(id);
                if (vehicle != null && !vehicle.isExploded && !vehicle.isDead)
                {
                    await UniTask.SwitchToMainThread();

                    await user.PrintMessageAsync(m_StringLocalizer["translations:vehicle_position", new { vehicle = pBunch.VehiclesKey.Where(z => z.InstanceId == id).First().VehicleName }], System.Drawing.Color.Green);

                    user.Player.Player.quests.replicateSetMarker(true, vehicle.transform.position, "Your vehicle!");
                }
                else
                {
                    await user.PrintMessageAsync(m_StringLocalizer["translations:vehicle_explode"]);

                    await m_KeysManager.TryRemoveKeyFromBunch(user.SteamId.ToString(), id);
                }
            }
            else
            {
                await user.PrintMessageAsync(m_StringLocalizer["translations:no_vehicle", new { vehicleID = id }]);
            }
        }
Esempio n. 17
0
        public virtual Task <bool> SetPositionAsync(Vector3 targetPosition)
        {
            async UniTask <bool> PositionTask()
            {
                if (!ValidationHelper.IsValid(targetPosition))
                {
                    return(false);
                }

                await UniTask.SwitchToMainThread();

                var unityPosition = targetPosition.ToUnityVector();

                if (m_Rigidbody != null)
                {
                    m_Rigidbody.position = unityPosition;
                }
                else
                {
                    m_Transform.position = unityPosition;
                }

                return(true);
            }

            return(PositionTask().AsTask());
        }
        protected override async Task OnExecuteAsync()
        {
            var user = (UnturnedUser)Context.Actor;

            if (Context.Parameters.Length <= 0)
            {
                throw new UserFriendlyException("Please specfiy a player!");
            }
            else if (Context.Parameters.Length <= 1)
            {
                throw new UserFriendlyException("Please specify a link!");
            }
            var targetname = await Context.Parameters.GetAsync <string>(0);

            var url = await Context.Parameters.GetAsync <string>(1);

            var target = (UnturnedUser)await ro_UserManager.FindUserAsync(KnownActorTypes.Player, targetname, UserSearchMode.FindByNameOrId);

            await UniTask.SwitchToMainThread();

            if (Context.Parameters.Length == 3)
            {
                var description = await Context.Parameters.GetAsync <string>(2);

                target.Player.sendBrowserRequest(description, url);
            }
            target.Player.sendBrowserRequest("", url);
        }
Esempio n. 19
0
        async UniTask OnChanged(object source, FileSystemEventArgs args, string root)
        {
            await UniTask.SwitchToMainThread();

            //Change
            if (File.Exists(args.FullPath) || Directory.Exists(args.FullPath))
            {
                //Directory change
                if (File.GetAttributes(args.FullPath) == FileAttributes.Directory)
                {
                    OnDirectoryChanged?.Invoke(args.FullPath, root);
                }
                //File change
                else
                {
                    string fileExtension = $"*{Path.GetExtension(args.FullPath)}";
                    for (int i = 0; i < FileExtensions.Length; i++)
                    {
                        if (fileExtension == FileExtensions[i])
                        {
                            OnFileChanged?.Invoke(args.FullPath, root);
                            break;
                        }
                    }
                }
            }
            //Remove
            else
            {
                OnDeleted?.Invoke(args.FullPath, root);
            }
        }
Esempio n. 20
0
        protected override async UniTask OnExecuteAsync()
        {
            // User either didn't provide an item or provided too much information
            if (Context.Parameters.Length < 1 || Context.Parameters.Length > 2)
            {
                throw new CommandWrongUsageException(Context);
            }

            string rawInput = Context.Parameters[0];
            var    item     = await m_ItemDirectory.FindByNameOrIdAsync(rawInput);

            if (item == null)
            {
                throw new CommandWrongUsageException(m_StringLocalizer["item:invalid", new { Item = rawInput }]);
            }

            var amount = Context.Parameters.Length == 2 ? await Context.Parameters.GetAsync <ushort>(1) : (ushort)1;

            if (!m_Configuration.GetItemAmount(amount, out amount))
            {
                throw new UserFriendlyException(m_StringLocalizer["items:too_much", new { UpperLimit = amount }]);
            }

            UnturnedUser uPlayer = (UnturnedUser)Context.Actor;

            await UniTask.SwitchToMainThread();

            for (ushort u = 0; u < amount; u++)
            {
                Item uItem = new(item.ItemAsset.id, EItemOrigin.ADMIN);
                uPlayer.Player.Player.inventory.forceAddItem(uItem, true);
            }

            await PrintAsync(m_StringLocalizer["item:success", new { Amount = amount, Item = item.ItemName, ID = item.ItemAssetId }]);
        }
Esempio n. 21
0
        protected override async UniTask OnUnloadAsync()
        {
            await UniTask.SwitchToMainThread();

            Level.onPostLevelLoaded -= OnPostLevelLoaded;
            m_Logger.LogInformation("LobbyEdit by Tortellio has been unloaded.");
        }
        public async UniTask <Result> InvokeAsync(Texture inputTex, PoseDetect.Result pose, bool useFilter, CancellationToken cancellationToken, PlayerLoopTiming timing)
        {
            var options = (inputTex is WebCamTexture)
                ? resizeOptions.GetModifedForWebcam((WebCamTexture)inputTex)
                : resizeOptions;

            cropMatrix = CalcCropMatrix(ref pose, ref options);
            RenderTexture rt = resizer.Resize(
                inputTex, options.width, options.height, true,
                cropMatrix,
                TextureResizer.GetTextureST(inputTex, options));

            await ToTensorAsync(rt, input0, false, cancellationToken);

            await UniTask.SwitchToThreadPool();

            interpreter.SetInputTensorData(0, input0);
            interpreter.Invoke();
            interpreter.GetOutputTensorData(0, output0);
            interpreter.GetOutputTensorData(1, output1);

            var result = GetResult(useFilter);
            await UniTask.SwitchToMainThread(timing, cancellationToken);

            return(result);
        }
Esempio n. 23
0
        public Task PrintMessageAsync(string message, Color color, bool isRich, string iconUrl)
        {
            async UniTask PrintMessageTask()
            {
                var lines = message.Replace(Environment.NewLine, "\n").Split('\n');

                if (lines.Length == 0)
                {
                    return;
                }

                await UniTask.SwitchToMainThread();

                foreach (var line in lines)
                {
                    var lineToDisplay = line.Trim();
                    if (lineToDisplay.Length == 0)
                    {
                        continue;
                    }

                    foreach (var lline in WrapLine(line))
                    {
                        ChatManager.serverSendMessage(
                            text: lline,
                            color: color.ToUnityColor(),
                            toPlayer: Player.SteamPlayer,
                            iconURL: iconUrl,
                            useRichTextFormatting: isRich);
                    }
                }
            }

            return(PrintMessageTask().AsTask());
        }
Esempio n. 24
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length > 1)
            {
                throw new CommandWrongUsageException(Context);
            }

            UnturnedUser uPlayer          = (UnturnedUser)Context.Actor;
            ulong        recipientSteamID = uPlayer.SteamId.m_SteamID;

            SteamPlayer requester;

            switch (Context.Parameters.Length)
            {
            case 0:
                if (!m_TpaRequestManager.IsRequestOpen(recipientSteamID))
                {
                    throw new UserFriendlyException(m_StringLocalizer["tpa:no_requests"]);
                }

                ulong firstRequester = m_TpaRequestManager.AcceptRequest(recipientSteamID);
                requester = PlayerTool.getSteamPlayer(firstRequester);

                if (requester == null)
                {
                    throw new UserFriendlyException(m_StringLocalizer["tpa:disconnected",
                                                                      new { Requester = firstRequester.ToString() }]);
                }
                break;

            case 1:
                string requesterName = Context.Parameters[0];
                if (!PlayerTool.tryGetSteamPlayer(requesterName, out requester))
                {
                    throw new UserFriendlyException(m_StringLocalizer["tpa:invalid_recipient",
                                                                      new { Recipient = requesterName }]);
                }

                if (!m_TpaRequestManager.IsRequestOpen(recipientSteamID, requester.playerID.steamID.m_SteamID))
                {
                    throw new UserFriendlyException(m_StringLocalizer["tpa:no_requests_from",
                                                                      new { Requester = requester.playerID.characterName }]);
                }
                break;

            default:
                throw new UserFriendlyException("This is a placeholder so that we can reassure the compiler that requester will never be null.");
            }

            //TODO: Change name to be less misleading.
            m_TpaRequestManager.AcceptRequest(recipientSteamID, requester.playerID.steamID.m_SteamID);

            await uPlayer.PrintMessageAsync(m_StringLocalizer["tpa:denied_self",
                                                              new { Requester = requester.playerID.characterName }]);

            await UniTask.SwitchToMainThread();

            ChatManager.serverSendMessage(m_StringLocalizer["tpa:denied_other",
                                                            new { Recipient = uPlayer.DisplayName }], Color.red, toPlayer: requester, useRichTextFormatting: true);
        }
Esempio n. 25
0
        public Task <IItemDrop?> SpawnItemAsync(Vector3 position, string itemId, IItemState?state = null)
        {
            async UniTask <IItemDrop?> SpawnItemTask()
            {
                ValidateState(state);

                if (!ushort.TryParse(itemId, out var parsedItemId))
                {
                    throw new ArgumentException($"Invalid Item ID: {itemId}", nameof(itemId));
                }

                var item = CreateItem(parsedItemId, state, out _);

                if (item == null)
                {
                    return(null);
                }

                await UniTask.SwitchToMainThread();

                return(DropItem(item, position));
            }

            return(SpawnItemTask().AsTask());
        }
Esempio n. 26
0
        public Task <IItemInstance?> GiveItemAsync(IInventory inventory, string itemId, IItemState?state = null)
        {
            async UniTask <IItemInstance?> GiveItemTask()
            {
                ValidateState(state);

                await UniTask.SwitchToMainThread();

                if (!ushort.TryParse(itemId, out var parsedItemId))
                {
                    throw new ArgumentException($"Invalid Item ID: {itemId}", nameof(itemId));
                }

                if (inventory is UnturnedPlayerInventory playerInventory)
                {
                    var item = CreateItem(parsedItemId, state);
                    if (item == null)
                    {
                        return(null);
                    }

                    if (!TryAddItem(item, playerInventory, out var itemJar))
                    {
                        return(DropItem(item, playerInventory.Player.transform.position.ToSystemVector()));
                    }

                    return(new UnturnedInventoryItem(itemJar !, new UnturnedItem(item)));
                }

                throw new NotSupportedException($"Inventory type not supported: {inventory.GetType().FullName}");
            }

            return(GiveItemTask().AsTask());
        }
Esempio n. 27
0
        public Task <bool> SetPositionAsync(Vector3 position, Vector3 rotation)
        {
            async UniTask <bool> TeleportationTask()
            {
                await UniTask.SwitchToMainThread();

                if (Player.transform.position == position.ToUnityVector() &&
                    Player.transform.rotation.eulerAngles == rotation.ToUnityVector())
                {
                    return(true);
                }

                if (!ValidationHelper.IsValid(position) || !ValidationHelper.IsValid(rotation))
                {
                    return(false);
                }

                var rotationAngle = MeasurementTool.angleToByte(rotation.Y);

                Player.channel.send("askTeleport", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, position, rotationAngle);
                return(true);
            }

            return(TeleportationTask().AsTask());
        }
Esempio n. 28
0
        protected override async UniTask OnUnloadAsync()
        {
            await UniTask.SwitchToMainThread();

            BarricadeManager.onDeployBarricadeRequested -= OnDeployBarricade;
            ro_Logger.LogInformation("Plugin unloaded correctly!");
        }
Esempio n. 29
0
        protected override async UniTask OnExecuteAsync()
        {
            var user = (UnturnedUser)Context.Actor;
            var look = user.Player.Player.look;

            await UniTask.SwitchToMainThread();

            if (!PhysicsUtility.raycast(new(look.getEyesPosition(), look.aim.forward),
                                        out var hit, 8f, RayMasks.BARRICADE | RayMasks.STRUCTURE | RayMasks.VEHICLE))
            {
                return;
            }

            var vehicle = hit.collider.GetComponent <InteractableVehicle>();

            if (vehicle != null)
            {
                VehicleManager.askVehicleDestroy(vehicle);
                return;
            }

            if (BarricadeManager.tryGetInfo(hit.transform, out var x, out var y, out var plant, out var index, out var region))
            {
                BarricadeManager.destroyBarricade(region, x, y, plant, index);
                return;
            }

            if (StructureManager.tryGetInfo(hit.transform, out x, out y, out index, out var structureRegion))
            {
                StructureManager.destroyStructure(structureRegion, x, y, index, Vector3.zero);
                return;
            }

            await PrintAsync(m_StringLocalizer["destroy:invalid"]);
        }
Esempio n. 30
0
        public async UniTask TelportPlayer(UnturnedUser target, UnturnedUser player) // player TO target
        {
            int interval = m_Configuration.GetSection("plugin_configuration:tpainterval").Get <int>() - 3;
            await Task.Delay(TimeSpan.FromSeconds(interval));

            await player.PrintMessageAsync("3...");

            await Task.Delay(TimeSpan.FromSeconds(1));

            await player.PrintMessageAsync("2...");

            await Task.Delay(TimeSpan.FromSeconds(1));

            await player.PrintMessageAsync("1...");

            await player.PrintMessageAsync(m_StringLocalizer["plugin_translation:tpa_now"]);

            await UniTask.SwitchToMainThread();

            if (!target.Player.IsAlive)
            {
                await player.PrintMessageAsync(m_StringLocalizer["plugin_translation:tpa_error_target_dead"]);
            }
            else if (!player.Player.IsAlive)
            {
                await player.PrintMessageAsync(m_StringLocalizer["plugin_translation:tpa_error_user_dead"]);
            }
            else
            {
                player.Player.Player.teleportToLocationUnsafe(target.Player.Player.transform.position, target.Player.Player.look.yaw);
            }
        }