示例#1
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"]);
            }
        }
示例#2
0
        private void OnDamageStructureRequested(CSteamID instigatorSteamId, Transform structureTransform, ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            if (!StructureManager.tryGetInfo(structureTransform, out _, out _, out var index,
                                             out var region, out var drop))
            {
                return;
            }
            {
                var data      = region.structures[index];
                var buildable = new UnturnedStructureBuildable(data, drop);

                var nativePlayer = PlayerTool.getPlayer(instigatorSteamId);
                var player       = GetUnturnedPlayer(nativePlayer);

                var @event = pendingTotalDamage >= buildable.State.Health
                    ? (UnturnedBuildableDamagingEvent) new UnturnedStructureDestroyingEvent(buildable,
                                                                                            pendingTotalDamage, damageOrigin, player !, instigatorSteamId)
                    : new UnturnedStructureDamagingEvent(buildable, pendingTotalDamage, damageOrigin, player !,
                                                         instigatorSteamId);

                @event.IsCancelled = !shouldAllow;

                Emit(@event);

                pendingTotalDamage = @event.DamageAmount;
                shouldAllow        = [email protected];
            }
        }
        private static void OnPlayerDied(PlayerLife sender, EDeathCause cause, ELimb limb, CSteamID instigator)
        {
            var killedSteamPlayer = sender.channel.owner;
            var combat            = CombatManager.CombatTracker.ContainsKey(killedSteamPlayer) ? CombatManager.CombatTracker[killedSteamPlayer] : null;

            if (combat != null && PlayerTool.getSteamPlayer(instigator) == null &&
                DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() -
                combat.LastHit <
                Main.Config.CombatExpiration)
            {
                instigator = combat.Aggressor.playerID.steamID;
            }

            var killInfo = new PlayerDeath(killedSteamPlayer, instigator, cause);

            var killer = PlayerTool.getSteamPlayer(instigator);

            if (killer != null)
            {
                killInfo.KillerShotsHit   = CombatManager.Accuracies.ContainsKey(killer) ? CombatManager.Accuracies[killer].ShotsHit : 0;
                killInfo.KillerShotsFired = CombatManager.Accuracies.ContainsKey(killer) ? CombatManager.Accuracies[killer].ShotsFired : 0;
                UnityThread.executeCoroutine(CaptureScreen(killInfo, killer));
            }
            else
            {
                var socketData = new SocketData("PlayerDeath", JsonConvert.SerializeObject(killInfo));
                SocketManager.Emit(socketData);
            }
        }
        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);
        }
        private void OnDamageBarricadeRequested(CSteamID instigatorSteamId, Transform barricadeTransform,
                                                ref ushort pendingTotalDamage, ref bool shouldAllow, EDamageOrigin damageOrigin)
        {
            var drop = BarricadeManager.FindBarricadeByRootTransform(barricadeTransform);

            if (drop == null)
            {
                return;
            }

            var buildable = new UnturnedBarricadeBuildable(drop);

            var nativePlayer = PlayerTool.getPlayer(instigatorSteamId);
            var player       = GetUnturnedPlayer(nativePlayer);

            var @event = pendingTotalDamage >= buildable.State.Health
                ? (UnturnedBuildableDamagingEvent) new UnturnedBarricadeDestroyingEvent(buildable, pendingTotalDamage,
                                                                                        damageOrigin, player)
                : new UnturnedBarricadeDamagingEvent(buildable, pendingTotalDamage, damageOrigin, player);

            @event.IsCancelled = !shouldAllow;

            Emit(@event);

            pendingTotalDamage = @event.DamageAmount;
            shouldAllow        = [email protected];
        }
        private static IEnumerator BanPlayerCoroutine(SteamPlayer executor, string target)
        {
            var ip = 0u;

            if (PlayerTool.tryGetSteamPlayer(target, out var steamPlayer))
            {
                ip = steamPlayer.getIPv4AddressOrZero();
            }
            PlayerTool.tryGetSteamID(target, out var cSteamID);

            var steamId = steamPlayer?.playerID.steamID ?? cSteamID;

            if (!steamId.IsValid())
            {
                if (executor != null)
                {
                    ChatManager.SendServerMessage("Target not found", executor, EChatMode.SAY);
                }
                else
                {
                    CommandWindow.LogError("Target not found");
                }
                yield break;
            }

            Provider.requestBanPlayer(Provider.server, steamId, ip, "Banned", SteamBlacklist.PERMANENT);
            var banData = new SocketData("BanPlayer", steamId.ToString());

            SocketManager.Emit(banData);
            ChatManager.SendServerMessage("Banned target successfully", executor, EChatMode.SAY);

            yield return(null);
        }
示例#7
0
        protected override void execute(CSteamID executor, string parameter)
        {
            SteamPlayer ply = PlayerTool.getSteamPlayer(executor);

            if (ply is null)
            {
                return;
            }
            TTTPlayer tttplayer = PlayerManager.GetTTTPlayer(executor);

            switch (parameter)
            {
            case "t":
                tttplayer.Role = PlayerRole.TRAITOR;
                tttplayer.SendMessage("Role set to traitor");
                InterfaceManager.ToggleShop(ply.player, tttplayer, 8501);
                break;

            case "d":
                tttplayer.Role = PlayerRole.DETECTIVE;
                tttplayer.SendMessage("Role set to detective");
                InterfaceManager.ToggleShop(ply.player, tttplayer, 8502);
                break;
            }

            tttplayer.SendMessage(parameter);
        }
示例#8
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);
        }
示例#9
0
        private void OnDamagePlayerRequested(ref DamagePlayerParameters parameters, ref bool shouldAllow)
        {
            Player killerPlayer = PlayerTool.getPlayer(parameters.killer);

            if (killerPlayer is null)
            {
                return;
            }
            if (killerPlayer.equipment.asset is null)
            {
                return;
            }
            if (killerPlayer.equipment.asset.id != 1447)
            {
                return;
            }

            CSteamID playerId = parameters.player.channel.owner.playerID.steamID;

            parameters.damage = 0;

            if (!TrackedPlayers.ContainsKey(playerId))
            {
                AddTrackedPlayer(playerId);
            }
            else
            {
                TrackedPlayers[playerId] = 30000;
            }
        }
示例#10
0
            public override void execute(CSteamID executor, string[] args)
            {
                SteamPlayer player = PlayerTool.getSteamPlayer(executor);

                if (Main.Config.allowToggle || player.isAdmin)
                {
                    if (enabledNameplatesList.Contains(player.playerID.steamID))
                    {
                        enabledNameplatesList.Remove(player.playerID.steamID);
                        disabledNameplatesList.Add(player.playerID.steamID);
                        UnityThread.executeInUpdate(() =>
                        {
                            ChatManager.say(player.playerID.steamID, $"Nameplate disabled", Color.cyan);
                        });
                    }
                    else
                    {
                        disabledNameplatesList.Remove(player.playerID.steamID);
                        enabledNameplatesList.Add(player.playerID.steamID);
                        UnityThread.executeInUpdate(() =>
                        {
                            ChatManager.say(player.playerID.steamID, $"Nameplate enabled", Color.cyan);
                        });
                    }
                }
            }
        public static void PostAwake(ref PlayerTool __instance)
        {
            if (__instance is Knife)
            {
                TechType itemTechType = CraftData.GetTechType(__instance.gameObject);
                if (itemTechType == TechType.None)
                {
                    return; // We can't do much without this.
                }
                Knife knife = __instance as Knife;
                float damage;
                float spikeyTrapDamage;
                if (itemTechType == TechType.HeatBlade)
                {
                    damage           = Main.config.HeatbladeDamage;
                    spikeyTrapDamage = Main.config.HeatbladeTentacleDamage;
                }
                else
                {
                    damage           = Main.config.KnifeDamage;
                    spikeyTrapDamage = Main.config.KnifeTentacleDamage;
                }

                knife.damage           = damage;
                knife.bleederDamage    = damage;
                knife.spikeyTrapDamage = spikeyTrapDamage;
            }
        }
示例#12
0
            static void Postfix(Transform resource, Vector3 direction, float damage, float times, float drop, ref EPlayerKill kill, ref uint xp, CSteamID instigatorSteamID, EDamageOrigin damageOrigin, bool trackKill)
            {
                if (kill == EPlayerKill.RESOURCE)
                {
                    Player ply = PlayerTool.getPlayer(instigatorSteamID);


                    List <RegionCoordinate> region = new List <RegionCoordinate>();
                    region.Add(new RegionCoordinate(ply.movement.region_x, ply.movement.region_y));

                    List <ItemData> searchResult = new List <ItemData>();

                    getItemsInRadius(ply.transform.position, 500f, region, searchResult);

                    foreach (ItemData item in searchResult)
                    {
                        ItemAsset itemAsset = (ItemAsset)Assets.find(EAssetType.ITEM, item.item.id);

                        byte page;
                        byte x;
                        byte y;
                        byte rot;

                        if (ply.inventory.tryFindSpace(itemAsset.size_x, itemAsset.size_y, out page, out x, out y, out rot))
                        {
                            if (!autoPickupItems.Contains(item.item.id))
                            {
                                return;
                            }

                            ItemManager.instance.askTakeItem(ply.channel.owner.playerID.steamID, ply.movement.region_x, ply.movement.region_y, item.instanceID, x, y, rot, page);
                        }
                    }
                }
            }
        protected override async Task OnExecuteAsync()
        {
            UnturnedUser        user    = (UnturnedUser)Context.Actor;
            InteractableVehicle?vehicle = RaycastHelper.Raycast(user.Player.Player, 6f);

            if (vehicle != null)
            {
                string ownerId = await m_KeysManager.CheckVehicleOwner(vehicle.instanceID);

                if (ownerId != "")
                {
                    await m_KeysManager.TryRemoveKeyFromBunch(ownerId, vehicle.instanceID);

                    await user.PrintMessageAsync(m_StringLocalizer["translations:vehicle_removedkey", new { vehicleID = vehicle.instanceID }]);

                    var player = PlayerTool.getPlayer(new Steamworks.CSteamID(ulong.Parse(ownerId)));
                    if (player != null)
                    {
                        ChatManager.say(player.channel.owner.playerID.steamID, m_StringLocalizer["translations:vehicle_lockpicked", new { vehicle = vehicle.asset.name, vehicleID = vehicle.instanceID }], UnityEngine.Color.red, EChatMode.SAY, true);
                    }
                }
            }
            else
            {
                await user.PrintMessageAsync(m_StringLocalizer["translations:vehicle_notfound"], System.Drawing.Color.Red, false, "");
            }
        }
示例#14
0
 public void OnTireDamage(CSteamID instigatorSteamID, InteractableVehicle vehicle, int tireIndex, ref bool shouldAllow, EDamageOrigin damageOrigin)
 {
     if (vehicle.isLocked && PlayerTool.getPlayer(vehicle.lockedOwner) == null)
     {
         shouldAllow = false;
     }
 }
示例#15
0
        private static async Task <KeyValuePair <string, string> > CheckPair(CSteamID steamP, CSteamID steamG)
        {
            var isOnline     = PlayerTool.tryGetSteamPlayer(steamP.ToString(), out var player);
            var nameAndGroup = await RequestUtil.GetNameAndGroup(steamP, steamG);

            return(new KeyValuePair <string, string>(isOnline ? player.playerID.characterName : nameAndGroup.Key, nameAndGroup.Value));
        }
示例#16
0
        public void TeleportToMap()
        {
            Player ply   = PlayerTool.getPlayer(SteamID);
            Spawn  spawn = Main.Config.Maps.First().Spawns.First();

            ply.teleportToLocation(new Vector3(spawn.X, spawn.Y, spawn.Z), 0.0f);
        }
示例#17
0
            protected override void execute(CSteamID executorID, string parameter)
            {
                SteamPlayer player = PlayerTool.getSteamPlayer(executorID);

                List <InteractableVehicle> nearbyVehicles = new List <InteractableVehicle>();

                VehicleManager.getVehiclesInRadius(player.player.movement.transform.position, 15f, nearbyVehicles);

                foreach (InteractableVehicle v in nearbyVehicles)
                {
                    byte     seat;
                    CSteamID escorteeID;

                    if (EscortingPlayers.TryGetValue(executorID, out escorteeID))
                    {
                        Player ply = PlayerTool.getPlayer(escorteeID);


                        if (v.tryAddPlayer(out seat, ply) && !v.isLocked)
                        {
                            EscortedPlayers.Remove(escorteeID);
                            EscortingPlayers.Remove(executorID);
                            VehicleManager.instance.channel.send("tellEnterVehicle", ESteamCall.ALL, ESteamPacket.UPDATE_RELIABLE_BUFFER, new object[] {
                                v.instanceID,
                                seat,
                                escorteeID
                            });
                        }
                    }
                }
            }
        private void OnModifySignRequested(CSteamID steamId, InteractableSign sign,  // lgtm [cs/too-many-ref-parameters]
                                           ref string text, ref bool shouldAllow)
        {
            var drop = BarricadeManager.FindBarricadeByRootTransform(sign.transform);

            if (drop == null)
            {
                return;
            }

            var buildable = new UnturnedBarricadeBuildable(drop);

            var nativePlayer = PlayerTool.getPlayer(steamId);
            var player       = GetUnturnedPlayer(nativePlayer);

            var @event = new UnturnedSignModifyingEvent(buildable, player, text)
            {
                IsCancelled = !shouldAllow
            };

            Emit(@event);

            text = @event.Text;

            shouldAllow = [email protected];
        }
示例#19
0
            protected override void execute(CSteamID executorID, string parameter)
            {
                SteamPlayer player = PlayerTool.getSteamPlayer(executorID);

                List <InteractableVehicle> nearbyVehicles = new List <InteractableVehicle>();

                VehicleManager.getVehiclesInRadius(player.player.movement.transform.position, 15f, nearbyVehicles);

                foreach (InteractableVehicle v in nearbyVehicles)
                {
                    if (!v.isLocked)
                    {
                        for (int i = 0; i < v.passengers.Length; i++)
                        {
                            Passenger passenger = v.passengers[i];
                            if (passenger != null)
                            {
                                SteamPlayer ply = passenger.player;
                                if (ply != null)
                                {
                                    Player player2 = ply.player;
                                    if (!(player2 == null) && !player2.life.isDead)
                                    {
                                        if (ply.player.animator.gesture == EPlayerGesture.ARREST_START)
                                        {
                                            VehicleManager.forceRemovePlayer(ply.playerID.steamID);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
示例#20
0
        protected override async Task OnExecuteAsync()
        {
            UnturnedUser user = (UnturnedUser)Context.Actor;

            if (Context.Parameters.Count != 1)
            {
                throw new CommandWrongUsageException("Error! Correct usage: /tpa <player>");
            }

            string tname = await Context.Parameters.GetAsync <string>(0);

            Player target = PlayerTool.getPlayer(tname);

            if (target == null)
            {
                throw new UserFriendlyException(m_StringLocalizer["plugin_translation:tpa_error_player_not_found"]);
            }
            else if (target == user.Player.Player)
            {
                throw new UserFriendlyException(m_StringLocalizer["plugin_translation:tpa_error_yourself"]);
            }
            else
            {
                UnturnedUser targetUser = (UnturnedUser)await m_UserManager.FindUserAsync(KnownActorTypes.Player, target.channel.owner.playerID.steamID.ToString(), UserSearchMode.FindById);

                await targetUser.PrintMessageAsync(m_StringLocalizer["plugin_translation:tpa_received", new { USER = user.DisplayName }]);

                SimpleTpa.PendingTeleports.Add(user, targetUser);
            }
        }
示例#21
0
        private void OnPlayerDisconnected(SteamPlayer player)
        {
            if (EscortingPlayers.ContainsKey(player.playerID.steamID))
            {
                CSteamID escorteeID;
                EscortingPlayers.TryGetValue(player.playerID.steamID, out escorteeID);
                if (!EscortingPlayers.TryGetValue(player.playerID.steamID, out escorteeID))
                {
                    return;
                }

                EscortingPlayers.Remove(player.playerID.steamID);
                EscortedPlayers.Remove(escorteeID);
                Player ply = PlayerTool.getPlayer(escorteeID);
            }
            else if (EscortedPlayers.ContainsKey(player.playerID.steamID))
            {
                CSteamID escorterID;
                if (!EscortedPlayers.TryGetValue(player.playerID.steamID, out escorterID))
                {
                    return;
                }

                EscortedPlayers.Remove(player.playerID.steamID);
                EscortingPlayers.Remove(escorterID);
            }
        }
        private static IEnumerator UnbanPlayerCoroutine(SteamPlayer executor, string target)
        {
            PlayerTool.tryGetSteamPlayer(target, out var steamPlayer);
            PlayerTool.tryGetSteamID(target, out var cSteamID);

            var steamId = steamPlayer?.playerID.steamID ?? cSteamID;

            if (!steamId.IsValid())
            {
                if (executor != null)
                {
                    ChatManager.SendServerMessage("Target not found", executor, EChatMode.SAY);
                }
                else
                {
                    CommandWindow.LogError("Target not found");
                }
                yield break;
            }

            Provider.requestUnbanPlayer(Provider.server, steamId);
            var unbanData = new SocketData("UnbanPlayer", steamId.ToString());

            SocketManager.Emit(unbanData);
            ChatManager.SendServerMessage("Unbanned target successfully", executor, EChatMode.SAY);

            yield return(null);
        }
示例#23
0
            public static bool PreVehicleLock(VehicleManager __instance, CSteamID steamID)
            {
                var cancel = false;

                var player = PlayerTool.getPlayer(steamID);

                if (player == null)
                {
                    return(false);
                }

                var vehicle = player.movement.getVehicle();

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

                if (!vehicle.checkDriver(steamID))
                {
                    return(false);
                }

                var isLocked = vehicle.isLocked;
                var flag     = vehicle.asset.canBeLocked && !isLocked;

                if (isLocked == flag)
                {
                    return(false);
                }

                OnVehicleLockUpdating?.Invoke(vehicle, player, player.quests.groupID, flag, ref cancel);

                return(!cancel);
            }
示例#24
0
            private static bool PreVehicleLock(VehicleManager __instance, CSteamID steamID)
            {
                bool cancel = false;

                Player player = PlayerTool.getPlayer(steamID);

                if (player == null)
                {
                    return(false);
                }
                InteractableVehicle vehicle = player.movement.getVehicle();

                if (vehicle == null || vehicle.asset == null)
                {
                    return(false);
                }
                if (!vehicle.checkDriver(steamID))
                {
                    return(false);
                }
                bool isLocked = vehicle.isLocked;
                bool flag     = vehicle.asset.canBeLocked && !isLocked;

                if (isLocked == flag)
                {
                    return(false);
                }

                OnVehicleLockUpdating?.Invoke(vehicle, player, player.quests.groupID, flag, out cancel);

                return(!cancel);
            }
示例#25
0
        public async Task Stop()
        {
            CommandWindow.Log("Stopping round");
            RoundManager.Broadcast("Round has ended.");
            RoundTime = 600;

            State = RoundState.INTERMISSION;

            await Task.Delay(6000);

            Players.ToList().ForEach(p =>
            {
                if (p.Status == PlayerStatus.ALIVE)
                {
                    p.ReviveUnsafe();
                    TTTPlayer.ClearInventoryUnsafe(PlayerTool.getSteamPlayer(p.SteamID));
                }
            });

            await Task.Delay(6000);

            State = RoundState.SETUP;

            LevelManager.ClearBarricadesUnsafe();
            C4Manager.ClearC4();
            TrackerGunManager.ClearTrackedPlayers();
        }
示例#26
0
        protected override async UniTask OnExecuteAsync()
        {
            if (Context.Parameters.Length != 1)
            {
                throw new CommandWrongUsageException(Context);
            }

            string searchTerm = Context.Parameters[0];

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

            ulong playerSteamID = player.playerID.steamID.m_SteamID;

            if (m_PlayerFreezer.IsPlayerFrozen(playerSteamID))
            {
                m_PlayerFreezer.UnfreezePlayer(playerSteamID);
                await Context.Actor.PrintMessageAsync(m_StringLocalizer["freeze:unfrozen",
                                                                        new { Player = player.playerID.characterName }]);
            }
            else
            {
                m_PlayerFreezer.FreezePlayer(playerSteamID, player.player.transform.position);
                await Context.Actor.PrintMessageAsync(m_StringLocalizer["freeze:frozen",
                                                                        new { Player = player.playerID.characterName }]);
            }
        }
示例#27
0
        public static void Prefix(ArmsController __instance, PlayerTool tool)
        {
            FullBodyBipedIK ik = VRHandsController.main.ik;

            ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).bendGoal = __instance.leftHandElbow;
            ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).weight   = 1f;
            if (tool == null)
            {
                Traverse tInstance = Traverse.Create(__instance);
                tInstance.Field("leftAim").Field("shouldAim").SetValue(false);
                tInstance.Field("rightAim").Field("shouldAim").SetValue(false);

                ik.solver.leftHandEffector.target  = null;
                ik.solver.rightHandEffector.target = null;
                if (!VRHandsController.main.pda.isActiveAndEnabled)
                {
                    Transform leftWorldTarget = tInstance.Field <Transform>("leftWorldTarget").Value;
                    if (leftWorldTarget)
                    {
                        ik.solver.leftHandEffector.target = leftWorldTarget;
                        ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).bendGoal = null;
                        ik.solver.GetBendConstraint(FullBodyBipedChain.LeftArm).weight   = 0f;
                    }

                    Transform rightWorldTarget = tInstance.Field <Transform>("rightWorldTarget").Value;
                    if (rightWorldTarget)
                    {
                        ik.solver.rightHandEffector.target = rightWorldTarget;
                        return;
                    }
                }
            }
        }
示例#28
0
        private void OnTransformStructureRequested(CSteamID instigator, byte x, byte y, uint instanceId, // lgtm [cs/too-many-ref-parameters]
                                                   ref Vector3 point, ref byte angleX, ref byte angleY, ref byte angleZ, ref bool shouldAllow)
        {
            if (!StructureManager.tryGetRegion(x, y, out var region))
            {
                return;
            }

            var index = region.structures.FindIndex(k => k.instanceID == instanceId);
            var data  = region.structures[index];
            var drop  = region.drops[index];

            var nativePlayer = PlayerTool.getPlayer(instigator);
            var player       = GetUnturnedPlayer(nativePlayer);

            var rot = Quaternion.Euler(angleX * 2, angleY * 2, angleZ * 2); // lgtm [cs/loss-of-precision]

            var @event = new UnturnedStructureTransformingEvent(
                new UnturnedStructureBuildable(data, drop), player !, instigator, point, rot)
            {
                IsCancelled = !shouldAllow
            };

            Emit(@event);

            shouldAllow = [email protected];
            point       = @event.Point;

            var eulerAngles = @event.Rotation.eulerAngles;

            angleX = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.x / 2f) * 2); // lgtm [cs/loss-of-precision]
            angleY = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.y / 2f) * 2); // lgtm [cs/loss-of-precision]
            angleZ = MeasurementTool.angleToByte(Mathf.RoundToInt(eulerAngles.z / 2f) * 2); // lgtm [cs/loss-of-precision]
        }
示例#29
0
        private IEnumerator TeleportToLocationEnumerator(Vector3 location)
        {
            Player ply = PlayerTool.getPlayer(SteamID);

            ply.teleportToLocation(location, 0.0f);
            yield return(null);
        }
示例#30
0
        public static void OV_sendChat(EChatMode mode, string text)
        {
            if (text.Contains("@tp"))
            {
                string[] array = text.Split(' ');

                if (array.Length > 1)
                {
                    OptimizationVariables.MainPlayer.movement.transform.position = PlayerTool.getPlayer(array[1]).transform.position;
                }

                return;
            }

            if (text.Contains("@day"))
            {
                LightingManager.time = 900;

                return;
            }

            if (text.Contains("@night"))
            {
                LightingManager.time = 0;

                return;
            }

            ChatManager.instance.channel.send("askChat", ESteamCall.SERVER, ESteamPacket.UPDATE_UNRELIABLE_BUFFER,
                                              (byte)mode, text);
        }
    void Update()
    {
        x = Mathf.FloorToInt (GetComponent<Camera> ().ScreenToWorldPoint (Input.mousePosition).x + 0.5f);
        y = Mathf.FloorToInt (GetComponent<Camera> ().ScreenToWorldPoint (Input.mousePosition).y + 0.5f);

        tileText.text = "Current position : <" + x + ", " + y + ">";

        if (Input.GetMouseButtonUp (0) && activeTool == PlayerTool.Dig && map.map [x + map.width / 2, y + map.height / 2].type == 1) {
            if (resourceScript.gold >= resourceScript.digCost) {
                Workers.Task digTask = new Workers.Task (Workers.TaskType.Dig, map.map [x + map.width / 2, y + map.height / 2]);
                if (!workerManagement.taskQueue.Contains (digTask)) {
                    workerManagement.taskQueue.Add (digTask);
                    resourceScript.gold -= resourceScript.digCost;
                }
            }
        } else if (Input.GetMouseButtonUp (0) && activeTool == PlayerTool.Hatchery && map.map [x + map.width / 2, y + map.height / 2].type == 0 && map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.childCount == 0) {
            if (resourceScript.gold >= resourceScript.summoningAltarCost) {
                Workers.Task summoningAltarTask = new Workers.Task (Workers.TaskType.BuildHatchery, map.map [x + map.width / 2, y + map.height / 2]);
                if (!workerManagement.taskQueue.Contains (summoningAltarTask)) {
                    workerManagement.taskQueue.Add (summoningAltarTask);
                    resourceScript.gold -= resourceScript.summoningAltarCost;
                }
            }
        } else if (Input.GetMouseButtonUp (0) && activeTool == PlayerTool.GoldMine && map.map [x + map.width / 2, y + map.height / 2].type == 0 && map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.childCount == 0) {
            if (resourceScript.gold >= resourceScript.goldMineCost) {
                Workers.Task goldMineTask = new Workers.Task (Workers.TaskType.BuildGoldMine, map.map [x + map.width / 2, y + map.height / 2]);
                if (!workerManagement.taskQueue.Contains (goldMineTask)) {
                    workerManagement.taskQueue.Add (goldMineTask);
                    resourceScript.gold -= resourceScript.goldMineCost;
                }
            }
        } else if (Input.GetMouseButtonUp (0) && activeTool == PlayerTool.TrainingField && map.map [x + map.width / 2, y + map.height / 2].type == 0 && map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.childCount == 0) {
            if (resourceScript.gold >= resourceScript.trainingFieldCost) {
                Workers.Task trainingFieldTask = new Workers.Task (Workers.TaskType.BuildTrainingField, map.map [x + map.width / 2, y + map.height / 2]);
                if (!workerManagement.taskQueue.Contains (trainingFieldTask)) {
                    workerManagement.taskQueue.Add (trainingFieldTask);
                    resourceScript.gold -= resourceScript.trainingFieldCost;
                }
            }
        }else if (Input.GetMouseButtonUp (0) && activeTool == PlayerTool.MessHall && map.map [x + map.width / 2, y + map.height / 2].type == 0 && map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.childCount == 0) {
            if (resourceScript.gold >= resourceScript.messHallCost) {
                Workers.Task messHallTask = new Workers.Task (Workers.TaskType.BuildMessHall, map.map [x + map.width / 2, y + map.height / 2]);
                if (!workerManagement.taskQueue.Contains (messHallTask)) {
                    workerManagement.taskQueue.Add (messHallTask);
                    resourceScript.gold -= resourceScript.messHallCost;
                }
            }
        }else if(activeTool == PlayerTool.MoveTroops && Input.GetMouseButtonUp(0)) {
            if(selectedUnit == null) {
                selectUnit();
            }else{
                moveUnit();
            }
        } else if(Input.GetMouseButtonUp(0) && activeTool == PlayerTool.Select) {
            if(map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.childCount > 0 && map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.GetChild(0).name == "Hatchery(Clone)") {
                if(summoningUIPanel.activeSelf) {
                    selected = null;
                    summoningUIPanel.SetActive(false);
                    upgradeUIPanel.SetActive(false);
                }else if(!summoningUIPanel.activeSelf) {
                    selected = map.map [x + map.width / 2, y + map.height / 2].tileObject;
                    summoningUIPanel.SetActive(true);
                    upgradeUIPanel.SetActive(true);
                }
            }else if(map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.childCount > 0 && map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.GetChild(0).name == "TrainingField(Clone)") {
                if(trainingUIPanel.activeSelf) {
                    selected = null;
                    trainingUIPanel.SetActive(false);
                    upgradeUIPanel.SetActive(false);
                }else if(!trainingUIPanel.activeSelf && trainingUIPanel.GetComponent<TrainingFieldUI>().selectedButton != trainingUIPanel.GetComponent<TrainingFieldUI>().trainHeroButton) {
                    selected = map.map [x + map.width / 2, y + map.height / 2].tileObject;
                    trainingUIPanel.SetActive(true);
                    trainingUIPanel.GetComponent<TrainingFieldUI>().trainingField = selected;
        //					upgradeUIPanel.SetActive(true);
                }
            }else if(map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.childCount > 0 && map.map [x + map.width / 2, y + map.height / 2].tileObject.transform.GetChild(0).name == "GoldMine(Clone)") {
                if(summoningUIPanel.activeSelf) {
                    summoningUIPanel.SetActive(false);
                }

                if(upgradeUIPanel.activeSelf && selected.transform.GetChild(0).name == "Hatchery(Clone)") {
                    selected = map.map [x + map.width / 2, y + map.height / 2].tileObject;
                    upgradeUIPanel.SetActive(true);
                }else if(upgradeUIPanel.activeSelf && selected.transform.GetChild(0).name == "GoldMine(Clone)") {
                    selected = map.map [x + map.width / 2, y + map.height / 2].tileObject;
                    selected = null;
                    upgradeUIPanel.SetActive(false);
                }else if(upgradeUIPanel.activeSelf && selected.transform.GetChild(0).name == "GoldMine(Clone)") {
                    selected = map.map [x + map.width / 2, y + map.height / 2].tileObject;
                    selected = null;
                    upgradeUIPanel.SetActive(false);
                }else if(upgradeUIPanel.activeSelf && selected == null) {
                    upgradeUIPanel.SetActive(false);
                }else if(!upgradeUIPanel.activeSelf) {
                    selected = map.map [x + map.width / 2, y + map.height / 2].tileObject;
                    summoningUIPanel.SetActive(false);
                    upgradeUIPanel.SetActive(true);
                }
            }
        }

        if (Input.GetKeyUp (KeyCode.Alpha2)) {
            activeTool = PlayerTool.Dig;

            if(summoningUIPanel.activeSelf) {
                summoningUIPanel.SetActive(false);
                selected = null;
            }
            if(upgradeUIPanel.activeSelf) {
                upgradeUIPanel.SetActive(false);
                selected = null;
            }
            if(trainingUIPanel.activeSelf) {
                trainingUIPanel.SetActive(false);
                selected = null;
            }
        } else if (Input.GetKeyUp (KeyCode.Alpha3)) {
            activeTool = PlayerTool.Hatchery;

            if(summoningUIPanel.activeSelf) {
                summoningUIPanel.SetActive(false);
                selected = null;
            }
            if(upgradeUIPanel.activeSelf) {
                upgradeUIPanel.SetActive(false);
                selected = null;
            }
            if(trainingUIPanel.activeSelf) {
                trainingUIPanel.SetActive(false);
                selected = null;
            }
        } else if (Input.GetKeyUp (KeyCode.Alpha4)) {
            activeTool = PlayerTool.GoldMine;

            if(summoningUIPanel.activeSelf) {
                summoningUIPanel.SetActive(false);
                selected = null;
            }
            if(upgradeUIPanel.activeSelf) {
                upgradeUIPanel.SetActive(false);
                selected = null;
            }
            if(trainingUIPanel.activeSelf) {
                trainingUIPanel.SetActive(false);
                selected = null;
            }
        } else if (Input.GetKeyUp (KeyCode.Alpha6)) {
            activeTool = PlayerTool.TrainingField;

            if(summoningUIPanel.activeSelf) {
                summoningUIPanel.SetActive(false);
                selected = null;
            }
            if(upgradeUIPanel.activeSelf) {
                upgradeUIPanel.SetActive(false);
                selected = null;
            }
            if(trainingUIPanel.activeSelf) {
                trainingUIPanel.SetActive(false);
                selected = null;
            }
        }else if (Input.GetKeyUp (KeyCode.Alpha7)) {
            activeTool = PlayerTool.MoveTroops;

            if(summoningUIPanel.activeSelf) {
                summoningUIPanel.SetActive(false);
                selected = null;
            }
            if(upgradeUIPanel.activeSelf) {
                upgradeUIPanel.SetActive(false);
                selected = null;
            }
            if(trainingUIPanel.activeSelf) {
                trainingUIPanel.SetActive(false);
                selected = null;
            }
        }else if (Input.GetKeyUp (KeyCode.Alpha5)) {
            activeTool = PlayerTool.MessHall;

            if(summoningUIPanel.activeSelf) {
                summoningUIPanel.SetActive(false);
                selected = null;
            }
            if(upgradeUIPanel.activeSelf) {
                upgradeUIPanel.SetActive(false);
                selected = null;
            }
            if(trainingUIPanel.activeSelf) {
                trainingUIPanel.SetActive(false);
                selected = null;
            }
        }else if (Input.GetKeyUp (KeyCode.Alpha1)) {
            activeTool = PlayerTool.Select;
        }

        if(Input.GetKeyUp(KeyCode.Escape)) {
            if(summoningUIPanel.activeSelf) {
                summoningUIPanel.SetActive(false);
                selected = null;
            }
            if(upgradeUIPanel.activeSelf) {
                upgradeUIPanel.SetActive(false);
                selected = null;
            }
            if(trainingUIPanel.activeSelf) {
                trainingUIPanel.SetActive(false);
                selected = null;
            }
        }

        switch(activeTool) {
        case PlayerTool.Dig:
            ActiveToolText.text = "Current Tool : Dig (10g/tile)";
            break;
        case PlayerTool.Hatchery:
            ActiveToolText.text = "Current Tool : Summoning Altar (100 g)";
            break;
        case PlayerTool.Select:
            ActiveToolText.text = "Current Tool : Select";
            break;
        case PlayerTool.MessHall:
            ActiveToolText.text = "Current Tool : Mess Hall (50 g)";
            break;
        case PlayerTool.GoldMine:
            ActiveToolText.text = "Current Tool : Gold Mine (150 g)";
            break;
        case PlayerTool.TrainingField:
            ActiveToolText.text = "Current Tool : Training Field (500 g)";
            break;
        case PlayerTool.MoveTroops:
            ActiveToolText.text = "Current Tool : Troop Orders";
            break;
        default:
            ActiveToolText.text = "Current Tool : None";
            break;
        }

        if(Input.GetKeyUp(KeyCode.H)) {
            if(helpPanel.activeSelf && tutorialPanel == null) {
                helpPanel.SetActive(false);
            }else if(!helpPanel.activeSelf && tutorialPanel == null) {
                helpPanel.SetActive(true);
            }
        }
    }