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 ForceRoute v0.1.0
ForceRoute.dll
Decompiled 5 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ForceRoute.NetcodePatcher; using HarmonyLib; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ForceRoute")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a0c44884827acc6eef2fedea9c8e5ab273da4cbc")] [assembly: AssemblyProduct("ForceRoute")] [assembly: AssemblyTitle("ForceRoute")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 ForceRoute { [BepInPlugin("SoftDiamond.ForceRoute", "ForceRoute", "0.1.0")] public class ForceRouteBase : BaseUnityPlugin { public ManualLogSource mls; private const string GUID = "SoftDiamond.ForceRoute"; private const string NAME = "ForceRoute"; private const string VERSION = "0.1.0"; private readonly Harmony harmony = new Harmony("SoftDiamond.ForceRoute"); public static ConfigEntry<string> config_PlanetName; public static ConfigEntry<bool> config_ForceOtherDays; public static ConfigEntry<bool> config_ForceLastDay; internal static ForceRouteBase Instance { get; private set; } private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("SoftDiamond.ForceRoute"); ConfigSetup(); harmony.PatchAll(); mls.LogInfo((object)"ForceRoute has initialized!"); NetcodePatcherAwake(); } private void ConfigSetup() { config_PlanetName = ((BaseUnityPlugin)this).Config.Bind<string>("Planet Name(s)", "Names", "", "What planets should be forced? Uses SelectableLevel.PlanetName variable."); config_ForceOtherDays = ((BaseUnityPlugin)this).Config.Bind<bool>("Force Other Days", "Force Other Days?", true, "Should the mod affect other days than just the first day?"); config_ForceLastDay = ((BaseUnityPlugin)this).Config.Bind<bool>("Force Last Day", "Force Last Day?", false, "Should the mod also affect the the Company/Selling Day?"); } private void NetcodePatcherAwake() { try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); Type[] types = executingAssembly.GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { try { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { try { methodInfo.Invoke(null, null); } catch (TargetInvocationException ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Failed to invoke method " + methodInfo.Name + ": " + ex.Message)); } } } catch (Exception ex2) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Error processing method " + methodInfo.Name + " in type " + type.Name + ": " + ex2.Message)); } } } } catch (Exception ex3) { ((BaseUnityPlugin)this).Logger.LogError((object)("An error occurred in NetcodePatcherAwake: " + ex3.Message)); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ForceRoute"; public const string PLUGIN_NAME = "ForceRoute"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace ForceRoute.Assets.Scripts { [HarmonyPatch] public static class Routing_Patches { public static string PlanetNames = ForceRouteBase.config_PlanetName.Value; public static bool forceOtherDays = ForceRouteBase.config_ForceOtherDays.Value; public static bool forceLastDay = ForceRouteBase.config_ForceLastDay.Value; public static SelectableLevel SelectableLevelName; public static string PlanetName; public static string GetRandomMoon(string PlanetsList) { string[] array = PlanetsList.Split(','); return array[Math.Abs(Guid.NewGuid().GetHashCode()) % array.Length].Trim(); } public static void TrySetPlanet(string planetName) { if (string.IsNullOrEmpty(planetName)) { return; } try { SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { if (val.PlanetName == planetName) { SelectableLevelName = val; break; } } ForceRouteBase.Instance.mls.LogDebug((object)$"Found Selectable Level to route: {SelectableLevelName.PlanetName} | {SelectableLevelName.levelID}"); StartOfRound.Instance.ChangeLevelServerRpc(SelectableLevelName.levelID, Object.FindObjectOfType<Terminal>().groupCredits); } catch (Exception arg) { ForceRouteBase.Instance.mls.LogError((object)$"Error forcing planet to: {planetName} | {arg}"); } if (StartOfRound.Instance.gameStats.daysSpent == 0) { ForceRouteBase.Instance.mls.LogInfo((object)("Forcing planet first day: " + planetName)); } else { ForceRouteBase.Instance.mls.LogInfo((object)("Forcing planet on other day: " + planetName)); } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "Start")] public static void FirstDaySettings(StartOfRound __instance) { if (NetworkManager.Singleton.IsServer) { ForceRouteBase.Instance.mls.LogDebug((object)"Is Server. forcing planet on client."); if (!((Object)(object)StartOfRound.Instance == (Object)null)) { SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { ForceRouteBase.Instance.mls.LogDebug((object)("Selectable Level Planet Name: " + val.PlanetName)); } ForceRouteBase.Instance.mls.LogDebug((object)"Forcing Start Patch"); if (StartOfRound.Instance.gameStats.daysSpent <= 0) { PlanetName = GetRandomMoon(PlanetNames); TrySetPlanet(PlanetName); } } } else { ForceRouteBase.Instance.mls.LogDebug((object)"Is Client. skipping force routing"); } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "SetShipReadyToLand")] public static void forcePlanetOtherDay(StartOfRound __instance) { if (NetworkManager.Singleton.IsServer) { ForceRouteBase.Instance.mls.LogDebug((object)"Is Server. forcing planet on client."); if (!((Object)(object)StartOfRound.Instance == (Object)null) && !((Object)(object)TimeOfDay.Instance == (Object)null)) { if (!forceLastDay && (float)TimeOfDay.Instance.daysUntilDeadline <= 0f) { ForceRouteBase.Instance.mls.LogDebug((object)"Not forcing planet on Company Day."); return; } if (!forceOtherDays && StartOfRound.Instance.gameStats.daysSpent != 0) { ForceRouteBase.Instance.mls.LogDebug((object)"Not forcing planet on other days. Config Disabled"); return; } ForceRouteBase.Instance.mls.LogDebug((object)"Forcing Other Days Patch"); PlanetName = GetRandomMoon(PlanetNames); TrySetPlanet(PlanetName); } } else { ForceRouteBase.Instance.mls.LogDebug((object)"Is Client. skipping force routing"); } } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { } } } namespace ForceRoute.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }