コード例 #1
0
        void ReadEvents()
        {
            CustomInput customInput = CustomInput.Instance;

            if (customInput.GetButtonDown("LeftClick"))
            {
                m_ped.OnFireButtonPressed();
            }

            if (customInput.GetButtonDown("RightClick"))
            {
                m_ped.OnAimButtonPressed();
            }

            if (customInput.GetKeyDown(KeyCode.Q))
            {
                m_ped.OnPreviousWeaponButtonPressed();
            }
            else if (customInput.GetKeyDown(KeyCode.E))
            {
                m_ped.OnNextWeaponButtonPressed();
            }

            if (customInput.GetButtonDown("Use"))
            {
                m_ped.OnSubmitPressed();
            }

            if (customInput.GetButtonDown("Jump"))
            {
                m_ped.OnJumpButtonPressed();
            }

            if (customInput.GetKeyDown(KeyCode.C))
            {
                m_ped.OnCrouchButtonPressed();
            }

            if (customInput.GetKeyDown(KeyCode.T))
            {
                m_ped.OnFlyButtonPressed();
            }

            if (customInput.GetKeyDown(KeyCode.R))
            {
                m_ped.OnFlyThroughButtonPressed();
            }
        }
コード例 #2
0
ファイル: PlayerPatch.cs プロジェクト: syrm/ValheimTwitch
        public static void Prefix(Player __instance)
        {
            if (CustomInput.GetKeyDown("ToggleAllRewards"))
            {
                new Thread(() =>
                {
                    Plugin.Instance.ToggleRewards(!Plugin.Instance.isRewardsEnabled);
                }).Start();
            }

            if (!Plugin.Instance.isInGame || !CustomInput.GetKeyDown("Whistle"))
            {
                return;
            }

            PlayerLoadPatch.Whistle(AudioMan.GetSFXVolume());

            foreach (var character in CharacterAwakePatch.tamedCharacters)
            {
                var znview = character.GetComponent <ZNetView>();

                if (znview == null)
                {
                    continue;
                }

                var zdo = znview.GetZDO();

                if (zdo == null)
                {
                    continue;
                }

                var customName = zdo.GetString($"{Plugin.GUID}-name");

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

                var ai = character.GetComponent <MonsterAI>();

                ai.SetFollowTarget(__instance.gameObject);
            }
        }