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 DecalsPeakTools.Behaviours;
using DecalsPeakTools.Interfaces;
using DecalsPeakTools.Models;
using DecalsPeakTools.Models.Configuration;
using DecalsPeakTools.Tools;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Photon.Pun;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Core.Editor;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("DecalsPeakTools")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fe234e17b2060982e7dbd8d565e92f1cc4986e4a")]
[assembly: AssemblyProduct("DecalsPeakTools")]
[assembly: AssemblyTitle("DecalsPeakTools")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.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 DecalsPeakTools
{
public class Constants
{
public const string Guid = "decalfree.decalspeaktools";
public const string Name = "DecalsPeakTools";
public const string Version = "1.0.0";
}
[BepInPlugin("decalfree.decalspeaktools", "DecalsPeakTools", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public Plugin()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
Logging.Initialize();
try
{
Main main = new GameObject("DecalsPeakTools v1.0.0").AddComponent<Main>();
main.Construct();
Object.DontDestroyOnLoad((Object)(object)main);
Harmony.CreateAndPatchAll(((object)this).GetType().Assembly, "decalfree.decalspeaktools");
}
catch (Exception arg)
{
Logging.Error(string.Format("Failed to load {0}: {1}", "DecalsPeakTools", arg));
}
}
}
}
namespace DecalsPeakTools.Tools
{
public static class Logging
{
private static ManualLogSource _logSource;
public static void Initialize()
{
_logSource = Logger.CreateLogSource("DecalsPeakTools");
}
private static void Log(LogLevel logLevel, object data)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
_logSource.Log(logLevel, data);
}
public static void Info(object data)
{
Log((LogLevel)16, data);
}
public static void Warning(object data)
{
Log((LogLevel)4, data);
}
public static void Error(object data)
{
Log((LogLevel)2, data);
}
}
}
namespace DecalsPeakTools.Patches
{
[HarmonyPatch(typeof(BoardingPass))]
public static class PatchBoardingPass
{
[HarmonyPatch("Initialize")]
[HarmonyPostfix]
public static void BoardingPassInitialized(BoardingPass __instance)
{
Events.BoardingPassInitialized_Invoke(__instance);
}
}
[HarmonyPatch(typeof(DesertRockSpawner))]
public static class PatchDesertRockSpawner
{
[HarmonyPatch("Go")]
[HarmonyPrefix]
public static bool OverrideTombSpawnChance(DesertRockSpawner __instance)
{
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
Logging.Info("DesertRockSpawner - Go has been called.");
((LevelGenStep)__instance).Clear();
for (int i = 0; i < __instance.enterences.childCount; i++)
{
Transform child = __instance.enterences.GetChild(i);
if (i == Random.Range(0, __instance.enterences.childCount) && Random.value < DataManager.Singleton.PlayerConfig.TombSpawnChance.Value)
{
HelperFunctions.InstantiatePrefab(__instance.enterenceObjects[Random.Range(0, __instance.enterenceObjects.Length)], child.position, child.rotation, child).transform.localScale = Vector3.one * 2f;
__instance.inside.position = new Vector3(child.position.x, __instance.inside.position.y, child.position.z);
}
else
{
HelperFunctions.InstantiatePrefab(__instance.blockerObjects[Random.Range(0, __instance.blockerObjects.Length)], child.position, child.rotation, child).transform.localScale = Vector3.one * 2f;
}
}
return false;
}
}
[HarmonyPatch(typeof(MapBaker))]
public static class PatchMapBaker
{
[HarmonyPatch("GetLevel")]
[HarmonyPrefix]
public static bool ShouldOverrideMap(MapBaker __instance, ref string __result)
{
if (Main.Singleton.LevelSelector.currentLevelIndex == 0)
{
return true;
}
__result = PathUtil.WithoutExtensions(PathUtil.GetFileName(__instance.AllLevels[Main.Singleton.LevelSelector.currentLevelIndex - 1]));
return false;
}
}
[HarmonyPatch(typeof(VersionString))]
public static class PatchVersionString
{
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void RenderExtraInformation(VersionString __instance)
{
if (PhotonNetwork.InRoom && Main.Singleton.currentSceneName.Contains("Level"))
{
bool activeSelf = ((Component)Main.Singleton.thirdBiomeObject.transform.GetChild(1)).gameObject.activeSelf;
TextMeshProUGUI text = __instance.m_text;
((TMP_Text)text).text = ((TMP_Text)text).text + $"\nIsMesaSeed: {activeSelf}";
}
}
}
}
namespace DecalsPeakTools.Models
{
public static class Events
{
public delegate void BoardingPassInitializedHandler(BoardingPass boardingPass);
public static event BoardingPassInitializedHandler OnBoardingPassInitialized;
internal static void BoardingPassInitialized_Invoke(BoardingPass boardingPass)
{
Events.OnBoardingPassInitialized?.Invoke(boardingPass);
}
}
public class LevelSelector : MonoBehaviour
{
private readonly List<string> _availableLevels = new List<string>();
public int currentLevelIndex = 0;
private TextMeshProUGUI _titleText;
private Button _incrementLevelButton;
private Button _decrementLevelButton;
private int MaxLevelIndex => SingletonAsset<MapBaker>.Instance.AllLevels.Length;
private void Start()
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
_titleText = ((Component)((Component)this).transform.Find("Level/Title")).GetComponent<TextMeshProUGUI>();
((TMP_Text)((Component)((Component)this).transform.Find("BOARDING PASS")).GetComponent<TextMeshProUGUI>()).text = "LEVEL SELECTOR";
((TMP_Text)((Component)((Component)this).transform.Find("PassengerName")).GetComponent<TextMeshProUGUI>()).text = NetworkConnector.GetUsername();
((TMP_Text)((Component)((Component)this).transform.Find("StartGameButton/Text")).GetComponent<TextMeshProUGUI>()).text = $"LEVELS:\n0 - {MaxLevelIndex - 1}";
_incrementLevelButton = ((Component)((Component)this).transform.Find("Level/IncrementButton")).GetComponent<Button>();
((UnityEvent)_incrementLevelButton.onClick).AddListener((UnityAction)delegate
{
currentLevelIndex++;
UpdateLevel();
});
_decrementLevelButton = ((Component)((Component)this).transform.Find("Level/DecrementButton")).GetComponent<Button>();
((UnityEvent)_decrementLevelButton.onClick).AddListener((UnityAction)delegate
{
currentLevelIndex--;
UpdateLevel();
});
_availableLevels.Add("Level_Daily");
for (int i = 0; i < MaxLevelIndex; i++)
{
_availableLevels.Add($"Level_{i}");
}
UpdateLevel();
}
public void UpdateLevel()
{
((Selectable)_incrementLevelButton).interactable = currentLevelIndex < MaxLevelIndex;
((Selectable)_decrementLevelButton).interactable = currentLevelIndex > 0;
((TMP_Text)_titleText).text = _availableLevels[currentLevelIndex];
}
}
public class PlayerConfig
{
[CompilerGenerated]
private sealed class <GetAllConfigOptions>d__8 : IEnumerable<ISharedConfigOption>, IEnumerable, IEnumerator<ISharedConfigOption>, IEnumerator, IDisposable
{
private int <>1__state;
private ISharedConfigOption <>2__current;
private int <>l__initialThreadId;
public PlayerConfig <>4__this;
ISharedConfigOption IEnumerator<ISharedConfigOption>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <GetAllConfigOptions>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
<>l__initialThreadId = Environment.CurrentManagedThreadId;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = <>4__this.MonitorResolution;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = <>4__this.TombSpawnChance;
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
[DebuggerHidden]
IEnumerator<ISharedConfigOption> IEnumerable<ISharedConfigOption>.GetEnumerator()
{
<GetAllConfigOptions>d__8 result;
if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
{
<>1__state = 0;
result = this;
}
else
{
result = new <GetAllConfigOptions>d__8(0)
{
<>4__this = <>4__this
};
}
return result;
}
[DebuggerHidden]
IEnumerator IEnumerable.GetEnumerator()
{
return ((IEnumerable<ISharedConfigOption>)this).GetEnumerator();
}
}
public StringConfigOption MonitorResolution { get; set; } = new StringConfigOption("Monitor Resolution", "Chosen monitor resolution.", new string[4] { "2560x1440", "1920x1440", "1920x1200", "1920x1080" }, "1920x1080");
public FloatConfigOption TombSpawnChance { get; set; } = new FloatConfigOption("Tomb Spawn Chance", "The chance the Tomb can spawn, 0.5 being 50%, 0 being default seed generation.", new float[11]
{
0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f,
1f
}, 0f);
[IteratorStateMachine(typeof(<GetAllConfigOptions>d__8))]
public IEnumerable<ISharedConfigOption> GetAllConfigOptions()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <GetAllConfigOptions>d__8(-2)
{
<>4__this = this
};
}
}
}
namespace DecalsPeakTools.Models.Configuration
{
public class BooleanConfigOption : SharedConfigOption<bool>
{
[CompilerGenerated]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private bool <defaultValue>P;
private readonly bool[] _acceptedValues;
[JsonProperty]
public override bool Value
{
get
{
return base.Value;
}
protected set
{
base.Value = (_acceptedValues.Contains(value) ? value : <defaultValue>P);
}
}
public BooleanConfigOption(string optionName, string optionDescription, bool[] acceptedValues, bool defaultValue)
{
<defaultValue>P = defaultValue;
_acceptedValues = acceptedValues;
base..ctor(optionName, optionDescription, acceptedValues, <defaultValue>P);
}
public override bool IsValid()
{
return _acceptedValues.Contains(Value);
}
}
public class FloatConfigOption : SharedConfigOption<float>
{
[CompilerGenerated]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private float <defaultValue>P;
private readonly float[] _acceptedValues;
[JsonProperty]
public override float Value
{
get
{
return base.Value;
}
protected set
{
base.Value = (_acceptedValues.Contains(value) ? value : <defaultValue>P);
}
}
public FloatConfigOption(string optionName, string optionDescription, float[] acceptedValues, float defaultValue)
{
<defaultValue>P = defaultValue;
_acceptedValues = acceptedValues;
base..ctor(optionName, optionDescription, acceptedValues, <defaultValue>P);
}
public override bool IsValid()
{
return _acceptedValues.Contains(Value);
}
}
public abstract class SharedConfigOption<T> : ISharedConfigOption
{
public string OptionName { get; }
public string OptionDescription { get; }
public T[] AcceptedValues { get; }
public T DefaultValue { get; }
public virtual T Value { get; protected set; }
object ISharedConfigOption.DefaultValue => DefaultValue;
object ISharedConfigOption.Value
{
get
{
return Value;
}
set
{
Value = (T)value;
}
}
protected SharedConfigOption(string optionName, string optionDescription, T[] acceptedValues, T defaultValue)
{
OptionName = optionName;
OptionDescription = optionDescription;
AcceptedValues = acceptedValues;
DefaultValue = defaultValue;
Value = defaultValue;
base..ctor();
}
public abstract bool IsValid();
public void ResetToDefault()
{
Value = DefaultValue;
}
}
public class StringConfigOption : SharedConfigOption<string>
{
[CompilerGenerated]
[DebuggerBrowsable(DebuggerBrowsableState.Never)]
private string <defaultValue>P;
private readonly string[] _acceptedValues;
[JsonProperty]
public override string Value
{
get
{
return base.Value;
}
protected set
{
base.Value = (_acceptedValues.Contains(value) ? value : <defaultValue>P);
}
}
public StringConfigOption(string optionName, string optionDescription, string[] acceptedValues, string defaultValue)
{
<defaultValue>P = defaultValue;
_acceptedValues = acceptedValues;
base..ctor(optionName, optionDescription, acceptedValues, <defaultValue>P);
}
public override bool IsValid()
{
return _acceptedValues.Contains(Value);
}
}
}
namespace DecalsPeakTools.Interfaces
{
public interface ISharedConfigOption
{
string OptionName { get; }
string OptionDescription { get; }
object DefaultValue { get; }
object Value { get; set; }
bool IsValid();
void ResetToDefault();
}
}
namespace DecalsPeakTools.Behaviours
{
public class DataManager : MonoBehaviour
{
private bool _initialized;
public static DataManager Singleton;
public PlayerConfig PlayerConfig;
private string PlayerConfigJsonPath => Paths.ConfigPath + "/DecalsPeakTools.json";
private void Start()
{
if (_initialized || Object.op_Implicit((Object)(object)Singleton))
{
return;
}
Singleton = this;
if (!File.Exists(PlayerConfigJsonPath))
{
PlayerConfig = new PlayerConfig();
}
else
{
string text = File.ReadAllText(PlayerConfigJsonPath);
PlayerConfig = JsonConvert.DeserializeObject<PlayerConfig>(text);
foreach (ISharedConfigOption allConfigOption in PlayerConfig.GetAllConfigOptions())
{
if (!allConfigOption.IsValid())
{
Logging.Warning(allConfigOption.OptionName + " has an invalid value, resetting to default value!");
allConfigOption.ResetToDefault();
}
}
}
SavePlayerConfig();
_initialized = true;
}
public void SavePlayerConfig()
{
//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_001b: Expected O, but got Unknown
using StreamWriter streamWriter = File.CreateText(PlayerConfigJsonPath);
JsonSerializer val = new JsonSerializer
{
Formatting = (Formatting)1
};
val.Serialize((TextWriter)streamWriter, (object)PlayerConfig);
}
}
public class Main : MonoBehaviour
{
private bool _initialized;
public static Main Singleton;
public string currentSceneName;
public GameObject thirdBiomeObject;
private Transform _levelSelectorPanel;
private Transform _levelSelectorBorder;
private readonly Dictionary<string, Vector3> _levelSelectorPanelPositions = new Dictionary<string, Vector3>
{
{
"2560x1440",
new Vector3(1280f, 220f, 0f)
},
{
"1920x1440",
new Vector3(960f, 220f, 0f)
},
{
"1920x1200",
new Vector3(960f, 180f, 0f)
},
{
"1920x1080",
new Vector3(960f, 165f, 0f)
}
};
public PlayerConnectionLog PlayerConnectionLog => Object.FindFirstObjectByType<PlayerConnectionLog>();
public LevelSelector LevelSelector => ((Component)_levelSelectorPanel).GetComponent<LevelSelector>();
public void Construct()
{
if (_initialized || Object.op_Implicit((Object)(object)Singleton))
{
Logging.Error("Failed to initialize DecalsPeakTools as it's already initialized.");
return;
}
Singleton = this;
((Component)this).gameObject.AddComponent<DataManager>();
SceneManager.sceneLoaded += SceneLoaded;
string text = SingletonAsset<MapBaker>.Instance.AllLevels.Aggregate(string.Empty, (string current, string level) => current + level + "\n");
Logging.Info("Current Levels:\n" + text);
Events.OnBoardingPassInitialized += delegate(BoardingPass boardingPass)
{
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: 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)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
if (PhotonNetwork.IsMasterClient)
{
if (Object.op_Implicit((Object)(object)_levelSelectorPanel) || Object.op_Implicit((Object)(object)_levelSelectorBorder))
{
_levelSelectorPanel.position = _levelSelectorPanelPositions[DataManager.Singleton.PlayerConfig.MonitorResolution.Value];
_levelSelectorBorder.position = _levelSelectorPanelPositions[DataManager.Singleton.PlayerConfig.MonitorResolution.Value];
}
else
{
_levelSelectorPanel = Object.Instantiate<Transform>(((Component)boardingPass).transform.Find("BoardingPass/Panel"), ((Component)boardingPass).transform.Find("BoardingPass"), true);
((Component)_levelSelectorPanel).gameObject.AddComponent<LevelSelector>();
((Object)_levelSelectorPanel).name = "Level Selector Panel";
_levelSelectorPanel.position = _levelSelectorPanelPositions[DataManager.Singleton.PlayerConfig.MonitorResolution.Value];
_levelSelectorPanel.localScale = new Vector3(0.5f, 0.5f, 0.5f);
_levelSelectorBorder = Object.Instantiate<Transform>(((Component)boardingPass).transform.Find("BoardingPass/Border"), ((Component)boardingPass).transform.Find("BoardingPass"), true);
((Object)_levelSelectorBorder).name = "Level Selector Border";
_levelSelectorBorder.position = _levelSelectorPanelPositions[DataManager.Singleton.PlayerConfig.MonitorResolution.Value];
_levelSelectorBorder.localScale = new Vector3(0.5f, 0.5f, 0.5f);
Object.Destroy((Object)(object)((Component)_levelSelectorPanel.GetChild(2)).GetComponent<LocalizedText>());
Object.Destroy((Object)(object)((Component)_levelSelectorPanel.GetChild(16)).GetComponent<Button>());
Object.Destroy((Object)(object)((Component)_levelSelectorPanel.GetChild(16)).GetComponent<Animator>());
Object.Destroy((Object)(object)((Component)_levelSelectorPanel.GetChild(16).GetChild(0)).GetComponent<LocalizedText>());
((Component)_levelSelectorPanel.GetChild(16).Find("Scouts")).gameObject.SetActive(false);
((Component)_levelSelectorPanel.GetChild(16).Find("Image")).gameObject.SetActive(false);
((Object)_levelSelectorPanel.GetChild(17)).name = "Level";
((Component)_levelSelectorPanel.GetChild(17).GetChild(1)).gameObject.SetActive(false);
}
}
};
_initialized = true;
Logging.Info(string.Format("Successfully initialized {0}: {1}", "DecalsPeakTools", _initialized));
}
private void SceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
currentSceneName = ((Scene)(ref scene)).name;
Logging.Info("Loaded scene " + ((Scene)(ref scene)).name);
if (!currentSceneName.Contains("Level"))
{
return;
}
thirdBiomeObject = GameObject.Find("Map/Biome_3");
if (!Mathf.Approximately(DataManager.Singleton.PlayerConfig.TombSpawnChance.Value, 0f) && ((Component)thirdBiomeObject.transform.GetChild(1)).gameObject.activeSelf)
{
Transform val = thirdBiomeObject.transform.Find("Desert/Desert_Segment/Platteau/Rocks/Timple");
DesertRockSpawner val2 = default(DesertRockSpawner);
if (((Component)val).TryGetComponent<DesertRockSpawner>(ref val2))
{
((LevelGenStep)val2).Go();
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}