using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MapUpgrade")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.12.0")]
[assembly: AssemblyInformationalVersion("1.0.12+8356d387eb2d0e20f689fd34391f86280b672dcc")]
[assembly: AssemblyProduct("MapUpgrade")]
[assembly: AssemblyTitle("MapUpgrade")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.12.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 Ardot.REPO.MapUpgrade
{
public static class DirectorChanges
{
public static void Init()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
Plugin.Harmony.Patch((MethodBase)AccessTools.Method(typeof(LevelGenerator), "GenerateDone", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(DirectorChanges), "OnLevelGenerated", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
Plugin.Harmony.Patch((MethodBase)AccessTools.Method(typeof(StatsManager), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(DirectorChanges), "OnStatsManagerStarted", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static void OnStatsManagerStarted()
{
StatsManager.instance.dictionaryOfDictionaries.Add("playerUpgradeMap", MapUpgrade.PlayerUpgrades);
}
private static void OnLevelGenerated()
{
MapUpgrade.UpdateUpgrade();
}
}
public class MapToolChanges : MonoBehaviour
{
public record struct BackgroundObject(Transform Object, Vector3 OriginalScale)
{
[CompilerGenerated]
private readonly bool PrintMembers(StringBuilder builder)
{
//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)
builder.Append("Object = ");
builder.Append(Object);
builder.Append(", OriginalScale = ");
Vector3 originalScale = OriginalScale;
builder.Append(((object)(Vector3)(ref originalScale)).ToString());
return true;
}
}
public static MapToolChanges Instance;
public static ConfigEntry<float> DefaultSize;
public static ConfigEntry<float> ZoomRate;
public MapToolController MapTool;
public Camera MapCamera;
public BackgroundObject[] BackgroundObjects = new BackgroundObject[3];
public const float ZoomScale = 2.25f;
public float MaxZoom = 1f;
public bool MapEnabled = true;
public static void Init()
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
ZoomRate = Plugin.Config.Bind<float>("Map", "ZoomSpeed", 1f, "Controls the speed that the map is zoomed");
DefaultSize = Plugin.Config.Bind<float>("Map", "DefaultSize", 1f, "The starting size of the map");
Plugin.Harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(MapToolChanges), "PlayerAwakePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
public static void PlayerAwakePostfix(PlayerAvatar __instance)
{
((Component)__instance.mapToolController).gameObject.AddComponent<MapToolChanges>();
}
public void Awake()
{
MapTool = ((Component)this).GetComponent<MapToolController>();
int backgroundObjectIndex = 0;
Utils.ForObjectsInTree(((Component)Map.Instance).transform.parent, delegate(Transform transform)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
Camera component = ((Component)transform).GetComponent<Camera>();
if ((Object)(object)component != (Object)null)
{
MapCamera = component;
}
switch (((Object)transform).name)
{
case "Fog":
case "Scanlines":
case "Background":
BackgroundObjects[backgroundObjectIndex] = new BackgroundObject(transform, transform.localScale);
backgroundObjectIndex++;
break;
case "Completed":
return false;
}
return true;
});
SetZoom(DefaultSize.Value);
}
public void Update()
{
if (MapEnabled && (bool)MapTool.Get<MapToolController>("Active"))
{
float axisRaw = Input.GetAxisRaw("Mouse ScrollWheel");
SetZoom(Mathf.Clamp(MapCamera.orthographicSize / 2.25f + axisRaw * ZoomRate.Value, 0.5f, MaxZoom));
}
}
public void SetMapEnabled(bool enabled)
{
((Renderer)MapTool.DisplayMesh).enabled = enabled;
((Behaviour)((Component)((Component)MapTool.DisplayMesh).transform.parent).GetComponentInChildren<Light>()).enabled = enabled;
MapEnabled = enabled;
}
public void SetMaxZoom(float zoom)
{
if (Mathf.Abs(zoom - MaxZoom) > 0.1f)
{
SetZoom(zoom);
}
MaxZoom = zoom;
}
public void SetZoom(float zoom)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
MapCamera.orthographicSize = zoom * 2.25f;
for (int i = 0; i < BackgroundObjects.Length; i++)
{
Vector3 originalScale = BackgroundObjects[i].OriginalScale;
BackgroundObjects[i].Object.localScale = new Vector3(originalScale.x * zoom, originalScale.y, originalScale.z * zoom);
}
}
}
public class MapUpgrade : MonoBehaviour
{
public static Dictionary<string, int> PlayerUpgrades = new Dictionary<string, int>();
public static Value Value;
public static ConfigEntry<bool> MapRequiresUpgrade;
public static ConfigEntry<float> MinCost;
public static ConfigEntry<float> MaxCost;
public static ConfigEntry<float> MapSizeIncrease;
private ItemToggle ItemToggle;
private PhotonView PhotonView;
public static void Init()
{
MapRequiresUpgrade = Plugin.Config.Bind<bool>("Upgrade", "MapRequiresUpgrade", true, "If true, one map upgrade is required before the map can be used");
MinCost = Plugin.Config.Bind<float>("Upgrade", "MinCost", 7000f, "The minimum price of a MapUpgrade in the shop");
MaxCost = Plugin.Config.Bind<float>("Upgrade", "MaxCost", 10000f, "The maximum price of a MapUpgrade in the shop");
MapSizeIncrease = Plugin.Config.Bind<float>("Upgrade", "MapSizeIncrease", 0.5f, "The amount that the map increases in size for every map upgrade");
Plugin.Config.SettingChanged += delegate(object caller, SettingChangedEventArgs arg)
{
if (!((Object)(object)PlayerAvatar.instance == (Object)null) && (arg.ChangedSetting == MapRequiresUpgrade || arg.ChangedSetting == MapToolChanges.DefaultSize || arg.ChangedSetting == MapSizeIncrease))
{
UpdateUpgrade();
}
};
Value = ScriptableObject.CreateInstance<Value>();
UpdateValue();
}
public static void UpdateValue()
{
Value.valueMin = MinCost.Value / 4f;
Value.valueMax = MaxCost.Value / 4f;
}
public void Awake()
{
ItemToggle = ((Component)this).GetComponent<ItemToggle>();
PhotonView = ((Component)this).GetComponent<PhotonView>();
UpdateValue();
ItemAttributes component = ((Component)this).GetComponent<ItemAttributes>();
component.item.value = Value;
}
[PunRPC]
public void Upgrade()
{
string key = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID((int)ItemToggle.Get<ItemToggle>("playerTogglePhotonID")));
if (!PlayerUpgrades.ContainsKey(key))
{
PlayerUpgrades.Add(key, 0);
}
PlayerUpgrades[key]++;
if (SemiFunc.IsMultiplayer() && Utils.IsHost())
{
PhotonView.RPC("Upgrade", (RpcTarget)1, Array.Empty<object>());
}
UpdateUpgrade();
}
public static void UpdateUpgrade()
{
for (int i = 0; i < GameDirector.instance.PlayerList.Count; i++)
{
PlayerAvatar obj = GameDirector.instance.PlayerList[i];
string key = (string)obj.Get<PlayerAvatar>("steamID");
if (!PlayerUpgrades.TryGetValue(key, out var value))
{
value = 0;
}
if (!MapRequiresUpgrade.Value)
{
value++;
}
if (!((Object)(object)PlayerAvatar.instance == (Object)null) && !((Object)(object)PlayerAvatar.instance.mapToolController == (Object)null))
{
MapToolChanges component = ((Component)PlayerAvatar.instance.mapToolController).GetComponent<MapToolChanges>();
if (!((Object)(object)component == (Object)null))
{
component.SetMapEnabled(value > 0);
component.SetMaxZoom(MapToolChanges.DefaultSize.Value + (float)(value - 1) * MapSizeIncrease.Value);
}
}
}
}
}
[BepInPlugin("Ardot.REPO.MapUpgrade", "MapUpgrade", "1.0.12")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string PluginGUID = "Ardot.REPO.MapUpgrade";
public static ConfigFile Config;
public static Harmony Harmony;
internal static ManualLogSource Logger;
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
Config = ((BaseUnityPlugin)this).Config;
Harmony = new Harmony("Ardot.REPO.MapUpgrade");
DirectorChanges.Init();
MapUpgrade.Init();
MapToolChanges.Init();
}
}
public static class Utils
{
private record struct FieldKey(Type Type, string Field);
private static Dictionary<FieldKey, FieldInfo> Fields = new Dictionary<FieldKey, FieldInfo>();
public static object Get<O>(this O obj, string field)
{
return GetField<O>(field).GetValue(obj);
}
public static T Get<T, O>(this O obj, string field)
{
return (T)obj.Get(field);
}
public static void Set<T>(this T obj, string field, object value)
{
GetField<T>(field).SetValue(obj, value);
}
public static FieldInfo GetField<T>(string field)
{
FieldKey key = new FieldKey(typeof(T), field);
if (!Fields.TryGetValue(key, out var value))
{
value = AccessTools.Field(typeof(T), field);
Fields.Add(key, value);
}
return value;
}
public static bool IsHost()
{
return SemiFunc.IsMasterClientOrSingleplayer();
}
public static void ForObjectsInTree(Transform root, Predicate<Transform> action)
{
Recurse(root);
void Recurse(Transform transform)
{
if (action(transform))
{
for (int num = transform.childCount - 1; num >= 0; num--)
{
Recurse(transform.GetChild(num));
}
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "MapUpgrade";
public const string PLUGIN_NAME = "MapUpgrade";
public const string PLUGIN_VERSION = "1.0.12";
}
}