Decompiled source of CodeRebirthLib v0.9.8
BepInEx/plugins/CodeRebirthLib/com.github.xuuxiaolan.coderebirthlib.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CodeRebirth.src.MiscScripts; using CodeRebirthLib.AssetManagement; using CodeRebirthLib.ConfigManagement; using CodeRebirthLib.ConfigManagement.Converters; using CodeRebirthLib.ContentManagement; using CodeRebirthLib.ContentManagement.Achievements; using CodeRebirthLib.ContentManagement.Enemies; using CodeRebirthLib.ContentManagement.Items; using CodeRebirthLib.ContentManagement.MapObjects; using CodeRebirthLib.ContentManagement.Unlockables; using CodeRebirthLib.ContentManagement.Unlockables.Progressive; using CodeRebirthLib.ContentManagement.Weathers; using CodeRebirthLib.Data; using CodeRebirthLib.Exceptions; using CodeRebirthLib.Extensions; using CodeRebirthLib.MiscScriptManagement; using CodeRebirthLib.ModCompats; using CodeRebirthLib.Patches; using CodeRebirthLib.Util; using CodeRebirthLib.Util.Attributes; using CodeRebirthLib.Util.INetworkSerializables; using CodeRebirthLib.Util.Pathfinding; using GameNetcodeStuff; using GoodItemScan; using LethalConfig.ConfigItems; using LethalLevelLoader; using LethalLib.Extras; using LethalLib.Modules; using LethalQuantities.Objects; using Microsoft.CodeAnalysis; using MrovLib.Events; using On; using On.BepInEx.Configuration; using On.LethalConfig.AutoConfig; using On.LethalQuantities.Patches; using PathfindingLib.API.SmartPathfinding; using TMPro; using Unity.Netcode; using Unity.Netcode.Components; using UnityEngine; using UnityEngine.AI; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.Serialization; using UnityEngine.UI; using UnityEngine.Video; using WeatherRegistry; using WeatherRegistry.Modules; using com.github.xuuxiaolan.coderebirthlib.NetcodePatcher; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("com.github.xuuxiaolan.coderebirthlib.editor")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("GoodItemScan")] [assembly: IgnoresAccessChecksTo("LethalConfig")] [assembly: IgnoresAccessChecksTo("LethalLib")] [assembly: IgnoresAccessChecksTo("LethalQuantities")] [assembly: IgnoresAccessChecksTo("MrovLib")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("WeatherRegistry")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("XuXiaolan,loaforc")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A library to simplify making large LethalCompany mods.")] [assembly: AssemblyFileVersion("0.9.8.0")] [assembly: AssemblyInformationalVersion("0.9.8+2f98dabbef1d1e837348edd8a54cab8d0fd64737")] [assembly: AssemblyProduct("CodeRebirthLib")] [assembly: AssemblyTitle("com.github.xuuxiaolan.coderebirthlib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.8.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedINetworkSerializable<NetworkTransformState>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedValueEquals<NetworkTransformState>(); } } 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 CodeRebirth.src.MiscScripts { [Serializable] public class MaterialsWithRenderer { public Material[] materials = Array.Empty<Material>(); public Renderer renderer; } [Serializable] public class MaterialRendererVariantWithWeight : IWeighted { public MaterialsWithRenderer materialsWithRenderer = new MaterialsWithRenderer(); [field: SerializeField] public int Weight { get; set; } = 1; } public class ApplyRendererVariants : NetworkBehaviour { [SerializeField] private MaterialRendererVariantWithWeight[] _materialsWithRendererWithWeight = Array.Empty<MaterialRendererVariantWithWeight>(); [SerializeField] private bool _applyOnSpawn = true; private NetworkVariable<int> _currentVariant = new NetworkVariable<int>(0, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)1); public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); if (((NetworkBehaviour)this).IsServer) { Random random = new Random(); _currentVariant.Value = Array.IndexOf(_materialsWithRendererWithWeight, random.NextWeighted(_materialsWithRendererWithWeight)); } if (_applyOnSpawn) { ApplyMaterialVariantsToRenderers(); } } public void ApplyMaterialVariantsToRenderers() { _materialsWithRendererWithWeight[_currentVariant.Value].materialsWithRenderer.renderer.sharedMaterials = _materialsWithRendererWithWeight[_currentVariant.Value].materialsWithRenderer.materials; } protected override void __initializeVariables() { if (_currentVariant == null) { throw new Exception("ApplyRendererVariants._currentVariant cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)_currentVariant).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)_currentVariant, "_currentVariant"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)_currentVariant); ((NetworkBehaviour)this).__initializeVariables(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ApplyRendererVariants"; } } } namespace CodeRebirthLib { internal static class CodeRebirthLibConfig { public static CompatibilityBool LethalConfigCompatibility; public static bool ExtendedLogging; internal static void Bind(ConfigManager manager) { using (ConfigContext configContext = manager.CreateConfigSection("Compatibility")) { LethalConfigCompatibility = configContext.Bind("Extend LethalConfig Support", "Patches LethalConfig to enable raw editing of strings for unknown types.\nCurrent Targeted Version: 1.4.6", CompatibilityBool.IfVersionMatches).Value; } using ConfigContext configContext2 = manager.CreateConfigSection("Debugging"); ExtendedLogging = configContext2.Bind("Extended Logging", "Enable debug logs", defaultValue: false).Value; } } [BepInPlugin("com.github.xuuxiaolan.coderebirthlib", "CodeRebirthLib", "0.9.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class CodeRebirthLibPlugin : BaseUnityPlugin { internal class MainAssets : AssetBundleLoader<MainAssets> { [LoadFromBundle("CodeRebirthLibNetworker.prefab")] public GameObject NetworkerPrefab { get; private set; } public MainAssets(AssetBundle bundle) : base(bundle) { } } internal static ManualLogSource Logger { get; private set; } internal static ConfigManager ConfigManager { get; private set; } internal static MainAssets Main { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; ConfigManager = new ConfigManager(((BaseUnityPlugin)this).Config); CodeRebirthLibConfig.Bind(ConfigManager); NetcodePatcher(); RoundManagerPatch.Patch(); GameNetworkManagerPatch.Init(); EnemyAIPatch.Init(); StartOfRoundPatch.Init(); TerminalPatch.Init(); DeleteFileButtonPatch.Init(); MenuManagerPatch.Init(); if (LethalConfigCompatibility.Enabled) { LethalConfigCompatibility.Init(); } if (WeatherRegistryCompatibility.Enabled) { WeatherRegistryCompatibility.Init(); } if (LethalQuantitiesCompatibility.Enabled) { LethalQuantitiesCompatibility.Init(); } ExtendedTOML.Init(); Main = new MainAssets(CRLib.LoadBundle(Assembly.GetExecutingAssembly(), "coderebirthlibmain")); string[] files = Directory.GetFiles(Paths.PluginPath, "*.crmod", SearchOption.AllDirectories); foreach (string text in files) { AssetBundle val = AssetBundle.LoadFromFile(text); ExtendedLogging("[AssetBundle Loading] " + ((Object)val).name + " contains these objects: " + string.Join(",", val.GetAllAssetNames())); CRModInformation[] array = val.LoadAllAssets<CRModInformation>(); if (array.Length == 0) { Logger.LogError((object)(".crmod bundle: '" + Path.GetFileName(text) + "' does not have a 'Mod Information' file!")); continue; } if (array.Length > 1) { Logger.LogError((object)(".crmod bundle: '" + Path.GetFileName(text) + "' has multiple 'Mod Information' files! Only the first one will be used.")); } Logger.LogInfo((object)("AuthorName: " + array[0].AuthorName + ", ModName: " + array[0].ModName + ", Version: " + array[0].Version)); CRLib.RegisterNoCodeMod(array[0].CreatePluginMetadata(), val, Path.GetDirectoryName(text)); } Logger.LogInfo((object)"com.github.xuuxiaolan.coderebirthlib v0.9.8 has loaded!"); } private void NetcodePatcher() { Type[] array = new Type[7] { typeof(UnlockShipUnlockable), typeof(SmartAgentNavigator), typeof(CodeRebirthLibNetworker), typeof(ClientNetworkTransform), typeof(OwnerNetworkAnimator), typeof(ChanceScript), typeof(ApplyRendererVariants) }; Type[] array2 = array; foreach (Type type in array2) { try { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array3 = methods; foreach (MethodInfo methodInfo in array3) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } catch (Exception arg) { Logger.LogWarning((object)$"supressed an error from netcode patcher, probably fine but should still log that something happened: {arg}."); } } } internal static void ExtendedLogging(object text) { if (CodeRebirthLibConfig.ExtendedLogging) { Logger.LogInfo(text); } } } public static class CRLib { public static AssetBundle LoadBundle(Assembly assembly, string filePath) { string text = Path.Combine(Path.GetDirectoryName(assembly.Location), "Assets", filePath); if (!File.Exists(text)) { string path = Path.Combine(Path.GetDirectoryName(assembly.Location), filePath); bool flag = File.Exists(path); string text2 = "The assetbundle at plugins/" + Path.GetRelativePath(Paths.PluginPath, text) + " does not exist!"; if (flag) { text2 = text2 + " The bundle was found at the incorrect spot: plugins/" + Path.GetRelativePath(Paths.PluginPath, path) + ". It should be within the Assets/ subfolder"; } throw new FileNotFoundException(text2); } return AssetBundle.LoadFromFile(text); } public static CRMod RegisterMod(BaseUnityPlugin plugin, AssetBundle mainBundle) { ConfigManager configManager = new ConfigManager(plugin.Config); return new CRMod(((object)plugin).GetType().Assembly, plugin, mainBundle, Path.GetDirectoryName(((object)plugin).GetType().Assembly.Location), configManager); } public static void BroadcastTip(HUDDisplayTip displayTip) { NetworkSingleton<CodeRebirthLibNetworker>.Instance?.BroadcastDisplayTipServerRPC(displayTip); } internal static CRMod RegisterNoCodeMod(BepInPlugin plugin, AssetBundle mainBundle, string basePath) { CodeRebirthLibPlugin.ExtendedLogging("Registering no-code mod!"); ConfigManager configManager = new ConfigManager(GenerateConfigFile(plugin)); CRMod cRMod = new CRMod(plugin, mainBundle, basePath, configManager); cRMod.Logger = Logger.CreateLogSource(plugin.GUID); foreach (AssetBundleData assetBundle in cRMod.Content.assetBundles) { new DefaultContentHandler(cRMod); } return cRMod; } internal static ConfigFile GenerateConfigFile(BepInPlugin plugin) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown return new ConfigFile(Utility.CombinePaths(new string[2] { Paths.ConfigPath, plugin.GUID + ".cfg" }), false, plugin); } } public class CRMod { private static readonly List<CRMod> _allMods = new List<CRMod>(); private readonly string _basePath; private readonly Dictionary<string, CRRegistry> _registries = new Dictionary<string, CRRegistry>(); public static IReadOnlyList<CRMod> AllMods => _allMods.AsReadOnly(); public ConfigManager ConfigManager { get; } public ContentContainer Content { get; } public Assembly? Assembly { get; } public ManualLogSource? Logger { get; set; } public BepInPlugin Plugin { get; } internal CRMod(Assembly assembly, BaseUnityPlugin plugin, AssetBundle mainBundle, string basePath, ConfigManager configManager) : this(MetadataHelper.GetMetadata(((object)plugin).GetType()), mainBundle, basePath, configManager) { Assembly = assembly; } internal CRMod(BepInPlugin plugin, AssetBundle mainBundle, string basePath, ConfigManager configManager) { ConfigManager = configManager; _basePath = basePath; Plugin = plugin; ContentContainer[] array = mainBundle.LoadAllAssets<ContentContainer>(); if (array.Length == 0) { throw new NoContentDefinitionInBundle(mainBundle); } if (array.Length >= 2) { throw new MultipleContentDefinitionsInBundle(mainBundle); } Content = array[0]; AddDefaultRegistries(); if (WeatherRegistryCompatibility.Enabled) { AddWeatherRegistry(); } _allMods.Add(this); } public string GetRelativePath(params string[] path) { return Path.Combine(_basePath, Path.Combine(path)); } public bool TryGetRelativeFile(out string fullPath, params string[] path) { fullPath = GetRelativePath(path); return File.Exists(fullPath); } public void CreateRegistry<T>(string name, CRRegistry<T> registry) where T : CRContentDefinition { _registries[name] = registry; CodeRebirthLibPlugin.ExtendedLogging("Created Registry: " + name); } public CRRegistry<T> GetRegistryByName<T>(string name) where T : CRContentDefinition { return (CRRegistry<T>)_registries[name]; } public CRRegistry<CREnemyDefinition> EnemyRegistry() { return GetRegistryByName<CREnemyDefinition>("enemies"); } public static IEnumerable<CREnemyDefinition> AllEnemies() { return AllMods.SelectMany((CRMod mod) => mod.EnemyRegistry()); } public CRRegistry<CRItemDefinition> ItemRegistry() { return GetRegistryByName<CRItemDefinition>("items"); } public static IEnumerable<CRItemDefinition> AllItems() { return AllMods.SelectMany((CRMod mod) => mod.ItemRegistry()); } public CRRegistry<CRMapObjectDefinition> MapObjectRegistry() { return GetRegistryByName<CRMapObjectDefinition>("map_objects"); } public static IEnumerable<CRMapObjectDefinition> AllMapObjects() { return AllMods.SelectMany((CRMod mod) => mod.MapObjectRegistry()); } public CRRegistry<CRUnlockableDefinition> UnlockableRegistry() { return GetRegistryByName<CRUnlockableDefinition>("unlockables"); } public static IEnumerable<CRUnlockableDefinition> AllUnlockables() { return AllMods.SelectMany((CRMod mod) => mod.UnlockableRegistry()); } public CRRegistry<CRAchievementBaseDefinition> AchievementRegistry() { return GetRegistryByName<CRAchievementBaseDefinition>("achievements"); } public static IEnumerable<CRAchievementBaseDefinition> AllAchievements() { return AllMods.SelectMany((CRMod mod) => mod.AchievementRegistry()); } public bool TryGetBundleDataFromName(string bundleName, [NotNullWhen(true)] out AssetBundleData? data) { string bundleName2 = bundleName; data = Content.assetBundles.FirstOrDefault((AssetBundleData it) => it.assetBundleName == bundleName2); return data != null; } private void AddDefaultRegistries() { CREnemyDefinition.RegisterTo(this); CRMapObjectDefinition.RegisterTo(this); CRItemDefinition.RegisterTo(this); CRUnlockableDefinition.RegisterTo(this); CRAchievementBaseDefinition.RegisterTo(this); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void AddWeatherRegistry() { CRWeatherDefinition.RegisterTo(this); } public void RegisterContentHandlers() { if (Assembly == null) { CodeRebirthLibPlugin.Logger.LogWarning((object)("Tried to Register Content Handlers for " + Plugin.Name + " but it is a no-code CRMod!")); return; } IEnumerable<Type> enumerable = from x in Assembly.GetLoadableTypes() where !x.IsNested && x.BaseType != null && x.BaseType.IsGenericType && x.BaseType.GetGenericTypeDefinition() == typeof(ContentHandler<>) select x; foreach (Type item in enumerable) { item.GetConstructor(new Type[1] { typeof(CRMod) }).Invoke(new object[1] { this }); } } } [CreateAssetMenu(fileName = "Mod Information", menuName = "CodeRebirthLib/Mod Information", order = -11)] public class CRModInformation : ScriptableObject { [field: SerializeField] public string AuthorName { get; private set; } [field: SerializeField] public string ModName { get; private set; } [field: SerializeField] public string Version { get; private set; } [field: SerializeField] public TextAsset READMEFile { get; private set; } [field: SerializeField] public TextAsset ChangelogFile { get; private set; } [field: SerializeField] public string ModDescription { get; private set; } [Tooltip("Comma separated list of dependencies that this mod depends on apart from the default CRLib, BepInEx and potentially WeatherRegistry, grab from the thunderstore page.")] [field: SerializeField] public List<string> ExtraDependencies { get; private set; } = new List<string>(); [field: SerializeField] public string WebsiteUrl { get; private set; } [field: SerializeField] public Texture2D ModIcon { get; private set; } public BepInPlugin CreatePluginMetadata() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown return new BepInPlugin(AuthorName + "." + ModName, ModName, Version); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.xuuxiaolan.coderebirthlib"; public const string PLUGIN_NAME = "CodeRebirthLib"; public const string PLUGIN_VERSION = "0.9.8"; } } namespace CodeRebirthLib.Util { public class CodeRebirthLibNetworker : NetworkSingleton<CodeRebirthLibNetworker> { internal static EntranceTeleport[] _entrancePoints = Array.Empty<EntranceTeleport>(); internal Random CRLibRandom = new Random(); internal ES3Settings SaveSettings; public static IReadOnlyList<EntranceTeleport> EntrancePoints => _entrancePoints; private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown if (!((Object)(object)StartOfRound.Instance == (Object)null)) { CRLibRandom = new Random(StartOfRound.Instance.randomMapSeed + 6969); ((UnityEvent)StartOfRound.Instance.StartNewRoundEvent).AddListener(new UnityAction(OnNewRoundStart)); SaveSettings = new ES3Settings("CRLib" + GameNetworkManager.Instance.currentSaveFileName, new Enum[1] { (Enum)(object)(EncryptionType)0 }); } } public IEnumerator Start() { yield return (object)new WaitUntil((Func<bool>)(() => ((NetworkBehaviour)this).NetworkObject.IsSpawned)); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)); if (((NetworkBehaviour)this).IsHost || ((NetworkBehaviour)this).IsServer) { ProgressiveUnlockableHandler.LoadAll(SaveSettings); yield break; } RequestProgressiveUnlockableStatesServerRpc(GameNetworkManager.Instance.localPlayerController, (from it in CRMod.AllUnlockables() where it.ProgressiveData != null select it.ProgressiveData.NetworkID).ToArray()); } [ServerRpc(RequireOwnership = false)] private void RequestProgressiveUnlockableStatesServerRpc(PlayerControllerReference requester, uint[] expectedOrder) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2427953758u, val, (RpcDelivery)0); bool flag = requester != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<PlayerControllerReference>(ref requester, default(ForNetworkSerializable)); } bool flag2 = expectedOrder != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag2, default(ForPrimitives)); if (flag2) { ((FastBufferWriter)(ref val2)).WriteValueSafe<uint>(expectedOrder, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2427953758u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } PlayerControllerB val3 = requester; CodeRebirthLibPlugin.Logger.LogDebug((object)("Sending states of progressive unlockables for player: '" + val3.playerUsername + "'")); bool[] array = new bool[expectedOrder.Length]; for (int i = 0; i < expectedOrder.Length; i++) { uint unlockableNetworkId = expectedOrder[i]; CRUnlockableDefinition cRUnlockableDefinition = CRMod.AllUnlockables().FirstOrDefault((CRUnlockableDefinition it) => it.ProgressiveData != null && it.ProgressiveData.NetworkID == unlockableNetworkId); if (Object.op_Implicit((Object)(object)cRUnlockableDefinition)) { array[i] = cRUnlockableDefinition.ProgressiveData.IsUnlocked; CodeRebirthLibPlugin.ExtendedLogging($"set values[{i}] = {array[i]}"); } else { CodeRebirthLibPlugin.Logger.LogError((object)$"client requested progressive data status of a non-existing unlockable!!! (index: {i}, networkID: {unlockableNetworkId})"); array[i] = false; } } ProgressiveUnlockableStateResponseClientRpc(array, new ClientRpcParams { Send = { TargetClientIds = new <>z__ReadOnlyArray<ulong>(new ulong[1] { ((NetworkBehaviour)val3).OwnerClientId }) } }); } [ClientRpc] private void ProgressiveUnlockableStateResponseClientRpc(bool[] states, ClientRpcParams rpcParams = default(ClientRpcParams)) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { FastBufferWriter val = ((NetworkBehaviour)this).__beginSendClientRpc(1599363290u, rpcParams, (RpcDelivery)0); bool flag = states != null; ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val)).WriteValueSafe<bool>(states, default(ForPrimitives)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val, 1599363290u, rpcParams, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { CRUnlockableDefinition[] array = (from it in CRMod.AllUnlockables() where it.ProgressiveData != null select it).ToArray(); for (int i = 0; i < array.Length; i++) { CRUnlockableDefinition cRUnlockableDefinition = array[i]; CodeRebirthLibPlugin.ExtendedLogging($"setting state of {cRUnlockableDefinition.UnlockableItemDef.unlockable.unlockableName} to {states[i]}. (index: {i}, networkID: {cRUnlockableDefinition.ProgressiveData.NetworkID})"); cRUnlockableDefinition.ProgressiveData.SetFromServer(states[i]); } } } internal void SaveCodeRebirthLibData() { CRAchievementHandler.SaveAll(); if (NetworkManager.Singleton.IsHost) { CodeRebirthLibPlugin.ExtendedLogging("Running SaveAll"); ProgressiveUnlockableHandler.SaveAll(SaveSettings); } } internal static void ResetCodeRebirthLibData(ES3Settings saveSettings) { ES3.DeleteFile(saveSettings); } private void OnNewRoundStart() { _entrancePoints = Object.FindObjectsByType<EntranceTeleport>((FindObjectsSortMode)1); EntranceTeleport[] entrancePoints = _entrancePoints; foreach (EntranceTeleport val in entrancePoints) { if (!val.FindExitPoint()) { CodeRebirthLibPlugin.Logger.LogError((object)"Something went wrong in the generation of the fire exits! (ignorable if EntranceTeleportOptimisation is installed)"); } } } [ServerRpc(RequireOwnership = false)] public void BroadcastDisplayTipServerRPC(HUDDisplayTip displayTip) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(829470014u, val, (RpcDelivery)0); bool flag = displayTip != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<HUDDisplayTip>(ref displayTip, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 829470014u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { BroadcastDisplayTipClientRPC(displayTip); } } [ClientRpc] private void BroadcastDisplayTipClientRPC(HUDDisplayTip displayTip) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1273870504u, val, (RpcDelivery)0); bool flag = displayTip != null; ((FastBufferWriter)(ref val2)).WriteValueSafe<bool>(ref flag, default(ForPrimitives)); if (flag) { ((FastBufferWriter)(ref val2)).WriteValueSafe<HUDDisplayTip>(ref displayTip, default(ForNetworkSerializable)); } ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1273870504u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { HUDManager.Instance.DisplayTip(displayTip); } } protected override void __initializeVariables() { base.__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_CodeRebirthLibNetworker() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(2427953758u, new RpcReceiveHandler(__rpc_handler_2427953758)); NetworkManager.__rpc_func_table.Add(1599363290u, new RpcReceiveHandler(__rpc_handler_1599363290)); NetworkManager.__rpc_func_table.Add(829470014u, new RpcReceiveHandler(__rpc_handler_829470014)); NetworkManager.__rpc_func_table.Add(1273870504u, new RpcReceiveHandler(__rpc_handler_1273870504)); } private static void __rpc_handler_2427953758(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); PlayerControllerReference requester = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<PlayerControllerReference>(ref requester, default(ForNetworkSerializable)); } bool flag2 = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag2, default(ForPrimitives)); uint[] expectedOrder = null; if (flag2) { ((FastBufferReader)(ref reader)).ReadValueSafe<uint>(ref expectedOrder, default(ForPrimitives)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((CodeRebirthLibNetworker)(object)target).RequestProgressiveUnlockableStatesServerRpc(requester, expectedOrder); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1599363290(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); bool[] states = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref states, default(ForPrimitives)); } ClientRpcParams client = rpcParams.Client; target.__rpc_exec_stage = (__RpcExecStage)2; ((CodeRebirthLibNetworker)(object)target).ProgressiveUnlockableStateResponseClientRpc(states, client); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_829470014(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); HUDDisplayTip displayTip = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<HUDDisplayTip>(ref displayTip, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)1; ((CodeRebirthLibNetworker)(object)target).BroadcastDisplayTipServerRPC(displayTip); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1273870504(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { bool flag = default(bool); ((FastBufferReader)(ref reader)).ReadValueSafe<bool>(ref flag, default(ForPrimitives)); HUDDisplayTip displayTip = null; if (flag) { ((FastBufferReader)(ref reader)).ReadValueSafe<HUDDisplayTip>(ref displayTip, default(ForNetworkSerializable)); } target.__rpc_exec_stage = (__RpcExecStage)2; ((CodeRebirthLibNetworker)(object)target).BroadcastDisplayTipClientRPC(displayTip); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "CodeRebirthLibNetworker"; } } public static class MoreLayerMasks { public static int CollidersAndRoomAndDefaultAndInteractableAndRailingAndEnemiesAndTerrainAndHazardAndVehicleMask { get; private set; } public static int CollidersAndRoomAndInteractableAndRailingAndEnemiesAndTerrainAndHazardAndVehicleMask { get; private set; } public static int CollidersAndRoomAndInteractableAndRailingAndTerrainAndHazardAndVehicleMask { get; private set; } public static int CollidersAndRoomAndPlayersAndEnemiesAndTerrainAndVehicleAndDefaultMask { get; private set; } public static int CollidersAndRoomAndRailingAndTerrainAndHazardAndVehicleAndDefaultMask { get; private set; } public static int CollidersAndRoomAndPlayersAndEnemiesAndTerrainAndVehicleMask { get; private set; } public static int CollidersAndRoomAndRailingAndInteractableMask { get; private set; } public static int CollidersAndRoomAndPlayersAndInteractableMask { get; private set; } public static int PlayersAndInteractableAndEnemiesAndPropsHazardMask { get; private set; } public static int CollidersAndRoomMaskAndDefaultAndEnemies { get; private set; } public static int PlayersAndEnemiesAndHazardMask { get; private set; } public static int PlayersAndRagdollMask { get; private set; } public static int PropsAndHazardMask { get; private set; } public static int TerrainAndFoliageMask { get; private set; } public static int PlayersAndEnemiesMask { get; private set; } public static int DefaultMask { get; private set; } public static int PropsMask { get; private set; } public static int HazardMask { get; private set; } public static int EnemiesMask { get; private set; } public static int InteractableMask { get; private set; } public static int RailingMask { get; private set; } public static int TerrainMask { get; private set; } public static int VehicleMask { get; private set; } public static void Init() { DefaultMask = LayerMask.GetMask(new string[1] { "Default" }); PropsMask = LayerMask.GetMask(new string[1] { "Props" }); HazardMask = LayerMask.GetMask(new string[1] { "MapHazards" }); EnemiesMask = LayerMask.GetMask(new string[1] { "Enemies" }); InteractableMask = LayerMask.GetMask(new string[1] { "InteractableObject" }); RailingMask = LayerMask.GetMask(new string[1] { "Railing" }); TerrainMask = LayerMask.GetMask(new string[1] { "Terrain" }); VehicleMask = LayerMask.GetMask(new string[1] { "Vehicle" }); PlayersAndRagdollMask = StartOfRound.Instance.playersMask | LayerMask.GetMask(new string[1] { "PlayerRagdoll" }); PropsAndHazardMask = PropsMask | HazardMask; TerrainAndFoliageMask = TerrainMask | LayerMask.GetMask(new string[1] { "Foliage" }); PlayersAndEnemiesMask = StartOfRound.Instance.playersMask | EnemiesMask; PlayersAndEnemiesAndHazardMask = PlayersAndEnemiesMask | HazardMask; CollidersAndRoomMaskAndDefaultAndEnemies = StartOfRound.Instance.collidersAndRoomMaskAndDefault | EnemiesMask; CollidersAndRoomAndRailingAndInteractableMask = StartOfRound.Instance.collidersAndRoomMask | InteractableMask | RailingMask; CollidersAndRoomAndPlayersAndInteractableMask = StartOfRound.Instance.collidersAndRoomMaskAndPlayers | InteractableMask; PlayersAndInteractableAndEnemiesAndPropsHazardMask = PlayersAndEnemiesAndHazardMask | InteractableMask | PropsMask; CollidersAndRoomAndRailingAndTerrainAndHazardAndVehicleAndDefaultMask = StartOfRound.Instance.collidersAndRoomMask | HazardMask | RailingMask | TerrainMask | VehicleMask | DefaultMask; CollidersAndRoomAndPlayersAndEnemiesAndTerrainAndVehicleMask = StartOfRound.Instance.collidersAndRoomMaskAndPlayers | EnemiesMask | TerrainMask | VehicleMask; CollidersAndRoomAndPlayersAndEnemiesAndTerrainAndVehicleAndDefaultMask = CollidersAndRoomAndPlayersAndEnemiesAndTerrainAndVehicleMask | DefaultMask; CollidersAndRoomAndInteractableAndRailingAndTerrainAndHazardAndVehicleMask = CollidersAndRoomAndRailingAndInteractableMask | HazardMask | TerrainMask | VehicleMask; CollidersAndRoomAndInteractableAndRailingAndEnemiesAndTerrainAndHazardAndVehicleMask = CollidersAndRoomAndInteractableAndRailingAndTerrainAndHazardAndVehicleMask | EnemiesMask; CollidersAndRoomAndDefaultAndInteractableAndRailingAndEnemiesAndTerrainAndHazardAndVehicleMask = CollidersAndRoomAndInteractableAndRailingAndEnemiesAndTerrainAndHazardAndVehicleMask | DefaultMask; } } public abstract class NetworkSingleton<T> : NetworkBehaviour where T : NetworkSingleton<T> { public static T? Instance { get; private set; } protected void OnDisable() { if ((Object)(object)Instance == (Object)(object)(T)this) { Instance = null; } } public override void OnNetworkSpawn() { ((NetworkBehaviour)this).OnNetworkSpawn(); Instance = (T)this; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string? __getTypeName() { return "NetworkSingleton`1"; } } } namespace CodeRebirthLib.Util.Pathfinding { public struct GenericPath<T> { public T Generic; public float PathLength; public GenericPath(T generic, float pathLength) { Generic = generic; PathLength = pathLength; } } [RequireComponent(typeof(NavMeshAgent))] public class SmartAgentNavigator : NetworkBehaviour { public enum AgentState { NotSet, Inside, Outside } public enum GoToDestinationResult { Success, InProgress, Failure } [HideInInspector] public bool cantMove; [HideInInspector] public UnityEvent<bool> OnUseEntranceTeleport = new UnityEvent<bool>(); [HideInInspector] public UnityEvent<bool> OnEnableOrDisableAgent = new UnityEvent<bool>(); [HideInInspector] public UnityEvent<bool> OnEnterOrExitElevator = new UnityEvent<bool>(); [HideInInspector] public EntranceTeleport? lastUsedEntranceTeleport; private Vector3 pointToGo = Vector3.zero; private Coroutine? searchRoutine; private SmartPathTask? pathingTask; private SmartPathTask? checkPathsTask; private SmartPathTask? roamingTask; private AgentState _agentState; [HideInInspector] public NavMeshAgent agent; [HideInInspector] public Coroutine? checkPathsRoutine; [Header("Search Algorithm")] [SerializeField] private float _nodeRemovalPrecision = 5f; [SerializeField] private SmartPathfindingLinkFlags _allowedLinks = (SmartPathfindingLinkFlags)15; private Coroutine? _searchRoutine; private float _searchRadius = 50f; private readonly List<Vector3> _positionsToSearch = new List<Vector3>(); private readonly List<Vector3> _roamingPointsVectorList = new List<Vector3>(); public void Awake() { agent = ((Component)this).gameObject.GetComponent<NavMeshAgent>(); SmartPathfinding.RegisterSmartAgent(agent); } public bool IsAgentOutside() { if (_agentState == AgentState.NotSet) { CodeRebirthLibPlugin.Logger.LogError((object)(((Object)this).name + " is not initialized yet! Please call `SetAllValues` first.")); return false; } return _agentState == AgentState.Outside; } public void SetAllValues(bool isOutside) { _agentState = ((!isOutside) ? AgentState.Inside : AgentState.Outside); } private SmartPathfindingLinkFlags GetAllowedPathLinks() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return _allowedLinks; } private void UseTeleport(EntranceTeleport teleport) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)teleport.exitPoint == (Object)null) && teleport.FindExitPoint()) { agent.Warp(teleport.exitPoint.position); SetThingOutsideServerRpc(new NetworkBehaviourReference((NetworkBehaviour)(object)teleport)); } } public bool DoPathingToDestination(Vector3 destination) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (searchRoutine != null) { StopSearchRoutine(); } if (cantMove) { return false; } if (!((Behaviour)agent).enabled) { HandleDisabledAgentPathing(); return false; } GoToDestinationResult goToDestinationResult = GoToDestination(destination); if (goToDestinationResult == GoToDestinationResult.Failure && DetermineIfNeedToDisableAgent(destination)) { return false; } if (goToDestinationResult != 0) { return goToDestinationResult == GoToDestinationResult.InProgress; } return true; } private GoToDestinationResult GoToDestination(Vector3 targetPosition) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) GoToDestinationResult result = GoToDestinationResult.InProgress; if (pathingTask == null) { pathingTask = new SmartPathTask(); pathingTask.StartPathTask(agent, ((Component)this).transform.position, targetPosition, GetAllowedPathLinks()); } if (!pathingTask.IsResultReady(0)) { return result; } SmartPathDestination? result2 = pathingTask.GetResult(0); if (result2.HasValue) { SmartPathDestination destination = result2.GetValueOrDefault(); result = ((!GoToSmartPathDestination(in destination)) ? GoToDestinationResult.Failure : GoToDestinationResult.Success); } else { result = GoToDestinationResult.Failure; } pathingTask.StartPathTask(agent, ((Component)this).transform.position, targetPosition, GetAllowedPathLinks()); return result; } public void DisposeOfTasks() { SmartPathTask? obj = pathingTask; if (obj != null) { obj.Dispose(); } SmartPathTask? obj2 = checkPathsTask; if (obj2 != null) { obj2.Dispose(); } SmartPathTask? obj3 = roamingTask; if (obj3 != null) { obj3.Dispose(); } } private bool GoToSmartPathDestination(in SmartPathDestination destination) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected I4, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) SmartDestinationType type = ((SmartPathDestination)(ref destination)).Type; switch ((int)type) { case 0: HandleDirectDestination(destination); break; case 1: HandleInternalTeleportDestination(destination); break; case 2: HandleEntranceTeleportDestination(destination); break; case 3: HandleElevatorDestination(destination); break; default: return false; } return true; } private void HandleDirectDestination(SmartPathDestination destination) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) agent.SetDestination(((SmartPathDestination)(ref destination)).Position); } private void HandleInternalTeleportDestination(SmartPathDestination destination) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) agent.SetDestination(((SmartPathDestination)(ref destination)).Position); if (!(Vector3.Distance(((Component)this).transform.position, ((SmartPathDestination)(ref destination)).Position) >= 1f + agent.stoppingDistance)) { agent.Warp(((SmartPathDestination)(ref destination)).InternalTeleport.Destination.position); } } private void HandleElevatorDestination(SmartPathDestination destination) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) agent.SetDestination(((SmartPathDestination)(ref destination)).Position); if (!(Vector3.Distance(((Component)this).transform.position, ((SmartPathDestination)(ref destination)).Position) >= 1f + agent.stoppingDistance)) { ((SmartPathDestination)(ref destination)).ElevatorFloor.CallElevator(); } } private void HandleEntranceTeleportDestination(SmartPathDestination destination) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) agent.SetDestination(((SmartPathDestination)(ref destination)).Position); if (!(Vector3.Distance(((Component)this).transform.position, ((SmartPathDestination)(ref destination)).Position) >= 1f + agent.stoppingDistance)) { UseTeleport(((SmartPathDestination)(ref destination)).EntranceTeleport); } } public bool CheckPathsOngoing() { return checkPathsRoutine != null; } public void CheckPaths<T>(IEnumerable<(T, Vector3)> points, Action<List<GenericPath<T>>> action) { if (checkPathsRoutine != null) { ((MonoBehaviour)this).StopCoroutine(checkPathsRoutine); } checkPathsRoutine = ((MonoBehaviour)this).StartCoroutine(CheckPathsCoroutine(points, action)); } private IEnumerator CheckPathsCoroutine<T>(IEnumerable<(T, Vector3)> points, Action<List<GenericPath<T>>> action) { List<GenericPath<T>> TList = new List<GenericPath<T>>(); if (checkPathsTask == null) { checkPathsTask = new SmartPathTask(); } List<Vector3> list = points.Select<(T, Vector3), Vector3>(((T, Vector3) x) => x.Item2).ToList(); List<T> pointsTList = points.Select<(T, Vector3), T>(((T, Vector3) x) => x.Item1).ToList(); checkPathsTask.StartPathTask(agent, ((Component)this).transform.position, list, GetAllowedPathLinks()); int listSize = list.Count; CodeRebirthLibPlugin.ExtendedLogging($"Checking paths for {listSize} objects"); yield return (object)new WaitUntil((Func<bool>)(() => checkPathsTask.IsComplete)); for (int i = 0; i < listSize; i++) { if (!checkPathsTask.IsResultReady(i)) { CodeRebirthLibPlugin.Logger.LogError((object)$"Result for task index: {i} on {((Object)((Component)this).gameObject).name} is not ready"); continue; } CodeRebirthLibPlugin.ExtendedLogging($"Checking result for task index: {i}, is result ready: {checkPathsTask.IsResultReady(i)}, result: {checkPathsTask.GetResult(i)}"); SmartPathDestination? result = checkPathsTask.GetResult(i); if (result.HasValue) { result.GetValueOrDefault(); TList.Add(new GenericPath<T>(pointsTList[i], checkPathsTask.GetPathLength(i))); } } action(TList); checkPathsRoutine = null; } public void StopAgent() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (((Behaviour)agent).enabled && agent.isOnNavMesh) { agent.ResetPath(); } agent.velocity = Vector3.zero; } private void HandleDisabledAgentPathing() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pointToGo; float num = 10f; float num2 = Vector3.Distance(((Component)this).transform.position, val); if (Vector3.Distance(((Component)this).transform.position, val) <= 1f) { OnEnableOrDisableAgent.Invoke(true); ((Behaviour)agent).enabled = true; agent.Warp(val); if (pathingTask != null) { pathingTask.StartPathTask(agent, ((Component)this).transform.position, val, GetAllowedPathLinks()); return; } pathingTask = new SmartPathTask(); pathingTask.StartPathTask(agent, ((Component)this).transform.position, val, GetAllowedPathLinks()); } else { float num3 = Mathf.Clamp01(Vector3.Distance(((Component)this).transform.position, val) / num2); Vector3 val2 = Vector3.MoveTowards(((Component)this).transform.position, val, Time.deltaTime * 10f); val2.y += Mathf.Sin(num3 * MathF.PI) * num; ((Component)this).transform.SetPositionAndRotation(val2, Quaternion.LookRotation(val - ((Component)this).transform.position)); } } private bool DetermineIfNeedToDisableAgent(Vector3 destination) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) float num = Vector3.Distance(((Component)this).transform.position, destination); if (num <= agent.stoppingDistance + 5f) { return false; } NavMeshHit val = default(NavMeshHit); if (!NavMesh.SamplePosition(destination, ref val, 3f, agent.areaMask)) { return false; } Vector3 val2 = FindClosestValidPoint(); agent.SetDestination(val2); if (Vector3.Distance(((Component)agent).transform.position, val2) <= agent.stoppingDistance) { pointToGo = ((NavMeshHit)(ref val)).position; OnEnableOrDisableAgent.Invoke(false); ((Behaviour)agent).enabled = false; CodeRebirthLibPlugin.ExtendedLogging($"Pathing to initial destination {destination} failed, going to fallback position {((NavMeshHit)(ref val)).position} instead."); return true; } return false; } public float CanPathToPoint(Vector3 startPos, Vector3 endPos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) NavMeshPath val = new NavMeshPath(); if (!NavMesh.CalculatePath(startPos, endPos, -1, val) || (int)val.status != 0) { return -1f; } float num = 0f; if (val.corners.Length > 1) { for (int i = 1; i < val.corners.Length; i++) { num += Vector3.Distance(val.corners[i - 1], val.corners[i]); } } return num; } [ServerRpc(RequireOwnership = false)] public void SetThingOutsideServerRpc(NetworkBehaviourReference entranceTeleportReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(4258763819u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref entranceTeleportReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 4258763819u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { SetThingOutsideClientRpc(entranceTeleportReference); } } } [ClientRpc] public void SetThingOutsideClientRpc(NetworkBehaviourReference entranceTeleportReference) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)base.__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(1493229376u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe<NetworkBehaviourReference>(ref entranceTeleportReference, default(ForNetworkSerializable)); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 1493229376u, val, (RpcDelivery)0); } if ((int)base.__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { lastUsedEntranceTeleport = (EntranceTeleport)NetworkBehaviourReference.op_Implicit(entranceTeleportReference); _agentState = (lastUsedEntranceTeleport.isEntranceToBuilding ? AgentState.Inside : AgentState.Outside); OnUseEntranceTeleport.Invoke(!lastUsedEntranceTeleport.isEntranceToBuilding); } } } private Vector3 FindClosestValidPoint() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return agent.pathEndPosition; } public void AdjustSpeedBasedOnDistance(float minDistance, float maxDistance, float minSpeed, float maxSpeed, float multiplierBoost) { float num = Mathf.Clamp(agent.remainingDistance, minDistance, maxDistance); float num2 = (num - minDistance) / (maxDistance - minDistance); agent.speed = Mathf.Lerp(minSpeed, maxSpeed, num2) * multiplierBoost; } public bool CurrentPathIsValid() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if ((int)agent.path.status == 1 || (int)agent.path.status == 2) { return false; } return true; } public void StartSearchRoutine(float radius) { if (((Behaviour)agent).enabled) { _searchRadius = radius; StopSearchRoutine(); _searchRoutine = ((MonoBehaviour)this).StartCoroutine(SearchAlgorithm(radius)); } } public void StopSearchRoutine() { if (_searchRoutine != null) { ((MonoBehaviour)this).StopCoroutine(_searchRoutine); } StopAgent(); _searchRoutine = null; } private IEnumerator SearchAlgorithm(float radius) { yield return (object)new WaitForSeconds(Random.Range(0f, 3f)); CodeRebirthLibPlugin.ExtendedLogging($"Starting search routine for {((Object)((Component)this).gameObject).name} at {((Component)this).transform.position} with radius {radius}"); _positionsToSearch.Clear(); yield return ((MonoBehaviour)this).StartCoroutine(GetSetOfAcceptableNodesForRoaming(radius)); while (true) { Vector3 positionToTravel = _positionsToSearch.FirstOrDefault(); if (_positionsToSearch.Count == 0 || positionToTravel == Vector3.zero) { break; } _positionsToSearch.RemoveAt(0); yield return ((MonoBehaviour)this).StartCoroutine(ClearProximityNodes(_positionsToSearch, positionToTravel, _nodeRemovalPrecision)); bool reachedDestination = false; while (!reachedDestination) { CodeRebirthLibPlugin.ExtendedLogging($"{((Object)((Component)this).gameObject).name} Search: {positionToTravel}"); GoToDestination(positionToTravel); yield return (object)new WaitForSeconds(0.5f); if (!((Behaviour)agent).enabled || Vector3.Distance(((Component)this).transform.position, positionToTravel) <= 3f + agent.stoppingDistance) { reachedDestination = true; } } } StartSearchRoutine(radius); } private IEnumerator GetSetOfAcceptableNodesForRoaming(float radius) { _roamingPointsVectorList.Clear(); if (((Enum)_allowedLinks).HasFlag((Enum)(object)(SmartPathfindingLinkFlags)8) || ((Enum)_allowedLinks).HasFlag((Enum)(object)(SmartPathfindingLinkFlags)4)) { if (RoundManager.Instance.insideAINodes != null) { _roamingPointsVectorList.AddRange(from x in RoundManager.Instance.insideAINodes where (Object)(object)x != (Object)null select x.transform.position); } if (RoundManager.Instance.outsideAINodes != null) { _roamingPointsVectorList.AddRange(from x in RoundManager.Instance.outsideAINodes where (Object)(object)x != (Object)null select x.transform.position); } } else if (IsAgentOutside()) { if (RoundManager.Instance.outsideAINodes != null) { _roamingPointsVectorList.AddRange(from x in RoundManager.Instance.outsideAINodes where (Object)(object)x != (Object)null select x.transform.position); } } else if (RoundManager.Instance.insideAINodes != null) { _roamingPointsVectorList.AddRange(from x in RoundManager.Instance.insideAINodes where (Object)(object)x != (Object)null select x.transform.position); } if (_roamingPointsVectorList.Count == 0) { for (int i = 0; i < 20; i++) { _roamingPointsVectorList.Add(RoundManager.Instance.GetRandomNavMeshPositionInRadius(((Component)this).transform.position, radius, default(NavMeshHit))); } } if (roamingTask == null) { roamingTask = new SmartPathTask(); } roamingTask.StartPathTask(agent, ((Component)this).transform.position, _roamingPointsVectorList, GetAllowedPathLinks()); int listSize = _roamingPointsVectorList.Count; CodeRebirthLibPlugin.ExtendedLogging($"Checking paths for {listSize} objects"); yield return (object)new WaitUntil((Func<bool>)(() => roamingTask.IsComplete)); for (int j = 0; j < listSize; j++) { if (!roamingTask.IsResultReady(j)) { CodeRebirthLibPlugin.Logger.LogError((object)$"Roaming task {j} is not ready"); continue; } SmartPathDestination? result = roamingTask.GetResult(j); if (result.HasValue) { result.GetValueOrDefault(); if (!(roamingTask.GetPathLength(j) > radius)) { _positionsToSearch.Add(_roamingPointsVectorList[j]); } } } _positionsToSearch.Shuffle(); } private IEnumerator ClearProximityNodes(List<Vector3> positionsToSearch, Vector3 positionToTravel, float radius) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) int count = positionsToSearch.Count; if (count == 0) { yield break; } for (int i = count - 1; i >= 0; i--) { if (Vector3.Distance(positionsToSearch[i], positionToTravel) <= radius) { positionsToSearch.RemoveAt(i); } yield return null; } } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_SmartAgentNavigator() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(4258763819u, new RpcReceiveHandler(__rpc_handler_4258763819)); NetworkManager.__rpc_func_table.Add(1493229376u, new RpcReceiveHandler(__rpc_handler_1493229376)); } private static void __rpc_handler_4258763819(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference thingOutsideServerRpc = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref thingOutsideServerRpc, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)1; ((SmartAgentNavigator)(object)target).SetThingOutsideServerRpc(thingOutsideServerRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_1493229376(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { NetworkBehaviourReference thingOutsideClientRpc = default(NetworkBehaviourReference); ((FastBufferReader)(ref reader)).ReadValueSafe<NetworkBehaviourReference>(ref thingOutsideClientRpc, default(ForNetworkSerializable)); target.__rpc_exec_stage = (__RpcExecStage)2; ((SmartAgentNavigator)(object)target).SetThingOutsideClientRpc(thingOutsideClientRpc); target.__rpc_exec_stage = (__RpcExecStage)0; } } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "SmartAgentNavigator"; } } } namespace CodeRebirthLib.Util.INetworkSerializables { public class HUDDisplayTip : INetworkSerializable { public enum AlertType { Hint, Warning } private AlertType _alertType; private string _header; private string _body; public string Header => _header; public string Body => _body; public AlertType Type => _alertType; public HUDDisplayTip(string header, string body, AlertType type = AlertType.Hint) { _header = header; _body = body; _alertType = type; } public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) serializer.SerializeValue(ref _header, false); serializer.SerializeValue(ref _body, false); ((BufferSerializer<AlertType>*)(&serializer))->SerializeValue<AlertType>(ref _alertType, default(ForEnums)); } } public class PlayerControllerReference : INetworkSerializable { private int _playerID; public unsafe void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer<int>*)(&serializer))->SerializeValue<int>(ref _playerID, default(ForPrimitives)); } public static implicit operator PlayerControllerB(PlayerControllerReference reference) { return StartOfRound.Instance.allPlayerScripts[reference._playerID]; } public static implicit operator PlayerControllerReference(PlayerControllerB player) { return new PlayerControllerReference { _playerID = Array.IndexOf(StartOfRound.Instance.allPlayerScripts, player) }; } public override bool Equals(object? obj) { if (obj is PlayerControllerReference playerControllerReference) { return playerControllerReference._playerID == _playerID; } PlayerControllerB val = (PlayerControllerB)((obj is PlayerControllerB) ? obj : null); if (val != null) { return Array.IndexOf(StartOfRound.Instance.allPlayerScripts, val) == _playerID; } return false; } public override int GetHashCode() { return _playerID; } } } namespace CodeRebirthLib.Util.Attributes { [Serializable] public class AttributeStack<T> { [SerializeField] private T _baseValue; private bool _isDirty = true; private T _lastCalculated; private List<Func<T, T>> _stack = new List<Func<T, T>>(); public T BaseValue => _baseValue; public AttributeStack() { } public AttributeStack(T baseValue) { _baseValue = baseValue; } public Func<T, T> Add(Func<T, T> transformer) { _stack.Add(transformer); _isDirty = true; return transformer; } public void Remove(Func<T, T> transformer) { _stack.Remove(transformer); } public void MarkDirty() { _isDirty = true; } public T Calculate(bool forceRecalculate = false) { if (!_isDirty && !forceRecalculate) { return _lastCalculated; } T val = _baseValue; foreach (Func<T, T> item in _stack) { val = item(val); } _lastCalculated = val; _isDirty = false; return val; } } } namespace CodeRebirthLib.Patches { public static class DeleteFileButtonPatch { [CompilerGenerated] private static class <>O { public static hook_DeleteFile <0>__DeleteFileButton_DeleteFile; } public static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__DeleteFileButton_DeleteFile; if (obj == null) { hook_DeleteFile val = DeleteFileButton_DeleteFile; <>O.<0>__DeleteFileButton_DeleteFile = val; obj = (object)val; } DeleteFileButton.DeleteFile += (hook_DeleteFile)obj; } private static void DeleteFileButton_DeleteFile(orig_DeleteFile orig, DeleteFileButton self) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown orig.Invoke(self); ES3Settings saveSettings = (ES3Settings)((!((Object)(object)NetworkSingleton<CodeRebirthLibNetworker>.Instance != (Object)null)) ? ((object)new ES3Settings($"CRLibLCSaveFile{self.fileToDelete + 1}", new Enum[1] { (Enum)(object)(EncryptionType)0 })) : ((object)NetworkSingleton<CodeRebirthLibNetworker>.Instance.SaveSettings)); CodeRebirthLibNetworker.ResetCodeRebirthLibData(saveSettings); } } internal static class EnemyAIPatch { [CompilerGenerated] private static class <>O { public static hook_Start <0>__EnemyAI_Start; public static hook_HitEnemy <1>__EnemyAI_HitEnemy; } public static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown object obj = <>O.<0>__EnemyAI_Start; if (obj == null) { hook_Start val = EnemyAI_Start; <>O.<0>__EnemyAI_Start = val; obj = (object)val; } EnemyAI.Start += (hook_Start)obj; object obj2 = <>O.<1>__EnemyAI_HitEnemy; if (obj2 == null) { hook_HitEnemy val2 = EnemyAI_HitEnemy; <>O.<1>__EnemyAI_HitEnemy = val2; obj2 = (object)val2; } EnemyAI.HitEnemy += (hook_HitEnemy)obj2; } private static void EnemyAI_Start(orig_Start orig, EnemyAI self) { orig.Invoke(self); CREnemyAdditionalData.CreateOrGet(self); } private static void EnemyAI_HitEnemy(orig_HitEnemy orig, EnemyAI self, int force, PlayerControllerB? playerWhoHit, bool playHitSFX, int hitID) { CREnemyAdditionalData cREnemyAdditionalData = CREnemyAdditionalData.CreateOrGet(self); if (Object.op_Implicit((Object)(object)playerWhoHit)) { cREnemyAdditionalData.PlayerThatLastHit = playerWhoHit; } if (!self.isEnemyDead && self.enemyHP - force <= 0 && (Object)(object)playerWhoHit != (Object)null) { cREnemyAdditionalData.KilledByPlayer = true; } orig.Invoke(self, force, playerWhoHit, playHitSFX, hitID); } } internal static class GameNetworkManagerPatch { [CompilerGenerated] private static class <>O { public static hook_Start <0>__GameNetworkManagerOnStart; public static hook_SaveItemsInShip <1>__GameNetworkManager_SaveItemsInShip; public static hook_ResetSavedGameValues <2>__GameNetworkManager_ResetSavedGameValues; } internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__GameNetworkManagerOnStart; if (obj == null) { hook_Start val = GameNetworkManagerOnStart; <>O.<0>__GameNetworkManagerOnStart = val; obj = (object)val; } GameNetworkManager.Start += (hook_Start)obj; object obj2 = <>O.<1>__GameNetworkManager_SaveItemsInShip; if (obj2 == null) { hook_SaveItemsInShip val2 = GameNetworkManager_SaveItemsInShip; <>O.<1>__GameNetworkManager_SaveItemsInShip = val2; obj2 = (object)val2; } GameNetworkManager.SaveItemsInShip += (hook_SaveItemsInShip)obj2; object obj3 = <>O.<2>__GameNetworkManager_ResetSavedGameValues; if (obj3 == null) { hook_ResetSavedGameValues val3 = GameNetworkManager_ResetSavedGameValues; <>O.<2>__GameNetworkManager_ResetSavedGameValues = val3; obj3 = (object)val3; } GameNetworkManager.ResetSavedGameValues += (hook_ResetSavedGameValues)obj3; } private static void GameNetworkManagerOnStart(orig_Start orig, GameNetworkManager self) { orig.Invoke(self); VanillaEnemies.Init(); } private static void GameNetworkManager_SaveItemsInShip(orig_SaveItemsInShip orig, GameNetworkManager self) { orig.Invoke(self); CodeRebirthLibPlugin.ExtendedLogging("Saving CodeRebirthLibData"); NetworkSingleton<CodeRebirthLibNetworker>.Instance?.SaveCodeRebirthLibData(); } private static void GameNetworkManager_ResetSavedGameValues(orig_ResetSavedGameValues orig, GameNetworkManager self) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown orig.Invoke(self); ES3Settings saveSettings = (ES3Settings)((!((Object)(object)NetworkSingleton<CodeRebirthLibNetworker>.Instance != (Object)null)) ? ((object)new ES3Settings("CRLib" + GameNetworkManager.Instance.currentSaveFileName, new Enum[1] { (Enum)(object)(EncryptionType)0 })) : ((object)NetworkSingleton<CodeRebirthLibNetworker>.Instance.SaveSettings)); CodeRebirthLibNetworker.ResetCodeRebirthLibData(saveSettings); } } internal static class MenuManagerPatch { [CompilerGenerated] private static class <>O { public static hook_Start <0>__MenuManager_Start; } internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__MenuManager_Start; if (obj == null) { hook_Start val = MenuManager_Start; <>O.<0>__MenuManager_Start = val; obj = (object)val; } MenuManager.Start += (hook_Start)obj; } private static void MenuManager_Start(orig_Start orig, MenuManager self) { orig.Invoke(self); CRAchievementHandler.LoadAll(); } } internal static class RoundManagerPatch { [CompilerGenerated] private static class <>O { public static hook_SpawnOutsideHazards <0>__SpawnOutsideMapObjects; } internal static List<RegisteredCRMapObject> registeredMapObjects = new List<RegisteredCRMapObject>(); internal static void Patch() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__SpawnOutsideMapObjects; if (obj == null) { hook_SpawnOutsideHazards val = SpawnOutsideMapObjects; <>O.<0>__SpawnOutsideMapObjects = val; obj = (object)val; } RoundManager.SpawnOutsideHazards += (hook_SpawnOutsideHazards)obj; } private static void SpawnOutsideMapObjects(orig_SpawnOutsideHazards orig, RoundManager self) { orig.Invoke(self); Random random = new Random(StartOfRound.Instance.randomMapSeed + 69); foreach (RegisteredCRMapObject registeredMapObject in registeredMapObjects) { HandleSpawningOutsideMapObjects(registeredMapObject, random); } } private static void HandleSpawningOutsideMapObjects(RegisteredCRMapObject mapObjDef, Random random) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) SelectableLevel currentLevel = RoundManager.Instance.currentLevel; AnimationCurve val = new AnimationCurve((Keyframe[])(object)new Keyframe[2] { new Keyframe(0f, 0f), new Keyframe(1f, 0f) }); GameObject prefabToSpawn = ((RegisteredMapObject)mapObjDef).outsideObject.spawnableObject.prefabToSpawn; val = ((RegisteredMapObject)mapObjDef).spawnRateFunction(currentLevel); int num2; if (mapObjDef.hasNetworkObject) { if (!NetworkManager.Singleton.IsServer) { return; } float num = val.Evaluate(Random.Range(0f, 1f)) + 0.5f; CodeRebirthLibPlugin.ExtendedLogging($"number generated for host only: {num}"); num2 = Mathf.FloorToInt(num); } else { float num3 = val.Evaluate(random.NextFloat(0f, 1f)) + 0.5f; CodeRebirthLibPlugin.ExtendedLogging("number generated for everyone: " + num3); num2 = Mathf.FloorToInt(num3); } CodeRebirthLibPlugin.ExtendedLogging($"Spawning {num2} of {((Object)prefabToSpawn).name} for level {currentLevel}"); RaycastHit val2 = default(RaycastHit); for (int i = 0; i < num2; i++) { Vector3 position; if (mapObjDef.hasNetworkObject) { position = RoundManager.Instance.outsideAINodes[Random.Range(0, RoundManager.Instance.outsideAINodes.Length)].transform.position; position = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), new Random(Random.Range(0, 10000)), -1, 1f) + Vector3.up * 2f; } else { position = RoundManager.Instance.outsideAINodes[random.Next(RoundManager.Instance.outsideAINodes.Length)].transform.position; position = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random, -1, 1f) + Vector3.up * 2f; } if (Physics.Raycast(position, Vector3.down, ref val2, 100f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && Object.op_Implicit((Object)(object)((RaycastHit)(ref val2)).collider)) { GameObject val3 = Object.Instantiate<GameObject>(prefabToSpawn, ((RaycastHit)(ref val2)).point, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform); CodeRebirthLibPlugin.ExtendedLogging($"Spawning {((Object)val3).name} at {((RaycastHit)(ref val2)).point}"); if (mapObjDef.alignWithTerrain) { val3.transform.up = ((RaycastHit)(ref val2)).normal; } if (mapObjDef.hasNetworkObject) { val3.GetComponent<NetworkObject>().Spawn(true); } } } } } internal static class StartOfRoundPatch { [CompilerGenerated] private static class <>O { public static hook_Start <0>__StartOfRoundOnStart; public static hook_SetPlanetsWeather <1>__RefreshEnemyWeights; public static hook_AutoSaveShipData <2>__StartOfRound_AutoSaveShipData; } internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown object obj = <>O.<0>__StartOfRoundOnStart; if (obj == null) { hook_Start val = StartOfRoundOnStart; <>O.<0>__StartOfRoundOnStart = val; obj = (object)val; } StartOfRound.Start += (hook_Start)obj; object obj2 = <>O.<1>__RefreshEnemyWeights; if (obj2 == null) { hook_SetPlanetsWeather val2 = RefreshEnemyWeights; <>O.<1>__RefreshEnemyWeights = val2; obj2 = (object)val2; } StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj2; object obj3 = <>O.<2>__StartOfRound_AutoSaveShipData; if (obj3 == null) { hook_AutoSaveShipData val3 = StartOfRound_AutoSaveShipData; <>O.<2>__StartOfRound_AutoSaveShipData = val3; obj3 = (object)val3; } StartOfRound.AutoSaveShipData += (hook_AutoSaveShipData)obj3; } private static void StartOfRound_AutoSaveShipData(orig_AutoSaveShipData orig, StartOfRound self) { orig.Invoke(self); NetworkSingleton<CodeRebirthLibNetworker>.Instance?.SaveCodeRebirthLibData(); } private static void RefreshEnemyWeights(orig_SetPlanetsWeather orig, StartOfRound self, int connectedplayersonserver) { orig.Invoke(self, connectedplayersonserver); CREnemyDefinition.UpdateAllWeights(); } private static void StartOfRoundOnStart(orig_Start orig, StartOfRound self) { StartOfRound self2 = self; CREnemyDefinition.CreateMoonAttributeStacks(); orig.Invoke(self2); MoreLayerMasks.Init(); ((NetworkBehaviour)self2).NetworkObject.OnSpawn(delegate { //IL_0042: Unknown result type (might be due to invalid IL or missing references) if ((((NetworkBehaviour)self2).IsServer || ((NetworkBehaviour)self2).IsHost) && !Object.op_Implicit((Object)(object)NetworkSingleton<CodeRebirthLibNetworker>.Instance)) { GameObject val = Object.Instantiate<GameObject>(CodeRebirthLibPlugin.Main.NetworkerPrefab); SceneManager.MoveGameObjectToScene(val, ((Component)self2).gameObject.scene); val.GetComponent<NetworkObject>().Spawn(false); } }); } } internal static class TerminalPatch { [CompilerGenerated] private static class <>O { public static hook_LoadNewNodeIfAffordable <0>__TerminalOnLoadNewNodeIfAffordable; } internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__TerminalOnLoadNewNodeIfAffordable; if (obj == null) { hook_LoadNewNodeIfAffordable val = TerminalOnLoadNewNodeIfAffordable; <>O.<0>__TerminalOnLoadNewNodeIfAffordable = val; obj = (object)val; } Terminal.LoadNewNodeIfAffordable += (hook_LoadNewNodeIfAffordable)obj; } private static void TerminalOnLoadNewNodeIfAffordable(orig_LoadNewNodeIfAffordable orig, Terminal self, TerminalNode node) { if (node.shipUnlockableID != -1) { UnlockableItem unlockableItem = StartOfRound.Instance.unlockablesList.unlockables[node.shipUnlockableID]; ProgressiveUnlockData progressiveUnlockData = ProgressiveUnlockableHandler.AllProgressiveUnlockables.FirstOrDefault((ProgressiveUnlockData it) => it.Definition.UnlockableItemDef.unlockable == unlockableItem); if (progressiveUnlockData != null && !progressiveUnlockData.IsUnlocked) { orig.Invoke(self, progressiveUnlockData.Definition.ProgressiveDenyNode); return; } } orig.Invoke(self, node); } } } namespace CodeRebirthLib.ModCompats { internal static class GoodItemScanCompatibility { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled.GetValueOrDefault(); if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("TestAccount666.GoodItemScan"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static bool TryGetRectTransform(ScanNodeProperties scanNodeProperties, [NotNullWhen(true)] out RectTransform? rectTransform) { rect