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 deeznutz v9004.0.0
BepInEx/plugins/TVLoaderExtended/TVLoaderExtended.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using TVLoaderExtended.Utils; using Unity.Netcode; using UnityEngine; using UnityEngine.Video; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("TVLoaderExtended")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("TVLoaderExtended")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5F5ACB51-F9E6-4E85-B3A4-028FEE7B0650")] [assembly: AssemblyFileVersion("1.1.3")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.1.3.0")] namespace TVLoaderExtended { [BepInPlugin("Filigrani.TVLoaderExtended", "TVLoaderExtended", "1.1.3")] public class TVLoaderExtendedPlugin : BaseUnityPlugin { private const string MyGUID = "Filigrani.TVLoaderExtended"; private const string PluginName = "TVLoaderExtended"; private const string VersionString = "1.1.3"; private static readonly Harmony Harmony = new Harmony("Filigrani.TVLoaderExtended"); public static ManualLogSource Log = new ManualLogSource("TVLoaderExtended"); private void Awake() { Log = ((BaseUnityPlugin)this).Logger; Harmony.PatchAll(); VideoManager.Load(); ((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("PluginName: {0}, VersionString: {1} is loaded. Video Count: {2}", "TVLoaderExtended", "1.1.3", VideoManager.Videos.Count)); } } } namespace TVLoaderExtended.Utils { internal static class VideoManager { public static List<string> Videos = new List<string>(); public static void Load() { Videos.Clear(); string[] directories = Directory.GetDirectories(Paths.PluginPath); string[] array = directories; foreach (string text in array) { string path = Path.Combine(Paths.PluginPath, text, "Television Videos"); if (Directory.Exists(path)) { string[] files = Directory.GetFiles(path, "*.mp4"); Videos.AddRange(files); TVLoaderExtendedPlugin.Log.LogInfo((object)$"{text} has {files.Length} videos."); } } string path2 = Path.Combine(Paths.PluginPath, "Television Videos"); if (!Directory.Exists(path2)) { Directory.CreateDirectory(path2); } string[] files2 = Directory.GetFiles(path2, "*.mp4"); Videos.AddRange(files2); TVLoaderExtendedPlugin.Log.LogInfo((object)$"Global has {files2.Length} videos."); TVLoaderExtendedPlugin.Log.LogInfo((object)$"Loaded {Videos.Count} total."); } } } namespace TVLoaderExtended.Patches { [HarmonyPatch(typeof(StartOfRound))] internal class NewSave { [HarmonyPatch("firstDayAnimation")] [HarmonyPostfix] internal static void StartPatching() { StartOfRound instance = StartOfRound.Instance; if (!((NetworkBehaviour)instance).NetworkManager.IsHost) { return; } List<UnlockableItem> unlockables = instance.unlockablesList.unlockables; foreach (UnlockableItem item in unlockables) { if (item.unlockableName == "Television") { UnlockShipItem(instance, unlockables.IndexOf(item), item.unlockableName); break; } } } private static void UnlockShipItem(StartOfRound instance, int unlockableID, string name) { try { MethodInfo method = ((object)instance).GetType().GetMethod("UnlockShipObject", BindingFlags.Instance | BindingFlags.NonPublic); method.Invoke(instance, new object[1] { unlockableID }); } catch (NullReferenceException) { } } } [HarmonyPatch(typeof(TVScript))] internal class TVScriptPatches { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static EventHandler <>9__22_0; internal void <PrepareVideo>b__22_0(VideoPlayer source) { TVLoaderExtendedPlugin.Log.LogInfo((object)"Prepared video!"); } } private static FieldInfo currentClipProperty = typeof(TVScript).GetField("currentClip", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo currentTimeProperty = typeof(TVScript).GetField("currentClipTime", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo wasTvOnLastFrameProp = typeof(TVScript).GetField("wasTvOnLastFrame", BindingFlags.Instance | BindingFlags.NonPublic); private static FieldInfo timeSinceTurningOffTVProp = typeof(TVScript).GetField("timeSinceTurningOffTV", BindingFlags.Instance | BindingFlags.NonPublic); private static MethodInfo setMatMethod = typeof(TVScript).GetMethod("SetTVScreenMaterial", BindingFlags.Instance | BindingFlags.NonPublic); private static MethodInfo onEnableMethod = typeof(TVScript).GetMethod("OnEnable", BindingFlags.Instance | BindingFlags.NonPublic); private static bool s_EverWasOn = false; private static RenderTexture renderTexture; private static List<string> m_Videos = new List<string>(); private static int s_LastSeed = 0; private static int s_LastSeenIndex = -1; private static string GetVideoPath(int Index) { return GetFullPath(m_Videos[Index]); } private static int GetSeed(TVScript Instance) { return ((NetworkBehaviour)Instance).NetworkObjectId.ToString().GetHashCode(); } private static void Shuffle<T>(List<T> List, int Seed) { Random random = new Random(Seed); int count = List.Count; for (int i = 0; i < count - 1; i++) { int index = i + random.Next(count - i); T value = List[index]; List[index] = List[i]; List[i] = value; } } public static List<string> GetClearList(List<string> Pathes) { List<string> list = new List<string>(); for (int i = 0; i < Pathes.Count; i++) { string text = Pathes[i]; string[] separator = new string[1] { "plugins" }; string[] array = text.Split(separator, StringSplitOptions.None); string item = array[1]; list.Add(item); } list.Sort(); return list; } public static string GetFullPath(string ShortPath) { foreach (string video in VideoManager.Videos) { if (video.EndsWith(ShortPath)) { return video; } } return ""; } public static void ShuffleVideos(TVScript Instance) { m_Videos = GetClearList(VideoManager.Videos); TVLoaderExtendedPlugin.Log.LogInfo((object)("[TVScriptExtended] ShuffleVideos " + GetSeed(Instance))); Shuffle(m_Videos, GetSeed(Instance)); for (int i = 0; i < m_Videos.Count; i++) { TVLoaderExtendedPlugin.Log.LogInfo((object)("[TVScriptExtended] m_Videos[" + i + "] " + m_Videos[i])); } } public static void ClientUpdate(TVScript Instance) { int num = (int)currentClipProperty.GetValue(Instance); if (s_LastSeenIndex != num) { s_LastSeenIndex = num; TVLoaderExtendedPlugin.Log.LogInfo((object)("[ClientUpdate] currentClip " + num + " Instance.tvOn " + Instance.tvOn)); if (Instance.tvOn) { PlayVideo(Instance); } } } public static bool PlayerIsHost(TVScript __instance) { if (Object.op_Implicit((Object)(object)__instance)) { return ((NetworkBehaviour)__instance).NetworkManager.IsHost; } return false; } [HarmonyPrefix] [HarmonyPatch("Update")] public static bool Update(TVScript __instance) { if ((Object)(object)renderTexture == (Object)null) { renderTexture = ((Component)__instance).GetComponent<VideoPlayer>().targetTexture; } if (!PlayerIsHost(__instance)) { ClientUpdate(__instance); } if (s_LastSeed != GetSeed(__instance)) { s_LastSeed = GetSeed(__instance); ShuffleVideos(__instance); if (PlayerIsHost(__instance)) { currentClipProperty.SetValue(__instance, 0); } else { currentClipProperty.SetValue(__instance, -1); } s_EverWasOn = false; } return false; } [HarmonyPrefix] [HarmonyPatch("TurnTVOnOff")] public static bool TurnTVOnOff(TVScript __instance, bool on) { TVLoaderExtendedPlugin.Log.LogInfo((object)$"TVOnOff: {on}"); if (VideoManager.Videos.Count == 0) { return false; } int num = (int)currentClipProperty.GetValue(__instance); __instance.tvOn = on; if (PlayerIsHost(__instance)) { if (on) { if (!s_EverWasOn) { s_EverWasOn = true; } else { num = (num + 1) % VideoManager.Videos.Count; currentClipProperty.SetValue(__instance, num); } PlayVideo(__instance); } } else if (on) { currentTimeProperty.SetValue(__instance, 0f); } if (on) { __instance.tvSFX.PlayOneShot(__instance.switchTVOn); WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOn, 1f); } else { __instance.video.Stop(); __instance.tvSFX.PlayOneShot(__instance.switchTVOff); WalkieTalkie.TransmitOneShotAudio(__instance.tvSFX, __instance.switchTVOff, 1f); } setMatMethod.Invoke(__instance, new object[1] { on }); return false; } [HarmonyPrefix] [HarmonyPatch("TVFinishedClip")] public static bool TVFinishedClip(TVScript __instance, VideoPlayer source) { if (__instance.tvOn && PlayerIsHost(__instance)) { TVLoaderExtendedPlugin.Log.LogInfo((object)"TVFinishedClip"); int num = (int)currentClipProperty.GetValue(__instance); if (VideoManager.Videos.Count > 0) { num = (num + 1) % VideoManager.Videos.Count; } currentTimeProperty.SetValue(__instance, 0f); currentClipProperty.SetValue(__instance, num); PlayVideo(__instance); } return false; } private static void PrepareVideo(TVScript instance, int index) { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown if (index < 0) { return; } string videoPath = GetVideoPath(index); Object.Destroy((Object)(object)instance.video); VideoPlayer val = ((Component)instance).gameObject.AddComponent<VideoPlayer>(); val.playOnAwake = false; val.isLooping = false; val.source = (VideoSource)1; val.controlledAudioTrackCount = 1; val.audioOutputMode = (VideoAudioOutputMode)1; val.SetTargetAudioSource((ushort)0, instance.tvSFX); TVLoaderExtendedPlugin.Log.LogInfo((object)("Going to prepare: " + videoPath)); val.url = "file://" + videoPath; val.skipOnDrop = true; val.Prepare(); object obj = <>c.<>9__22_0; if (obj == null) { EventHandler val2 = delegate { TVLoaderExtendedPlugin.Log.LogInfo((object)"Prepared video!"); }; <>c.<>9__22_0 = val2; obj = (object)val2; } val.prepareCompleted += (EventHandler)obj; instance.video = val; } private static void PlayVideo(TVScript instance) { if (VideoManager.Videos.Count != 0) { currentTimeProperty.SetValue(instance, 0f); PrepareVideo(instance, (int)currentClipProperty.GetValue(instance)); onEnableMethod.Invoke(instance, new object[0]); TVLoaderExtendedPlugin.Log.LogInfo((object)("TV Current Video Index " + (int)currentClipProperty.GetValue(instance))); instance.video.targetTexture = renderTexture; instance.video.Play(); if (PlayerIsHost(instance)) { instance.SyncTVServerRpc(); } } } } }
CustomOutsideObjects.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using CustomOutsideObjects.Patches; using HarmonyLib; using LethalLib.Extras; using Unity.Collections; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Custom Outside Objects")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Custom Outside Objects")] [assembly: AssemblyCopyright("Copyright Spookybuddy 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("28f2f16b-6471-4c7e-b0a4-007e3a2450d4")] [assembly: AssemblyFileVersion("1.3.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.3.0.0")] namespace CustomOutsideObjects { public class BreakObject : MonoBehaviour { public List<GameObject> prefabs = new List<GameObject>(); private void OnTriggerEnter(Collider other) { //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: 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_00c6: 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_00d3: Unknown result type (might be due to invalid IL or missing references) VehicleController val = default(VehicleController); if (!((Component)other).TryGetComponent<VehicleController>(ref val) || !(((Vector3)(ref val.averageVelocity)).magnitude > 5f)) { return; } if (prefabs.Count > 0) { int num = ((prefabs.Count > 1) ? ((int)(100f * Mathf.Abs(((Component)this).transform.position.y)) % prefabs.Count) : 0); if ((Object)(object)prefabs[num] != (Object)null && num < prefabs.Count && num > -1) { Object.Instantiate<GameObject>(prefabs[num], ((Component)this).transform.parent.position, default(Quaternion), RoundManager.Instance.mapPropsContainer.transform); } else { CustomOutsideModBase.mls.LogError((object)$"{num} was either out of range or null!"); } } Object.Destroy((Object)(object)((Component)((Component)this).transform.parent).gameObject); VehicleController obj = val; Vector3 val2 = val.mainRigidbody.position - ((Component)this).transform.position; obj.CarReactToObstacle(((Vector3)(ref val2)).normalized, ((Component)this).transform.position, Vector3.zero, (CarObstacleType)2, 1f, (EnemyAI)null, true); } } internal class ConfigControl : SyncedInstance<ConfigControl> { public struct ObjectConfig { public ConfigEntry<bool> cfgEnabled; public ConfigEntry<string> cfgWhitelist; public ConfigEntry<string> cfgTagOverride; public bool Enabled { get { return cfgEnabled.Value; } set { cfgEnabled.Value = value; } } public string Moons { get { if (cfgWhitelist == null) { return (string)((ConfigEntryBase)cfgWhitelist).DefaultValue; } return cfgWhitelist.Value; } set { cfgWhitelist.Value = value; } } public string NewTags { get { if (cfgTagOverride == null) { return (string)((ConfigEntryBase)cfgTagOverride).DefaultValue; } return cfgTagOverride.Value; } set { cfgTagOverride.Value = value; } } } public ObjectConfig[] objects; private List<string> moons = new List<string>(); public ConfigControl(ConfigFile cfg) { InitInstance(this); string text = "Base game:\nExperimentation, Assurance, Vow, Offense, March, Adamance, Rend, Dine, Titan, Embrion, Artifice"; cfg.Bind<string>("-Valid Options", "Valid Moon Names", "", text); cfg.Bind<string>("-Valid Options", "Valid Tag Names", "", "Common tags:\nGravel, Grass, Snow, Rock, Concrete, Catwalk, Wood\n\nOther valid tags:\nUntagged, Metal, Carpet, Puddle, Aluminum"); objects = new ObjectConfig[CustomOutsideModBase.Instance.loadedInjectableOutsideObjects.Count]; for (int i = 0; i < objects.Length; i++) { string name = ((Object)CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject).name; string text2 = string.Join(", ", CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject.spawnableFloorTags); moons.Clear(); for (int j = 0; j < CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject.spawnableFloorTags.Length; j++) { switch (CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject.spawnableFloorTags[j]) { case "Gravel": if (!moons.Contains("Experimentation")) { moons.Add("Experimentation"); } if (!moons.Contains("Assurance")) { moons.Add("Assurance"); } if (!moons.Contains("Offense")) { moons.Add("Offense"); } break; case "Grass": if (!moons.Contains("Vow")) { moons.Add("Vow"); } if (!moons.Contains("March")) { moons.Add("March"); } if (!moons.Contains("Adamance")) { moons.Add("Adamance"); } if (!moons.Contains("Artifice")) { moons.Add("Artifice"); } break; case "Snow": if (!moons.Contains("Rend")) { moons.Add("Rend"); } if (!moons.Contains("Dine")) { moons.Add("Dine"); } if (!moons.Contains("Titan")) { moons.Add("Titan"); } break; case "Rock": if (!moons.Contains("Adamance")) { moons.Add("Adamance"); } if (!moons.Contains("Embrion")) { moons.Add("Embrion"); } break; case "Concrete": if (!moons.Contains("Experimentation")) { moons.Add("Experimentation"); } if (!moons.Contains("Vow")) { moons.Add("Vow"); } if (!moons.Contains("Titan")) { moons.Add("Titan"); } if (!moons.Contains("Embrion")) { moons.Add("Embrion"); } if (!moons.Contains("Artifice")) { moons.Add("Artifice"); } break; case "Catwalk": if (!moons.Contains("Experimentation")) { moons.Add("Experimentation"); } if (!moons.Contains("Titan")) { moons.Add("Titan"); } if (!moons.Contains("Artifice")) { moons.Add("Artifice"); } break; case "Wood": if (!moons.Contains("Artifice")) { moons.Add("Artifice"); } break; } } string text3 = string.Join(", ", moons.ToArray()); objects[i].cfgEnabled = cfg.Bind<bool>(name, "Enabled", true, name + " can spawn."); objects[i].cfgWhitelist = cfg.Bind<string>(name, "Spawn on Moons", text3, "What moons the object can spawn on.\nDefault moons match the Default Tags. Separate moon names with a comma."); objects[i].cfgTagOverride = cfg.Bind<string>(name, "Spawn on Tags", text2, "What surfaces the object can spawn on. Separate tags with a comma."); } } } [BepInPlugin("CustomOutsideObjects", "CustomOutsideObjects", "1.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class CustomOutsideModBase : BaseUnityPlugin { public const string modGUID = "CustomOutsideObjects"; private const string modName = "CustomOutsideObjects"; private const string modVersion = "1.3.0"; private readonly Harmony harmony = new Harmony("CustomOutsideObjects"); internal static CustomOutsideModBase Instance; internal static ManualLogSource mls; internal static ConfigControl Configuration; internal static string[] foundOutsideAssetFiles; internal static AssetBundle currentAsset; internal static SpawnableOutsideObjectDef[] currentAssetObjects; internal List<SpawnableOutsideObjectWithRarity> loadedInjectableOutsideObjects = new List<SpawnableOutsideObjectWithRarity>(); private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("CustomOutsideObjects"); string text = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location).ToString(); string[] array = text.Split(new char[1] { '\\' }); for (int num = array.Length - 1; num > 0; num--) { if (array[num].Equals("plugins")) { for (int i = 0; i < array.Length - num - 1; i++) { text = Directory.GetParent(text).ToString(); } foundOutsideAssetFiles = Directory.GetFiles(text, "*.coo", SearchOption.AllDirectories); break; } } if (foundOutsideAssetFiles != null && foundOutsideAssetFiles.Length != 0) { for (int j = 0; j < foundOutsideAssetFiles.Length; j++) { currentAsset = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), foundOutsideAssetFiles[j])); if ((Object)(object)currentAsset != (Object)null) { currentAssetObjects = currentAsset.LoadAllAssets<SpawnableOutsideObjectDef>(); if (currentAssetObjects != null && currentAssetObjects.Length != 0) { GameObject[] array2 = currentAsset.LoadAllAssets<GameObject>(); for (int k = 0; k < currentAssetObjects.Length; k++) { if (currentAssetObjects[k].spawnableMapObject != null) { if (currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn.layer.Equals(25)) { if (((Object)currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn.transform.GetChild(0)).name.Equals("BreakTrigger")) { ((Component)currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn.transform.GetChild(0)).gameObject.AddComponent<TerrainObstacleTrigger>(); string name = ((Object)currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn).name; if ((Object)(object)currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn.GetComponentInChildren<TerrainObstacleTrigger>() != (Object)null) { mls.LogInfo((object)("Added generic break trigger script to " + name + "!")); } else { mls.LogError((object)("Add generic break to " + name + " failed!")); } } else { BreakObject breakObject = ((Component)currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn.transform.GetChild(0)).gameObject.AddComponent<BreakObject>(); string name2 = ((Object)currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn).name; for (int l = 0; l < array2.Length; l++) { if (((Object)array2[l]).name.Contains(name2) && ((Object)array2[l]).name.Contains("Break")) { breakObject.prefabs.Add(array2[l]); } } if ((Object)(object)currentAssetObjects[k].spawnableMapObject.spawnableObject.prefabToSpawn.GetComponentInChildren<BreakObject>() != (Object)null) { mls.LogInfo((object)("Added custom break trigger script to " + name2 + "!")); } else { mls.LogError((object)("Add custom break to " + name2 + " failed!")); } } } loadedInjectableOutsideObjects.Add(currentAssetObjects[k].spawnableMapObject); mls.LogInfo((object)("Custom Outside Object added: " + ((Object)currentAssetObjects[k].spawnableMapObject.spawnableObject).name)); } else { mls.LogWarning((object)$"Spawnable Rarity {currentAssetObjects[k]} found, but no Spawnable Map Object is attached."); } } } else { mls.LogWarning((object)("No Spawnable Map Object found in " + foundOutsideAssetFiles[j] + ".coo.")); } } else { mls.LogError((object)("Failed to load " + foundOutsideAssetFiles[j] + ".coo.")); } } if (loadedInjectableOutsideObjects.Count < 1 || loadedInjectableOutsideObjects == null) { mls.LogWarning((object)"No Custom Outside Objects were added."); return; } Configuration = new ConfigControl(((BaseUnityPlugin)this).Config); mls.LogInfo((object)"Generated Config file for all loaded objects."); harmony.PatchAll(typeof(CustomOutsideModBase)); harmony.PatchAll(typeof(RoundManagerPatch)); mls.LogInfo((object)"Outside Objects loaded."); } else { mls.LogWarning((object)"No Custom Outside Objects were found."); } } } [Serializable] public class SyncedInstance<T> { [NonSerialized] protected static int IntSize = 4; internal static CustomMessagingManager MessageManager => NetworkManager.Singleton.CustomMessagingManager; internal static bool IsClient => NetworkManager.Singleton.IsClient; internal static bool IsHost => NetworkManager.Singleton.IsHost; public static T Default { get; private set; } public static T Instance { get; private set; } public static bool Synced { get; internal set; } protected void InitInstance(T instance) { Default = instance; Instance = instance; IntSize = 4; } internal static void SyncInstance(byte[] data) { Instance = DeserializeFromBytes(data); Synced = true; } internal static void RevertSync() { Instance = Default; Synced = false; } public static byte[] SerializeToBytes(T val) { BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream memoryStream = new MemoryStream(); try { binaryFormatter.Serialize(memoryStream, val); return memoryStream.ToArray(); } catch (Exception arg) { CustomOutsideModBase.mls.LogError((object)$"Error serializing instance: {arg}"); return null; } } public static T DeserializeFromBytes(byte[] data) { BinaryFormatter binaryFormatter = new BinaryFormatter(); MemoryStream serializationStream = new MemoryStream(data); try { return (T)binaryFormatter.Deserialize(serializationStream); } catch (Exception arg) { CustomOutsideModBase.mls.LogError((object)$"Error deserializing instance: {arg}"); return default(T); } } public static void RequestSync() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (IsClient) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(IntSize, (Allocator)2, -1); MessageManager.SendNamedMessage("CustomOutsideObjects_OnRequestConfigSync", 0uL, val, (NetworkDelivery)3); } } public static void OnRequestSync(ulong clientId, FastBufferReader _) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) if (!IsHost) { return; } CustomOutsideModBase.mls.LogInfo((object)$"Config sync request received from client: {clientId}"); byte[] array = SerializeToBytes(Instance); int num = array.Length; FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(num + IntSize, (Allocator)2, -1); try { ((FastBufferWriter)(ref val)).WriteValueSafe<int>(ref num, default(ForPrimitives)); ((FastBufferWriter)(ref val)).WriteBytesSafe(array, -1, 0); MessageManager.SendNamedMessage("CustomOutsideObjects_OnReceiveConfigSync", clientId, val, (NetworkDelivery)3); } catch (Exception arg) { CustomOutsideModBase.mls.LogInfo((object)$"Error occurred syncing config with client: {clientId}\n{arg}"); } } public static void OnReceiveSync(ulong _, FastBufferReader reader) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!((FastBufferReader)(ref reader)).TryBeginRead(IntSize)) { CustomOutsideModBase.mls.LogError((object)"Config sync error: Could not begin reading buffer."); return; } int num = default(int); ((FastBufferReader)(ref reader)).ReadValueSafe<int>(ref num, default(ForPrimitives)); if (!((FastBufferReader)(ref reader)).TryBeginRead(num)) { CustomOutsideModBase.mls.LogError((object)"Config sync error: Host could not sync."); return; } byte[] data = new byte[num]; ((FastBufferReader)(ref reader)).ReadBytesSafe(ref data, num, 0); SyncInstance(data); CustomOutsideModBase.mls.LogInfo((object)"Successfully synced config with host."); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "SteamMatchmaking_OnLobbyMemberJoined")] public static void InitializeLocalPlayer() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown if (IsHost) { MessageManager.RegisterNamedMessageHandler("CustomOutsideObjects_OnRequestConfigSync", new HandleNamedMessageDelegate(OnRequestSync)); Synced = true; } else { Synced = false; MessageManager.RegisterNamedMessageHandler("CustomOutsideObjects_OnReceiveConfigSync", new HandleNamedMessageDelegate(OnReceiveSync)); RequestSync(); } } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "StartDisconnect")] public static void PlayerLeave() { SyncedInstance<ConfigControl>.RevertSync(); } } } namespace CustomOutsideObjects.Patches { [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void ModifyTags() { for (int i = 0; i < CustomOutsideModBase.Instance.loadedInjectableOutsideObjects.Count; i++) { CustomOutsideModBase.mls.LogInfo((object)("Updating " + ((Object)CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject).name + "'s tags.")); string[] array = SyncedInstance<ConfigControl>.Instance.objects[i].NewTags.Split(new string[3] { ", ", ",", " " }, StringSplitOptions.RemoveEmptyEntries); CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject.spawnableFloorTags = new string[array.Length]; for (int j = 0; j < array.Length; j++) { CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject.spawnableFloorTags[j] = array[j]; } } } [HarmonyPatch("SpawnOutsideHazards")] [HarmonyPrefix] private static void OutsideHazardPatch(ref SelectableLevel ___currentLevel) { string text = ___currentLevel.PlanetName.ToLower().Trim(); string text2 = ((Object)___currentLevel).name.ToLower().Trim(); string[] array = text.Split(new char[1] { ' ' }); string[] array2 = text2.Split(new string[2] { "level", "selectable" }, StringSplitOptions.RemoveEmptyEntries); CustomOutsideModBase.mls.LogWarning((object)("Planet " + array2[0] + ".")); List<SpawnableOutsideObjectWithRarity> list = new List<SpawnableOutsideObjectWithRarity>(); for (int i = 0; i < CustomOutsideModBase.Instance.loadedInjectableOutsideObjects.Count; i++) { if (!SyncedInstance<ConfigControl>.Instance.objects[i].Enabled) { continue; } string[] array3 = SyncedInstance<ConfigControl>.Instance.objects[i].Moons.Split(new string[3] { ", ", ",", " " }, StringSplitOptions.RemoveEmptyEntries); int num = 0; while (num < array3.Length) { if (array3[num].ToLower().Equals(array2[0])) { goto IL_0151; } for (int num2 = 0; num2 < array.Length; num2++) { if (array3[num].ToLower().Equals(array[num2])) { goto IL_0151; } } num++; continue; IL_0151: if (list.Contains(CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i])) { break; } int num3 = 0; while (true) { if (num3 < ___currentLevel.spawnableOutsideObjects.Length) { if (((object)___currentLevel.spawnableOutsideObjects[num3]).Equals((object?)CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i]) || ((Object)___currentLevel.spawnableOutsideObjects[num3].spawnableObject).name.ToLower().Equals(((Object)CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject).name.ToLower())) { break; } num3++; continue; } list.Add(CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i]); CustomOutsideModBase.mls.LogInfo((object)("Added " + ((Object)CustomOutsideModBase.Instance.loadedInjectableOutsideObjects[i].spawnableObject).name + " as potential spawns.")); break; } break; } } SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = ___currentLevel.spawnableOutsideObjects; for (int j = 0; j < spawnableOutsideObjects.Length; j++) { list.Add(spawnableOutsideObjects[j]); } ___currentLevel.spawnableOutsideObjects = list.ToArray(); for (int k = 0; k < ___currentLevel.spawnableOutsideObjects.Length; k++) { CustomOutsideModBase.mls.LogInfo((object)$"#{k}: {((Object)___currentLevel.spawnableOutsideObjects[k].spawnableObject).name}"); } } } }