Наследование: MonoBehaviour
Пример #1
0
        static bool Prefix(out Vector3 spawnPoint, out Vector3 aimDir, Humanoid ___m_character)
        {
            spawnPoint = Vector3.zero;
            aimDir     = Vector3.zero;

            if (___m_character != Player.m_localPlayer || !VHVRConfig.UseVrControls())
            {
                return(true);
            }

            if (EquipScript.getLeft() == EquipType.Bow)
            {
                spawnPoint = BowLocalManager.spawnPoint;
                aimDir     = BowLocalManager.aimDir;
                return(false);
            }

            switch (EquipScript.getRight())
            {
            case EquipType.Fishing:
                spawnPoint = FishingManager.spawnPoint;
                aimDir     = FishingManager.aimDir;
                return(false);

            case EquipType.Spear:
            case EquipType.SpearChitin:
                spawnPoint = SpearManager.spawnPoint;
                aimDir     = SpearManager.aimDir;
                return(false);
            }

            return(true);
        }
Пример #2
0
        static void Postfix(bool __result, string ___m_rightItem, ref GameObject ___m_rightItemInstance)
        {
            if (!__result || ___m_rightItemInstance == null)
            {
                return;
            }

            MeshFilter meshFilter = ___m_rightItemInstance.GetComponentInChildren <MeshFilter>();

            if (meshFilter == null)
            {
                return;
            }

            Player player = ___m_rightItemInstance.GetComponentInParent <Player>();

            if (player == null)
            {
                return;
            }

            var vrPlayerSync = player.GetComponent <VRPlayerSync>();

            if (vrPlayerSync != null)
            {
                player.GetComponent <VRPlayerSync>().currentRightWeapon      = meshFilter.gameObject;
                player.GetComponent <VRPlayerSync>().currentRightWeapon.name = ___m_rightItem;
                VrikCreator.resetVrikHandTransform(player);
            }

            if (Player.m_localPlayer != player || !VHVRConfig.UseVrControls())
            {
                return;
            }

            if (StaticObjects.quickSwitch != null)
            {
                StaticObjects.quickSwitch.GetComponent <QuickSwitch>().refreshItems();
                StaticObjects.quickActions.GetComponent <QuickActions>().refreshItems();
            }

            switch (EquipScript.getRight())
            {
            case EquipType.Fishing:
                meshFilter.gameObject.AddComponent <FishingManager>();
                return;

            case EquipType.Spear:
            case EquipType.SpearChitin:
                meshFilter.gameObject.AddComponent <SpearManager>();
                // (no return, we want collider for spear also)
                break;
            }

            StaticObjects.rightWeaponCollider().GetComponent <WeaponCollision>().setColliderParent(meshFilter.transform, ___m_rightItem, true);
            ParticleFix.maybeFix(___m_rightItemInstance);
        }
Пример #3
0
        static void Postfix(Character __instance)
        {
            if (__instance != Player.m_localPlayer || EquipScript.getLeft() != EquipType.Shield || !VHVRConfig.UseVrControls())
            {
                return;
            }

            ShieldManager.resetBlocking();
        }
Пример #4
0
        static void Prefix(Character __instance, HitData hit)
        {
            if (__instance != Player.m_localPlayer || EquipScript.getLeft() != EquipType.Shield || !VHVRConfig.UseVrControls())
            {
                return;
            }

            ShieldManager.setBlocking(hit.m_dir);
        }
Пример #5
0
        static void Postfix(bool __result, string ___m_leftItem, GameObject ___m_leftItemInstance)
        {
            if (!__result || ___m_leftItemInstance == null)
            {
                return;
            }

            MeshFilter meshFilter = ___m_leftItemInstance.GetComponentInChildren <MeshFilter>();

            if (meshFilter == null)
            {
                return;
            }

            Player player = ___m_leftItemInstance.GetComponentInParent <Player>();

            if (player == null)
            {
                return;
            }

            var vrPlayerSync = player.GetComponent <VRPlayerSync>();

            if (vrPlayerSync != null)
            {
                player.GetComponent <VRPlayerSync>().currentLeftWeapon = meshFilter.gameObject;
                VrikCreator.resetVrikHandTransform(player);
            }

            if (Player.m_localPlayer != player || !VHVRConfig.UseVrControls())
            {
                return;
            }

            if (StaticObjects.quickSwitch != null)
            {
                StaticObjects.quickSwitch.GetComponent <QuickSwitch>().refreshItems();
                StaticObjects.quickActions.GetComponent <QuickActions>().refreshItems();
            }

            switch (EquipScript.getLeft())
            {
            case EquipType.Bow:
                meshFilter.gameObject.AddComponent <BowLocalManager>();
                return;

            case EquipType.Shield:
                meshFilter.gameObject.AddComponent <ShieldManager>()._name = ___m_leftItem;
                return;
            }

            StaticObjects.leftWeaponCollider().GetComponent <WeaponCollision>().setColliderParent(meshFilter.transform, ___m_leftItem, false);
            ParticleFix.maybeFix(___m_leftItemInstance);
        }
Пример #6
0
        static bool Prefix(Humanoid __instance, ref bool __result)
        {
            if (__instance != Player.m_localPlayer || EquipScript.getLeft() != EquipType.Shield || !VHVRConfig.UseVrControls())
            {
                return(true);
            }

            __result = ShieldManager.isBlocking();

            return(false);
        }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     txt    = GetComponent <Text>();
     equip  = GameObject.Find("EquipButton");
     equipS = equip.GetComponent <EquipScript>();
     eat    = GameObject.Find("EatButton");
     eatS   = eat.GetComponent <EatScript>();
     if (shopMode)
     {
         buy  = GameObject.Find("BuyButton");
         buyS = buy.GetComponent <BuyScript>();
         buy.SetActive(false);
     }
     equip.SetActive(false);
     eat.SetActive(false);
 }
Пример #8
0
 static void Prefix(Humanoid __instance, ref HitData hit, ref float ___m_blockTimer)
 {
     if (__instance != Player.m_localPlayer || EquipScript.getLeft() != EquipType.Shield || !VHVRConfig.UseVrControls())
     {
         return;
     }
     ___m_blockTimer = ShieldManager.blockTimer;
     if (ShieldManager.isBlocking())
     {
         hit.m_dir = -__instance.transform.forward;
     }
     else
     {
         hit.m_dir = __instance.transform.forward;
     }
 }
Пример #9
0
        private void checkHandOverShoulder(bool isRightHand, Hand hand, SteamVR_Input_Sources inputSource, ref bool toggleShowHand)
        {
            var camera = CameraUtils.getCamera(CameraUtils.VR_CAMERA).transform;
            var action = SteamVR_Actions.valheim_Grab;

            if (camera.InverseTransformPoint(hand.transform.position).y > -0.4f &&
                camera.InverseTransformPoint(hand.transform.position).z < 0)
            {
                if (action.GetStateDown(inputSource))
                {
                    if (isRightHand && isHoldingItem(isRightHand) && isUnpressSheath())
                    {
                        return;
                    }

                    toggleShowHand = false;
                    hand.hapticAction.Execute(0, 0.2f, 100, 0.3f, inputSource);

                    if (isRightHand && EquipScript.getLeft() == EquipType.Bow)
                    {
                        BowLocalManager.instance.toggleArrow();
                    }
                    else if (isHoldingItem(isRightHand))
                    {
                        getPlayerCharacter().HideHandItems();
                    }
                    else
                    {
                        getPlayerCharacter().ShowHandItems();
                        justUnsheathed = true;
                    }
                }
                else if (!justUnsheathed && isRightHand && action.GetStateUp(inputSource))
                {
                    if (isHoldingItem(isRightHand) && isUnpressSheath())
                    {
                        getPlayerCharacter().HideHandItems();
                    }
                }
            }
            if (justUnsheathed && isRightHand && action.GetStateUp(inputSource) && isUnpressSheath())
            {
                justUnsheathed = false;
            }
        }
Пример #10
0
        static void Postfix(Humanoid __instance, bool __result, ref float ___m_blockTimer)
        {
            if (__instance != Player.m_localPlayer || EquipScript.getLeft() != EquipType.Shield || !VHVRConfig.UseVrControls())
            {
                return;
            }

            if (__result)
            {
                if (___m_blockTimer < ShieldManager.blockTimerTolerance)
                {
                    VRPlayer.leftHand.hapticAction.Execute(0, 0.4f, 100, 0.5f, SteamVR_Input_Sources.LeftHand);
                    VRPlayer.leftHand.hapticAction.Execute(0.4f, 0.7f, 100, 0.2f, SteamVR_Input_Sources.LeftHand);
                }
                else
                {
                    VRPlayer.leftHand.hapticAction.Execute(0, 0.2f, 100, 0.5f, SteamVR_Input_Sources.LeftHand);
                }
                ShieldManager.block();
            }
        }
Пример #11
0
        static bool Prefix(Humanoid __instance, ref float __result)
        {
            if (__instance != Player.m_localPlayer || !VHVRConfig.UseVrControls())
            {
                return(true);
            }

            if (EquipScript.getLeft() == EquipType.Bow)
            {
                __result = BowLocalManager.attackDrawPercentage;
                return(false);
            }

            if (EquipScript.getRight() == EquipType.Fishing)
            {
                __result = FishingManager.attackDrawPercentage;
                return(false);
            }

            return(true);
        }
Пример #12
0
 private bool isBuildingTool()
 {
     return(EquipScript.getRight() == EquipType.Hammer ||
            EquipScript.getRight() == EquipType.Hoe ||
            EquipScript.getRight() == EquipType.Cultivator);
 }
Пример #13
0
 private bool isHoldingThrowable()
 {
     return(EquipScript.getRight() == EquipType.Spear ||
            EquipScript.getRight() == EquipType.SpearChitin ||
            EquipScript.getRight() == EquipType.Fishing);
 }
Пример #14
0
 // Use this for initialization
 void Start()
 {
     txt = GetComponent<Text>();
     equip = GameObject.Find("EquipButton");
     equipS = equip.GetComponent<EquipScript>();
     eat = GameObject.Find("EatButton");
     eatS = eat.GetComponent<EatScript>();
     if (shopMode) {
         buy = GameObject.Find("BuyButton");
         buyS = buy.GetComponent<BuyScript>();
         buy.SetActive(false);
     }
     equip.SetActive(false);
     eat.SetActive(false);
 }
Пример #15
0
        static void Prefix(Player __instance, ref bool attack, ref bool attackHold, ref bool block, ref bool blockHold,
                           ref bool secondaryAttack)
        {
            if (!VHVRConfig.UseVrControls() || __instance != Player.m_localPlayer)
            {
                return;
            }

            if (EquipScript.getLeft() == EquipType.Bow)
            {
                if (BowLocalManager.aborting)
                {
                    block     = true;
                    blockHold = true;
                    BowLocalManager.aborting = false;
                }
                else if (BowLocalManager.startedPulling)
                {
                    attack = true;
                    BowLocalManager.startedPulling = false;
                }
                else
                {
                    attackHold = BowLocalManager.isPulling;
                }
                return;
            }

            if (EquipScript.getLeft() == EquipType.Shield)
            {
                blockHold = ShieldManager.isBlocking();
            }

            switch (EquipScript.getRight())
            {
            case EquipType.Fishing:
                if (FishingManager.isThrowing)
                {
                    attack     = true;
                    attackHold = true;
                    FishingManager.isThrowing = false;
                }

                blockHold = FishingManager.isPulling;
                break;

            case EquipType.Spear:
                if (SpearManager.isThrowing)
                {
                    secondaryAttack         = true;
                    SpearManager.isThrowing = false;
                }

                break;

            // no one knows why all spears throw with right click, only spear-chitin throws with left click:
            case EquipType.SpearChitin:
                if (SpearManager.isThrowing)
                {
                    attack = true;
                    SpearManager.isThrowing = false;
                }

                break;
            }
        }