private IEnumerator ApplyGameCoreModifications() { yield return(new WaitForSeconds(0.1f)); Saber[] sabers = Resources.FindObjectsOfTypeAll <Saber>(); foreach (Saber saber in sabers) { // Only scale solo sabers in solo mode if (IsMultiplayerEnv || IsSoloGameplaySaber(saber.gameObject)) { // Scaling sabers will affect its hitbox, so save the default hitbox positions first before scaling HitboxRevertWorkaround hitboxVariables = null; if (!EnableHitboxScaling) { hitboxVariables = new HitboxRevertWorkaround(saber); } // Rescale visible saber (FIXME: Need to account for custom sabers once that mod is available again) RescaleSaber(saber.gameObject, LengthMultiplier, Configuration.Scale.Girth); // Revert hitbox changes to sabers, if hitbox scaling is disabled if (hitboxVariables != null) { hitboxVariables.RestoreHitbox(); } } } #region TrailScaling // The new SaberTrail in 1.12.1 is kinda hardcoded to current blade top/bottom positions. So disabling trail scaling for now. /* * IEnumerable<SaberModelController> saberModelControllers = Resources.FindObjectsOfTypeAll<SaberModelController>(); * foreach (SaberModelController saberModelController in saberModelControllers) * { * SaberTrail saberTrail = saberModelController.GetField<SaberTrail, SaberModelController>("_saberTrail"); * Logger.log.Debug("SaberTrailName is '" + saberTrail.name + "'."); * * if (!usingCustomModels || saberTrail.name != "BasicSaberModel") * { * //RescaleWeaponTrail(saberTrail, Configuration.Scale.Length, usingCustomModels); * } * } */ #endregion #region CustomSabers // Deal with CustomSabers once it got updated. /* * if (Utilities.Utils.IsPluginEnabled("Custom Sabers")) * { * // Wait a moment for CustomSaber to catch up * yield return new WaitForSeconds(0.1f); * GameObject customSaberClone = GameObject.Find("_CustomSaber(Clone)"); * * // If customSaberClone is null, CustomSaber is most likely not replacing the default sabers. * if (customSaberClone != null) * { * LeftSaber = GameObject.Find("LeftSaber"); * RightSaber = GameObject.Find("RightSaber"); * usingCustomModels = true; * } * else * { * Logger.log.Debug("Either the Default Sabers are selected or CustomSaber were too slow!"); * } * } */ #endregion yield return(null); }
private IEnumerator ApplyGameCoreModifications() { bool usingCustomModels = false; Saber defaultLeftSaber = null; Saber defaultRightSaber = null; GameObject LeftSaber = null; GameObject RightSaber = null; // Find and set the default sabers first IEnumerable <Saber> sabers = Resources.FindObjectsOfTypeAll <Saber>(); foreach (Saber saber in sabers) { if (saber.saberType == SaberType.SaberB) { defaultLeftSaber = saber; LeftSaber = saber.gameObject; } else if (saber.saberType == SaberType.SaberA) { defaultRightSaber = saber; RightSaber = saber.gameObject; } } if (Utilities.Utils.IsPluginEnabled("Custom Sabers")) { // Wait a moment for CustomSaber to catch up yield return(new WaitForSeconds(0.1f)); GameObject customSaberClone = GameObject.Find("_CustomSaber(Clone)"); // If customSaberClone is null, CustomSaber is most likely not replacing the default sabers. if (customSaberClone != null) { LeftSaber = GameObject.Find("LeftSaber"); RightSaber = GameObject.Find("RightSaber"); usingCustomModels = true; } else { Logger.log.Debug("Either the Default Sabers are selected or CustomSaber were too slow!"); } } // Scaling default saber will affect its hitbox, so save the default hitbox positions first before scaling HitboxRevertWorkaround hitboxVariables = null; if (!usingCustomModels && !Configuration.Scale.ScaleHitBox) { hitboxVariables = new HitboxRevertWorkaround(defaultLeftSaber, defaultRightSaber); } // Rescale visible sabers (either default or custom) RescaleSaber(LeftSaber, Configuration.Scale.Length, Configuration.Scale.Girth); RescaleSaber(RightSaber, Configuration.Scale.Length, Configuration.Scale.Girth); // Scaling custom sabers will not change their hitbox, so a manual hitbox rescale is necessary, if the option is enabled if (usingCustomModels && Configuration.Scale.ScaleHitBox) { RescaleSaberHitBox(defaultLeftSaber, Configuration.Scale.Length); RescaleSaberHitBox(defaultRightSaber, Configuration.Scale.Length); } // Revert hitbox changes to default sabers, if hitbox scaling is disabled if (hitboxVariables != null) { hitboxVariables.RestoreHitbox(); } IEnumerable <BasicSaberModelController> basicSaberModelControllers = Resources.FindObjectsOfTypeAll <BasicSaberModelController>(); foreach (BasicSaberModelController basicSaberModelController in basicSaberModelControllers) { XWeaponTrail saberWeaponTrail = basicSaberModelController.GetField <XWeaponTrail, BasicSaberModelController>("_saberWeaponTrail"); if (!usingCustomModels || saberWeaponTrail.name != "BasicSaberModel") { RescaleWeaponTrail(saberWeaponTrail, Configuration.Scale.Length, usingCustomModels); } } yield return(null); }