using System;
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Bingo.Utility;
using BingoSave.App;
using BingoSave.Properties;
using CommonAPI;
using CommonAPI.Phone;
using HarmonyLib;
using Reptile;
using Reptile.Phone;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.6", FrameworkDisplayName = ".NET Framework 4.6")]
[assembly: AssemblyCompany("BingoSave")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("BingoSaves")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BingoSave")]
[assembly: AssemblyTitle("BingoSave")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
internal static class JsonUtilityEx
{
[Serializable]
private class Wrapper<T>
{
public T[] array;
}
public static T[] getJsonArray<T>(string json)
{
return JsonUtility.FromJson<Wrapper<T>>("{ \"array\": " + json + "}").array;
}
public static string arrayToJson<T>(T[] array)
{
return JsonUtility.ToJson((object)new Wrapper<T>
{
array = array
});
}
}
namespace Bingo.Utility
{
public class TextureUtil
{
public static Texture2D GetTextureFromBitmap(Bitmap bitmap, FilterMode filterMode = 1)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_0042: Expected O, but got Unknown
byte[] array = (byte[])((TypeConverter)new ImageConverter()).ConvertTo((object?)bitmap, typeof(byte[]));
Texture2D val = new Texture2D(((Image)bitmap).Width, ((Image)bitmap).Height);
ImageConversion.LoadImage(val, array);
((Texture)val).filterMode = filterMode;
val.Apply();
return val;
}
}
}
namespace BingoSave
{
[BepInPlugin("Ariki.BingoSave", "BingoSave", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string CharacterAPIGuid = "com.Viliger.CharacterAPI";
private const string CommonAPIGUID = "CommonAPI";
private void Awake()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogMessage((object)"BingoSave v1.0.0 starting...");
new Harmony("ariki.BingoSave").PatchAll();
((BaseUnityPlugin)this).Logger.LogMessage((object)"Init Phone App");
BingoApp.Initialize();
}
private void Update()
{
}
}
public static class LoadUtil
{
public static readonly BindingFlags BindingFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
public static Assets GetAssets(CharacterLoader instance)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
return (Assets)(((object)instance).GetType().GetField("assets", BindingFlags)?.GetValue(instance));
}
public static MethodInfo GetMethod(this object instance, string name)
{
return instance.GetType().GetMethod(name, BindingFlags);
}
public static void InvokeMethod(this object instance, string name, params object[] parameters)
{
Traverse.Create(instance).Method(name, parameters).GetValue(parameters);
}
public static void InvokeMethod(this object instance, string name, Type[] types, params object[] parameters)
{
Traverse.Create(instance).Method(name, types, (object[])null).GetValue(parameters);
}
public static FieldInfo GetField(this object instance, string name)
{
return instance.GetType().GetField(name, BindingFlags);
}
public static T GetComponentValue<T>(this object instance, string name) where T : Component
{
object? value = instance.GetField(name).GetValue(instance);
return (T)((value is T) ? value : null);
}
public static T GetFieldValue<T>(this object instance, string name) where T : class
{
return instance.GetField(name).GetValue(instance) as T;
}
public static void SetField(this object instance, string name, object value)
{
instance.GetField(name).SetValue(instance, value);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "BingoSave";
public const string PLUGIN_NAME = "BingoSave";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace BingoSave.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
public class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
resourceMan = new ResourceManager("BingoSave.Properties.Resources", typeof(Resources).Assembly);
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
public static Bitmap logo_background => (Bitmap)ResourceManager.GetObject("logo_background", resourceCulture);
public static Bitmap phoneAppIcon => (Bitmap)ResourceManager.GetObject("phoneAppIcon", resourceCulture);
internal Resources()
{
}
}
}
namespace BingoSave.App
{
public class BingoApp : CustomApp
{
private static Sprite Icon;
public static void Initialize()
{
Icon = TextureUtility.CreateSpriteFromTexture(TextureUtil.GetTextureFromBitmap(Resources.phoneAppIcon, (FilterMode)1));
PhoneAPI.RegisterApp<BingoApp>("Bingo", Icon);
}
public override void OnAppInit()
{
((CustomApp)this).OnAppInit();
((CustomApp)this).CreateTitleBar("Bingo", Icon, 80f);
base.ScrollView = PhoneScrollView.Create((CustomApp)(object)this, 275f, 1600f);
SimplePhoneButton val = PhoneUIUtility.CreateSimpleButton("Bingo");
((PhoneButton)val).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val).OnConfirm, (Action)delegate
{
SaveSlotData currentSaveSlot5 = Core.Instance.SaveManager.CurrentSaveSlot;
ResetGrafitti(currentSaveSlot5);
ResetEncounters(currentSaveSlot5);
ResetCollectables(currentSaveSlot5);
LockPolice(currentSaveSlot5, lockState: false);
LockTaxi(currentSaveSlot5, lockState: false);
setMapFound(currentSaveSlot5, lockState: false);
setVisitState(currentSaveSlot5, lockState: true);
Core.Instance.SaveManager.SaveCurrentSaveSlot();
});
base.ScrollView.AddButton((PhoneButton)(object)val);
SimplePhoneButton val2 = PhoneUIUtility.CreateSimpleButton("ResetGraffiti");
((PhoneButton)val2).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val2).OnConfirm, (Action)delegate
{
SaveSlotData currentSaveSlot4 = Core.Instance.SaveManager.CurrentSaveSlot;
ResetGrafitti(currentSaveSlot4);
Core.Instance.SaveManager.SaveCurrentSaveSlot();
});
base.ScrollView.AddButton((PhoneButton)(object)val2);
SimplePhoneButton val3 = PhoneUIUtility.CreateSimpleButton("ResetEncounters");
((PhoneButton)val3).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val3).OnConfirm, (Action)delegate
{
SaveSlotData currentSaveSlot3 = Core.Instance.SaveManager.CurrentSaveSlot;
ResetEncounters(currentSaveSlot3);
Core.Instance.SaveManager.SaveCurrentSaveSlot();
});
base.ScrollView.AddButton((PhoneButton)(object)val3);
SimplePhoneButton val4 = PhoneUIUtility.CreateSimpleButton("ResetCollectables");
((PhoneButton)val4).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val4).OnConfirm, (Action)delegate
{
SaveSlotData currentSaveSlot2 = Core.Instance.SaveManager.CurrentSaveSlot;
ResetCollectables(currentSaveSlot2);
Core.Instance.SaveManager.SaveCurrentSaveSlot();
});
base.ScrollView.AddButton((PhoneButton)(object)val4);
SimplePhoneButton val5 = PhoneUIUtility.CreateSimpleButton("ResetNPC");
((PhoneButton)val5).OnConfirm = (Action)Delegate.Combine(((PhoneButton)val5).OnConfirm, (Action)delegate
{
SaveSlotData currentSaveSlot = Core.Instance.SaveManager.CurrentSaveSlot;
ResetNPC(currentSaveSlot);
Core.Instance.SaveManager.SaveCurrentSaveSlot();
});
base.ScrollView.AddButton((PhoneButton)(object)val5);
}
public override void OnAppEnable()
{
((App)this).OnAppEnable();
}
public override void OnAppDisable()
{
((App)this).OnAppDisable();
}
public void ResetGrafitti(SaveSlotData save)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
foreach (StageProgress val in allStageProgress)
{
List<ProgressableData> list = new List<ProgressableData>();
foreach (ProgressableData progressable in val.progressables)
{
if (progressable is GraffitiSpotProgress)
{
list.Add(progressable);
}
}
foreach (ProgressableData item in list)
{
val.progressables.Remove(item);
}
}
}
public void ResetEncounters(SaveSlotData save)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
foreach (StageProgress val in allStageProgress)
{
List<ProgressableData> list = new List<ProgressableData>();
foreach (ProgressableData progressable in val.progressables)
{
if (progressable is EncounterProgress)
{
list.Add(progressable);
}
}
foreach (ProgressableData item in list)
{
val.progressables.Remove(item);
}
}
}
public void ResetCollectables(SaveSlotData save)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
foreach (StageProgress val in allStageProgress)
{
List<ProgressableData> list = new List<ProgressableData>();
foreach (ProgressableData progressable in val.progressables)
{
if (progressable is CollectableProgress)
{
list.Add(progressable);
}
}
foreach (ProgressableData item in list)
{
val.progressables.Remove(item);
}
}
}
public void ResetNPC(SaveSlotData save)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
List<ProgressableData> list = new List<ProgressableData>();
StageProgress[] array = allStageProgress;
foreach (StageProgress val in array)
{
foreach (ProgressableData progressable in val.progressables)
{
if (progressable is NPCProgress)
{
list.Add(progressable);
}
}
foreach (ProgressableData item in list)
{
val.progressables.Remove(item);
}
}
}
public void LockPolice(SaveSlotData save, bool lockState)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
for (int i = 0; i < allStageProgress.Length; i++)
{
allStageProgress[i].policeAllowed = lockState;
}
}
public void LockTaxi(SaveSlotData save, bool lockState)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
for (int i = 0; i < allStageProgress.Length; i++)
{
allStageProgress[i].taxiFound = lockState;
}
}
public void setVisitState(SaveSlotData save, bool lockState)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
for (int i = 0; i < allStageProgress.Length; i++)
{
allStageProgress[i].alreadyVisited = lockState;
}
}
public void setMapFound(SaveSlotData save, bool lockState)
{
StageProgress[] allStageProgress = save.GetAllStageProgress();
for (int i = 0; i < allStageProgress.Length; i++)
{
allStageProgress[i].mapFound = lockState;
}
}
}
}