Decompiled source of ShrineOfSwiftness v1.0.0

ShrineOfSwiftness.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using HG.Reflection;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.Navigation;
using RoR2.Networking;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShrineOfSwiftness")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+01dabd3420d0ebc2d2384d3ebc2f1937e0b2f617")]
[assembly: AssemblyProduct("ShrineOfSwiftness")]
[assembly: AssemblyTitle("ShrineOfSwiftness")]
[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 ShrineOfSwiftness
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("HIFU.ShrineOfSwiftness", "ShrineOfSwiftness", "1.0.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.ShrineOfSwiftness";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "ShrineOfSwiftness";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource sosLogger;

		public static AssetBundle bundle;

		public static ConfigEntry<int> baseCost;

		public static ConfigEntry<int> costIncreasePerActivation;

		public static ConfigEntry<int> maxActivations;

		public static ConfigEntry<string> stageWhitelist;

		public static ConfigEntry<string> itemWhitelist;

		public static List<string> stagesToAppearOn = new List<string>();

		public static List<string> itemsToDrop = new List<string>();

		public static List<ItemIndex> itemIndexList = new List<ItemIndex>();

		public static Main Instance;

		public void Awake()
		{
			Instance = this;
			sosLogger = ((BaseUnityPlugin)this).Logger;
			bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Instance).Info.Location), "shrineofswiftness"));
			baseCost = ((BaseUnityPlugin)this).Config.Bind<int>("Shrine of Swiftness", "Base Cost", 25, "The base cost of the Shrine of Swiftness. For reference, a Chest is $25, and a Large Chest is $50.");
			costIncreasePerActivation = ((BaseUnityPlugin)this).Config.Bind<int>("Shrine of Swiftness", "Cost Increase per Activation", 25, "");
			maxActivations = ((BaseUnityPlugin)this).Config.Bind<int>("Shrine of Swiftness", "Maximum Amount of Activations", 3, "");
			stageWhitelist = ((BaseUnityPlugin)this).Config.Bind<string>("Shrine of Swiftness", "Stage Whitelist", "frozenwall | wispgraveyard | sulfurpools | habitat | habitatfall", "A list of internal stage names that Shrine of Swiftness can spawn on, separated by a space, following a pipe symbol and another space. Use the DebugToolkit mod and its list_stage command to see all internal stage names.");
			itemWhitelist = ((BaseUnityPlugin)this).Config.Bind<string>("Shrine of Swiftness", "Item Whitelist", "ITEM_HOOF_NAME | ITEM_SPRINTBONUS_NAME | ITEM_SPRINTOUTOFCOMBAT_NAME", "A list of internal item name tokens that Shrine of Swiftness can drop, separated by a space, following a pipe symbol and another space. Use the DebugToolkit mod and its list_item or item_list command to see all internal item names.");
			stagesToAppearOn = stageWhitelist.Value.Split(" | ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
			itemsToDrop = itemWhitelist.Value.Split(" | ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
			for (int i = 0; i < stagesToAppearOn.Count; i++)
			{
				string text = stagesToAppearOn[i];
			}
			for (int j = 0; j < itemsToDrop.Count; j++)
			{
				string text2 = itemsToDrop[j];
			}
			Prefabs.Init();
		}

		[SystemInitializer(new Type[] { typeof(ItemCatalog) })]
		private static void GetItemIndices()
		{
			//IL_0002: 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_000a: 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)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<ItemDef> enumerator = ItemCatalog.allItemDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ItemDef current = enumerator.Current;
					if (itemsToDrop.Contains(current.nameToken))
					{
						itemIndexList.Add(current.itemIndex);
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			for (int i = 0; i < itemIndexList.Count; i++)
			{
				ItemIndex val = itemIndexList[i];
			}
		}
	}
	public class Prefabs
	{
		public static GameObject shrinePrefab;

		public static InteractableSpawnCard interactableSpawnCard;

		public static GameObject shrineVFX;

		public static void Init()
		{
			//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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Expected O, but got Unknown
			//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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: 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_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: 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)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_026b: Expected O, but got Unknown
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			shrineVFX = Addressables.LoadAssetAsync<GameObject>((object)"0fa235b9d7e778f4ba2cd8f2437f72d9").WaitForCompletion();
			shrinePrefab = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"8a681654848ac374980fea55c4cf55a7").WaitForCompletion(), "Shrine of Swiftness");
			shrinePrefab.AddComponent<ShrineOfSwiftnessController>();
			shrinePrefab.AddComponent<UnityJankMoment>();
			Transform transform = shrinePrefab.transform;
			ModelLocator component = shrinePrefab.GetComponent<ModelLocator>();
			Transform modelTransform = component._modelTransform;
			((Object)modelTransform).name = "mdlShrineSwiftness";
			MeshRenderer component2 = ((Component)modelTransform).GetComponent<MeshRenderer>();
			Material val = new Material(Addressables.LoadAssetAsync<Material>((object)"0de2169c1f513a44a8b439821be523eb").WaitForCompletion());
			val.SetTexture("_MainTex", (Texture)(object)Addressables.LoadAssetAsync<Texture2D>((object)"50576454418d775439d1c15ea6e3d694").WaitForCompletion());
			val.SetColor("_TintColor", Color.white);
			val.SetFloat("_SpecularStrength", 1f);
			val.SetFloat("_SpecularExponent", 1.164457f);
			val.SetFloat("_SnowBias", -1f);
			val.SetFloat("_Depth", 0.9161675f);
			val.SetInt("_RampInfo", 4);
			((Renderer)component2).material = val;
			MeshRenderer component3 = ((Component)transform.Find("Symbol")).GetComponent<MeshRenderer>();
			MeshRenderer component4 = ((Component)component3).GetComponent<MeshRenderer>();
			Material val2 = new Material(Addressables.LoadAssetAsync<Material>((object)"4f1b6f101f0d1cb42893fca3d83b9154").WaitForCompletion());
			val2.SetTexture("_MainTex", (Texture)(object)Main.bundle.LoadAsset<Texture2D>("texShrineOfSwiftnessSymbol.png"));
			val2.SetColor("_TintColor", Color32.op_Implicit(new Color32((byte)130, (byte)188, (byte)232, byte.MaxValue)));
			((Renderer)component4).material = val2;
			PurchaseInteraction component5 = shrinePrefab.GetComponent<PurchaseInteraction>();
			component5.displayNameToken = "SHRINE_SWIFTNESS_NAME";
			component5.contextToken = "SHRINE_SWIFTNESS_CONTEXT";
			component5.cost = Main.baseCost.Value;
			component5.automaticallyScaleCostWithDifficulty = false;
			GenericDisplayNameProvider component6 = shrinePrefab.GetComponent<GenericDisplayNameProvider>();
			component6.displayToken = "SHRINE_SWIFTNESS_NAME";
			InspectDef val3 = ScriptableObject.CreateInstance<InspectDef>();
			InspectInfo val4 = new InspectInfo
			{
				TitleToken = component6.displayToken,
				DescriptionToken = "SHRINE_SWIFTNESS_DESCRIPTION",
				FlavorToken = "shrine of swiftness flavor token",
				isConsumedItem = false,
				Visual = Addressables.LoadAssetAsync<Sprite>((object)"RoR2/Base/Common/MiscIcons/texShrineIconOutlined.png").WaitForCompletion(),
				TitleColor = Color.white
			};
			InspectInfo val5 = val4;
			val3.Info = val4;
			InspectInfo info = val5;
			shrinePrefab.GetComponent<GenericInspectInfoProvider>().InspectInfo = Object.Instantiate<InspectDef>(shrinePrefab.GetComponent<GenericInspectInfoProvider>().InspectInfo);
			shrinePrefab.GetComponent<GenericInspectInfoProvider>().InspectInfo.Info = info;
			Object.DestroyImmediate((Object)(object)shrinePrefab.GetComponent<ShrineChanceBehavior>());
			PrefabAPI.RegisterNetworkPrefab(shrinePrefab);
			ContentAddition.AddNetworkedObject(shrinePrefab);
			interactableSpawnCard = ScriptableObject.CreateInstance<InteractableSpawnCard>();
			((SpawnCard)interactableSpawnCard).prefab = shrinePrefab;
			((SpawnCard)interactableSpawnCard).sendOverNetwork = true;
			((SpawnCard)interactableSpawnCard).hullSize = (HullClassification)1;
			((SpawnCard)interactableSpawnCard).nodeGraphType = (GraphType)0;
			((SpawnCard)interactableSpawnCard).requiredFlags = (NodeFlags)0;
			((SpawnCard)interactableSpawnCard).directorCreditCost = 0;
			((SpawnCard)interactableSpawnCard).occupyPosition = true;
			((SpawnCard)interactableSpawnCard).eliteRules = (EliteRules)0;
			interactableSpawnCard.orientToFloor = false;
			interactableSpawnCard.slightlyRandomizeOrientation = false;
			interactableSpawnCard.skipSpawnWhenDevotionArtifactEnabled = true;
			interactableSpawnCard.weightScalarWhenSacrificeArtifactEnabled = 1f;
			interactableSpawnCard.skipSpawnWhenDevotionArtifactEnabled = false;
			interactableSpawnCard.maxSpawnsPerStage = 1;
			interactableSpawnCard.prismaticTrialSpawnChance = 1f;
			((Object)interactableSpawnCard).name = "iscShrineSwiftness";
			LanguageAPI.Add("SHRINE_SWIFTNESS_NAME", "Shrine of Swiftness");
			LanguageAPI.Add("SHRINE_SWIFTNESS_CONTEXT", "Offer to Shrine of Swiftness");
			LanguageAPI.Add("SHRINE_SWIFTNESS_USE_MESSAGE", "<style=cShrine>{0} offered to the shrine and received a gift of celerity.</style>");
			LanguageAPI.Add("SHRINE_SWIFTNESS_USE_MESSAGE_2P", "<style=cShrine>You offer to the shrine and receive a gift of celerity.</style>");
			LanguageAPI.Add("SHRINE_SWIFTNESS_DESCRIPTION", "When activated by a survivor the Shrine of Swiftness drops a random movement speed item.");
			SceneDirector.onPrePopulateSceneServer += OnPrePopulateSceneServer;
		}

		private static void OnPrePopulateSceneServer(SceneDirector director)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_002c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			if (Main.stagesToAppearOn.Contains(SceneCatalog.mostRecentSceneDef.cachedName))
			{
				DirectorPlacementRule val = new DirectorPlacementRule
				{
					placementMode = (PlacementMode)4
				};
				GameObject val2 = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest((SpawnCard)(object)interactableSpawnCard, val, Run.instance.runRNG));
			}
		}
	}
	public class UnityJankMoment : MonoBehaviour
	{
		public PurchaseInteraction purchaseInteraction;

		public ShrineOfSwiftnessController shrineOfSwiftnessController;

		public void Start()
		{
			shrineOfSwiftnessController = ((Component)this).GetComponent<ShrineOfSwiftnessController>();
			purchaseInteraction = ((Component)this).GetComponent<PurchaseInteraction>();
			((UnityEvent<Interactor>)(object)purchaseInteraction.onPurchase).AddListener((UnityAction<Interactor>)SoTrue);
		}

		public void SoTrue(Interactor interactor)
		{
			shrineOfSwiftnessController.AddShrineStack(interactor);
		}
	}
	public class ShrineOfSwiftnessController : ShrineBehavior
	{
		public int maxPurchaseCount = Main.maxActivations.Value;

		public Transform symbolTransform;

		private PurchaseInteraction purchaseInteraction;

		private int purchaseCount = 0;

		private float refreshTimer;

		private const float refreshDuration = 2f;

		private bool waitingForRefresh;

		public Transform dropletOrigin;

		public Xoroshiro128Plus rng;

		public float cachedCostMultiplierPerPurchase;

		public override int GetNetworkChannel()
		{
			return QosChannelIndex.defaultReliable.intVal;
		}

		private void Start()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			purchaseInteraction = ((Component)this).GetComponent<PurchaseInteraction>();
			symbolTransform = ((Component)this).transform.Find("Symbol");
			dropletOrigin = ((Component)this).transform.Find("DropletOrigin");
			if (NetworkServer.active)
			{
				rng = new Xoroshiro128Plus(Run.instance.treasureRng.nextUlong);
			}
			purchaseInteraction.Networkcost = Run.instance.GetDifficultyScaledCost(Main.baseCost.Value);
			cachedCostMultiplierPerPurchase = Run.instance.GetDifficultyScaledCost(Main.costIncreasePerActivation.Value);
		}

		public void AddShrineStack(Interactor interactor)
		{
			//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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//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_00f3: Expected O, but got Unknown
			//IL_002e: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			if (NetworkServer.active)
			{
				waitingForRefresh = true;
				CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
					{
						subjectAsCharacterBody = component,
						baseToken = "SHRINE_SWIFTNESS_USE_MESSAGE"
					});
				}
				ItemIndex val = Main.itemIndexList[rng.RangeInt(0, Main.itemIndexList.Count)];
				PickupIndex val2 = PickupCatalog.FindPickupIndex(val);
				PickupDropletController.CreatePickupDroplet(val2, dropletOrigin.position, dropletOrigin.forward * 20f);
				EffectManager.SpawnEffect(Prefabs.shrineVFX, new EffectData
				{
					origin = ((Component)this).transform.position,
					rotation = Quaternion.identity,
					scale = 1f,
					color = new Color32((byte)130, (byte)188, (byte)232, byte.MaxValue)
				}, true);
				Util.PlaySound("Play_mage_m2_iceSpear_shoot", ((Component)this).gameObject);
				Util.PlaySound("Play_ui_obj_lunarPool_activate", ((Component)this).gameObject);
				purchaseCount++;
				refreshTimer = 2f;
				if (purchaseCount >= maxPurchaseCount)
				{
					((Component)symbolTransform).gameObject.SetActive(false);
					((ShrineBehavior)this).CallRpcSetPingable(false);
				}
			}
		}

		public void FixedUpdate()
		{
			if (waitingForRefresh)
			{
				refreshTimer -= Time.fixedDeltaTime;
				if (refreshTimer <= 0f && purchaseCount < maxPurchaseCount)
				{
					purchaseInteraction.SetAvailable(true);
					purchaseInteraction.Networkcost = (int)((float)purchaseInteraction.cost + cachedCostMultiplierPerPurchase);
					waitingForRefresh = false;
				}
			}
		}

		private void UNetVersion()
		{
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			return ((ShrineBehavior)this).OnSerialize(writer, forceAll);
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			((ShrineBehavior)this).OnDeserialize(reader, initialState);
		}

		public override void PreStartClient()
		{
			((ShrineBehavior)this).PreStartClient();
		}
	}
}