using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using FishNet; using FishNet.Broadcast; using FishNet.Connection; using FishNet.Object; using FishNet.Serializing; using FishNet.Transporting; using HarmonyLib; using MetaVoiceChat.Output.AudioSource; using Microsoft.CodeAnalysis; using NWaves.Effects; using NWaves.Filters.Base; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ArceDev.HowToChonk")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0")] [assembly: AssemblyProduct("ArceDev.HowToChonk")] [assembly: AssemblyTitle("HowToChonk")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace HowToChonk { internal static class BodyMassSystem { private const float BroadcastInterval = 0.25f; private static readonly Dictionary BodyWeight = new Dictionary(); private static float _nextBroadcastAt; internal static void Consume(Player player, Creature creature) { if (InstanceFinder.IsServerStarted && Object.op_Implicit((Object)(object)player) && !((NetworkBehaviour)player).IsDeinitializing && Object.op_Implicit((Object)(object)creature) && !((NetworkBehaviour)creature).IsDeinitializing) { int num = (int)((float)creature.FullnessToRestore * GameInfo.CooknessEatCurve.Evaluate(((Item)creature).Cookness)); float num2 = Mathf.Max(0f, ((Item)creature)._weight * ((Item)creature).RandomizedWeight); float num3 = BodyMassRules.ExcessWeightGain(player.Vitals.Fullness, num, num2, Plugin.WeightGainMultiplier); if (!(num3 <= 0f)) { float num4 = Current(player) + num3; BodyWeight[((NetworkBehaviour)player).ObjectId] = Mathf.Clamp(num4, 0f - Plugin.MaximumThinWeight, Plugin.MaximumFatWeight); Plugin.Log.LogInfo((object)($"{player.SteamName} gained {num3:0.###} body weight from {num2:0.###} kg of food " + $"at {player.Vitals.Fullness}/100 fullness (+{num}).")); } } } internal static void UpdateServer() { if (!InstanceFinder.IsServerStarted) { return; } foreach (Player player in PlayerManager.Players) { UpdatePlayer(player); } if (Time.time < _nextBroadcastAt) { return; } _nextBroadcastAt = Time.time + 0.25f; foreach (Player player2 in PlayerManager.Players) { BodyNetwork.Send(player2, Shape(player2)); } } internal static void Remove(Player player) { BodyWeight.Remove(((NetworkBehaviour)player).ObjectId); } private static void UpdatePlayer(Player player) { if (Object.op_Implicit((Object)(object)player) && !((NetworkBehaviour)player).IsDeinitializing && !player.Dying.IsDead) { BodyWeight[((NetworkBehaviour)player).ObjectId] = BodyMassRules.Update(Current(player), player.Vitals.Fullness, Time.deltaTime, Plugin.NaturalFatLossPerMinute, Plugin.StarvationLossPerMinute, Plugin.CriticalFullness, Plugin.MaximumThinWeight); } } private static float Current(Player player) { if (!BodyWeight.TryGetValue(((NetworkBehaviour)player).ObjectId, out var value)) { return 0f; } return value; } private static float Shape(Player player) { float num = Current(player); float num2 = ((num >= 0f) ? Plugin.MaximumFatWeight : Plugin.MaximumThinWeight); return Mathf.Clamp(num / num2, -1f, 1f); } } internal static class BodyMassRules { internal static float ExcessWeightGain(int fullness, int fullnessGain, float creatureWeight, float multiplier) { if (fullnessGain <= 0 || creatureWeight <= 0f || multiplier <= 0f) { return 0f; } int num = Mathf.Max(0, 100 - fullness); int num2 = Mathf.Max(0, fullnessGain - num); return creatureWeight * (float)num2 / (float)fullnessGain * multiplier; } internal static float Update(float bodyWeight, int fullness, float deltaTime, float fatLossPerMinute, float starvationLossPerMinute, int criticalFullness, float maximumThinWeight) { if (bodyWeight > 0f) { return Mathf.MoveTowards(bodyWeight, 0f, fatLossPerMinute / 60f * deltaTime); } if (fullness >= criticalFullness) { return bodyWeight; } float num = (float)(criticalFullness - fullness) / (float)criticalFullness; float num2 = starvationLossPerMinute / 60f * num * deltaTime; return Mathf.Max(0f - maximumThinWeight, bodyWeight - num2); } internal static void Validate() { if (!Mathf.Approximately(ExcessWeightGain(80, 20, 10f, 1f), 0f) || !Mathf.Approximately(ExcessWeightGain(90, 20, 10f, 1f), 5f) || !Mathf.Approximately(ExcessWeightGain(100, 20, 10f, 1f), 10f) || !Mathf.Approximately(Update(10f, 100, 60f, 2f, 2f, 50, 20f), 8f) || !Mathf.Approximately(Update(0f, 25, 60f, 2f, 2f, 50, 20f), -1f) || !Mathf.Approximately(Update(-5f, 75, 60f, 2f, 2f, 50, 20f), -5f)) { throw new InvalidOperationException("Body mass rule validation failed."); } } } internal readonly record struct BodyShapeBroadcast(int PlayerObjectId, float Shape) : IBroadcast; internal static class BodyNetwork { private static readonly Action Handler = OnBodyShape; private static readonly Dictionary Shapes = new Dictionary(); private static bool _clientRegistered; internal static void Initialize() { GenericWriter.SetWrite((Action)delegate(Writer writer, BodyShapeBroadcast message) { writer.WriteInt32(message.PlayerObjectId); writer.WriteSingle(message.Shape); }); GenericReader.SetRead((Func)((Reader reader) => new BodyShapeBroadcast(reader.ReadInt32(), reader.ReadSingle()))); } internal static void RegisterClient() { if (!_clientRegistered && Object.op_Implicit((Object)(object)InstanceFinder.ClientManager)) { InstanceFinder.ClientManager.RegisterBroadcast(Handler); _clientRegistered = true; } } internal static void Send(Player player, float shape) { if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)InstanceFinder.ServerManager)) { return; } BodyShapeBroadcast bodyShapeBroadcast = new BodyShapeBroadcast(((NetworkBehaviour)player).ObjectId, Mathf.Clamp(shape, -1f, 1f)); foreach (NetworkConnection value in InstanceFinder.ServerManager.Clients.Values) { if (value.IsAuthenticated) { InstanceFinder.ServerManager.Broadcast(value, bodyShapeBroadcast, true, (Channel)0); } } } internal static float ShapeFor(Player player) { if (!Object.op_Implicit((Object)(object)player) || !Shapes.TryGetValue(((NetworkBehaviour)player).ObjectId, out var value)) { return 0f; } return value; } internal static void Remove(Player player) { Shapes.Remove(((NetworkBehaviour)player).ObjectId); } private static void OnBodyShape(BodyShapeBroadcast message, Channel channel) { Shapes[message.PlayerObjectId] = Mathf.Clamp(message.Shape, -1f, 1f); } } [DefaultExecutionOrder(10000)] internal sealed class BodyShapeController : MonoBehaviour { private readonly List _bones = new List(); private BeanVisualBinding? _beanVisual; private Player _player; private float _currentShape; internal static void Attach(Player player) { BodyShapeController bodyShapeController = ((Component)player).GetComponent() ?? ((Component)player).gameObject.AddComponent(); bodyShapeController._player = player; bodyShapeController.CaptureBones(); } internal static void Refresh(Player player) { BodyShapeController component = ((Component)player).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.CaptureBones(); } } private void OnDisable() { RestoreBones(); } private void LateUpdate() { _currentShape = Mathf.MoveTowards(_currentShape, Plugin.ShapeFor(_player), Time.deltaTime * 1.5f); foreach (BoneBinding bone in _bones) { bone.Apply(_currentShape); } _beanVisual?.Apply(_currentShape); } private void CaptureBones() { RestoreBones(); _bones.Clear(); _beanVisual = null; Transform[] array = (from bone in ((Component)this).GetComponentsInChildren(true).SelectMany((SkinnedMeshRenderer renderer) => renderer.bones) where Object.op_Implicit((Object)(object)bone) select bone).Distinct().ToArray(); Transform[] array2 = array; foreach (Transform val in array2) { if (BodyShapeProfile.TryClassify(((Object)val).name, out var region)) { _bones.Add(new BoneBinding(val, region)); } } Player player = _player; PlayerBody val2 = ((player != null) ? player.Body : null); if (val2 != null && val2._isOldModel) { _beanVisual = new BeanVisualBinding(val2); } } private void RestoreBones() { _beanVisual?.Restore(); foreach (BoneBinding bone in _bones) { bone.Restore(); } } } internal sealed class BeanVisualBinding { private readonly Transform _body; private readonly Transform _head; private readonly Transform _nameCanvas; private readonly Vector3 _bodyScale; private readonly Vector3 _headScale; private readonly Vector3 _nameCanvasScale; private readonly bool _headInheritsBodyScale; internal BeanVisualBinding(PlayerBody playerBody) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) _body = playerBody._oldCharacter.transform; _head = playerBody._oldHead.transform; _nameCanvas = playerBody._nameTextCanvasHolder; _bodyScale = _body.localScale; _headScale = _head.localScale; _nameCanvasScale = _nameCanvas.localScale; _headInheritsBodyScale = _head.IsChildOf(_body); } internal void Apply(float shape) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) float num = BodyShapeProfile.RadialMultiplier(BoneRegion.Torso, shape); float num2 = BodyShapeProfile.RadialMultiplier(BoneRegion.Head, shape); _body.localScale = RadialScale(_bodyScale, num); _head.localScale = RadialScale(_headScale, _headInheritsBodyScale ? (num2 / num) : num2); _nameCanvas.localScale = RadialScale(_nameCanvasScale, 1f / num); } internal void Restore() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_body)) { _body.localScale = _bodyScale; } if (Object.op_Implicit((Object)(object)_head)) { _head.localScale = _headScale; } if (Object.op_Implicit((Object)(object)_nameCanvas)) { _nameCanvas.localScale = _nameCanvasScale; } } private static Vector3 RadialScale(Vector3 original, float multiplier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return Vector3.Scale(original, new Vector3(multiplier, 1f, multiplier)); } } internal sealed class BoneBinding { private readonly Transform _bone; private readonly BoneRegion _region; private readonly Vector3 _originalScale; private readonly int _lengthAxis; internal BoneBinding(Transform bone, BoneRegion region) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _bone = bone; _region = region; _originalScale = bone.localScale; _lengthAxis = LongestChildAxis(bone); } internal void Apply(float shape) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_bone)) { float num = BodyShapeProfile.RadialMultiplier(_region, shape); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(num, num, num); ((Vector3)(ref val))[_lengthAxis] = 1f; _bone.localScale = Vector3.Scale(_originalScale, val); } } internal void Restore() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_bone)) { _bone.localScale = _originalScale; } } private static int LongestChildAxis(Transform bone) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (from index in Enumerable.Range(0, bone.childCount) select bone.GetChild(index).localPosition into position orderby ((Vector3)(ref position)).sqrMagnitude descending select position).FirstOrDefault(); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Mathf.Abs(val.x), Mathf.Abs(val.y), Mathf.Abs(val.z)); if (val2.x > val2.y && val2.x > val2.z) { return 0; } if (val2.z > val2.y) { return 2; } return 1; } } internal enum BoneRegion { Torso, UpperLimb, LowerLimb, Extremity, Head } internal static class BodyShapeProfile { internal static bool TryClassify(string name, out BoneRegion region) { string value = name.Replace("_", string.Empty).Replace(" ", string.Empty).ToLowerInvariant(); if (ContainsAny(value, "armlower", "lowerarm", "forearm", "leglower", "lowerleg", "calf", "shin")) { region = BoneRegion.LowerLimb; return true; } if (ContainsAny(value, "armupper", "upperarm", "legupper", "upperleg", "thigh")) { region = BoneRegion.UpperLimb; return true; } if (ContainsAny(value, "hand", "foot")) { region = BoneRegion.Extremity; return true; } if (ContainsAny(value, "head", "neck")) { region = BoneRegion.Head; return true; } if (ContainsAny(value, "body", "spine", "chest", "torso", "hip", "pelvis", "belly")) { region = BoneRegion.Torso; return true; } region = BoneRegion.Torso; return false; } internal static float RadialMultiplier(BoneRegion region, float shape) { if (!(shape < 0f)) { return ChonkMultiplier(region, shape); } return ThinMultiplier(region, 0f - shape); } private static float ChonkMultiplier(BoneRegion region, float shape) { return region switch { BoneRegion.Torso => 1f + 0.7f * Stage(shape, 0f, 0.5f), BoneRegion.UpperLimb => 1f + 0.38f * Stage(shape, 0.2f, 0.8f), BoneRegion.LowerLimb => 1f + 0.24f * Stage(shape, 0.45f, 1f), BoneRegion.Extremity => 1f + 0.1f * Stage(shape, 0.7f, 1f), BoneRegion.Head => 1f + 0.03f * Stage(shape, 0.9f, 1f), _ => 1f, }; } private static float ThinMultiplier(BoneRegion region, float thin) { return region switch { BoneRegion.Torso => 1f - 0.28f * thin, BoneRegion.UpperLimb => 1f - 0.18f * thin, BoneRegion.LowerLimb => 1f - 0.12f * thin, BoneRegion.Extremity => 1f - 0.04f * thin, BoneRegion.Head => 1f - 0.01f * thin, _ => 1f, }; } internal static void Validate() { if (Enum.GetValues(typeof(BoneRegion)).Cast().Any((BoneRegion region) => RadialMultiplier(region, 0f) != 1f) || RadialMultiplier(BoneRegion.UpperLimb, 0.1f) != 1f || RadialMultiplier(BoneRegion.LowerLimb, 0.4f) != 1f || RadialMultiplier(BoneRegion.Extremity, 0.6f) != 1f || !(RadialMultiplier(BoneRegion.Torso, 1f) > RadialMultiplier(BoneRegion.UpperLimb, 1f)) || !(RadialMultiplier(BoneRegion.UpperLimb, 1f) > RadialMultiplier(BoneRegion.LowerLimb, 1f)) || !(RadialMultiplier(BoneRegion.Torso, -1f) < RadialMultiplier(BoneRegion.UpperLimb, -1f))) { throw new InvalidOperationException("Body shape profile validation failed."); } } private static bool ContainsAny(string value, params string[] candidates) { return candidates.Any(value.Contains); } private static float Stage(float value, float start, float end) { return Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(start, end, value)); } } internal sealed class PitchShiftProcessor { private const int FftSize = 1024; private const int HopSize = 128; private const float Smoothing = 0.001f; private const float BypassThreshold = 0.001f; private const float PeakLimit = 0.9f; private const float LimiterReleasePerBlock = 0.02f; private readonly int _sampleRate; private PitchShiftVocoderEffect[] _effects; private float _currentPitch = 1f; private float _wet; private float _limiterGain = 1f; private int _processedFrames; internal PitchShiftProcessor(int sampleRate) { _sampleRate = sampleRate; _effects = CreateEffects(2); } internal void Process(float[] data, int channels, float targetPitch) { if (channels <= 0 || data.Length % channels != 0) { return; } EnsureChannels(channels); targetPitch = Math.Clamp(targetPitch, 0.5f, 2f); for (int i = 0; i < data.Length; i += channels) { _currentPitch += (targetPitch - _currentPitch) * 0.001f; _processedFrames++; float num = ((_processedFrames >= 1024 && MathF.Abs(_currentPitch - 1f) >= 0.001f) ? 1f : 0f); _wet += (num - _wet) * 0.001f; float num2 = ((_currentPitch < 1f) ? (_currentPitch * _currentPitch * _currentPitch) : 1f); for (int j = 0; j < channels; j++) { PitchShiftVocoderEffect val = _effects[j]; val.Shift = _currentPitch; float num3 = data[i + j]; float num4 = ((OverlapAddFilter)val).Process(num3) * num2; data[i + j] = num3 + (num4 - num3) * _wet; } } LimitPeaks(data); } internal static void Validate() { } private void EnsureChannels(int channels) { if (_effects.Length < channels) { _effects = CreateEffects(channels); } } private PitchShiftVocoderEffect[] CreateEffects(int channels) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown PitchShiftVocoderEffect[] array = (PitchShiftVocoderEffect[])(object)new PitchShiftVocoderEffect[channels]; for (int i = 0; i < channels; i++) { array[i] = new PitchShiftVocoderEffect(_sampleRate, 1.0, 1024, 128); } return array; } private void LimitPeaks(float[] data) { if (_wet <= 0.001f) { _limiterGain = 1f; return; } float num = 0f; for (int i = 0; i < data.Length; i++) { num = MathF.Max(num, MathF.Abs(data[i])); } float num2 = ((num > 0.9f) ? (0.9f / num) : 1f); _limiterGain = ((num2 < _limiterGain) ? num2 : MathF.Min(num2, _limiterGain + 0.02f)); if (!(_limiterGain >= 1f)) { for (int j = 0; j < data.Length; j++) { data[j] *= _limiterGain; } } } } [BepInPlugin("ArceDev.HowToChonk", "HowToChonk", "0.2.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "OnStartClient")] private static class PlayerStartPatch { private static void Postfix(Player __instance) { BodyNetwork.RegisterClient(); BodyShapeController.Attach(__instance); } } [HarmonyPatch(typeof(Player), "OnStopClient")] private static class PlayerStopPatch { private static void Prefix(Player __instance) { BodyMassSystem.Remove(__instance); BodyNetwork.Remove(__instance); } } [HarmonyPatch(typeof(Server), "RpcLogic___FinishEatingCreature___1039939981")] private static class FinishEatingPatch { private static void Prefix(Creature __0, Player __1) { BodyMassSystem.Consume(__1, __0); } } [HarmonyPatch(typeof(PlayerBody), "ToggleOldModel")] private static class PlayerModelPatch { private static void Postfix(Player ____player) { BodyShapeController.Refresh(____player); } } [HarmonyPatch(typeof(VcAudioSourceOutput), "Start")] private static class VoicePitchPatch { private static void Postfix(VcAudioSourceOutput __instance, Player ____player) { if (Object.op_Implicit((Object)(object)____player) && Object.op_Implicit((Object)(object)__instance.audioSource)) { VoicePitchFilter.Attach(__instance.audioSource, ____player); } } } public const string Id = "ArceDev.HowToChonk"; internal static ManualLogSource Log { get; private set; } internal static float WeightGainMultiplier => GainMultiplier.Value; internal static float NaturalFatLossPerMinute => FatLossPerMinute.Value; internal static float StarvationLossPerMinute => ThinLossPerMinute.Value; internal static float MaximumFatWeight => MaxFatWeight.Value; internal static float MaximumThinWeight => MaxThinWeight.Value; internal static int CriticalFullness => CriticalFullnessEntry.Value; private static ConfigEntry GainMultiplier { get; set; } private static ConfigEntry FatLossPerMinute { get; set; } private static ConfigEntry ThinLossPerMinute { get; set; } private static ConfigEntry MaxFatWeight { get; set; } private static ConfigEntry MaxThinWeight { get; set; } private static ConfigEntry CriticalFullnessEntry { get; set; } private static ConfigEntry ChonkVoicePitch { get; set; } private static ConfigEntry ThinVoicePitch { get; set; } public static string Name => "HowToChonk"; public static string Version => "0.2.0"; private void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; GainMultiplier = ((BaseUnityPlugin)this).Config.Bind("Body Weight", "GainMultiplier", 1f, new ConfigDescription("Multiplier applied to the excess fraction of a creature's real weight.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 10f), Array.Empty())); FatLossPerMinute = ((BaseUnityPlugin)this).Config.Bind("Body Weight", "NaturalFatLossPerMinute", 1f, new ConfigDescription("Positive body weight naturally lost per minute.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 20f), Array.Empty())); ThinLossPerMinute = ((BaseUnityPlugin)this).Config.Bind("Body Weight", "StarvationLossPerMinute", 1f, new ConfigDescription("Maximum body deficit gained per minute at zero fullness.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 20f), Array.Empty())); MaxFatWeight = ((BaseUnityPlugin)this).Config.Bind("Body Weight", "MaximumFatWeight", 50f, new ConfigDescription("Body weight that displays maximum chonk.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 500f), Array.Empty())); MaxThinWeight = ((BaseUnityPlugin)this).Config.Bind("Body Weight", "MaximumThinWeight", 20f, new ConfigDescription("Body deficit that displays maximum thinness.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 200f), Array.Empty())); CriticalFullnessEntry = ((BaseUnityPlugin)this).Config.Bind("Body Weight", "CriticalFullness", 50, new ConfigDescription("Below this fullness, a base-weight character gradually becomes thin.", (AcceptableValueBase)(object)new AcceptableValueRange(1, 99), Array.Empty())); ChonkVoicePitch = ((BaseUnityPlugin)this).Config.Bind("Voice", "PitchAtMaximumChonk", 0.7f, new ConfigDescription("Voice pitch multiplier at maximum chonk.", (AcceptableValueBase)(object)new AcceptableValueRange(0.5f, 1f), Array.Empty())); ThinVoicePitch = ((BaseUnityPlugin)this).Config.Bind("Voice", "PitchAtMaximumThinness", 1.5f, new ConfigDescription("Voice pitch multiplier at maximum thinness.", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 1.5f), Array.Empty())); BodyShapeProfile.Validate(); BodyMassRules.Validate(); ValidateVoicePitch(); PitchShiftProcessor.Validate(); BodyNetwork.Initialize(); Harmony.CreateAndPatchAll(typeof(Plugin).Assembly, "ArceDev.HowToChonk"); Log.LogInfo((object)("Plugin " + Name + " is loaded.")); } private void Update() { BodyMassSystem.UpdateServer(); } internal static float ShapeFor(Player player) { return BodyNetwork.ShapeFor(player); } internal static float VoicePitchFor(Player player) { return VoicePitchForShape(ShapeFor(player)); } private static float VoicePitchForShape(float shape) { return Mathf.Lerp(1f, (shape < 0f) ? ThinVoicePitch.Value : ChonkVoicePitch.Value, Mathf.Abs(shape)); } private static void ValidateVoicePitch() { if (!Mathf.Approximately(VoicePitchForShape(0f), 1f) || !Mathf.Approximately(VoicePitchForShape(-1f), ThinVoicePitch.Value) || !Mathf.Approximately(VoicePitchForShape(1f), ChonkVoicePitch.Value)) { throw new InvalidOperationException("Voice pitch profile validation failed."); } } } internal sealed class VoicePitchFilter : MonoBehaviour { private PitchShiftProcessor _processor; private Player _player; private volatile float _targetPitch = 1f; internal static void Attach(AudioSource source, Player player) { VoicePitchFilter voicePitchFilter = ((Component)source).GetComponent() ?? ((Component)source).gameObject.AddComponent(); voicePitchFilter._player = player; VoicePitchFilter voicePitchFilter2 = voicePitchFilter; if (voicePitchFilter2._processor == null) { voicePitchFilter2._processor = new PitchShiftProcessor(AudioSettings.outputSampleRate); } } private void Update() { if (Object.op_Implicit((Object)(object)_player)) { _targetPitch = Plugin.VoicePitchFor(_player); } } private void OnAudioFilterRead(float[] data, int channels) { _processor.Process(data, channels, _targetPitch); } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ConstantExpectedAttribute : Attribute { public object? Min { get; set; } public object? Max { get; set; } } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ExperimentalAttribute : Attribute { public string DiagnosticId { get; } public string? UrlFormat { get; set; } public ExperimentalAttribute(string diagnosticId) { DiagnosticId = diagnosticId; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SetsRequiredMembersAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class StringSyntaxAttribute : Attribute { public const string CompositeFormat = "CompositeFormat"; public const string DateOnlyFormat = "DateOnlyFormat"; public const string DateTimeFormat = "DateTimeFormat"; public const string EnumFormat = "EnumFormat"; public const string GuidFormat = "GuidFormat"; public const string Json = "Json"; public const string NumericFormat = "NumericFormat"; public const string Regex = "Regex"; public const string TimeOnlyFormat = "TimeOnlyFormat"; public const string TimeSpanFormat = "TimeSpanFormat"; public const string Uri = "Uri"; public const string Xml = "Xml"; public string Syntax { get; } public object?[] Arguments { get; } public StringSyntaxAttribute(string syntax) { Syntax = syntax; Arguments = new object[0]; } public StringSyntaxAttribute(string syntax, params object?[] arguments) { Syntax = syntax; Arguments = arguments; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class UnscopedRefAttribute : Attribute { } } namespace System.Runtime.Versioning { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiresPreviewFeaturesAttribute : Attribute { public string? Message { get; } public string? Url { get; set; } public RequiresPreviewFeaturesAttribute() { } public RequiresPreviewFeaturesAttribute(string? message) { Message = message; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CallerArgumentExpressionAttribute : Attribute { public string ParameterName { get; } public CallerArgumentExpressionAttribute(string parameterName) { ParameterName = parameterName; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CollectionBuilderAttribute : Attribute { public Type BuilderType { get; } public string MethodName { get; } public CollectionBuilderAttribute(Type builderType, string methodName) { BuilderType = builderType; MethodName = methodName; } } [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class CompilerFeatureRequiredAttribute : Attribute { public const string RefStructs = "RefStructs"; public const string RequiredMembers = "RequiredMembers"; public string FeatureName { get; } public bool IsOptional { get; set; } public CompilerFeatureRequiredAttribute(string featureName) { FeatureName = featureName; } } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute { public string[] Arguments { get; } public InterpolatedStringHandlerArgumentAttribute(string argument) { Arguments = new string[1] { argument }; } public InterpolatedStringHandlerArgumentAttribute(params string[] arguments) { Arguments = arguments; } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class InterpolatedStringHandlerAttribute : Attribute { } [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal static class IsExternalInit { } [AttributeUsage(AttributeTargets.Method, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class ModuleInitializerAttribute : Attribute { } [AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class OverloadResolutionPriorityAttribute : Attribute { public int Priority { get; } public OverloadResolutionPriorityAttribute(int priority) { Priority = priority; } } [AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)] [ExcludeFromCodeCoverage] internal sealed class ParamCollectionAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class RequiredMemberAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] [EditorBrowsable(EditorBrowsableState.Never)] [ExcludeFromCodeCoverage] internal sealed class RequiresLocationAttribute : Attribute { } [AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)] [ExcludeFromCodeCoverage] internal sealed class SkipLocalsInitAttribute : Attribute { } }