using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BoneLib;
using BoneLib.BoneMenu;
using BoneLib.Notifications;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.PuppetMasta;
using MelonLoader;
using Microsoft.CodeAnalysis;
using RagdollNPCs;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(RagdollNPCsMod), "Ragdoll NPCs", "1.0.0", "habibis_v on discord", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("RagdollNPCs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RagdollNPCs")]
[assembly: AssemblyTitle("RagdollNPCs")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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]
[Microsoft.CodeAnalysis.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;
}
}
}
namespace RagdollNPCs
{
public class RagdollNPCsMod : MelonMod
{
private static readonly Dictionary<int, float> _savedWeights = new Dictionary<int, float>();
private static bool _built;
public override void OnInitializeMelon()
{
Hooking.OnUIRigCreated += BuildMenu;
((MelonBase)this).LoggerInstance.Msg("Ragdoll NPCs loaded.");
}
private static void BuildMenu()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
if (!_built)
{
_built = true;
Page val = Page.Root.CreatePage("Ragdoll NPCs", Color.magenta, 0, true);
val.CreateFunction("Ragdoll All NPCs", Color.red, (Action)delegate
{
RagdollAll();
});
val.CreateFunction("Restore All NPCs", Color.green, (Action)delegate
{
RestoreAll();
});
val.CreateFunction("────────────────", Color.blue, (Action)delegate
{
});
val.CreateFunction("Add me on discord", Color.blue, (Action)delegate
{
});
val.CreateFunction("if you need help!", Color.blue, (Action)delegate
{
});
val.CreateFunction("Discord: habibis_v", Color.blue, (Action)delegate
{
});
}
}
private static void RagdollAll()
{
Il2CppArrayBase<AIBrain> val = Object.FindObjectsOfType<AIBrain>();
if (val == null || val.Count == 0)
{
Notify((NotificationType)1, "No NPCs found.");
return;
}
int num = 0;
foreach (AIBrain item in val)
{
if (!((Object)(object)((item != null) ? item.puppetMaster : null) == (Object)null))
{
PuppetMaster puppetMaster = item.puppetMaster;
int instanceID = ((Object)puppetMaster).GetInstanceID();
if (!_savedWeights.ContainsKey(instanceID))
{
_savedWeights[instanceID] = puppetMaster.muscleWeight;
}
puppetMaster.muscleWeight = 0f;
num++;
}
}
MelonLogger.Msg($"[RagdollNPCs] Ragdolled {num} NPCs.");
Notify((NotificationType)3, $"Ragdolled {num} NPC{((num == 1) ? "" : "s")}!");
}
private static void RestoreAll()
{
if (_savedWeights.Count == 0)
{
Notify((NotificationType)1, "Nothing to restore.");
return;
}
Il2CppArrayBase<AIBrain> val = Object.FindObjectsOfType<AIBrain>();
int num = 0;
foreach (AIBrain item in val)
{
if (!((Object)(object)((item != null) ? item.puppetMaster : null) == (Object)null))
{
PuppetMaster puppetMaster = item.puppetMaster;
int instanceID = ((Object)puppetMaster).GetInstanceID();
if (_savedWeights.TryGetValue(instanceID, out var value))
{
puppetMaster.muscleWeight = value;
num++;
}
}
}
_savedWeights.Clear();
MelonLogger.Msg($"[RagdollNPCs] Restored {num} NPCs.");
Notify((NotificationType)3, $"Restored {num} NPC{((num == 1) ? "" : "s")}!");
}
private static void Notify(NotificationType type, string message)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
Notifier.Send(new Notification
{
Title = NotificationText.op_Implicit("Ragdoll NPCs"),
Message = NotificationText.op_Implicit(message),
Type = type,
ShowTitleOnPopup = true,
PopupLength = 2f
});
}
}
}