using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using RoR2; using RoR2.ContentManagement; using RoR2.Navigation; using RoR2.PointOfInterest; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("RoR2")] [assembly: IgnoresAccessChecksTo("HGCSharpUtils")] [assembly: IgnoresAccessChecksTo("HGUnityUtils")] [assembly: IgnoresAccessChecksTo("com.unity.multiplayer-hlapi.Runtime")] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace Stage3AccessNodes { [BepInPlugin("custom.Stage3AccessNodes", "Stage3AccessNodes", "2.3.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Stage3AccessNodesPlugin : BaseUnityPlugin { private class Provider : IContentPackProvider { private readonly ContentPack pack = new ContentPack(); public string identifier => "custom.Stage3AccessNodes"; public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args) { try { AccessTools.Property(typeof(ContentPack), "identifier")?.SetValue(pack, "custom.Stage3AccessNodes", null); } catch { } if (Object.op_Implicit((Object)(object)FxPrefab)) { EffectDef val = new EffectDef(FxPrefab); try { FieldInfo fieldInfo = AccessTools.Field(typeof(EffectDef), "shouldPool"); if (fieldInfo != null) { fieldInfo.SetValue(val, false); } } catch { } pack.effectDefs.Add((EffectDef[])(object)new EffectDef[1] { val }); } args.ReportProgress(1f); yield break; } public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args) { ContentPack.Copy(pack, args.output); args.ReportProgress(1f); yield break; } public IEnumerator FinalizeAsync(FinalizeAsyncArgs args) { args.ReportProgress(1f); yield break; } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static CollectContentPackProvidersDelegate <>9__22_0; public static Action <>9__22_1; public static UnityAction <>9__28_0; public static Func <>9__28_1; public static Func <>9__38_0; public static Func <>9__38_1; public static Func <>9__39_0; public static Func <>9__39_1; internal void b__22_0(AddContentPackProviderDelegate add) { add.Invoke((IContentPackProvider)(object)new Provider()); } internal void b__22_1(Stage ) { completed = false; listened = false; CustomNodes.Reset(); } internal void b__28_0() { completed = true; Log.LogInfo((object)"Access nodes completed - teleporter unlocked."); } internal bool b__28_1(AccessCodesNodeData n) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)n.node)) { return !n.node.activeInHierarchy; } return true; } internal bool b__38_0(PointOfInterest p) { return Object.op_Implicit((Object)(object)p); } internal bool b__38_1(PointOfInterest p) { return Object.op_Implicit((Object)(object)p); } internal bool b__39_0(PortalStatueBehavior a) { //IL_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)a)) { Scene scene = ((Component)a).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return (int)a.portalType == 0; } } return false; } internal float b__39_1(PortalStatueBehavior a) { return Random.value; } } internal static ManualLogSource Log; internal static ConfigEntry Enabled; internal static ConfigEntry ForceAll; internal static ConfigEntry LockTeleporter; internal static ConfigEntry ApplyOnLoops; internal static ConfigEntry ForceScenes; internal static ConfigEntry LockedText; internal static ConfigEntry CustomScenes; internal static ConfigEntry CustomCount; internal static ConfigEntry CustomRadius; internal static Stage3AccessNodesPlugin Instance; internal static GameObject Holder; internal static GameObject FxPrefab; internal static GameObject OffTemplate; internal static GameObject OnTemplate; internal static GameObject SuccessVfx; internal const string GUID = "custom.Stage3AccessNodes"; private static bool completed; private static bool listened; private float pollTimer; private string lastStates; private void Awake() { //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Expected O, but got Unknown //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Expected O, but got Unknown //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Expected O, but got Unknown //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Enable the mod."); ForceAll = ((BaseUnityPlugin)this).Config.Bind("Spawn", "GuaranteeOnAllMaps", true, "Every map that can have the Access Node mission always has it."); ForceScenes = ((BaseUnityPlugin)this).Config.Bind("Spawn", "GuaranteeScenes", "habitat;habitatfall", "Scenes (internal names) where the Access Node mission is always present even if GuaranteeOnAllMaps is off. habitat = Treeborn Colony, habitatfall = Golden Dieback."); LockTeleporter = ((BaseUnityPlugin)this).Config.Bind("Teleporter", "LockUntilNodesComplete", true, "On stage 3 (and any map with the Access Node mission) the teleporter cannot be activated until every Access Node has been hit and the code completed."); ApplyOnLoops = ((BaseUnityPlugin)this).Config.Bind("Teleporter", "ApplyOnLoops", true, "Also lock on stages 8, 13, ..."); LockedText = ((BaseUnityPlugin)this).Config.Bind("Teleporter", "LockedPrompt", "Activate all the Access Nodes first", "Prompt shown on the locked teleporter."); CustomScenes = ((BaseUnityPlugin)this).Config.Bind("CustomNodes", "Scenes", "habitat;habitatfall", "Maps without built-in Access Nodes that get one added (a real Access Node mission, exactly like the built-in ones: press the interact key, Solus Amalgamator boss fight; needs LocationsOfPrecipitation, otherwise a simple walk-up node). Placed at a Newt Altar spot or a random ground spot. habitat = Treeborn Colony, habitatfall = Golden Dieback."); CustomCount = ((BaseUnityPlugin)this).Config.Bind("CustomNodes", "Count", 1, "Number of custom Access Nodes."); CustomRadius = ((BaseUnityPlugin)this).Config.Bind("CustomNodes", "ActivationRadius", 6f, "Walk within this many metres of a custom node to activate it."); Instance = this; if (!Enabled.Value) { return; } try { MakeAssets(); } catch (Exception ex) { Log.LogError((object)("Assets: " + ex)); } object obj = <>c.<>9__22_0; if (obj == null) { CollectContentPackProvidersDelegate val = delegate(AddContentPackProviderDelegate add) { add.Invoke((IContentPackProvider)(object)new Provider()); }; <>c.<>9__22_0 = val; obj = (object)val; } ContentManager.collectContentPackProviders += (CollectContentPackProvidersDelegate)obj; Stage.onStageStartGlobal += OnStageStart; Harmony val2 = new Harmony("custom.Stage3AccessNodes"); val2.Patch((MethodBase)AccessTools.Method(typeof(AccessCodesMissionController), "OnEnable", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ForcePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)AccessTools.Method(typeof(AccessCodesMissionController), "OnStartServer", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ForcePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); MethodInfo methodInfo = AccessTools.Method(typeof(AccessCodesMissionController), "ActivateCode", (Type[])null, (Type[])null); HarmonyMethod val3 = new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ActivateCodePostfix", (Type[])null); val2.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val3, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)AccessTools.Method(typeof(TeleporterInteraction), "GetInteractability", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "InteractPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val2.Patch((MethodBase)AccessTools.Method(typeof(TeleporterInteraction), "GetContextString", (Type[])null, (Type[])null), new HarmonyMethod(typeof(Stage3AccessNodesPlugin), "ContextPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); if (ForceAll.Value) { AccessCodesMissionController.forceAccessNode = true; } Stage.onStageStartGlobal += delegate { completed = false; listened = false; CustomNodes.Reset(); }; } private static void ActivateCodePostfix() { if (!completed) { Log.LogInfo((object)"Access code activated - teleporter unlocked."); } completed = true; } private void Update() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) pollTimer -= Time.deltaTime; if (pollTimer > 0f) { return; } pollTimer = 0.25f; try { AccessCodesMissionController instance = AccessCodesMissionController.instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } NodesComplete(instance); string text = "code " + instance._currentCode + "/" + instance._finalCode + " nodes:"; if (instance.nodes != null) { AccessCodesNodeData[] nodes = instance.nodes; foreach (AccessCodesNodeData val in nodes) { if (!Object.op_Implicit((Object)(object)val.node)) { text += " (missing)"; continue; } EntityStateMachine componentInChildren = val.node.GetComponentInChildren(true); text = text + " " + ((!((Object)(object)componentInChildren != (Object)null) || componentInChildren.state == null) ? "?" : ((object)componentInChildren.state).GetType().Name); } } if (text != lastStates) { lastStates = text; Log.LogInfo((object)("Access nodes: " + text + ((!completed) ? string.Empty : " [complete]"))); } } catch { } } private static bool SceneForced(string scene) { if (ForceAll.Value) { return true; } if (string.IsNullOrEmpty(scene)) { return false; } return (ForceScenes.Value ?? string.Empty).Split(new char[1] { ';' }).Any((string s) => s.Trim().Equals(scene, StringComparison.OrdinalIgnoreCase)); } private static void ForcePrefix(AccessCodesMissionController __instance) { //IL_000e: 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) try { object obj; if (Object.op_Implicit((Object)(object)__instance)) { Scene scene = ((Component)__instance).gameObject.scene; obj = ((Scene)(ref scene)).name; } else { obj = null; } string text = (string)obj; if (string.IsNullOrEmpty(text) && Object.op_Implicit((Object)(object)SceneCatalog.mostRecentSceneDef)) { text = SceneCatalog.mostRecentSceneDef.cachedName; } if (SceneForced(text)) { AccessCodesMissionController.forceAccessNode = true; } } catch (Exception ex) { Log.LogWarning((object)("ForcePrefix: " + ex.Message)); } } private static bool LockStageAllowed() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)Run.instance)) { return false; } if (Run.instance.stageClearCount >= 5 && !ApplyOnLoops.Value) { return false; } SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; if (Object.op_Implicit((Object)(object)mostRecentSceneDef)) { return (int)mostRecentSceneDef.sceneType == 1; } return false; } private static bool NodesComplete(AccessCodesMissionController mc) { //IL_003f: 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_004a: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_00fc: Unknown result type (might be due to invalid IL or missing references) if (completed) { return true; } if (NetworkServer.active && !listened && mc.onTriggerAlternateFightServer != null) { listened = true; UnityEvent onTriggerAlternateFightServer = mc.onTriggerAlternateFightServer; object obj = <>c.<>9__28_0; if (obj == null) { UnityAction val = delegate { completed = true; Log.LogInfo((object)"Access nodes completed - teleporter unlocked."); }; <>c.<>9__28_0 = val; obj = (object)val; } onTriggerAlternateFightServer.AddListener((UnityAction)obj); } try { if (mc._finalCode != 0 && mc._currentCode == mc._finalCode) { completed = true; Log.LogInfo((object)("Access code complete (" + mc._currentCode + ") - teleporter unlocked.")); return true; } } catch { } if (mc.nodes == null) { return true; } if (mc.nodes.All((AccessCodesNodeData n) => !Object.op_Implicit((Object)(object)n.node) || !n.node.activeInHierarchy)) { return true; } int num = 0; AccessCodesNodeData[] nodes = mc.nodes; foreach (AccessCodesNodeData val2 in nodes) { if (!Object.op_Implicit((Object)(object)val2.node)) { continue; } num++; EntityStateMachine[] componentsInChildren = val2.node.GetComponentsInChildren(true); foreach (EntityStateMachine val3 in componentsInChildren) { if (val3.state != null && ((object)val3.state).GetType().Name == "Complete") { completed = true; return true; } } } return num == 0; } internal static bool Locked() { if (!LockTeleporter.Value || completed || !LockStageAllowed()) { return false; } AccessCodesMissionController instance = AccessCodesMissionController.instance; if (IsCustomScene() && !Object.op_Implicit((Object)(object)instance)) { return !CustomNodes.AllActive(); } if (!Object.op_Implicit((Object)(object)instance) || !((Behaviour)instance).isActiveAndEnabled) { return false; } try { if (!instance.RunHasRequiredExpansion()) { return false; } } catch { } return !NodesComplete(instance); } private static bool InteractPrefix(ref Interactability __result) { try { if (Locked()) { __result = (Interactability)1; return false; } } catch (Exception ex) { Log.LogError((object)ex); } return true; } private static bool ContextPrefix(ref string __result) { try { if (Locked()) { __result = LockedText.Value; return false; } } catch { } return true; } internal static bool IsCustomScene() { SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef; string n = ((!Object.op_Implicit((Object)(object)mostRecentSceneDef)) ? null : mostRecentSceneDef.cachedName); if (string.IsNullOrEmpty(n)) { return false; } return (CustomScenes.Value ?? string.Empty).Split(new char[1] { ';' }).Any((string x) => x.Trim().Equals(n, StringComparison.OrdinalIgnoreCase)); } private static GameObject StripCopy(GameObject prefab, string name) { if (!Object.op_Implicit((Object)(object)prefab)) { return null; } GameObject val = Object.Instantiate(prefab, Holder.transform); ((Object)val).name = name; MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } NetworkIdentity[] componentsInChildren2 = val.GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } return val; } private static void MakeAssets() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0077: 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_0092: 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_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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) Holder = new GameObject("Stage3AccessNodesPrefabs"); Holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)Holder); FxPrefab = new GameObject("S3NodeFx"); FxPrefab.transform.SetParent(Holder.transform, false); EffectComponent obj = FxPrefab.AddComponent(); obj.applyScale = false; obj.positionAtReferencedTransform = false; obj.parentToReferencedTransform = false; VFXAttributes obj2 = FxPrefab.AddComponent(); obj2.vfxPriority = (VFXPriority)2; obj2.vfxIntensity = (VFXIntensity)0; FxPrefab.AddComponent(); try { OffTemplate = StripCopy(Addressables.LoadAssetAsync((object)"RoR2/DLC3/AccessCodesNode/AccessCodesNodeOFF.prefab").WaitForCompletion(), "S3NodeOff"); } catch (Exception ex) { Log.LogWarning((object)("Node OFF model: " + ex.Message)); } try { OnTemplate = StripCopy(Addressables.LoadAssetAsync((object)"RoR2/DLC3/AccessCodesNode/AccessCodesNodeON.prefab").WaitForCompletion(), "S3NodeOn"); } catch (Exception ex2) { Log.LogWarning((object)("Node ON model: " + ex2.Message)); } try { SuccessVfx = Addressables.LoadAssetAsync((object)"RoR2/DLC3/AccessCodesNode/NodeSuccessVFX.prefab").WaitForCompletion(); } catch { } } private void OnStageStart(Stage st) { if (NetworkServer.active && IsCustomScene() && LockStageAllowed()) { ((MonoBehaviour)this).StartCoroutine(ServerNodes()); } } private static Vector3 Ground(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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) Vector3 val = p + Vector3.up * 30f; Vector3 down = Vector3.down; LayerIndex world = LayerIndex.world; RaycastHit val2 = default(RaycastHit); if (Physics.Raycast(val, down, ref val2, 200f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1)) { return ((RaycastHit)(ref val2)).point; } return p; } private static bool SpawnRealMission(Vector3 position) { //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_00a7: 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_00ae: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) try { Type type = AccessTools.TypeByName("LOP.SetupDLC3AccessNode"); FieldInfo fieldInfo = ((type == null) ? null : AccessTools.Field(type, "accessNodeMissionController")); GameObject val = (GameObject)((fieldInfo == null) ? null : /*isinst with value type is only supported in some contexts*/); if (!Object.op_Implicit((Object)(object)val)) { Log.LogWarning((object)"LocationsOfPrecipitation's Access Node mission isn't available; using a simple walk-up node instead."); return false; } GameObject val2 = Addressables.LoadAssetAsync((object)"383d1a1eefe41db4eb8708719f86fc03").WaitForCompletion(); if (!Object.op_Implicit((Object)(object)val2)) { Log.LogWarning((object)"Access Node prefab not found; using a simple walk-up node instead."); return false; } Quaternion val3 = Quaternion.Euler(0f, Random.Range(0f, 360f), 0f); EnsurePointOfInterest(position, val3); GameObject val4 = Object.Instantiate(val2, position, val3); NetworkServer.Spawn(val4); GameObject val5 = Object.Instantiate(val); val5.GetComponent().nodes = (AccessCodesNodeData[])(object)new AccessCodesNodeData[1] { new AccessCodesNodeData { node = val4, id = 0 } }; NetworkServer.Spawn(val5); Log.LogInfo((object)"Added a real Access Node mission to this map."); return true; } catch (Exception ex) { Log.LogError((object)("Access Node mission: " + ex)); return false; } } private static void EnsurePointOfInterest(Vector3 position, Quaternion rotation) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) PointOfInterestManager singleton = PointOfInterestManager.Singleton; if (!Object.op_Implicit((Object)(object)singleton) || singleton.PointsOfInterest == null || singleton.PointsOfInterest.Count((PointOfInterest p) => Object.op_Implicit((Object)(object)p)) < 1 || !singleton.PointsOfInterest.All((PointOfInterest p) => Object.op_Implicit((Object)(object)p))) { GameObject val = new GameObject("S3AccessNodePointsOfInterest"); GameObject val2 = new GameObject("S3AccessNodePoint"); val2.transform.SetParent(val.transform, false); val2.transform.SetPositionAndRotation(position, rotation); PointOfInterest val3 = val2.AddComponent(); PointOfInterestManager val4 = val.AddComponent(); val4.PointsOfInterest = (PointOfInterest[])(object)new PointOfInterest[1] { val3 }; PointOfInterestManager.Singleton = val4; } } private IEnumerator ServerNodes() { yield return (object)new WaitForSeconds(3f); int num = Mathf.Max(1, CustomCount.Value); List list = new List(); List list2 = (from a in Resources.FindObjectsOfTypeAll().Where(delegate(PortalStatueBehavior a) { //IL_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Invalid comparison between Unknown and I4 if (Object.op_Implicit((Object)(object)a)) { Scene scene = ((Component)a).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return (int)a.portalType == 0; } } return false; }) orderby Random.value select a).ToList(); foreach (PortalStatueBehavior item in list2) { if (list.Count >= num) { break; } Vector3 forward = ((Component)item).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { forward = Vector3.forward; } list.Add(Ground(((Component)item).transform.position + ((Vector3)(ref forward)).normalized * 6f)); } try { NodeGraph val = ((!Object.op_Implicit((Object)(object)SceneInfo.instance)) ? null : SceneInfo.instance.groundNodes); Array array = ((!Object.op_Implicit((Object)(object)val)) ? null : (AccessTools.Field(typeof(NodeGraph), "nodes")?.GetValue(val) as Array)); if (array != null && array.Length > 0) { FieldInfo fieldInfo = null; int num2 = 0; while (list.Count < num && num2 < 400) { object value = array.GetValue(Random.Range(0, array.Length)); if (fieldInfo == null) { fieldInfo = value.GetType().GetField("position"); } Vector3 p = (Vector3)fieldInfo.GetValue(value); if (list.All((Vector3 q) => Vector3.Distance(q, p) > 60f)) { list.Add(p); } num2++; } } } catch (Exception ex) { Log.LogWarning((object)("Ground nodes: " + ex.Message)); } if (Object.op_Implicit((Object)(object)AccessCodesMissionController.instance)) { Log.LogInfo((object)"This map already has an Access Node mission."); } else if (list.Count <= 0 || !SpawnRealMission(list[0])) { Log.LogInfo((object)("Placed " + list.Count + " custom Access Node(s) (" + Mathf.Min(list2.Count, num) + " at Newt Altars).")); CustomNodes.ServerInit(list); while (CustomNodes.ServerActive) { CustomNodes.ServerTick(); yield return (object)new WaitForSeconds(0.25f); } } } } internal static class CustomNodes { private class Vis { public Vector3 pos; public bool on; public GameObject go; } private static readonly Dictionary vis = new Dictionary(); private static int count; private static List sPts; private static bool[] sOn; private static float lastBroadcast; internal static bool ServerActive; internal static void Reset() { foreach (Vis value in vis.Values) { if (Object.op_Implicit((Object)(object)value.go)) { Object.Destroy((Object)(object)value.go); } } vis.Clear(); count = 0; sPts = null; sOn = null; ServerActive = false; } internal static bool AllActive() { if (NetworkServer.active && sOn != null) { return sOn.All((bool x) => x); } if (count <= 0) { return true; } if (vis.Count >= count) { return vis.Values.All((Vis v) => v.on); } return false; } internal static void ServerInit(List pts) { sPts = pts; sOn = new bool[pts.Count]; ServerActive = pts.Count > 0; Broadcast(); } internal static void ServerTick() { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) if (sPts == null) { return; } float value = Stage3AccessNodesPlugin.CustomRadius.Value; bool flag = false; foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances) { CharacterBody val = ((!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)instance.master)) ? null : instance.master.GetBody()); if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.healthComponent) || !val.healthComponent.alive) { continue; } for (int i = 0; i < sPts.Count; i++) { if (!sOn[i] && Vector3.Distance(val.footPosition, sPts[i]) <= value) { sOn[i] = true; flag = true; } } } if (flag) { int num = sOn.Count((bool x) => x); SimpleChatMessage val2 = new SimpleChatMessage(); val2.baseToken = "Access Node activated (" + num + "/" + sOn.Length + ")"; Chat.SendBroadcastChat((ChatMessageBase)(object)val2); if (num == sOn.Length) { val2 = new SimpleChatMessage(); val2.baseToken = "All Access Nodes activated - the teleporter is unlocked."; Chat.SendBroadcastChat((ChatMessageBase)(object)val2); } } if (flag || Time.time - lastBroadcast > 1.5f) { Broadcast(); } } private static void Broadcast() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown lastBroadcast = Time.time; if (!Object.op_Implicit((Object)(object)Stage3AccessNodesPlugin.FxPrefab) || sPts == null) { return; } for (int i = 0; i < sPts.Count; i++) { uint genericUInt = (uint)((i & 0xFF) | (sOn[i] ? 256 : 0) | ((sPts.Count & 0xFF) << 16)); try { EffectManager.SpawnEffect(Stage3AccessNodesPlugin.FxPrefab, new EffectData { origin = sPts[i], genericUInt = genericUInt }, true); } catch { } } } internal static void ClientUpdate(int idx, Vector3 pos, bool on, int total) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) count = total; if (!vis.TryGetValue(idx, out var value)) { value = new Vis { pos = pos }; vis[idx] = value; } if (Object.op_Implicit((Object)(object)value.go) && value.on == on) { return; } bool num = on && Object.op_Implicit((Object)(object)value.go) && !value.on; if (Object.op_Implicit((Object)(object)value.go)) { Object.Destroy((Object)(object)value.go); } GameObject val = ((!on) ? Stage3AccessNodesPlugin.OffTemplate : (Stage3AccessNodesPlugin.OnTemplate ?? Stage3AccessNodesPlugin.OffTemplate)); if (Object.op_Implicit((Object)(object)val)) { value.go = Object.Instantiate(val, pos, Quaternion.identity); value.go.SetActive(true); } else { value.go = GameObject.CreatePrimitive((PrimitiveType)2); value.go.transform.position = pos + Vector3.up; value.go.transform.localScale = new Vector3(2f, 1f, 2f); } value.on = on; if (!num) { return; } if (Object.op_Implicit((Object)(object)Stage3AccessNodesPlugin.SuccessVfx)) { try { Object.Instantiate(Stage3AccessNodesPlugin.SuccessVfx, pos, Quaternion.identity); } catch { } } try { Util.PlaySound("Play_UI_artifactSelect", value.go); } catch { } } } public class S3NodeFx : MonoBehaviour { private void Start() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) try { EffectComponent component = ((Component)this).GetComponent(); EffectData val = ((!Object.op_Implicit((Object)(object)component)) ? null : component.effectData); if (val != null) { CustomNodes.ClientUpdate((int)(val.genericUInt & 0xFF), val.origin, (val.genericUInt & 0x100) != 0, (int)((val.genericUInt >> 16) & 0xFF)); } } catch (Exception ex) { Stage3AccessNodesPlugin.Log.LogWarning((object)("Node fx: " + ex.Message)); } Object.Destroy((Object)(object)((Component)this).gameObject); } } }