using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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 UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("MUCK-Archipelago")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Muck for Archipelago")]
[assembly: AssemblyTitle("MUCK-Archipelago")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 ARCHIPELAGO
{
[BepInPlugin("MUCK-Archipelago", "Muck for Archipelago", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static Plugin Instance;
public GameState previousState;
public Dictionary<string, int> givenPowerups;
public Harmony harmony = new Harmony("MUCK-Archipelago");
private async void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin MUCK-Archipelago is loaded!");
Logger.LogInfo((object)"It's muckin' time");
harmony.PatchAll();
if (!File.Exists("ARCHIPELAGO_Powerups.itmlst"))
{
Logger.LogInfo((object)"Creatinng ARCHIPELAGO_Powerups.itmlst");
File.WriteAllText("ARCHIPELAGO_Powerups.itmlst", "Broccoli,0\r\nDumbbell,0\r\nJetpack,0\r\nOrange Juice,0\r\nPeanut Butter,0\r\nBlue Pill,0\r\nRed Pill,0\r\nSneaker,0\r\nRobin Hood Hat,0\r\nSpooo Bean,0\r\nBulldozer,0\r\nHorseshoe,0\r\nDanis Milk,0\r\nPiggybank,0\r\nCrimson Dagger,0\r\nDracula,0\r\nJanniks Frog,0\r\nJuice,0\r\nAdrenaline,0\r\nBerserk,0\r\nCheckered Shirt,0\r\nSniper Scope,0\r\nKnuts Hammer,0\r\nWings of Glory,0\r\nEnforcer,0\r\n");
}
if (!File.Exists("ARCHIPELAGO_Locations.lctlst"))
{
Logger.LogInfo((object)"Creatinng ARCHIPELAGO_Locations.lctlst");
File.WriteAllText("ARCHIPELAGO_Locations.lctlst", "PowerupWhite,0\r\nPowerupBlue,0\r\nPowerupOrange,0\r\n");
}
Instance = this;
resetGivenPowerups();
}
public void Update()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Invalid comparison between Unknown and I4
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0027: Invalid comparison between Unknown and I4
if ((int)previousState == 0 && (int)GameManager.state == 1)
{
atGameStart();
}
if ((int)GameManager.state == 1)
{
try
{
updateGivenPowerups(getPowerupsDict());
}
catch
{
}
}
previousState = GameManager.state;
}
public void atGameStart()
{
resetGivenPowerups();
updateGivenPowerups(getPowerupsDict());
}
public void forceGivePowerup(int powerupId, int count)
{
FieldInfo field = ((object)PowerupInventory.Instance).GetType().GetField("powerups", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
int[] array = (int[])field.GetValue(PowerupInventory.Instance);
array[powerupId] += count;
field.SetValue(PowerupInventory.Instance, array);
UiEvents.Instance.AddPowerup(ItemManager.Instance.allPowerups[powerupId]);
for (int i = 0; i < count; i++)
{
PowerupUI.Instance.AddPowerup(powerupId);
}
}
public bool isGamePlaying()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
return (int)GameManager.state == 1;
}
public bool isPlayerDead()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
return (int)GameManager.state == 2;
}
public void printPowerupList()
{
foreach (KeyValuePair<string, int> item in ItemManager.Instance.stringToPowerupId)
{
Logger.LogInfo((object)$"name : {item.Key}, id : {item.Value}");
}
}
public Dictionary<string, int> getPowerupsDict()
{
string str = File.ReadAllText("ARCHIPELAGO_Powerups.itmlst");
return strToDict(str);
}
public void resetGivenPowerups()
{
Logger.LogInfo((object)"Powerup Dict Reset");
givenPowerups = new Dictionary<string, int>
{
{ "Broccoli", 0 },
{ "Dumbbell", 0 },
{ "Jetpack", 0 },
{ "Orange Juice", 0 },
{ "Peanut Butter", 0 },
{ "Blue Pill", 0 },
{ "Red Pill", 0 },
{ "Sneaker", 0 },
{ "Robin Hood Hat", 0 },
{ "Spooo Bean", 0 },
{ "Bulldozer", 0 },
{ "Horseshoe", 0 },
{ "Danis Milk", 0 },
{ "Piggybank", 0 },
{ "Crimson Dagger", 0 },
{ "Dracula", 0 },
{ "Janniks Frog", 0 },
{ "Juice", 0 },
{ "Adrenaline", 0 },
{ "Berserk", 0 },
{ "Checkered Shirt", 0 },
{ "Sniper Scope", 0 },
{ "Knuts Hammer", 0 },
{ "Wings of Glory", 0 },
{ "Enforcer", 0 }
};
}
public void sendLocation(string locationName)
{
Dictionary<string, int> dictionary = strToDict(File.ReadAllText("ARCHIPELAGO_Locations.lctlst"));
dictionary[locationName]++;
Logger.LogInfo((object)dictToStr(dictionary));
File.WriteAllText("ARCHIPELAGO_Locations.lctlst", dictToStr(dictionary));
}
public static Dictionary<string, int> strToDict(string str)
{
string[] array = str.Split(new string[2]
{
Environment.NewLine,
"\n"
}, StringSplitOptions.None);
Dictionary<string, int> dictionary = new Dictionary<string, int>();
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split(",".ToCharArray());
dictionary.Add(array3[0], int.Parse(array3[1]));
}
return dictionary;
}
public static string dictToStr(Dictionary<string, int> dict)
{
string text = "";
bool flag = true;
foreach (KeyValuePair<string, int> item in dict)
{
if (flag)
{
text += $"{item.Key},{item.Value}";
flag = false;
}
else
{
text += $"\n{item.Key},{item.Value}";
}
}
return text;
}
public void updateGivenPowerups(Dictionary<string, int> powerupsToHave)
{
foreach (KeyValuePair<string, int> item in powerupsToHave)
{
if (item.Value > givenPowerups[item.Key])
{
int num = item.Value - givenPowerups[item.Key];
Logger.LogInfo((object)(item.Key + " : " + num));
forceGivePowerup(ItemManager.Instance.stringToPowerupId[item.Key], num);
givenPowerups[item.Key] += num;
}
}
}
public void win()
{
File.WriteAllText("victory", "Bob defeated");
}
}
[HarmonyPatch(typeof(PowerupInventory))]
[HarmonyPatch("AddPowerup")]
internal class PatcherAddPowerup
{
private static bool Prefix(string name, int powerupId, int objectId)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Invalid comparison between Unknown and I4
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Invalid comparison between Unknown and I4
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Invalid comparison between Unknown and I4
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Invalid comparison between Unknown and I4
Vector3 position = ItemManager.Instance.list[objectId].transform.position;
ParticleSystem component = Object.Instantiate<GameObject>(PowerupInventory.Instance.powerupFx, position, Quaternion.identity).GetComponent<ParticleSystem>();
MainModule main = component.main;
((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(ItemManager.Instance.allPowerups[powerupId].GetOutlineColor());
if ((int)ItemManager.Instance.allPowerups[powerupId].tier == 2)
{
((Component)component).gameObject.GetComponent<RandomSfx>().sounds = (AudioClip[])(object)new AudioClip[1] { PowerupInventory.Instance.goodPowerupSfx };
((Component)component).GetComponent<RandomSfx>().Randomize(0f);
}
if ((int)ItemManager.Instance.allPowerups[powerupId].tier == 0)
{
Plugin.Instance.sendLocation("PowerupWhite");
}
else if ((int)ItemManager.Instance.allPowerups[powerupId].tier == 1)
{
Plugin.Instance.sendLocation("PowerupBlue");
}
else if ((int)ItemManager.Instance.allPowerups[powerupId].tier == 2)
{
Plugin.Instance.sendLocation("PowerupOrange");
}
return false;
}
}
[HarmonyPatch(typeof(ServerSend))]
[HarmonyPatch("GameOver")]
internal class PatcherGameOver
{
private static bool Prefix(int winnerId = -2)
{
if (winnerId == -3)
{
Plugin.Instance.win();
}
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MUCK-Archipelago";
public const string PLUGIN_NAME = "Muck for Archipelago";
public const string PLUGIN_VERSION = "1.0.0";
}
}