Beispiel #1
0
 private static void UpdateMeleeThresholdOnCurrentHand(bool dominant, string expectedName, float threshold)
 {
     if (HandsReady && (dominant ? dominantHand : nonDominantHand).currentHand.gameObject.name.Contains(expectedName))
     {
         MeleeSkill melee = (dominant ? dominantHand : nonDominantHand).currentHand.GetComponent <MeleeSkill>();
         melee.speedThreshold = threshold;
     }
 }
Beispiel #2
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);
                }
            }
        }