using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using EntityStates.Duplicator;
using EntityStates.Scrapper;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using RoR2;
using RoR2.EntityLogic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[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 RiskOfResources
{
[BepInPlugin("com.riskofresources.fast.interactable", "BalancedFasterInteractables", "0.1.0")]
[BepInIncompatibility("riskofresources.FasterInteractableBalancer")]
[BepInIncompatibility("FlyingComputer.ExchangeChanges")]
[BepInIncompatibility("Felda.ActuallyFaster")]
internal class BalancedFasterInteractables : BaseUnityPlugin
{
public const string version = "0.1.0";
public const string identifier = "com.riskofresources.fast.interactable";
private static ConfigEntry<bool> teleporter;
private static ConfigEntry<bool> penalty;
private static ConfigEntry<float> speed;
protected void Awake()
{
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
teleporter = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Only After Teleporter", true, "By default, this plugin will only take effect on stages with a teleporter, after it has been charged.");
penalty = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Time Penalty", true, "Any time taken off the activation will be directly added to the game stopwatch.");
speed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Speed", 75f, new ConfigDescription("Time to complete each interaction is reduced by this percentage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 100f), Array.Empty<object>()));
Harmony.CreateAndPatchAll(typeof(BalancedFasterInteractables), (string)null);
}
[HarmonyPatch(typeof(ScrapperBaseState), "OnEnter")]
[HarmonyPatch(typeof(Duplicating), "OnEnter")]
[HarmonyPostfix]
private static void PrintAndScrap(BaseState __instance)
{
if (teleporter.Value)
{
TeleporterInteraction instance = TeleporterInteraction.instance;
if (!(((instance != null) ? instance.currentState : null) is ChargedState))
{
return;
}
}
float num = speed.Value / 100f;
if (!(__instance is Duplicating))
{
if (!(__instance is WaitToBeginScrapping))
{
if (!(__instance is Scrapping))
{
if (!(__instance is ScrappingToIdle))
{
return;
}
num *= ScrappingToIdle.duration * 0.5f;
}
else
{
num *= Scrapping.duration;
}
}
else
{
num *= WaitToBeginScrapping.duration;
}
}
else
{
((UnityEventBase)((EntityState)__instance).GetComponent<DelayedEvent>().action).SetPersistentListenerState(0, (UnityEventCallState)0);
((EntityState)__instance).GetComponent<PurchaseInteraction>().SetUnavailableTemporarily(4f * (1f - num));
num *= Duplicating.initialDelayDuration + Duplicating.timeBetweenStartAndDropDroplet;
}
((EntityState)__instance).fixedAge = ((EntityState)__instance).fixedAge + num;
UpdateStopwatch(num);
}
[HarmonyPatch(typeof(ShrineChanceBehavior), "AddShrineStack")]
[HarmonyPostfix]
private static void SpeedUp(ShrineChanceBehavior __instance)
{
if (teleporter.Value)
{
TeleporterInteraction instance = TeleporterInteraction.instance;
if (!(((instance != null) ? instance.currentState : null) is ChargedState))
{
return;
}
}
float num = speed.Value / 100f * __instance.refreshTimer;
__instance.refreshTimer -= num;
UpdateStopwatch(num);
}
private static void UpdateStopwatch(float time)
{
Run instance = Run.instance;
if (penalty.Value && Object.op_Implicit((Object)(object)instance) && NetworkServer.active)
{
instance.SetRunStopwatch(instance.GetRunStopwatch() + time);
}
}
}
}