using System;
using System.Collections;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UltraAchievementsRevamped.Core.Achievements;
using UnityEngine;
using UnityEngine.AddressableAssets;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("UltraAchievementsRevamped.Mod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Content mod for Ultrakill which contains UltraAchievements")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+9feab18fa052fdeb2a12a79832b0577f650570d9")]
[assembly: AssemblyProduct("UltraAchievementsRevamped.Mod")]
[assembly: AssemblyTitle("UltraAchievementsRevamped.Mod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.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 UltraAchievementsRevamped.Mod
{
internal static class Assets
{
public static string AssetPath => Path.Combine(ModFolder, "Assets");
private static string ModFolder => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
private static string CatalogPath => Path.Combine(AssetPath, "catalog_mod.json");
internal static void LoadAssets()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
Addressables.LoadContentCatalogAsync(CatalogPath, true, (string)null).WaitForCompletion();
List<AchievementInfo> achievementInfos = new List<AchievementInfo>();
Addressables.LoadAssetsAsync<AchievementInfo>((object)"UltraAchievementsMod", (Action<AchievementInfo>)delegate(AchievementInfo asset)
{
Debug.Log((object)("Loaded Achievement: " + asset.Id));
achievementInfos.Add(asset);
}).WaitForCompletion();
AchievementManager.RegisterAchievementInfos((IEnumerable<AchievementInfo>)achievementInfos);
}
}
[BepInPlugin("protract.ultrakill.ultra_achievements_revamped", "UltraAchievementsRevamped.Mod", "2.0.1")]
[BepInDependency("protract.ultrakill.ultra_achievements_core", "2.0.0")]
internal class Plugin : BaseUnityPlugin
{
private static class PluginInfo
{
public const string Name = "UltraAchievementsRevamped.Mod";
public const string Guid = "protract.ultrakill.ultra_achievements_revamped";
public const string Version = "2.0.1";
}
internal static ManualLogSource Logger;
private void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"UltraAchievementsRevamped.Mod 2.0.1 has loaded!");
new Harmony("protract.ultrakill.ultra_achievements_core").PatchAll();
Assets.LoadAssets();
}
}
}
namespace UltraAchievementsRevamped.Mod.Achievements
{
[HarmonyPatch]
internal class BoardLegally
{
[HarmonyPatch(typeof(FerrymanFake), "BlowCoin")]
[HarmonyPostfix]
private static void FerrymanCoinCheck()
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.boardLegally");
}
}
[HarmonyPatch]
internal class CultOfJakito
{
[HarmonyPatch(typeof(HudMessage), "PlayMessage")]
[HarmonyPostfix]
private static void WorldDestructionCheckPatch(HudMessage __instance)
{
if (__instance.message.Contains("THANK YOU. NOW I SHALL LAY WASTE TO THIS WORLD."))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.cultOfJakito");
}
}
}
[HarmonyPatch]
internal class DeathSimulator
{
[HarmonyPatch(typeof(NewMovement), "Respawn")]
[HarmonyPrefix]
private static void DeathPatch()
{
AchievementManager.AddProgressToAchievement("ultraAchievementsRevamped.deathSimulator", 1);
}
}
[HarmonyPatch]
internal class DiscoParty
{
[HarmonyPatch(typeof(ItemPlaceZone), "CheckItem")]
[HarmonyPostfix]
private static void SoapPlacedPatch(ItemPlaceZone __instance)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Invalid comparison between Unknown and I4
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Invalid comparison between Unknown and I4
StatsManager instance = MonoSingleton<StatsManager>.Instance;
if (instance == null || instance.levelNumber != 18 || (int)__instance.acceptedItemType != 6)
{
return;
}
ItemIdentifier componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<ItemIdentifier>();
if ((Object)(object)componentInChildren == (Object)null || (int)componentInChildren.itemType != 6)
{
return;
}
GameObject[] activateOnSuccess = __instance.activateOnSuccess;
for (int i = 0; i < activateOnSuccess.Length; i++)
{
if (((Object)activateOnSuccess[i]).name.Contains("Rainbow"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.discoParty");
}
}
}
}
[HarmonyPatch]
internal class DoubleIt
{
private static int _dualWieldCounter;
[HarmonyPatch(typeof(DualWield), "Start")]
[HarmonyPostfix]
private static void DualWieldGainPatch()
{
_dualWieldCounter++;
if (_dualWieldCounter >= 3)
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.doubleIt");
}
}
[HarmonyPatch(typeof(DualWield), "EndPowerUp")]
[HarmonyPostfix]
private static void DualWieldEndPatch()
{
_dualWieldCounter--;
}
}
[HarmonyPatch]
internal class IfIWasRich
{
[HarmonyPatch(typeof(MoneyText), "DivideMoney")]
[HarmonyPrefix]
private static void MoneyCheck(int dosh)
{
if (dosh > 1000000000)
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.ifIWasRich");
}
}
}
[HarmonyPatch]
internal class KillAFish : MonoBehaviour
{
[HarmonyPatch(typeof(Breakable), "Break", new Type[] { typeof(float) })]
[HarmonyPostfix]
private static void FishDeathPatch(Breakable __instance)
{
FishGhost val = default(FishGhost);
if (((Component)__instance).gameObject.TryGetComponent<FishGhost>(ref val))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.killAFish");
}
}
}
[HarmonyPatch]
internal class KillingMachine
{
[HarmonyPatch(typeof(FinalRank), "LevelChange")]
[HarmonyPrefix]
private static void RankTimeCheckPrefix(FinalRank __instance)
{
string[] array = __instance.time.text.Split(':');
if (array.Length >= 2 && int.TryParse(array[0], out var result) && float.TryParse(array[1], out var result2))
{
float num = (float)(result * 60) + result2;
if (__instance.totalRank.text.Contains(">P<") && num <= 60f)
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.killingMachine");
}
}
}
}
[HarmonyPatch]
internal class MemoryWiped
{
[HarmonyPatch(typeof(SaveSlotMenu), "ConfirmWipe")]
[HarmonyPostfix]
private static void DeleteSavePatch()
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.memoryWiped");
}
}
[HarmonyPatch]
internal class PipeClip
{
[HarmonyPatch(typeof(HudMessage), "PlayMessage")]
[HarmonyPostfix]
private static void PipeClipCheckPatch(HudMessage __instance)
{
if (__instance.message.Contains("PIPE CLIP"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.pipeClip");
}
}
}
[HarmonyPatch]
internal class SandboxAddiction : MonoBehaviour
{
[CompilerGenerated]
private sealed class <SandboxTimeCheck>d__2 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
private WaitForSeconds <wait>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SandboxTimeCheck>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<wait>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
}
else
{
<>1__state = -1;
<wait>5__2 = new WaitForSeconds(60f);
}
SteamController instance = SteamController.Instance;
if (((instance != null) ? instance.GetSandboxStats().hoursSpend : 0f) > 5f)
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.sandboxAddiction");
return false;
}
<>2__current = <wait>5__2;
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPatch(typeof(ShopZone), "Start")]
[HarmonyPostfix]
private static void TerminalSpawnPatch(ShopZone __instance)
{
if (!(((Object)__instance).name != "Sandbox Shop"))
{
((Component)__instance).gameObject.AddComponent<SandboxAddiction>();
}
}
private void Start()
{
((MonoBehaviour)this).StartCoroutine(SandboxTimeCheck());
}
[IteratorStateMachine(typeof(<SandboxTimeCheck>d__2))]
private static IEnumerator SandboxTimeCheck()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SandboxTimeCheck>d__2(0);
}
}
[HarmonyPatch]
internal class SequenceBreak
{
[HarmonyPatch(typeof(StatsManager), "GetFinalRank")]
[HarmonyPostfix]
private static void WeaponsCheckPatch()
{
int? num = MonoSingleton<StatsManager>.Instance?.levelNumber;
if (!num.HasValue)
{
return;
}
switch (num.GetValueOrDefault())
{
case 1:
if (!HasWeapon("Revolver"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.sequenceBreak");
}
break;
case 3:
if (!HasWeapon("Shotgun"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.sequenceBreak");
}
break;
case 6:
if (!HasWeapon("Nailgun"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.sequenceBreak");
}
break;
case 11:
if (!HasWeapon("Railcannon"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.sequenceBreak");
}
break;
case 22:
if (!HasWeapon("Rocket Launcher"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.sequenceBreak");
}
break;
}
}
private static bool HasWeapon(string name)
{
return (MonoSingleton<GunControl>.Instance?.allWeapons ?? new List<GameObject>()).Any((GameObject weapon) => ((Object)weapon).name.Contains(name));
}
}
[HarmonyPatch]
internal class SoftDamage
{
private static bool _timerStarted;
private static float _timePassed;
[HarmonyPatch(typeof(NewMovement), "Update")]
[HarmonyPostfix]
public static void Postfix(NewMovement __instance)
{
if (_timerStarted)
{
_timePassed += Time.deltaTime;
if (_timePassed < 6f && __instance.hp >= 99)
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.softDamage");
}
else if (_timePassed > 6f)
{
_timerStarted = false;
}
}
else if (__instance.antiHp >= 98f)
{
_timerStarted = true;
}
}
}
[HarmonyPatch]
internal class V2IntroKill
{
[HarmonyPatch(typeof(V2), "Die")]
[HarmonyPrefix]
private static void V2DeathPatch(V2 __instance)
{
if (__instance.inIntro)
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.v2IntroKill");
}
}
}
[HarmonyPatch]
internal class YouAreAMonster
{
[HarmonyPatch(typeof(Breakable), "Break", new Type[] { typeof(float) })]
[HarmonyPostfix]
private static void SandcastleCheck(Breakable __instance)
{
if (((Object)__instance).name.Contains("Sand Castle"))
{
AchievementManager.MarkAchievementComplete("ultraAchievementsRevamped.youAreAMonster");
}
}
}
}