Decompiled source of EOSExt NavigationalSpline v1.0.0

plugins/Inas07.EOSExt.NavigationalSpline.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AssetShards;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using ChainedPuzzles;
using EOSExt.DimensionWarp.Definition;
using EOSExt.NavigationalSpline;
using ExtraObjectiveSetup.BaseClasses;
using ExtraObjectiveSetup.ExtendedWardenEvents;
using ExtraObjectiveSetup.Utils;
using GTFO.API;
using GameData;
using HarmonyLib;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Inas07.EOSExt.NavigationalSpline")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e098f2b3f04db80593d5a6d1fe37fb4d9af10269")]
[assembly: AssemblyProduct("Inas07.EOSExt.NavigationalSpline")]
[assembly: AssemblyTitle("Inas07.EOSExt.NavigationalSpline")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 EOSExt.DimensionWarp
{
	public class NavigationalSplineManager : GenericExpeditionDefinitionManager<NavigationalSplineDefinition>
	{
		public enum WardenEvents_NavigationalSpline
		{
			ToggleSplineState = 610
		}

		public static NavigationalSplineManager Current { get; private set; }

		protected override string DEFINITION_NAME => "NavigationalSpline";

		private Dictionary<string, GameObject> SplineGroups { get; } = new Dictionary<string, GameObject>();


		private void InstantiateSplines()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			if (!base.definitions.TryGetValue(RundownManager.ActiveExpedition.LevelLayoutData, out var value))
			{
				return;
			}
			foreach (NavigationalSplineDefinition definition in value.Definitions)
			{
				if (SplineGroups.ContainsKey(definition.WorldEventObjectFilter))
				{
					EOSLogger.Error("NavigationalSplineManager: duplicate 'WorldEventObjectFilter': " + definition.WorldEventObjectFilter + ", won't build");
					continue;
				}
				GameObject val = new GameObject("NavigationalSpline_" + definition.WorldEventObjectFilter);
				for (int i = 0; i < definition.Splines.Count; i++)
				{
					Spline spline = definition.Splines[i];
					GameObject val2 = new GameObject($"NavigationalSpline_{definition.WorldEventObjectFilter}_{i}");
					val2.transform.SetParent(val.transform);
					CP_Holopath_Spline val3 = val2.AddComponent<CP_Holopath_Spline>();
					val3.m_splineGeneratorPrefab = Asset.SplineGeneratorGO;
					val3.Setup(false);
					val3.GeneratePath(spline.From.ToVector3(), spline.To.ToVector3());
					if (definition.RevealSpeedMulti > 0f)
					{
						val3.m_revealSpeed *= definition.RevealSpeedMulti;
					}
				}
				SplineGroups[definition.WorldEventObjectFilter] = val;
			}
		}

		internal void ToggleSplineState(string WorldEventObjectFilter, int state)
		{
			if (!SplineGroups.TryGetValue(WorldEventObjectFilter, out var value))
			{
				EOSLogger.Error("NavigationalSplineManager: cannot find Spline Group with name '" + WorldEventObjectFilter);
				return;
			}
			switch (state)
			{
			case 0:
			{
				for (int j = 0; j < value.transform.childCount; j++)
				{
					CP_Holopath_Spline component2 = ((Component)value.transform.GetChild(j)).gameObject.GetComponent<CP_Holopath_Spline>();
					if ((Object)(object)component2 != (Object)null)
					{
						component2.SetSplineProgress(0f);
						component2.Reveal(0f);
					}
				}
				break;
			}
			case 1:
			{
				for (int k = 0; k < value.transform.childCount; k++)
				{
					CP_Holopath_Spline component3 = ((Component)value.transform.GetChild(k)).gameObject.GetComponent<CP_Holopath_Spline>();
					if ((Object)(object)component3 != (Object)null)
					{
						component3.SetSplineProgress(0.95f);
						component3.Reveal(0f);
					}
				}
				break;
			}
			case 2:
			{
				for (int i = 0; i < value.transform.childCount; i++)
				{
					CP_Holopath_Spline component = ((Component)value.transform.GetChild(i)).gameObject.GetComponent<CP_Holopath_Spline>();
					if ((Object)(object)component != (Object)null)
					{
						component.SetVisible(false);
					}
				}
				break;
			}
			}
		}

		private void Clear()
		{
			foreach (GameObject value in SplineGroups.Values)
			{
				Object.Destroy((Object)(object)value);
			}
			SplineGroups.Clear();
		}

		private NavigationalSplineManager()
		{
			LevelAPI.OnBuildDone += InstantiateSplines;
			LevelAPI.OnBuildStart += Clear;
			LevelAPI.OnLevelCleanup += Clear;
			EOSWardenEventManager.Current.AddEventDefinition(WardenEvents_NavigationalSpline.ToggleSplineState.ToString(), 610u, (Action<WardenObjectiveEventData>)delegate(WardenObjectiveEventData e)
			{
				ToggleSplineState(e.WorldEventObjectFilter, e.Count);
			});
		}

		static NavigationalSplineManager()
		{
			Current = new NavigationalSplineManager();
			AssetShardManager.OnStartupAssetsLoaded += Action.op_Implicit((Action)Asset.Init);
		}
	}
	[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.*/)]
	[BepInPlugin("Inas.EOSExt.NavigationalSpline", "EOSExt.NavigationalSpline", "1.0.0")]
	public class EntryPoint : BasePlugin
	{
		public const string AUTHOR = "Inas";

		public const string PLUGIN_NAME = "EOSExt.NavigationalSpline";

		public const string VERSION = "1.0.0";

		private Harmony m_Harmony;

		public override void Load()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			SetupManagers();
			m_Harmony = new Harmony("EOSExt.NavigationalSpline");
			m_Harmony.PatchAll();
			EOSLogger.Log("ExtraObjectiveSetup.NavigationalSpline loaded.");
		}

		private void SetupManagers()
		{
			((GenericExpeditionDefinitionManager<NavigationalSplineDefinition>)NavigationalSplineManager.Current).Init();
		}
	}
}
namespace EOSExt.DimensionWarp.Definition
{
	public class Spline
	{
		public Vec3 From { get; set; } = new Vec3();


		public Vec3 To { get; set; } = new Vec3();

	}
	public class NavigationalSplineDefinition
	{
		public string WorldEventObjectFilter { get; set; } = string.Empty;


		public float RevealSpeedMulti { get; set; } = 1f;


		public List<Spline> Splines { get; set; } = new List<Spline>
		{
			new Spline()
		};

	}
}
namespace EOSExt.NavigationalSpline
{
	internal static class Asset
	{
		public static GameObject SplineGeneratorGO { get; private set; }

		internal static void Init()
		{
			SplineGeneratorGO = AssetAPI.GetLoadedAsset<GameObject>("Assets/EOSAssets/LG_ChainedPuzzleSplineGenerator.prefab");
		}
	}
}