Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Y4NGZContent v1.0.0
LGUCasinoSignDump.dll
Decompiled an hour agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; [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("LGUCasinoSignDump")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8a72f49be1165548a6e8f513d9e3988ce29f5647")] [assembly: AssemblyProduct("LGUCasinoSignDump")] [assembly: AssemblyTitle("LGUCasinoSignDump")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LGUCasinoSignDump { [BepInPlugin("com.y4ngz.lgucasinosigndump", "LGUCasinoSignDump", "1.0.0")] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.y4ngz.lgucasinosigndump"; public const string PLUGIN_NAME = "LGUCasinoSignDump"; public const string PLUGIN_VERSION = "1.0.0"; public static ManualLogSource Log; private Harmony _harmony; private bool _menuPatchApplied; private void Awake() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"LGUCasinoSignDump v1.0.0 loaded."); _harmony = new Harmony("com.y4ngz.lgucasinosigndump"); TryPatchMenuManagerFix(); if (!_menuPatchApplied) { AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoaded; SceneManager.sceneLoaded += OnSceneLoaded; ((MonoBehaviour)this).StartCoroutine(DelayedMenuFix()); } } private void OnAssemblyLoaded(object sender, AssemblyLoadEventArgs args) { if (!_menuPatchApplied) { TryPatchMenuManagerFix(); } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (!_menuPatchApplied) { TryPatchMenuManagerFix(); } } private IEnumerator DelayedMenuFix() { yield return null; yield return null; TryPatchMenuManagerFix(); } private void OnDestroy() { try { AppDomain.CurrentDomain.AssemblyLoad -= OnAssemblyLoaded; } catch { } try { SceneManager.sceneLoaded -= OnSceneLoaded; } catch { } Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void TryPatchMenuManagerFix() { if (_menuPatchApplied) { return; } try { Type type = AccessTools.TypeByName("MenuManager"); if (type == null) { return; } MethodInfo methodInfo = AccessTools.Method(type, "Start", (Type[])null, (Type[])null); if (methodInfo == null) { Log.LogWarning((object)"Found MenuManager type but could not find Start method."); return; } bool flag = false; int num = 0; Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo); if (patchInfo != null) { foreach (Patch postfix in patchInfo.Postfixes) { string text = postfix.PatchMethod?.DeclaringType?.FullName; if (text != null && text.StartsWith("LethalCasino")) { try { _harmony.Unpatch((MethodBase)methodInfo, postfix.PatchMethod); Log.LogInfo((object)("Unpatched LethalCasino postfix: " + text + "." + postfix.PatchMethod.Name + " (owner: " + postfix.owner + ") from MenuManager.Start.")); flag = true; } catch (Exception ex) { Log.LogWarning((object)("Failed to unpatch " + text + "." + postfix.PatchMethod.Name + ": " + ex.Message)); } } } foreach (Patch prefix in patchInfo.Prefixes) { MethodInfo patchMethod = prefix.PatchMethod; if ((object)patchMethod != null && patchMethod.DeclaringType?.FullName?.StartsWith("LethalCasino") == true) { num++; } } foreach (Patch transpiler in patchInfo.Transpilers) { MethodInfo patchMethod2 = transpiler.PatchMethod; if ((object)patchMethod2 != null && patchMethod2.DeclaringType?.FullName?.StartsWith("LethalCasino") == true) { num++; } } foreach (Patch finalizer in patchInfo.Finalizers) { MethodInfo patchMethod3 = finalizer.PatchMethod; if ((object)patchMethod3 != null && patchMethod3.DeclaringType?.FullName?.StartsWith("LethalCasino") == true) { num++; } } } if (num > 0) { Log.LogWarning((object)$"Saw {num} other LethalCasino patch(es) on MenuManager.Start (prefix/transpiler/finalizer) — left them in place."); } if (flag) { _menuPatchApplied = true; try { AppDomain.CurrentDomain.AssemblyLoad -= OnAssemblyLoaded; } catch { } try { SceneManager.sceneLoaded -= OnSceneLoaded; } catch { } Log.LogInfo((object)"Removed LethalCasino postfix(es) from MenuManager.Start — Mirage's MonoMod hook chain should now complete and voice mimicking should work."); } } catch (Exception ex2) { Log.LogWarning((object)("Could not unpatch LethalCasino MenuManager.Start postfix: " + ex2.Message)); } } } public static class PluginInfo { public const string PLUGIN_GUID = "LGUCasinoSignDump"; public const string PLUGIN_NAME = "LGUCasinoSignDump"; public const string PLUGIN_VERSION = "1.0.0"; } }
LGUEmotes.dll
Decompiled an hour agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using ModelReplacement; using ModelReplacement.Patches; using ModelReplacement.Scripts.Player; using TooManyEmotes; using TooManyEmotes.Audio; using TooManyEmotes.Networking; using Unity.Collections; using Unity.Netcode; 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("LGUEmotes")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8a72f49be1165548a6e8f513d9e3988ce29f5647")] [assembly: AssemblyProduct("LGUEmotes")] [assembly: AssemblyTitle("LGUEmotes")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LGUEmotes { public sealed class BundyBodyReplacement : SuitBodyReplacement { } [BepInPlugin("com.y4ngz.lguemotes", "LGUEmotes", "1.0.0")] [BepInDependency("FlipMods.TooManyEmotes", "2.3.17")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { private sealed class PreparedEmote { public string Slug; public string DisplayName; public AnimationClip Clip; public AudioClip Audio; public int Rarity; public bool IsPose; public bool ShouldLoop; public bool AudioLoops; } [Serializable] public sealed class EmoteRegistry { public string bundle_name; public string source_humanoid_avatar_fbx; public float fbx_animation_sample_rate; public List<EmoteEntry> emotes; } [Serializable] public sealed class EmoteEntry { public string slug; public string display_name; public string bucket; public string source_fbx; public string animation_asset_name; public string audio_asset_name; public string audio_path; public int rarity; public float speed_multiplier; public float snippet_length_sec; public float snippet_bpm; public bool loop_time; public float trim_start_sec; public float trim_end_sec; public string shares_motion_with; public bool disabled; public bool loop_audio = true; public EmoteSegments segments; } [Serializable] public sealed class EmoteSegments { public EmoteSegment begin; public EmoteSegment loop; public EmoteSegment stop; } [Serializable] public sealed class EmoteSegment { public string source_fbx; public string animation_asset_name; public bool loop_time; } public const string GUID = "com.y4ngz.lguemotes"; public const string NAME = "LGUEmotes"; public const string VERSION = "1.0.0"; internal const string TooManyEmotesGuid = "FlipMods.TooManyEmotes"; internal const string TooManyEmotesVersion = "2.3.17"; private const string BundleFilename = "y4ngz_emotes.bundle"; private const string LegacyBundleFilename = "y4ngz_emotes.lethalbundle"; private const string RegistryAsset = "y4ngz_emotes_registry"; private static readonly Dictionary<string, AudioClip> AudioByKey = new Dictionary<string, AudioClip>(StringComparer.Ordinal); internal static ManualLogSource Log; internal static ConfigEntry<bool> DiagnosticsEnabled; internal static ConfigEntry<bool> RequireHostFingerprint; internal static ConfigEntry<bool> AllowAnyTooManyEmotesVersion; internal static Plugin Instance; internal static readonly HashSet<UnlockableEmote> RegisteredEmotes = new HashSet<UnlockableEmote>(); internal static string LocalMapFingerprint = "no-lgu-emotes"; internal const string DisabledFingerprint = "no-lgu-emotes"; private AssetBundle _bundle; private Dictionary<string, AnimationClip> _clipsByName; private readonly HashSet<int> _clipsAlreadyRegistered = new HashSet<int>(); internal static bool CustomEmotesBlocked { get { if (!LocalRegistrationFailed) { return EmoteFingerprintHandshake.MismatchDetected; } return true; } } internal static bool LocalRegistrationFailed { get; private set; } private bool DiagnosticsActive { get { if (DiagnosticsEnabled != null) { return DiagnosticsEnabled.Value; } return false; } } private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; try { Initialize(); } catch (Exception ex) { DisableCustomEmotes("Unhandled exception during LGUEmotes startup: " + ex); } try { Suits.Initialize(((BaseUnityPlugin)this).Config); } catch (Exception ex2) { Log.LogError((object)("Suits are DISABLED: unhandled exception during registration: " + ex2)); } } private void Initialize() { DiagnosticsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Diagnostics", "Enable Verbose Diagnostics", false, "Log the deterministic TooManyEmotes registration map and audio routing details."); RequireHostFingerprint = ((BaseUnityPlugin)this).Config.Bind<bool>("Multiplayer", "Require Host Fingerprint", true, "Treat a host that never answers the emote fingerprint handshake as a mismatch and disable custom emotes locally. A silent host almost always means the host is not running LGUEmotes at all, which guarantees that emote IDs mean different things on each machine. Set to false only for a lobby you know is consistent."); AllowAnyTooManyEmotesVersion = ((BaseUnityPlugin)this).Config.Bind<bool>("Compatibility", "Allow Any TooManyEmotes Version", false, "Register custom emotes even when the loaded TooManyEmotes is not exactly 2.3.17. The pin exists because TooManyEmotes puts bare list indices on the wire, so a version that ships a different built-in emote count silently shifts every LGU emote ID. Enabling this is only safe when every peer runs the same TooManyEmotes build; the fingerprint handshake still compares the TooManyEmotes version and will disable custom emotes on any client that differs from the host."); try { Harmony.CreateAndPatchAll(typeof(TooManyEmotesAudioPatches), "com.y4ngz.lguemotes.tme-audio"); Harmony.CreateAndPatchAll(typeof(EmoteGuardPatches), "com.y4ngz.lguemotes.guards"); } catch (Exception ex) { DisableCustomEmotes("Harmony could not patch TooManyEmotes 2.3.17: " + ex.Message); return; } if (!ValidateTooManyEmotesVersion(out var problem)) { DisableCustomEmotes(problem); return; } string text = FindBundlePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "y4ngz_emotes.bundle", "y4ngz_emotes.lethalbundle"); if (text == null) { DisableCustomEmotes("Emote bundle not found beside LGUEmotes.dll."); return; } _bundle = FindPreloadedBundle("y4ngz_emotes_registry") ?? AssetBundle.LoadFromFile(text); if ((Object)(object)_bundle == (Object)null) { DisableCustomEmotes("AssetBundle.LoadFromFile returned null for " + text + "."); return; } _clipsByName = (from clip in _bundle.LoadAllAssets<AnimationClip>() where (Object)(object)clip != (Object)null && !((Object)clip).name.StartsWith("__preview__", StringComparison.Ordinal) select clip).GroupBy<AnimationClip, string>((AnimationClip clip) => ((Object)clip).name, StringComparer.Ordinal).ToDictionary<IGrouping<string, AnimationClip>, string, AnimationClip>((IGrouping<string, AnimationClip> group) => group.Key, (IGrouping<string, AnimationClip> group) => group.First(), StringComparer.Ordinal); EmoteRegistry emoteRegistry = LoadRegistry(_bundle); if (emoteRegistry == null || emoteRegistry.emotes == null) { DisableCustomEmotes("Failed to parse registry asset 'y4ngz_emotes_registry'."); return; } IReadOnlyList<PreparedEmote> prepared = PrepareRegistry(emoteRegistry.emotes); RegisterWithTooManyEmotes(prepared); } internal static void DisableCustomEmotes(string reason) { LocalRegistrationFailed = true; LocalMapFingerprint = "no-lgu-emotes"; (Log ?? (Log = Logger.CreateLogSource("LGUEmotes"))).LogError((object)("LGUEmotes custom emotes are DISABLED on this machine: " + reason + " The plugin stays loaded, TooManyEmotes keeps working, and this client will neither perform nor emit LGU custom emote IDs.")); } private static bool ValidateTooManyEmotesVersion(out string problem) { Version version = new Version("2.3.17"); Plugin instance = Plugin.instance; object obj; if (instance == null) { obj = null; } else { PluginInfo info = ((BaseUnityPlugin)instance).Info; if (info == null) { obj = null; } else { BepInPlugin metadata = info.Metadata; obj = ((metadata != null) ? metadata.Version : null); } } Version version2 = (Version)obj; if (version2 != null && version2 == version) { problem = null; return true; } string text = version2?.ToString() ?? "unknown"; if (version2 != null && AllowAnyTooManyEmotesVersion != null && AllowAnyTooManyEmotesVersion.Value) { Log.LogWarning((object)("LGUEmotes is built against TooManyEmotes " + version?.ToString() + " but loaded " + text + ". 'Allow Any TooManyEmotes Version' is enabled, so custom emotes are registered anyway. Every peer must run this same TooManyEmotes build or the fingerprint handshake will disable custom emotes for the mismatched clients.")); problem = null; return true; } problem = "LGUEmotes requires TooManyEmotes " + version?.ToString() + " exactly; loaded " + text + ". Exact versions preserve multiplayer emote IDs. Set 'Compatibility/Allow Any TooManyEmotes Version' to true to override."; return false; } private IReadOnlyList<PreparedEmote> PrepareRegistry(IEnumerable<EmoteEntry> entries) { List<PreparedEmote> list = new List<PreparedEmote>(); HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal); foreach (EmoteEntry entry in entries) { if (entry == null) { throw new InvalidOperationException("The emote registry contains a null row."); } if (entry.disabled) { Log.LogInfo((object)("Emote '" + entry.slug + "' is disabled in the registry; skipped.")); continue; } if (string.IsNullOrWhiteSpace(entry.slug) || !hashSet.Add(entry.slug)) { throw new InvalidOperationException("Duplicate or empty emote slug: '" + entry.slug + "'."); } bool isPose; bool flag; string text; switch (entry.bucket) { case "showpiece": isPose = false; flag = false; text = entry.animation_asset_name; break; case "loopable": isPose = false; flag = true; text = entry.animation_asset_name; break; case "pose": isPose = true; flag = true; text = entry.segments?.loop?.animation_asset_name; break; default: throw new InvalidOperationException("Emote '" + entry.slug + "' has unsupported bucket '" + entry.bucket + "'."); } if (string.IsNullOrWhiteSpace(text) || !_clipsByName.TryGetValue(text, out var value)) { throw new InvalidOperationException("Emote '" + entry.slug + "' is missing animation asset '" + text + "'."); } if (!((Motion)value).isHumanMotion) { throw new InvalidOperationException("Emote '" + entry.slug + "' animation '" + text + "' is not humanoid."); } AnimationClip val = CloneClipIfShared(value, entry.slug); if (flag && !((Motion)val).isLooping) { Log.LogWarning((object)("Emote '" + entry.slug + "' is marked " + entry.bucket + " but animation '" + ((Object)val).name + "' lacks Unity's loop flag.")); } AudioClip val2 = null; if (!string.IsNullOrWhiteSpace(entry.audio_asset_name)) { val2 = _bundle.LoadAsset<AudioClip>(entry.audio_asset_name); if ((Object)(object)val2 == (Object)null) { throw new InvalidOperationException("Emote '" + entry.slug + "' is missing audio asset '" + entry.audio_asset_name + "'."); } } list.Add(new PreparedEmote { Slug = entry.slug, DisplayName = (string.IsNullOrWhiteSpace(entry.display_name) ? entry.slug : entry.display_name), Clip = val, Audio = val2, Rarity = ClampRarity(entry.rarity), IsPose = isPose, ShouldLoop = flag, AudioLoops = entry.loop_audio }); } return list; } private AnimationClip CloneClipIfShared(AnimationClip clip, string slug) { if (_clipsAlreadyRegistered.Add(((Object)clip).GetInstanceID())) { return clip; } AnimationClip val = Object.Instantiate<AnimationClip>(clip); ((Object)val).name = ((Object)clip).name + "__" + slug; Log.LogInfo((object)("Emote '" + slug + "' shares animation '" + ((Object)clip).name + "'; using deterministic clone '" + ((Object)val).name + "'.")); return val; } private void RegisterWithTooManyEmotes(IReadOnlyList<PreparedEmote> prepared) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown if (EmotesManager.allUnlockableEmotes == null || EmotesManager.allUnlockableEmotesDict == null || EmotesManager.allEmotesTier0 == null || EmotesManager.allEmotesTier1 == null || EmotesManager.allEmotesTier2 == null || EmotesManager.allEmotesTier3 == null) { throw new InvalidOperationException("TooManyEmotes has not built its emote lists. The hard dependency load order is invalid."); } foreach (PreparedEmote item in prepared) { if (EmotesManager.allUnlockableEmotesDict.ContainsKey(item.Slug)) { throw new InvalidOperationException("TooManyEmotes already contains emote slug '" + item.Slug + "'. Registration aborted to protect multiplayer ID identity."); } } int count = EmotesManager.allUnlockableEmotes.Count; List<string> list = new List<string>(prepared.Count); foreach (PreparedEmote item2 in prepared) { int count2 = EmotesManager.allUnlockableEmotes.Count; UnlockableEmote val = new UnlockableEmote { emoteId = count2, emoteName = item2.Slug, displayName = item2.DisplayName, animationClip = item2.Clip, rarity = item2.Rarity, purchasable = true, complementary = false, isPose = item2.IsPose, canSyncEmote = true, isBoomboxAudio = false, overrideAudioClipName = (((Object)(object)item2.Audio != (Object)null) ? item2.Slug : string.Empty), overrideAudioLoopClipName = (((Object)(object)item2.Audio != (Object)null && item2.AudioLoops) ? item2.Slug : string.Empty) }; EmotesManager.allUnlockableEmotes.Add(val); EmotesManager.allUnlockableEmotesDict.Add(item2.Slug, val); TierList(item2.Rarity).Add(val); RegisteredEmotes.Add(val); if ((Object)(object)item2.Audio != (Object)null) { RegisterAudioKey(item2.Slug, item2.Audio); RegisterAudioKey(((Object)item2.Clip).name, item2.Audio); } list.Add(count2 + ":" + item2.Slug); } ValidateContiguousIds(count, prepared.Count); string text = (LocalMapFingerprint = ComputeIdFingerprint(list)); Log.LogInfo((object)("Registered " + prepared.Count + " emotes directly with TooManyEmotes 2.3.17; ids " + count + "-" + (count + prepared.Count - 1) + "; map fingerprint=" + text + ".")); if (DiagnosticsActive) { Log.LogInfo((object)("Deterministic emote ID map: " + string.Join(", ", list))); } } private static List<UnlockableEmote> TierList(int rarity) { return rarity switch { 0 => EmotesManager.allEmotesTier0, 1 => EmotesManager.allEmotesTier1, 2 => EmotesManager.allEmotesTier2, _ => EmotesManager.allEmotesTier3, }; } private static void ValidateContiguousIds(int firstId, int count) { for (int i = 0; i < count; i++) { int num = firstId + i; UnlockableEmote val = EmotesManager.allUnlockableEmotes[num]; if (val == null || val.emoteId != num || EmotesManager.allUnlockableEmotesDict[val.emoteName] != val) { throw new InvalidOperationException("TooManyEmotes registration produced a non-contiguous multiplayer ID at " + num + "."); } } } internal static string ComputeIdFingerprint(IEnumerable<string> idMap) { ulong num = 14695981039346656037uL; string text = string.Join(";", idMap); foreach (char c in text) { num ^= c; num *= 1099511628211L; } return num.ToString("x16"); } private static void RegisterAudioKey(string key, AudioClip clip) { if (!string.IsNullOrEmpty(key) && !((Object)(object)clip == (Object)null)) { if (AudioByKey.TryGetValue(key, out var value) && (Object)(object)value != (Object)(object)clip) { throw new InvalidOperationException("Conflicting custom emote audio key: '" + key + "'."); } AudioByKey[key] = clip; } } internal static bool TryGetCustomAudio(string key, out AudioClip clip) { if (key != null && AudioByKey.TryGetValue(key, out clip) && (Object)(object)clip != (Object)null) { return true; } clip = null; return false; } private static int ClampRarity(int rarity) { if (rarity >= 0) { if (rarity <= 3) { return rarity; } return 3; } return 0; } private static string FindBundlePath(string directory, params string[] fileNames) { foreach (string path in fileNames) { string text = Path.Combine(directory, path); if (File.Exists(text)) { return text; } } return null; } private static AssetBundle FindPreloadedBundle(string probeAssetName) { foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if ((Object)(object)allLoadedAssetBundle == (Object)null) { continue; } try { if (allLoadedAssetBundle.Contains(probeAssetName)) { return allLoadedAssetBundle; } } catch { } } return null; } private static EmoteRegistry LoadRegistry(AssetBundle bundle) { TextAsset val = bundle.LoadAsset<TextAsset>("y4ngz_emotes_registry"); if ((Object)(object)val == (Object)null) { return null; } try { return JsonUtility.FromJson<EmoteRegistry>(val.text); } catch (Exception ex) { Log.LogError((object)("Could not parse emote registry: " + ex)); return null; } } } [HarmonyPatch] internal static class TooManyEmotesAudioPatches { [HarmonyPatch(typeof(AudioManager), "AudioExists")] [HarmonyPostfix] private static void AudioExistsPostfix(string audioName, ref bool __result) { if (!__result && Plugin.TryGetCustomAudio(audioName, out var _)) { __result = true; } } [HarmonyPatch(typeof(AudioManager), "LoadAudioClip")] [HarmonyPrefix] private static bool LoadAudioClipPrefix(string clipName, ref AudioClip __result) { if (!Plugin.TryGetCustomAudio(clipName, out var clip)) { return true; } __result = clip; return false; } } internal static class EmoteFingerprintHandshake { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnRequestReceived; public static HandleNamedMessageDelegate <1>__OnReplyReceived; } internal const string RequestMessage = "Y4NGZ.LGUEmotes.FingerprintRequest"; internal const string ReplyMessage = "Y4NGZ.LGUEmotes.FingerprintReply"; private const float ReplyTimeoutSeconds = 15f; private const int MessageBufferBytes = 512; private const int MaxFingerprintLength = 256; private static int _handlerNetworkManagerId; private static bool _handlersRegisteredAsServer; private static bool _requestSent; private static bool _replyReceived; private static string _cachedListFingerprint; private static Coroutine _timeoutRoutine; internal static bool MismatchDetected { get; private set; } internal static void OnLocalClientReady() { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || singleton.CustomMessagingManager == null) { return; } int instanceID = ((Object)singleton).GetInstanceID(); if (_handlerNetworkManagerId != instanceID || _handlersRegisteredAsServer != singleton.IsServer) { ResetLobbyState(); _handlerNetworkManagerId = instanceID; _handlersRegisteredAsServer = singleton.IsServer; } try { if (singleton.IsServer) { CustomMessagingManager customMessagingManager = singleton.CustomMessagingManager; object obj = <>O.<0>__OnRequestReceived; if (obj == null) { HandleNamedMessageDelegate val = OnRequestReceived; <>O.<0>__OnRequestReceived = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler("Y4NGZ.LGUEmotes.FingerprintRequest", (HandleNamedMessageDelegate)obj); } else { CustomMessagingManager customMessagingManager2 = singleton.CustomMessagingManager; object obj2 = <>O.<1>__OnReplyReceived; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnReplyReceived; <>O.<1>__OnReplyReceived = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler("Y4NGZ.LGUEmotes.FingerprintReply", (HandleNamedMessageDelegate)obj2); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("LGUEmotes could not register its fingerprint handshake handlers: " + ex.Message)); return; } if (singleton.IsServer) { Plugin.Log.LogInfo((object)("LGUEmotes emote fingerprint (host authority): " + BuildLocalPayload())); } else if (!_requestSent) { _requestSent = true; SendRequest(singleton); if ((Object)(object)Plugin.Instance != (Object)null) { _timeoutRoutine = ((MonoBehaviour)Plugin.Instance).StartCoroutine(WaitForReply()); } } } internal static void OnDisconnected() { ResetForNewSession(); } internal static void ResetForNewSession() { _handlerNetworkManagerId = 0; _handlersRegisteredAsServer = false; ResetLobbyState(); } private static void ResetLobbyState() { _requestSent = false; _replyReceived = false; MismatchDetected = false; if (_timeoutRoutine != null && (Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StopCoroutine(_timeoutRoutine); } _timeoutRoutine = null; _cachedListFingerprint = null; } private static void SendRequest(NetworkManager network) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(512, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(BuildLocalPayload(), false); network.CustomMessagingManager.SendNamedMessage("Y4NGZ.LGUEmotes.FingerprintRequest", 0uL, val, (NetworkDelivery)3); } catch (Exception ex) { Plugin.Log.LogWarning((object)("LGUEmotes could not send its fingerprint request: " + ex.Message)); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } private static void OnRequestReceived(ulong senderClientId, FastBufferReader reader) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsServer || singleton.CustomMessagingManager == null || senderClientId == singleton.LocalClientId) { return; } string text = "unreadable"; try { ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false); if (text != null && text.Length > 256) { text = text.Substring(0, 256); } } catch (Exception ex) { Plugin.Log.LogWarning((object)("LGUEmotes received a malformed fingerprint request from client " + senderClientId + ": " + ex.Message)); } string text2 = BuildLocalPayload(); if (!string.Equals(text2, text, StringComparison.Ordinal)) { Plugin.Log.LogWarning((object)("LGUEmotes emote map MISMATCH with client " + senderClientId + ". host=" + text2 + " client=" + text + ". That client will disable its custom emotes.")); } FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(512, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe(text2, false); singleton.CustomMessagingManager.SendNamedMessage("Y4NGZ.LGUEmotes.FingerprintReply", senderClientId, val, (NetworkDelivery)3); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("LGUEmotes could not reply to the fingerprint request from client " + senderClientId + ": " + ex2.Message)); } finally { ((FastBufferWriter)(ref val)).Dispose(); } } private static void OnReplyReceived(ulong senderClientId, FastBufferReader reader) { if (senderClientId == 0L && !_replyReceived) { _replyReceived = true; string text = default(string); try { ((FastBufferReader)(ref reader)).ReadValueSafe(ref text, false); } catch (Exception ex) { Plugin.Log.LogWarning((object)("LGUEmotes could not read the host fingerprint reply: " + ex.Message)); text = null; } string text2 = BuildLocalPayload(); if (string.Equals(text, text2, StringComparison.Ordinal)) { Plugin.Log.LogInfo((object)("LGUEmotes emote map verified against host: " + text2 + ".")); } else { ApplyMismatch(text ?? "unreadable", text2); } } } private static IEnumerator WaitForReply() { float deadline = Time.realtimeSinceStartup + 15f; while (!_replyReceived && Time.realtimeSinceStartup < deadline) { NetworkManager singleton = NetworkManager.Singleton; if ((Object)(object)singleton == (Object)null || !singleton.IsClient) { yield break; } yield return null; } _timeoutRoutine = null; if (!_replyReceived) { if (!Plugin.RequireHostFingerprint.Value) { Plugin.Log.LogWarning((object)("LGUEmotes got no emote fingerprint from the host within " + 15f + "s. 'Require Host Fingerprint' is disabled, so custom emotes stay enabled and unverified. If the host is not running LGUEmotes, your custom emote IDs will play the wrong animations for everyone else.")); } else { ApplyMismatch("no reply (host is probably not running LGUEmotes)", BuildLocalPayload()); } } } private static void ApplyMismatch(string hostPayload, string localPayload) { MismatchDetected = true; Plugin.Log.LogError((object)("=================================================================\nLGUEmotes EMOTE MAP MISMATCH - custom emotes disabled for this lobby.\n host = " + hostPayload + "\n local = " + localPayload + "\nTooManyEmotes sends emote IDs as bare list indices, so a list that is not composed identically on both machines makes the same ID mean different emotes.\nLikely causes: the host is running a different mod set (any mod that registers emotes shifts every ID after it), a row is disabled in one side's emote registry, or the two sides ship different y4ngz_emotes bundles.\nWHAT THIS PROTECTS: this client will not perform LGU custom emotes, will not send an LGU emote ID to the host, and will not play an LGU custom emote resolved from an incoming ID.\nWHAT THIS CANNOT PROTECT: an incoming ID from another peer that lands on a *TooManyEmotes* emote here rather than an LGU one still plays whatever this machine has at that index - there is no way to correct it without a full emote map exchange, which TooManyEmotes does not support. Other peers may also still see wrong animations for each other. Align the mod sets to fix this properly.\n=================================================================")); } private static string BuildLocalPayload() { Plugin instance = Plugin.instance; object obj; if (instance == null) { obj = null; } else { PluginInfo info = ((BaseUnityPlugin)instance).Info; if (info == null) { obj = null; } else { BepInPlugin metadata = info.Metadata; obj = ((metadata == null) ? null : metadata.Version?.ToString()); } } if (obj == null) { obj = "unknown"; } string text = (string)obj; return "v1|tme=" + text + "|lgu=" + Plugin.LocalMapFingerprint + "|list=" + GetListFingerprint(); } private static string GetListFingerprint() { if (_cachedListFingerprint != null) { return _cachedListFingerprint; } List<UnlockableEmote> allUnlockableEmotes = EmotesManager.allUnlockableEmotes; if (allUnlockableEmotes == null) { _cachedListFingerprint = "none"; return _cachedListFingerprint; } List<string> list = new List<string>(allUnlockableEmotes.Count); for (int i = 0; i < allUnlockableEmotes.Count; i++) { UnlockableEmote val = allUnlockableEmotes[i]; list.Add(i + ":" + ((val == null) ? "<null>" : val.emoteName)); } _cachedListFingerprint = allUnlockableEmotes.Count + "-" + Plugin.ComputeIdFingerprint(list); return _cachedListFingerprint; } } [HarmonyPatch] internal static class EmoteGuardPatches { [HarmonyPatch(typeof(PlayerControllerB), "ConnectClientToPlayerObject")] [HarmonyPostfix] private static void PostConnectClientToPlayerObject() { try { EmoteFingerprintHandshake.OnLocalClientReady(); } catch (Exception ex) { Plugin.Log.LogWarning((object)("LGUEmotes fingerprint handshake setup failed: " + ex)); } } [HarmonyPatch(typeof(GameNetworkManager), "Disconnect")] [HarmonyPostfix] private static void PostDisconnect() { EmoteFingerprintHandshake.OnDisconnected(); } [HarmonyPatch(typeof(StartOfRound), "Awake")] [HarmonyPostfix] private static void PostStartOfRoundAwake() { EmoteFingerprintHandshake.ResetForNewSession(); } [HarmonyPatch(typeof(EmoteControllerPlayer), "TryPerformingEmoteLocal")] [HarmonyPrefix] private static bool PreTryPerformingEmoteLocal(UnlockableEmote emote, ref bool __result) { if (!Plugin.CustomEmotesBlocked || !Plugin.RegisteredEmotes.Contains(emote)) { return true; } __result = false; WarnBlocked(emote, "perform"); return false; } [HarmonyPatch(typeof(EmoteControllerPlayer), "TrySyncingEmoteWithEmoteController")] [HarmonyPrefix] private static bool PreTrySyncingEmote(EmoteController emoteController, ref bool __result) { if (!Plugin.CustomEmotesBlocked) { return true; } UnlockableEmote val = (((Object)(object)emoteController != (Object)null) ? emoteController.performingEmote : null); if (val == null || !Plugin.RegisteredEmotes.Contains(val)) { return true; } __result = false; WarnBlocked(val, "sync with"); return false; } [HarmonyPatch(typeof(EmoteControllerPlayer), "PerformEmote", new Type[] { typeof(UnlockableEmote), typeof(int), typeof(bool) })] [HarmonyPrefix] private static bool PrePerformEmote(UnlockableEmote emote, ref bool __result) { if (!Plugin.CustomEmotesBlocked || !Plugin.RegisteredEmotes.Contains(emote)) { return true; } __result = false; return false; } [HarmonyPatch(typeof(EmoteControllerMaskedEnemy), "PerformEmote", new Type[] { typeof(UnlockableEmote), typeof(int), typeof(bool) })] [HarmonyPrefix] private static bool PreMaskedEnemyPerformEmote(UnlockableEmote emote, ref bool __result) { if (!Plugin.CustomEmotesBlocked || !Plugin.RegisteredEmotes.Contains(emote)) { return true; } __result = false; return false; } [HarmonyPatch(typeof(SyncManager), "SendOnUnlockEmoteUpdate")] [HarmonyPrefix] private static bool PreSendOnUnlockEmoteUpdate(int emoteId) { if (!Plugin.CustomEmotesBlocked) { return true; } List<UnlockableEmote> allUnlockableEmotes = EmotesManager.allUnlockableEmotes; if (allUnlockableEmotes == null || emoteId < 0 || emoteId >= allUnlockableEmotes.Count) { return true; } if (!Plugin.RegisteredEmotes.Contains(allUnlockableEmotes[emoteId])) { return true; } Plugin.Log.LogWarning((object)("LGUEmotes suppressed an unlock update for custom emote id " + emoteId + " because this client's emote map is not verified against the host.")); return false; } private static void WarnBlocked(UnlockableEmote emote, string action) { Plugin.Log.LogWarning((object)("LGUEmotes blocked an attempt to " + action + " custom emote '" + ((emote != null) ? emote.emoteName : "null") + "': this client's emote map does not match the host's.")); } } public abstract class SuitBodyReplacement : BodyReplacementBase { private static readonly Vector3 TemplateParkPosition = new Vector3(0f, -5000f, 0f); private GameObject _modelTemplate; protected override GameObject LoadAssetsAndReturnModel() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) GameObject val = Suits.ModelPrefabFor(((object)this).GetType()); if ((Object)(object)val == (Object)null) { return null; } _modelTemplate = Object.Instantiate<GameObject>(val); ((Object)_modelTemplate).name = ((Object)val).name; _modelTemplate.transform.position = TemplateParkPosition; return _modelTemplate; } protected override ViewModelUpdater GetViewModelUpdater() { Object.Destroy((Object)(object)base.replacementViewModel); base.replacementViewModel = null; return ((BodyReplacementBase)this).GetViewModelUpdater(); } protected override void Start() { ((BodyReplacementBase)this).Start(); ReleaseModelTemplate(); } protected override void OnDestroy() { ((BodyReplacementBase)this).OnDestroy(); ReleaseModelTemplate(); } private void ReleaseModelTemplate() { if (!((Object)(object)_modelTemplate == (Object)null)) { Object.Destroy((Object)(object)_modelTemplate); _modelTemplate = null; } } } internal sealed class SuitDefinition { internal readonly string StoreName; internal readonly string ConfigSection; internal readonly string EnableKey; internal readonly string EnableDescription; internal readonly string PriceDescription; internal readonly int DefaultPrice; internal readonly string BundleFilename; internal readonly string PrefabName; internal readonly string RackMaterialName; internal readonly Type BodyReplacement; internal SuitDefinition(string storeName, string configSection, string enableKey, string enableDescription, string priceDescription, int defaultPrice, string bundleFilename, string prefabName, string rackMaterialName, Type bodyReplacement) { StoreName = storeName; ConfigSection = configSection; EnableKey = enableKey; EnableDescription = enableDescription; PriceDescription = priceDescription; DefaultPrice = defaultPrice; BundleFilename = bundleFilename; PrefabName = prefabName; RackMaterialName = rackMaterialName; BodyReplacement = bodyReplacement; } } [HarmonyPatch] internal static class SuitHeldItemPatches { private const int MaxIndexLoadDistance = 4; [HarmonyPatch(typeof(BodyReplacementBase), "UpdateItemTransform")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> UpdateItemTransformTranspiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { return ReadSlotThroughUtilityBelt(instructions, original); } [HarmonyPatch(typeof(LocateHeldObjectsOnModelReplacementPatch), "LateUpdatePatch")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> LocateHeldObjectTranspiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { return ReadSlotThroughUtilityBelt(instructions, original); } private static IEnumerable<CodeInstruction> ReadSlotThroughUtilityBelt(IEnumerable<CodeInstruction> instructions, MethodBase original) { FieldInfo fieldInfo = AccessTools.Field(typeof(PlayerControllerB), "ItemSlots"); FieldInfo currentItemSlot = AccessTools.Field(typeof(PlayerControllerB), "currentItemSlot"); MethodInfo operand = AccessTools.Method(typeof(UtilityBelt), "ItemInSlot", (Type[])null, (Type[])null); List<CodeInstruction> list = new List<CodeInstruction>(instructions); int num = 0; for (int i = 0; i < list.Count; i++) { if (CodeInstructionExtensions.LoadsField(list[i], fieldInfo, false)) { int num2 = list.FindIndex(i + 1, Math.Min(4, list.Count - i - 1), (CodeInstruction instruction) => CodeInstructionExtensions.LoadsField(instruction, currentItemSlot, false)); if (num2 >= 0 && num2 + 1 < list.Count && !(list[num2 + 1].opcode != OpCodes.Ldelem_Ref)) { list[i].opcode = OpCodes.Nop; list[i].operand = null; list[num2 + 1].opcode = OpCodes.Call; list[num2 + 1].operand = operand; num++; } } } string text = original.DeclaringType?.Name + "." + original.Name; if (num == 0) { Plugin.Log.LogWarning((object)("Utility belt guard: " + text + " no longer reads ItemSlots[currentItemSlot]; left unchanged.")); } else { Plugin.Log.LogInfo((object)("Utility belt guard: " + text + " reads the utility belt item through ItemOnlySlot.")); } return list; } } internal static class Suits { private static class Registration { private static SuitDefinition[] Definitions() { return new SuitDefinition[2] { new SuitDefinition("Fik Suit", "Whistleblower Suit", "Enable Whistleblower Suit", "Sell the original Whistleblower character model as a suit at the store terminal. Requires LethalLib and ModelReplacementAPI; the feature disables itself when either is missing.", "Store terminal price in credits for the Whistleblower suit. 0 makes the suit free.", 750, "y4ngz_suits.bundle", "WhistleblowerSuit", "WhistleblowerSuitMat", typeof(WhistleblowerBodyReplacement)), new SuitDefinition("Bundy Suit", "Bundy Suit", "Enable Bundy Suit", "Sell the Bundy character model as a suit at the store terminal. Requires LethalLib and ModelReplacementAPI; the feature disables itself when either is missing.", "Store terminal price in credits for the Bundy suit. 0 makes the suit free.", 750, "y4ngz_bundy_suit.bundle", "BundySuit", "BundySuitMat", typeof(BundyBodyReplacement)) }; } internal static void RegisterAll(ConfigFile config) { SuitDefinition[] array = Definitions(); foreach (SuitDefinition suitDefinition in array) { try { RegisterSuit(config, suitDefinition); } catch (Exception ex) { Plugin.Log.LogError((object)(suitDefinition.StoreName + " is DISABLED: unhandled exception during registration: " + ex)); } } if (StoreNames.Count > 0) { ApplyPatches(typeof(SuitTerminalKeywords), ".suit-keywords"); ApplyPatches(typeof(SuitHeldItemPatches), ".suit-held-items"); } } private static void ApplyPatches(Type patches, string idSuffix) { try { Harmony.CreateAndPatchAll(patches, "com.y4ngz.lguemotes" + idSuffix); } catch (Exception ex) { Plugin.Log.LogError((object)("Suits: could not apply " + patches.Name + ": " + ex)); } } private static void RegisterSuit(ConfigFile config, SuitDefinition suit) { //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Expected O, but got Unknown ConfigEntry<bool> obj = config.Bind<bool>(suit.ConfigSection, suit.EnableKey, true, suit.EnableDescription); ConfigEntry<int> val = config.Bind<int>(suit.ConfigSection, "Suit Price", suit.DefaultPrice, suit.PriceDescription); if (!obj.Value) { Plugin.Log.LogInfo((object)(suit.StoreName + " is disabled by config.")); return; } string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string text = ((directoryName == null) ? null : Path.Combine(directoryName, suit.BundleFilename)); if (text == null || !File.Exists(text)) { Plugin.Log.LogWarning((object)(suit.StoreName + " is DISABLED: '" + suit.BundleFilename + "' was not found beside LGUEmotes.dll.")); return; } AssetBundle val2 = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle loaded) => (Object)(object)loaded != (Object)null && loaded.Contains(suit.PrefabName))) ?? AssetBundle.LoadFromFile(text); if ((Object)(object)val2 == (Object)null) { Plugin.Log.LogError((object)(suit.StoreName + " is DISABLED: AssetBundle.LoadFromFile returned null for " + text + ".")); return; } GameObject val3 = val2.LoadAsset<GameObject>(suit.PrefabName); if ((Object)(object)val3 == (Object)null) { Plugin.Log.LogError((object)(suit.StoreName + " is DISABLED: prefab '" + suit.PrefabName + "' is missing from " + suit.BundleFilename + ".")); return; } Material val4 = val2.LoadAsset<Material>(suit.RackMaterialName); if ((Object)(object)val4 == (Object)null) { Plugin.Log.LogError((object)(suit.StoreName + " is DISABLED: rack material '" + suit.RackMaterialName + "' is missing from " + suit.BundleFilename + ".")); } else { Unlockables.RegisterUnlockable(new UnlockableItem { unlockableName = suit.StoreName, unlockableType = 0, suitMaterial = val4, alreadyUnlocked = false, canBeStored = true, maxNumber = 1, alwaysInStock = true }, (StoreType)1, (TerminalNode)null, (TerminalNode)null, (TerminalNode)null, val.Value); ModelPrefabs[suit.BodyReplacement] = val3; StoreNames.Add(suit.StoreName); ModelReplacementAPI.RegisterSuitModelReplacement(suit.StoreName, suit.BodyReplacement); Plugin.Log.LogInfo((object)(suit.StoreName + " registered at " + val.Value + " credits, model replacement bound.")); } } } internal const string LethalLibGuid = "evaisa.lethallib"; internal const string ModelReplacementApiGuid = "meow.ModelReplacementAPI"; private const string PriceKey = "Suit Price"; private static readonly Dictionary<Type, GameObject> ModelPrefabs = new Dictionary<Type, GameObject>(); private static readonly List<string> StoreNames = new List<string>(); internal static IReadOnlyList<string> RegisteredStoreNames => StoreNames; internal static GameObject ModelPrefabFor(Type bodyReplacement) { if (!ModelPrefabs.TryGetValue(bodyReplacement, out var value)) { return null; } return value; } internal static void Initialize(ConfigFile config) { if (!Chainloader.PluginInfos.ContainsKey("evaisa.lethallib")) { Plugin.Log.LogWarning((object)"Suits are DISABLED: LethalLib is not installed."); } else if (!Chainloader.PluginInfos.ContainsKey("meow.ModelReplacementAPI")) { Plugin.Log.LogWarning((object)"Suits are DISABLED: ModelReplacementAPI is not installed."); } else { Registration.RegisterAll(config); } } } [HarmonyPatch] internal static class SuitTerminalKeywords { [HarmonyPatch(typeof(Terminal), "Start")] [HarmonyPostfix] private static void AddTypedSpellings(Terminal __instance) { TerminalNodesList terminalNodes = __instance.terminalNodes; foreach (string registeredStoreName in Suits.RegisteredStoreNames) { string text = registeredStoreName.ToLowerInvariant().Replace(" ", "-"); string text2 = WithoutPunctuation(text); if (text2 == text || (Object)(object)FindKeyword(terminalNodes, text2) != (Object)null) { continue; } TerminalKeyword keyword = FindKeyword(terminalNodes, text); if ((Object)(object)keyword == (Object)null) { continue; } TerminalKeyword val = ScriptableObject.CreateInstance<TerminalKeyword>(); ((Object)val).name = text2; val.word = text2; val.defaultVerb = keyword.defaultVerb; terminalNodes.allKeywords = Append(terminalNodes.allKeywords, val); TerminalKeyword[] allKeywords = terminalNodes.allKeywords; foreach (TerminalKeyword val2 in allKeywords) { if (val2.isVerb && val2.compatibleNouns != null) { CompatibleNoun val3 = Array.Find(val2.compatibleNouns, (CompatibleNoun candidate) => (Object)(object)candidate.noun == (Object)(object)keyword); if (val3 != null) { CompatibleNoun val4 = AccessTools.CreateInstance<CompatibleNoun>(); val4.noun = val; val4.result = val3.result; val2.compatibleNouns = Append(val2.compatibleNouns, val4); } } } Plugin.Log.LogInfo((object)("Terminal: '" + text2 + "' also reaches " + registeredStoreName + ".")); } } private static TerminalKeyword FindKeyword(TerminalNodesList nodes, string word) { return Array.Find(nodes.allKeywords, (TerminalKeyword keyword) => keyword.word == word); } private static string WithoutPunctuation(string word) { StringBuilder stringBuilder = new StringBuilder(word.Length); foreach (char c in word) { if (!char.IsPunctuation(c)) { stringBuilder.Append(c); } } return stringBuilder.ToString(); } private static T[] Append<T>(T[] items, T item) { T[] array = new T[items.Length + 1]; items.CopyTo(array, 0); array[items.Length] = item; return array; } } internal static class UtilityBelt { private static readonly FieldRef<PlayerControllerB, GrabbableObject> ItemOnlySlot = AccessTools.FieldRefAccess<PlayerControllerB, GrabbableObject>("ItemOnlySlot"); internal static GrabbableObject ItemInSlot(PlayerControllerB player, int slot) { if ((uint)slot >= (uint)player.ItemSlots.Length) { return ItemOnlySlot.Invoke(player); } return player.ItemSlots[slot]; } } public sealed class WhistleblowerBodyReplacement : SuitBodyReplacement { } public static class MyPluginInfo { public const string PLUGIN_GUID = "LGUEmotes"; public const string PLUGIN_NAME = "LGUEmotes"; public const string PLUGIN_VERSION = "1.0.0"; } }
LGUSportsbook.dll
Decompiled an hour agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; 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("LGUSportsbook")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8a72f49be1165548a6e8f513d9e3988ce29f5647")] [assembly: AssemblyProduct("LGUSportsbook")] [assembly: AssemblyTitle("LGUSportsbook")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 LGUSportsbook { [BepInPlugin("com.y4ngz.lgusportsbook", "LGUSportsbook", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.y4ngz.lgusportsbook"; public const string PLUGIN_NAME = "LGUSportsbook"; public const string PLUGIN_VERSION = "1.0.0"; private const string LETHAL_CASINO_GUID = "mrgrm7.LethalCasino"; private const string BUNDLE_FILENAME = "sportsbook.bundle"; private const string LEGACY_BUNDLE_FILENAME = "sportsbook.lethalbundle"; internal static ManualLogSource Log; public static AssetBundle SportsbookBundle; public static GameObject Y4NGZ_MarqueePrefab; private Harmony _harmony; internal static Plugin Instance { get; private set; } private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; LoadBundle(); NetcodeWeaver(); _harmony = new Harmony("com.y4ngz.lgusportsbook"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Log.LogInfo((object)"LGUSportsbook 1.0.0 loaded."); } private void LoadBundle() { string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = FindBundlePath(directoryName, "sportsbook.bundle", "sportsbook.lethalbundle"); if (text == null) { Log.LogError((object)("Bundle not found in " + directoryName + " (looked for sportsbook.bundle and sportsbook.lethalbundle). Sign visuals will be skipped.")); return; } SportsbookBundle = FindPreloadedBundle("Y4NGZ_Marquee") ?? AssetBundle.LoadFromFile(text); if ((Object)(object)SportsbookBundle == (Object)null) { Log.LogError((object)("Failed to load bundle: " + text)); return; } Y4NGZ_MarqueePrefab = SportsbookBundle.LoadAsset<GameObject>("Y4NGZ_Marquee"); if ((Object)(object)Y4NGZ_MarqueePrefab == (Object)null) { Log.LogWarning((object)"Y4NGZ_Marquee not found in bundle."); } } private static string FindBundlePath(string dir, params string[] fileNames) { foreach (string path in fileNames) { string text = Path.Combine(dir, path); if (File.Exists(text)) { return text; } } return null; } private static AssetBundle FindPreloadedBundle(string probeAssetName) { foreach (AssetBundle allLoadedAssetBundle in AssetBundle.GetAllLoadedAssetBundles()) { if ((Object)(object)allLoadedAssetBundle == (Object)null) { continue; } try { if (allLoadedAssetBundle.Contains(probeAssetName)) { return allLoadedAssetBundle; } } catch { } } return null; } private static void NetcodeWeaver() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); for (int i = 0; i < types.Length; i++) { MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0) { methodInfo.Invoke(null, null); } } } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "LGUSportsbook"; public const string PLUGIN_NAME = "LGUSportsbook"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace LGUSportsbook.Patches { [HarmonyPatch] internal static class CasinoBuildingPatch { private static readonly string[] LetterChildren = new string[6] { "LettersBulb01_C", "LettersBulb01_A (2)", "LettersBulb01_S", "LettersBulb01_I", "LettersBulb01_N", "LettersBulb01_O" }; private static readonly Vector3 MarqueeLocalPos = new Vector3(-2.95f, 7.1f, 2.55f); private static readonly Quaternion MarqueeLocalRot = Quaternion.Euler(0f, 180f, 0f); private static readonly Vector3 MarqueeLocalScale = new Vector3(1.35f, 1.35f, 1.3f); private static MethodBase TargetMethod() { return AccessTools.Method("LethalCasino.Custom.CasinoBuilding:Awake", (Type[])null, (Type[])null); } private static void Postfix(Component __instance) { //IL_0085: 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) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) Transform transform = __instance.transform; string[] letterChildren = LetterChildren; foreach (string text in letterChildren) { Transform val = transform.Find(text); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } else { Plugin.Log.LogWarning((object)("CASINO letter not found: " + text)); } } if ((Object)(object)Plugin.Y4NGZ_MarqueePrefab == (Object)null) { Plugin.Log.LogWarning((object)"[LGUSportsbook] Y4NGZ_Marquee prefab not loaded, skipping marquee instantiation"); return; } GameObject obj = Object.Instantiate<GameObject>(Plugin.Y4NGZ_MarqueePrefab, transform, false); obj.transform.localPosition = MarqueeLocalPos; obj.transform.localRotation = MarqueeLocalRot; obj.transform.localScale = MarqueeLocalScale; Plugin.Log.LogInfo((object)"[LGUSportsbook] Y4NGZ_Marquee instantiated at local (-2.95, 7.1, 2.55) rot (0, 180, 0) scale (1.35, 1.35, 1.3)"); } } }