Ejemplo n.º 1
0
        private static void ChangeHandDominance(object sender, EventArgs e)
        {
            if (LeftDominantHand.Value == prevLeftHandedValue)
            {
                return;
            }

            prevLeftHandedValue = LeftDominantHand.Value;

            Controllers.ChangeDominanceDependantMaps();
            MotionControls.UpdateDominance();
        }
Ejemplo n.º 2
0
        private IEnumerator InitVR(bool useOculus)
        {
            XRSettings.LoadDeviceByName(useOculus ? "Oculus" : "OpenVR");
            yield return(null);

            if (XRSettings.loadedDeviceName != (useOculus ? "Oculus" : "OpenVR"))
            {
                yield break;
            }

            XRSettings.enabled = true;
            XRDevice.SetTrackingSpaceType(ModConfig.InitialRoomscaleValue ? TrackingSpaceType.RoomScale : TrackingSpaceType.Stationary);

            if (!useOculus)
            {
                Valve.VR.SteamVR_Settings.instance.trackingSpace = ModConfig.InitialRoomscaleValue ? Valve.VR.ETrackingUniverseOrigin.TrackingUniverseStanding : Valve.VR.ETrackingUniverseOrigin.TrackingUniverseSeated;
                Valve.VR.SteamVR_Settings.instance.pauseGameWhenDashboardVisible = false;
                Valve.VR.SteamVR.Initialize();
                Valve.VR.SteamVR_Actions.gameplay.Activate();
                Valve.VR.SteamVR_Actions.ui.Activate();
            }
            Controllers.Init();
            ControllerGlyphs.Init();
        }
Ejemplo n.º 3
0
        internal static void Init()
        {
            On.RoR2.CameraRigController.Start += InitHandsAndHUDs;

            On.RoR2.CharacterBody.OnSprintStart += OnSprintStart;
            On.RoR2.CharacterBody.OnSprintStop  += OnSprintStop;

            On.RoR2.CharacterModel.UpdateMaterials += UpdateHandMaterials;

            PlayerCharacterMasterController.onPlayerAdded += (pcmc) =>
            {
                pcmc.master.onBodyStart += (body) =>
                {
                    if (!body.master.IsLocalMaster() || body == currentBody)
                    {
                        return;
                    }

                    currentBody = body;
                    string bodyName = body.name.Substring(0, body.name.IndexOf("(Clone)"));
                    VRMod.StaticLogger.LogInfo(String.Format("Local cached body \'{0}\' found. Applying hand pair.", bodyName));

                    SetHandPair(body);
                    Controllers.ApplyRemaps(bodyName);
                };
            };

            On.RoR2.ModelSkinController.ApplySkin += (orig, self, index) =>
            {
                orig(self, index);
                if (self.characterModel.body == currentBody && onSkinApplied != null)
                {
                    onSkinApplied();
                }
            };

            On.RoR2.CharacterBody.OnInventoryChanged += OnInventoryChanged;

            On.RoR2.CharacterModel.InitMaterials += ShrinkShieldEffects;

            handControllerPrefab = VRMod.VRAssetBundle.LoadAsset <GameObject>("VRHand");

            string[] prefabNames = new string[]
            {
                "CommandoPistol",
                "HuntressBow",
                "HuntressHand",
                "BanditRifle",
                "BanditHand",
                "MULTTools",
                "MULTTools2",
                "EngiHand",
                "EngiHand2",
                "ArtiHand",
                "ArtiHand2",
                "MercHand",
                "MercSword",
                "RexGun",
                "RexFlower",
                "LoaderHand",
                "LoaderHand2",
                "AcridHand",
                "AcridHand2",
                "CaptainHand",
                "CaptainGun",
                "HereticWing",
                "VoidFiendStub",
                "VoidFiendHand",
                "RailgunnerRifle",
                "RailgunnerHand"
            };

            loaderMelee = new MeleeSkill[2];
            acridMelee  = new MeleeSkill[2];

            foreach (string prefabName in prefabNames)
            {
                GameObject prefab = VRMod.VRAssetBundle.LoadAsset <GameObject>(prefabName);

                if (prefabName == "BanditRifle")
                {
                    banditMainHand = prefab.GetComponent <TwoHandedMainHand>();

                    banditMainHand.snapAngle = ModConfig.BanditWeaponGripSnapAngle.Value;
                }
                else if (prefabName == "MercSword")
                {
                    mercMelee = prefab.GetComponent <MeleeSkill>();

                    mercMelee.speedThreshold = ModConfig.MercSwingSpeedThreshold.Value;
                }
                else if (prefabName == "LoaderHand")
                {
                    loaderMelee[0] = prefab.GetComponent <MeleeSkill>();

                    loaderMelee[0].speedThreshold = ModConfig.LoaderSwingSpeedThreshold.Value;
                }
                else if (prefabName == "LoaderHand2")
                {
                    loaderMelee[1] = prefab.GetComponent <MeleeSkill>();

                    loaderMelee[1].speedThreshold = ModConfig.LoaderSwingSpeedThreshold.Value;
                }
                else if (prefabName == "AcridHand")
                {
                    acridMelee[0] = prefab.GetComponent <MeleeSkill>();

                    acridMelee[0].speedThreshold = ModConfig.AcridSwingSpeedThreshold.Value;
                }
                else if (prefabName == "AcridHand2")
                {
                    acridMelee[1] = prefab.GetComponent <MeleeSkill>();

                    acridMelee[1].speedThreshold = ModConfig.AcridSwingSpeedThreshold.Value;
                }
                else if (prefabName == "RailgunnerRifle")
                {
                    railgunnerMainHand = prefab.GetComponent <TwoHandedMainHand>();

                    railgunnerMainHand.snapAngle = ModConfig.RailgunnerWeaponGripSnapAngle.Value;
                }

                if (prefab)
                {
                    AddHandPrefab(prefab);
                }
            }
        }