using System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Microsoft.CodeAnalysis; using ModelReplacement; using ModelReplacement.AvatarBodyUpdater; using ModelReplacement.Scripts.Player; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PeteyPiranha")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PeteyPiranha")] [assembly: AssemblyTitle("PeteyPiranha")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace PeteyPiranha { [BepInPlugin("JLeonL.PeteyPiranha", "Sargento Pingu", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class PeteyPiranhaPlugin : BaseUnityPlugin { public const string PluginGuid = "JLeonL.PeteyPiranha"; public const string PluginName = "Sargento Pingu"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static AssetBundle Bundle; internal static GameObject PeteyPrefab; internal static ConfigEntry FirstPersonLeafHandScale; internal static ConfigEntry ModelVerticalOffset; private ConfigEntry replaceEveryPlayer; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; replaceEveryPlayer = ((BaseUnityPlugin)this).Config.Bind("Testing", "ReplaceEveryPlayer", false, "Replace every player with Sargento Pingu. Leave disabled to use the selectable suit."); FirstPersonLeafHandScale = ((BaseUnityPlugin)this).Config.Bind("Visuals", "FirstPersonLeafHandScale", 0.6f, "Scale applied only to Sargento Pingu's leaf tips in first person. The third-person model is unchanged."); ModelVerticalOffset = ((BaseUnityPlugin)this).Config.Bind("Visuals", "ModelVerticalOffset", -0.55f, "Vertical offset applied only to Sargento Pingu's full body model. Negative values lower the model without moving the camera or player collider."); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "peteypiranhaassets"); Bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)Bundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not load Petey Piranha AssetBundle: " + text)); return; } PeteyPrefab = Bundle.LoadAsset("PeteyPiranhaModel"); if ((Object)(object)PeteyPrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"AssetBundle did not contain a GameObject named PeteyPiranhaModel."); return; } PreparePrefab(PeteyPrefab); if (replaceEveryPlayer.Value) { ModelReplacementAPI.RegisterModelReplacementOverride(typeof(PeteyPiranhaBodyReplacement)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered Sargento Pingu as the global player model replacement for testing."); } else { ModelReplacementAPI.RegisterSuitModelReplacement("Sargento Pingu", typeof(PeteyPiranhaBodyReplacement)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered Sargento Pingu for the suit named Sargento Pingu."); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Sargento Pingu 1.0.0 loaded."); } private static void PreparePrefab(GameObject prefab) { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) Animator componentInChildren = prefab.GetComponentInChildren(); if ((Object)(object)componentInChildren == (Object)null) { throw new InvalidOperationException("PeteyPiranhaModel has no Animator."); } if ((Object)(object)componentInChildren.avatar == (Object)null || !componentInChildren.avatar.isValid || !componentInChildren.avatar.isHuman) { throw new InvalidOperationException("PeteyPiranhaModel does not contain a valid humanoid Avatar."); } OffsetBuilder obj = ((Component)componentInChildren).GetComponent() ?? ((Component)componentInChildren).gameObject.AddComponent(); float num = Mathf.Clamp(ModelVerticalOffset.Value, -0.8f, 0.1f); obj.rootPositionOffset = new Vector3(0f, num, 0f); obj.rootScale = Vector3.one; obj.itemPositonOffset = Vector3.zero; obj.itemRotationOffset = Quaternion.identity; obj.UseNoPostProcessing = false; obj.GenerateViewModel = true; obj.RemoveHelmet = true; Log.LogInfo((object)("Prepared Petey Piranha humanoid prefab. " + $"Renderers={prefab.GetComponentsInChildren(true).Length}; avatar={((Object)componentInChildren.avatar).name}; " + $"verticalOffset={num:0.000}")); } } public sealed class PeteyPiranhaBodyReplacement : BodyReplacementBase { protected override GameObject LoadAssetsAndReturnModel() { if ((Object)(object)PeteyPiranhaPlugin.PeteyPrefab == (Object)null) { throw new InvalidOperationException("Petey Piranha prefab is not loaded."); } return PeteyPiranhaPlugin.PeteyPrefab; } protected override ViewModelUpdater GetViewModelUpdater() { return (ViewModelUpdater)(object)new PeteyPiranhaViewModelUpdater(); } } public sealed class PeteyPiranhaViewModelUpdater : ViewModelUpdater { public override void AssignViewModelReplacement(GameObject player, GameObject replacementViewModel) { ((ViewModelUpdater)this).AssignViewModelReplacement(player, replacementViewModel); float num = Mathf.Clamp(PeteyPiranhaPlugin.FirstPersonLeafHandScale.Value, 0.25f, 1f); ScaleHand(((ViewModelUpdater)this).GetViewModelTransformFromBoneName("hand.L"), num); ScaleHand(((ViewModelUpdater)this).GetViewModelTransformFromBoneName("hand.R"), num); PeteyPiranhaPlugin.Log.LogInfo((object)$"Applied first-person leaf hand scale: {num:0.00}"); } private static void ScaleHand(Transform hand, float scale) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hand != (Object)null) { hand.localScale = Vector3.one * scale; } } } }