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 System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using HersysMod.Config;
using HersysMod.Patches;
using HersysMod.Scoreboard;
using Microsoft.CodeAnalysis;
using Peak;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;
[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("com.github.glarmer.hershysmod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+f5e96af902c936bf3dc5ba65e6f24cf7c7d99248")]
[assembly: AssemblyProduct("com.github.glarmer.hershysmod")]
[assembly: AssemblyTitle("HersysMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace HersysMod
{
public readonly struct FrisbeeScore
{
public int ThrowDistanceInMetres { get; }
public int DistanceToPoleInMetres { get; }
public FrisbeeScore(int throwDistanceInMetres, int distanceToPoleInMetres)
{
ThrowDistanceInMetres = throwDistanceInMetres;
DistanceToPoleInMetres = distanceToPoleInMetres;
}
}
[BepInPlugin("com.github.glarmer.hershysmod", "HersysMod", "0.1.0")]
public class Plugin : BaseUnityPlugin, IInRoomCallbacks, IOnEventCallback
{
private const byte TextSyncEventCode = 187;
private const byte TextUpdateEventType = 1;
private const byte TextSnapshotRequestEventType = 2;
private const string TargetFlagRadiusRoomProperty = "TargetFlagRadiusInMetres";
public static ConfigurationHandler ConfigurationHandler;
private readonly Harmony _harmony = new Harmony("com.github.glarmer.hershysmod");
private ModConfigurationUI _ui;
private GameObject _modUIGameObject;
private bool _pushedNameColor = false;
private bool _requestedTextSnapshot;
public const string Id = "com.github.glarmer.hershysmod";
internal static ManualLogSource Log { get; private set; }
internal static Plugin Instance { get; private set; }
public static string Name => "HersysMod";
public static string Version => "0.1.0";
private void Awake()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Expected O, but got Unknown
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
ConfigurationHandler = new ConfigurationHandler(((BaseUnityPlugin)this).Config);
GameObject val = new GameObject(Name + "_Menu_UI");
Object.DontDestroyOnLoad((Object)(object)val);
_ui = val.AddComponent<ModConfigurationUI>();
_ui.Init(new List<Option>
{
Option.InputAction("Menu Key", ConfigurationHandler.ConfigMenuKey),
Option.InputAction("Scoreboard Key", ConfigurationHandler.ConfigScoreboardKey),
Option.InputAction("Toggle Target Flag Message Key", ConfigurationHandler.ConfigTargetFlagMessageKey),
Option.Int("Target Flag Radius (metres)", ConfigurationHandler.ConfigTargetFlagRadiusInMetres, 5, 50),
Option.Bool("Haze Fog Enabled", ConfigurationHandler.ConfigCalderaHazeEnabled),
Option.Colour("Name Colour", ConfigurationHandler.NameColourR, ConfigurationHandler.NameColourG, ConfigurationHandler.NameColourB)
});
GameObject val2 = new GameObject(Name + "_Score_UI");
Object.DontDestroyOnLoad((Object)(object)val2);
val2.AddComponent<ScoreboardUI>();
_harmony.PatchAll(typeof(JungleMushroomSporeExplosionCounter));
_harmony.PatchAll(typeof(MushroomBounceCounter));
_harmony.PatchAll(typeof(CheckpointFlagPatches));
_harmony.PatchAll(typeof(ItemPatches));
_harmony.PatchAll(typeof(FrisbeePatches));
PhotonNetwork.AddCallbackTarget((object)this);
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void Update()
{
if (ConfigurationHandler.MenuAction.WasPerformedThisFrame())
{
ModConfigurationUI.Instance.ToggleMenu();
}
if (ConfigurationHandler.ScoreBoardAction.WasPerformedThisFrame())
{
ScoreboardUI.Instance.ToggleMenu();
}
if (ConfigurationHandler.TargetFlagMessageAction.WasPerformedThisFrame())
{
TargetFlag.ToggleMessageVisibility();
}
if (!_pushedNameColor && PhotonNetwork.InRoom)
{
try
{
ConfigurationHandler.PushNameColourToPhoton();
}
catch
{
}
_pushedNameColor = true;
}
if (!PhotonNetwork.InRoom)
{
_requestedTextSnapshot = false;
}
else if (!PhotonNetwork.IsMasterClient && !_requestedTextSnapshot)
{
RequestTextSnapshot();
}
ConfigurationHandler.Update();
}
private void OnDestroy()
{
PhotonNetwork.RemoveCallbackTarget((object)this);
}
internal void BroadcastTextUpdate(string key, int languageIndex, string value)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Expected O, but got Unknown
if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
{
RaiseTextEvent(new object[4]
{
(byte)1,
key,
languageIndex,
value
}, new RaiseEventOptions
{
Receivers = (ReceiverGroup)0
});
}
}
internal void PublishTargetFlagRadius()
{
//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_0049: Expected O, but got Unknown
//IL_0051: Expected O, but got Unknown
if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient && PhotonNetwork.CurrentRoom != null)
{
Room currentRoom = PhotonNetwork.CurrentRoom;
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)"TargetFlagRadiusInMetres", (object)ConfigurationHandler.ConfigTargetFlagRadiusInMetres.Value);
currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
}
}
public void OnJoinedRoom()
{
ConfigurationHandler.StartScoreHistorySession();
MushroomBounceCounter.Reset();
ScoreboardUI.Instance?.RefreshScoreboard();
if (PhotonNetwork.IsMasterClient)
{
PublishTargetFlagRadius();
return;
}
ApplyTargetFlagRadiusFromRoom();
RequestTextSnapshot();
}
public void OnPlayerEnteredRoom(Player newPlayer)
{
ConfigurationHandler.SaveScoreHistory(newPlayer);
}
public void OnMasterClientSwitched(Player newMasterClient)
{
if (newMasterClient == PhotonNetwork.LocalPlayer)
{
ConfigurationHandler.ClearHostTargetFlagRadius();
PublishTargetFlagRadius();
SendTextSnapshot();
}
else
{
_requestedTextSnapshot = false;
ScoreboardUI.Instance?.CloseIfNotHost();
}
}
public void OnEvent(EventData photonEvent)
{
if (photonEvent.Code != 187 || !(photonEvent.CustomData is object[] array) || array.Length == 0 || !(array[0] is byte b))
{
return;
}
switch (b)
{
case 2:
if (PhotonNetwork.IsMasterClient && photonEvent.Sender > 0)
{
SendTextSnapshot(photonEvent.Sender);
}
break;
case 1:
if (array.Length == 4 && PhotonNetwork.MasterClient != null && photonEvent.Sender == PhotonNetwork.MasterClient.ActorNumber && array[1] is string key && array[2] is int languageIndex && array[3] is string value)
{
ConfigurationHandler.ApplyNetworkedText(key, languageIndex, value);
}
break;
}
}
public void OnPlayerLeftRoom(Player otherPlayer)
{
ConfigurationHandler.SaveScoreHistory(otherPlayer);
}
public void OnRoomPropertiesUpdate(Hashtable propertiesThatChanged)
{
if (!PhotonNetwork.IsMasterClient && ((Dictionary<object, object>)(object)propertiesThatChanged).TryGetValue((object)"TargetFlagRadiusInMetres", out object value) && value is int radiusInMetres)
{
ConfigurationHandler.ApplyHostTargetFlagRadius(radiusInMetres);
}
bool flag = false;
foreach (object key in ((Dictionary<object, object>)(object)propertiesThatChanged).Keys)
{
if (key is string propertyName && MushroomBounceCounter.IsMushroomBounceRoomProperty(propertyName))
{
flag = true;
break;
}
}
if (flag)
{
Player[] playerList = PhotonNetwork.PlayerList;
foreach (Player player in playerList)
{
ConfigurationHandler.SaveScoreHistory(player);
}
ScoreboardUI.Instance?.RefreshScoreboard();
}
}
public void OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
{
bool flag = ((Dictionary<object, object>)(object)changedProps).ContainsKey((object)"SporeExplosions");
if (flag)
{
ConfigurationHandler.SaveScoreHistory(targetPlayer);
}
if (flag || ((Dictionary<object, object>)(object)changedProps).ContainsKey((object)"NameColour"))
{
ScoreboardUI.Instance?.RefreshScoreboard();
}
}
public void OnLeftRoom()
{
ConfigurationHandler.EndScoreHistorySession();
ConfigurationHandler.ClearHostTargetFlagRadius();
}
private void ApplyTargetFlagRadiusFromRoom()
{
Room currentRoom = PhotonNetwork.CurrentRoom;
if (currentRoom != null && ((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)"TargetFlagRadiusInMetres", out object value) && value is int radiusInMetres)
{
ConfigurationHandler.ApplyHostTargetFlagRadius(radiusInMetres);
}
}
private void SendTextSnapshot(int targetActorNumber = 0)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_002e: Unknown result type (might be due to invalid IL or missing references)
if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
{
object obj;
if (targetActorNumber <= 0)
{
obj = (object)new RaiseEventOptions
{
Receivers = (ReceiverGroup)0
};
}
else
{
RaiseEventOptions val = new RaiseEventOptions();
val.TargetActors = new int[1] { targetActorNumber };
obj = val;
}
RaiseEventOptions options = (RaiseEventOptions)obj;
int sent = 0;
ConfigurationHandler.ForEachTextEntry(delegate(string key, int languageIndex, string value)
{
RaiseTextEvent(new object[4]
{
(byte)1,
key,
languageIndex,
value
}, options);
sent++;
});
Log.LogInfo((object)string.Format("Sent {0} text strings{1}.", sent, (targetActorNumber > 0) ? $" to player {targetActorNumber}" : " to room"));
}
}
private void RequestTextSnapshot()
{
//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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
if (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient)
{
RaiseTextEvent(new object[1] { (byte)2 }, new RaiseEventOptions
{
Receivers = (ReceiverGroup)2
});
_requestedTextSnapshot = true;
}
}
private static void RaiseTextEvent(object[] payload, RaiseEventOptions options)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
PhotonNetwork.RaiseEvent((byte)187, (object)payload, options, SendOptions.SendReliable);
}
}
public static class PostFogToggle
{
private static GameObject _postFogObject;
public static void TogglePostFog(bool enabled)
{
if ((Object)(object)_postFogObject == (Object)null)
{
_postFogObject = GameObject.Find("Post Fog");
}
if ((Object)(object)_postFogObject == (Object)null)
{
Plugin.Log.LogError((object)"Can't find Post Fog, can't toggle");
}
else
{
_postFogObject.SetActive(enabled);
}
}
}
public class TargetFlag : MonoBehaviour
{
private const string InputIconPath = "GAME/GUIManager/Canvas_HUD/Prompts/InteractPrompts/UI_interactPrompt_E/UI_InputIcon";
private bool _promptVisible;
public static GameObject? CurrentFlag = null;
private GameObject? _infiniteStamSphereVfx;
private GameObject? _inputIcon;
private string _textName = " ";
private string _textInteract = " ";
public static List<Item> TrackedFrisbees = new List<Item>();
private static readonly Dictionary<int, FrisbeeScore> FrisbeeScoresByActorNumber = new Dictionary<int, FrisbeeScore>();
private static bool _messageVisible = true;
private float _infiniteStamSphereScaleFactor = 1f;
private static float RadiusInMetres => Plugin.ConfigurationHandler.TargetFlagRadiusInMetres;
public static int? GetFrisbeeScore(Player? player)
{
if (player != null && FrisbeeScoresByActorNumber.TryGetValue(player.ActorNumber, out var value))
{
return value.ThrowDistanceInMetres;
}
return null;
}
public static int? GetFrisbeeToPoleDistance(Player? player)
{
if (player != null && FrisbeeScoresByActorNumber.TryGetValue(player.ActorNumber, out var value))
{
return value.DistanceToPoleInMetres;
}
return null;
}
public static void ToggleMessageVisibility()
{
_messageVisible = !_messageVisible;
}
private void Awake()
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)CurrentFlag != (Object)null)
{
Plugin.Log.LogInfo((object)"An existing flag has been placed, delete it");
PhotonNetwork.Destroy(CurrentFlag);
}
FrisbeeScoresByActorNumber.Clear();
CurrentFlag = ((Component)this).gameObject;
((Component)this).transform.localScale = new Vector3(3f, 3f, 3f);
SpawnInfiniteStamSphereVfx();
ShowPrompt("Flag 1", " ");
Object.Destroy((Object)(object)((Component)this).gameObject.GetComponent<CheckpointFlag>());
}
private void OnDestroy()
{
if ((Object)(object)CurrentFlag == (Object)(object)((Component)this).gameObject)
{
SetInputIconActive(active: true);
}
if ((Object)(object)_infiniteStamSphereVfx != (Object)null)
{
Object.Destroy((Object)(object)_infiniteStamSphereVfx);
}
}
private void SetInputIconActive(bool active)
{
if (_inputIcon == null)
{
_inputIcon = GameObject.Find("GAME/GUIManager/Canvas_HUD/Prompts/InteractPrompts/UI_interactPrompt_E/UI_InputIcon");
}
if ((Object)(object)_inputIcon != (Object)null)
{
_inputIcon.SetActive(active);
}
}
private void SpawnInfiniteStamSphereVfx()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
InfiniteStamSphere val = Character.localCharacter?.refs.infiniteStamSphere;
if ((Object)(object)val == (Object)null)
{
Plugin.Log.LogWarning((object)"Could not spawn VFX_InfiniteStamSphere: the local character is not available.");
return;
}
_infiniteStamSphereVfx = ((Component)Object.Instantiate<InfiniteStamSphere>(val, ((Component)this).transform.position, Quaternion.identity)).gameObject;
Object.Destroy((Object)(object)_infiniteStamSphereVfx.GetComponent<InfiniteStamSphere>());
_infiniteStamSphereScaleFactor = _infiniteStamSphereVfx.transform.localScale.x / 6.5f;
ApplyRadius();
((Object)_infiniteStamSphereVfx).name = "VFX_InfiniteStamSphere_TargetFlag";
}
public static void RefreshRadius()
{
GameObject? currentFlag = CurrentFlag;
if (currentFlag != null)
{
currentFlag.GetComponent<TargetFlag>()?.ApplyRadius();
}
}
private void ApplyRadius()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
GameObject? infiniteStamSphereVfx = _infiniteStamSphereVfx;
if (infiniteStamSphereVfx != null)
{
infiniteStamSphereVfx.transform.localScale = new Vector3(_infiniteStamSphereScaleFactor * RadiusInMetres, 1000f, _infiniteStamSphereScaleFactor * RadiusInMetres);
}
}
private void Start()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
GameObject? infiniteStamSphereVfx = _infiniteStamSphereVfx;
if (infiniteStamSphereVfx != null)
{
((Renderer)infiniteStamSphereVfx.GetComponent<MeshRenderer>()).material.color = new Color(0.2941f, 1f, 0f, 0.86f);
}
GameObject? infiniteStamSphereVfx2 = _infiniteStamSphereVfx;
object obj;
if (infiniteStamSphereVfx2 == null)
{
obj = null;
}
else
{
Transform obj2 = infiniteStamSphereVfx2.transform.Find("Inverse");
obj = ((obj2 != null) ? ((Component)obj2).gameObject : null);
}
GameObject val = (GameObject)obj;
if (val != null)
{
((Renderer)val.GetComponent<MeshRenderer>()).material.color = new Color(0.2941f, 1f, 0f, 0.86f);
}
}
public void ShowPrompt(string itemName, string actionText)
{
_promptVisible = true;
GUIManager instance = GUIManager.instance;
if (!((Object)(object)instance == (Object)null))
{
_textName = itemName;
_textInteract = actionText;
}
}
public void HidePrompt()
{
_promptVisible = false;
SetInputIconActive(active: true);
if ((Object)(object)GUIManager.instance != (Object)null)
{
GUIManager.instance.RefreshInteractablePrompt();
}
}
private void LateUpdate()
{
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
if (!PhotonNetwork.IsMasterClient || !_promptVisible || (Object)(object)GUIManager.instance == (Object)null)
{
return;
}
GUIManager instance = GUIManager.instance;
SetInputIconActive(active: false);
if (!_messageVisible)
{
instance.interactName.SetActive(false);
instance.interactPromptPrimary.SetActive(false);
return;
}
instance.interactName.SetActive(true);
instance.interactPromptPrimary.SetActive(true);
instance.interactPromptSecondary.SetActive(false);
instance.interactPromptHold.SetActive(false);
_textName = "";
for (int num = TrackedFrisbees.Count - 1; num >= 0; num--)
{
Item val = TrackedFrisbees[num];
if ((Object)(object)val == (Object)null)
{
TrackedFrisbees.RemoveAt(num);
}
else
{
float num2 = Vector3.Distance(CurrentFlag.transform.position, val.transform.position);
int num3 = Mathf.RoundToInt(num2 * CharacterStats.unitsToMeters);
string arg = (((Object)(object)val.lastThrownCharacter == (Object)null) ? "Unknown" : val.lastThrownCharacter.characterName);
_textName += $"{arg}'s frisbee: {num3} meters<br>";
}
}
((TMP_Text)instance.interactNameText).text = _textName;
((TMP_Text)instance.interactPromptText).text = _textInteract;
}
public static void RecordFarthestFrisbeeScore(Item frisbee, int frisbeeToPoleDistanceInMetres, int frisbeeThrowDistanceInMetres)
{
Character lastThrownCharacter = frisbee.lastThrownCharacter;
object obj;
if (lastThrownCharacter == null)
{
obj = null;
}
else
{
PhotonView photonView = ((MonoBehaviourPun)lastThrownCharacter).photonView;
obj = ((photonView != null) ? photonView.Owner : null);
}
Player val = (Player)obj;
if (val == null || (float)frisbeeToPoleDistanceInMetres > RadiusInMetres)
{
return;
}
if (FrisbeeScoresByActorNumber.TryGetValue(val.ActorNumber, out var value))
{
bool flag = frisbeeThrowDistanceInMetres < value.ThrowDistanceInMetres;
bool flag2 = frisbeeThrowDistanceInMetres == value.ThrowDistanceInMetres && frisbeeToPoleDistanceInMetres >= value.DistanceToPoleInMetres;
if (flag || flag2)
{
return;
}
}
FrisbeeScoresByActorNumber[val.ActorNumber] = new FrisbeeScore(frisbeeThrowDistanceInMetres, frisbeeToPoleDistanceInMetres);
ScoreboardUI.Instance?.RefreshScoreboard();
Plugin.ConfigurationHandler?.SaveScoreHistory(val);
Plugin.Log.LogInfo((object)("Frisbee new score: " + val.NickName));
}
}
}
namespace HersysMod.Scoreboard
{
public class ScoreboardUI : MenuWindow
{
private class Column
{
public string Header;
public Func<Player, string> GetValue;
public Column(string header, Func<Player, string> getValue)
{
Header = header;
GetValue = getValue;
}
}
public static ScoreboardUI Instance;
private bool _visible;
private GameObject _scoreboard;
private RectTransform _content;
private GridLayoutGroup _grid;
private const float CellWidth = 220f;
private const float CellHeight = 32f;
private const float CellSpacing = 4f;
private readonly List<Column> _columns = new List<Column>();
private void Awake()
{
if ((Object)(object)Instance != (Object)null)
{
Object.Destroy((Object)(object)Instance);
}
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
CreateScoreboard();
AddColumn("Player", (Player player) => player.character.characterName);
AddColumn("Mushroom Bounces", (Player player) => MushroomBounceCounter.GetBounceCount(player.view.Owner).ToString());
AddColumn("Bombshrooms", (Player player) => JungleMushroomSporeExplosionCounter.GetExplosionCount(player.view.Owner).ToString());
AddColumn("Farthest Frisbee", (Player player) => TargetFlag.GetFrisbeeScore(player.view.Owner)?.ToString() ?? "-");
((MenuWindow)this).StartClosed();
}
public void ToggleMenu()
{
if (!PhotonNetwork.IsMasterClient)
{
CloseMenu();
return;
}
_visible = !_visible;
if (_visible)
{
RefreshScoreboard();
_scoreboard.SetActive(true);
((MenuWindow)this).Open();
}
else
{
CloseMenu();
}
}
public void CloseIfNotHost()
{
if (!PhotonNetwork.IsMasterClient)
{
CloseMenu();
}
}
private void CloseMenu()
{
_visible = false;
_scoreboard.SetActive(false);
((MenuWindow)this).Close();
}
public void AddColumn(string header, Func<Player, string> getValue)
{
_columns.Add(new Column(header, getValue));
}
public void ClearColumns()
{
_columns.Clear();
}
public void RefreshScoreboard()
{
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_content == (Object)null || _columns.Count == 0)
{
return;
}
foreach (Transform item in (Transform)_content)
{
Transform val = item;
Object.Destroy((Object)(object)((Component)val).gameObject);
}
_grid.constraintCount = _columns.Count;
float num = (float)_columns.Count * 220f + (float)(_columns.Count - 1) * 4f;
_content.SetSizeWithCurrentAnchors((Axis)0, num);
foreach (Column column in _columns)
{
CreateCell(column.Header, header: true);
}
foreach (Player allPlayer in PlayerHandler.GetAllPlayers())
{
Color playerColour = GetPlayerColour(allPlayer.view.Owner);
foreach (Column column2 in _columns)
{
string value;
try
{
value = column2.GetValue(allPlayer);
}
catch
{
value = "-";
}
CreateCell(value, header: false, playerColour);
}
}
}
private static Color GetPlayerColour(Player player)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
Color result = default(Color);
if (((Dictionary<object, object>)(object)player.CustomProperties).TryGetValue((object)"NameColour", out object value) && value is string text && ColorUtility.TryParseHtmlString("#" + text, ref result))
{
return result;
}
return Color.white;
}
private void CreateScoreboard()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Expected O, but got Unknown
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Expected O, but got Unknown
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Expected O, but got Unknown
//IL_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
_scoreboard = new GameObject("Scoreboard", new Type[4]
{
typeof(RectTransform),
typeof(Canvas),
typeof(CanvasScaler),
typeof(GraphicRaycaster)
});
_scoreboard.transform.SetParent(((Component)this).transform, false);
Canvas component = _scoreboard.GetComponent<Canvas>();
component.renderMode = (RenderMode)0;
component.sortingOrder = 100;
CanvasScaler component2 = _scoreboard.GetComponent<CanvasScaler>();
component2.uiScaleMode = (ScaleMode)1;
component2.referenceResolution = new Vector2(1920f, 1080f);
GameObject val = new GameObject("ScrollView", new Type[3]
{
typeof(RectTransform),
typeof(Image),
typeof(ScrollRect)
});
val.transform.SetParent(_scoreboard.transform, false);
RectTransform component3 = val.GetComponent<RectTransform>();
component3.anchorMin = new Vector2(0.5f, 0.5f);
component3.anchorMax = new Vector2(0.5f, 0.5f);
component3.pivot = new Vector2(0.5f, 0.5f);
component3.sizeDelta = new Vector2(1000f, 600f);
Image component4 = val.GetComponent<Image>();
((Graphic)component4).color = new Color(0f, 0f, 0f, 0.75f);
GameObject val2 = new GameObject("Viewport", new Type[2]
{
typeof(RectTransform),
typeof(RectMask2D)
});
val2.transform.SetParent(val.transform, false);
RectTransform component5 = val2.GetComponent<RectTransform>();
component5.anchorMin = Vector2.zero;
component5.anchorMax = Vector2.one;
component5.offsetMin = Vector2.zero;
component5.offsetMax = Vector2.zero;
GameObject val3 = new GameObject("Content", new Type[3]
{
typeof(RectTransform),
typeof(GridLayoutGroup),
typeof(ContentSizeFitter)
});
val3.transform.SetParent(val2.transform, false);
_content = val3.GetComponent<RectTransform>();
_content.anchorMin = new Vector2(0f, 1f);
_content.anchorMax = new Vector2(0f, 1f);
_content.pivot = new Vector2(0f, 1f);
_content.anchoredPosition = Vector2.zero;
_grid = val3.GetComponent<GridLayoutGroup>();
_grid.cellSize = new Vector2(220f, 32f);
_grid.spacing = new Vector2(4f, 4f);
_grid.startCorner = (Corner)0;
_grid.startAxis = (Axis)0;
((LayoutGroup)_grid).childAlignment = (TextAnchor)0;
_grid.constraint = (Constraint)1;
_grid.constraintCount = 1;
ContentSizeFitter component6 = val3.GetComponent<ContentSizeFitter>();
component6.horizontalFit = (FitMode)0;
component6.verticalFit = (FitMode)2;
ScrollRect component7 = val.GetComponent<ScrollRect>();
component7.viewport = component5;
component7.content = _content;
component7.horizontal = true;
component7.vertical = true;
component7.movementType = (MovementType)2;
component7.scrollSensitivity = 30f;
_scoreboard.SetActive(false);
}
private void CreateCell(string value, bool header, Color? colour = null)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(header ? "Header" : "Cell", new Type[2]
{
typeof(RectTransform),
typeof(TextMeshProUGUI)
});
val.transform.SetParent((Transform)(object)_content, false);
TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
((TMP_Text)component).text = value;
((TMP_Text)component).fontSize = 22f;
((TMP_Text)component).alignment = (TextAlignmentOptions)514;
((Graphic)component).color = (Color)(((??)colour) ?? Color.white);
if (header)
{
((TMP_Text)component).fontStyle = (FontStyles)1;
}
}
}
}
namespace HersysMod.Patches
{
public class CheckpointFlagPatches
{
[HarmonyPatch(typeof(CheckpointFlag), "SetColor")]
[HarmonyPrefix]
private static bool SetColorPatch(CheckpointFlag __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)((Component)__instance).gameObject != (Object)null)
{
MaterialPropertyBlock val = new MaterialPropertyBlock();
val.SetColor(CheckpointFlag.FlagColorPropertyId, new Color(1f, 1f, 1f));
__instance.flagRenderer.SetPropertyBlock(val);
((Component)__instance).gameObject.AddComponent<TargetFlag>();
}
else
{
Plugin.Log.LogError((object)"The current flag is null, can't do the stuff");
}
return false;
}
[HarmonyPatch(typeof(GameUtils), "IncrementPermanentItemsPlaced")]
[HarmonyPrefix]
private static bool IncrementPermanentItemsPlacedPatch()
{
if (Character.localCharacter.inAirport)
{
return false;
}
return true;
}
}
public class FrisbeePatches
{
[HarmonyPatch(typeof(Frisbee), "OnCollisionEnter")]
[HarmonyPrefix]
private static void OnCollisionEnterPatch(Frisbee __instance)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
if (TargetFlag.TrackedFrisbees.Contains(__instance.item) && (Object)(object)TargetFlag.CurrentFlag != (Object)null)
{
float num = Vector3.Distance(TargetFlag.CurrentFlag.transform.position, __instance.item.transform.position);
int frisbeeToPoleDistanceInMetres = Mathf.RoundToInt(num * CharacterStats.unitsToMeters);
int frisbeeThrowDistanceInMetres = Mathf.RoundToInt(__instance.throwDistance * CharacterStats.unitsToMeters);
TargetFlag.RecordFarthestFrisbeeScore(__instance.item, frisbeeToPoleDistanceInMetres, frisbeeThrowDistanceInMetres);
}
}
}
public class ItemPatches
{
[HarmonyPatch(typeof(Item), "RPC_SetThrownData")]
[HarmonyPostfix]
private static void RPC_SetThrownDataPatch(Item __instance)
{
if (((Object)((Component)__instance).gameObject).name.Contains("Frisbee"))
{
TargetFlag.TrackedFrisbees.Add(__instance);
}
}
}
public class JungleMushroomSporeExplosionCounter
{
private const string ScorePropertyPrefix = "SporeExplosions_";
public static int GetExplosionCount(Player? player)
{
if (player == null || PhotonNetwork.CurrentRoom == null)
{
return 0;
}
object value;
return (((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)GetScorePropertyName(player.ActorNumber), out value) && value is int num) ? num : 0;
}
[HarmonyPatch(typeof(TriggerEvent), "OnTriggerEnter")]
[HarmonyPrefix]
private static void CaptureTriggeringCharacter(TriggerEvent __instance, Collider other, out Character? __state)
{
__state = null;
if (!(((Object)((Component)__instance).gameObject).name != "Jungle_SporeMushroomExplo") && !__instance.hasTriggered && !__instance.hasActivated)
{
PhotonView componentInParent = ((Component)__instance).GetComponentInParent<PhotonView>();
if (!((Object)(object)componentInParent == (Object)null) && componentInParent.IsMine)
{
__state = ((Component)other).GetComponentInParent<Character>();
}
}
}
[HarmonyPatch(typeof(TriggerEvent), "OnTriggerEnter")]
[HarmonyPostfix]
private static void CountConfirmedExplosion(TriggerEvent __instance, Character? __state)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0060: Expected O, but got Unknown
object obj;
if (__state == null)
{
obj = null;
}
else
{
PhotonView photonView = ((MonoBehaviourPun)__state).photonView;
obj = ((photonView != null) ? photonView.Owner : null);
}
if (obj != null && __instance.hasActivated)
{
Player owner = ((MonoBehaviourPun)__state).photonView.Owner;
int num = GetExplosionCount(owner) + 1;
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)GetScorePropertyName(owner.ActorNumber), (object)num);
Hashtable val2 = val;
Room currentRoom = PhotonNetwork.CurrentRoom;
if (currentRoom != null)
{
currentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
}
Plugin.Log.LogInfo((object)$"Updated {owner.NickName}'s SporeExplosions to {num}");
}
}
private static string GetScorePropertyName(int actorNumber)
{
return string.Format("{0}{1}", "SporeExplosions_", actorNumber);
}
}
public class MushroomBounceCounter
{
private const string RoomPropertyPrefix = "MushroomBounces_";
private static int count;
public static bool IsMushroomBounceRoomProperty(string propertyName)
{
return propertyName.StartsWith("MushroomBounces_", StringComparison.Ordinal);
}
public static int GetBounceCount(Player player)
{
Room currentRoom = PhotonNetwork.CurrentRoom;
if (currentRoom != null && ((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)GetRoomPropertyKey(player.ActorNumber), out object value) && value is int result)
{
return result;
}
return 0;
}
public static void Reset()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_0054: Expected O, but got Unknown
count = 0;
try
{
if (PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null && PhotonNetwork.LocalPlayer != null)
{
Room currentRoom = PhotonNetwork.CurrentRoom;
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)GetRoomPropertyKey(PhotonNetwork.LocalPlayer.ActorNumber), (object)0);
currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
Plugin.Log.LogInfo((object)"Reset MushroomBounces for the new room session.");
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Failed to reset MushroomBounces: {arg}");
}
}
[HarmonyPatch(typeof(CollisionModifier), "TriggerCharacterBouncedEvents")]
[HarmonyPostfix]
private static void Postfix(CollisionModifier __instance, Character bouncedCharacter)
{
if (!((Object)((Component)__instance).gameObject).name.Contains(bouncedCharacter.characterName))
{
count++;
Plugin.Log.LogInfo((object)$"Number of mushroom bounces: {count} by {bouncedCharacter.characterName}");
MakeMushroomCapsGreen(((Component)__instance).gameObject);
((Object)((Component)__instance).gameObject).name = ((Object)((Component)__instance).gameObject).name + "_" + bouncedCharacter.characterName;
if (((MonoBehaviourPun)bouncedCharacter).photonView.IsMine)
{
PushMushroomBouncesToPhoton();
}
}
}
private static void PushMushroomBouncesToPhoton()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Expected O, but got Unknown
//IL_0050: Expected O, but got Unknown
try
{
if (PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null && PhotonNetwork.LocalPlayer != null)
{
int num = GetBounceCount(PhotonNetwork.LocalPlayer) + 1;
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)GetRoomPropertyKey(PhotonNetwork.LocalPlayer.ActorNumber), (object)num);
Hashtable val2 = val;
PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
Plugin.Log.LogInfo((object)$"Updated MushroomBounces to {num}");
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Failed to update MushroomBounces {arg}");
}
}
private static string GetRoomPropertyKey(int actorNumber)
{
return string.Format("{0}{1}", "MushroomBounces_", actorNumber);
}
private static void MakeMushroomCapsGreen(GameObject parent)
{
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
string[] array = new string[5] { "_Tint", "_BaseColor", "_Color1", "_Color21", "_Color3" };
Renderer[] componentsInChildren = parent.GetComponentsInChildren<Renderer>(true);
float num = default(float);
float num2 = default(float);
float num3 = default(float);
foreach (Renderer val in componentsInChildren)
{
if (!((Object)val).name.StartsWith("sourceName_LOD_") || (Object)(object)((Component)val).transform.parent == (Object)null || ((Object)((Component)val).transform.parent).name.IndexOf("Top Mush", StringComparison.OrdinalIgnoreCase) < 0)
{
continue;
}
Material[] materials = val.materials;
foreach (Material val2 in materials)
{
Shader shader = val2.shader;
if (((shader != null) ? ((Object)shader).name : null) != "W/Peak_Standard")
{
continue;
}
string[] array2 = array;
foreach (string text in array2)
{
if (val2.HasProperty(text))
{
Color color = val2.GetColor(text);
Color.RGBToHSV(color, ref num, ref num2, ref num3);
if (!(num2 < 0.2f) && (!(num > 0.14f) || !(num < 0.94f)))
{
Color val3 = Color.HSVToRGB(Mathf.Repeat(num + 1f / 3f, 1f), num2, num3, true);
val3.a = color.a;
val2.SetColor(text, val3);
}
}
}
}
}
}
}
}
namespace HersysMod.Config
{
public class ConfigurationHandler
{
private readonly ConfigFile _config;
public ConfigEntry<string> ConfigMenuKey;
public ConfigEntry<string> ConfigScoreboardKey;
public ConfigEntry<string> ConfigTargetFlagMessageKey;
public ConfigEntry<bool> ConfigCalderaHazeEnabled;
public ConfigEntry<int> ConfigHiderGracePeriod;
public ConfigEntry<int> ConfigTargetFlagRadiusInMetres;
public ConfigEntry<int> NameColourR;
public ConfigEntry<int> NameColourG;
public ConfigEntry<int> NameColourB;
private ConfigFile _textConfig;
private readonly Dictionary<string, ConfigEntry<string>[]> _textConfigEntries = new Dictionary<string, ConfigEntry<string>[]>();
private readonly ConfigFile _scoreHistoryConfig;
private string? _scoreHistorySessionSection;
private int _nextScoreHistorySessionNumber;
private FileSystemWatcher _textWatcher;
private volatile bool _textConfigChanged;
private float _reloadTime = -1f;
private int? _hostTargetFlagRadiusInMetres;
public InputAction MenuAction { get; private set; }
public InputAction ScoreBoardAction { get; private set; }
public InputAction TargetFlagMessageAction { get; private set; }
public float TargetFlagRadiusInMetres => _hostTargetFlagRadiusInMetres ?? ConfigTargetFlagRadiusInMetres.Value;
private void SetupTextConfiguration()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
string text = Path.Combine(Paths.ConfigPath, "HersysMod.TextConfiguration.cfg");
bool flag = !File.Exists(text);
_textConfig = new ConfigFile(text, false)
{
SaveOnConfigSet = false
};
foreach (KeyValuePair<string, List<string>> item in LocalizedText.mainTable)
{
for (int i = 0; i < 14; i++)
{
if (item.Value[i] != null)
{
string originalKey = item.Key;
string text2 = Convert.ToBase64String(Encoding.UTF8.GetBytes(originalKey)).TrimEnd('=').Replace('+', '-')
.Replace('/', '_');
int index = i;
ConfigEntry<string> configEntry = _textConfig.Bind<string>($"{i}: {((object)(Language)i/*cast due to .constrained prefix*/).ToString()}", text2, item.Value[i], "Edit this value to change " + originalKey + "'s text in game.");
if (!_textConfigEntries.TryGetValue(originalKey, out ConfigEntry<string>[] value))
{
value = new ConfigEntry<string>[14];
_textConfigEntries.Add(originalKey, value);
}
value[i] = configEntry;
item.Value[i] = configEntry.Value;
configEntry.SettingChanged += delegate
{
OnTextValueChanged(configEntry, originalKey, index);
};
}
}
}
if (flag)
{
_textConfig.Save();
}
_textWatcher = new FileSystemWatcher(Paths.ConfigPath, Path.GetFileName(_textConfig.ConfigFilePath));
_textWatcher.NotifyFilter = NotifyFilters.Size | NotifyFilters.LastWrite;
_textWatcher.Changed += delegate
{
_textConfigChanged = true;
};
_textWatcher.EnableRaisingEvents = true;
}
private void OnTextValueChanged(ConfigEntry<string> configEntry, string key, int index)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
{
LocalizedText.mainTable[key][index] = configEntry.Value;
Plugin.Log.LogInfo((object)("Updated " + key + ": " + configEntry.Value + " for " + ((object)(Language)index/*cast due to .constrained prefix*/).ToString()));
Plugin.Instance?.BroadcastTextUpdate(key, index, configEntry.Value);
}
}
public void ForEachTextEntry(Action<string, int, string> action)
{
foreach (KeyValuePair<string, ConfigEntry<string>[]> textConfigEntry in _textConfigEntries)
{
for (int i = 0; i < textConfigEntry.Value.Length; i++)
{
if (LocalizedText.mainTable.TryGetValue(textConfigEntry.Key, out var value) && i < value.Count)
{
action(textConfigEntry.Key, i, value[i]);
}
}
}
}
public void ApplyNetworkedText(string key, int languageIndex, string value)
{
if (!LocalizedText.mainTable.TryGetValue(key, out var value2) || languageIndex < 0 || languageIndex >= value2.Count)
{
Plugin.Log.LogWarning((object)$"Ignored invalid text update for {key} ({languageIndex}).");
}
else
{
value2[languageIndex] = value;
}
}
public List<Option> FindTextOptions(string search)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected I4, but got Unknown
List<Option> list = new List<Option>();
int num = (int)LocalizedText.CURRENT_LANGUAGE;
if ((num < 0 || num >= 14) ? true : false)
{
return list;
}
foreach (KeyValuePair<string, ConfigEntry<string>[]> textConfigEntry in _textConfigEntries)
{
ConfigEntry<string> val = textConfigEntry.Value[num];
if (val.Value.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0)
{
list.Add(Option.String(textConfigEntry.Key, val));
}
}
return list;
}
public void SaveTextConfiguration()
{
_textConfig.Save();
}
public void ApplyHostTargetFlagRadius(int radiusInMetres)
{
_hostTargetFlagRadiusInMetres = Mathf.Clamp(radiusInMetres, 5, 50);
TargetFlag.RefreshRadius();
}
public void ClearHostTargetFlagRadius()
{
_hostTargetFlagRadiusInMetres = null;
TargetFlag.RefreshRadius();
}
public void StartScoreHistorySession()
{
if (PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null)
{
_nextScoreHistorySessionNumber++;
_scoreHistorySessionSection = $"Session {_nextScoreHistorySessionNumber:D4}";
_scoreHistoryConfig.Bind<string>(_scoreHistorySessionSection, "Room", PhotonNetwork.CurrentRoom.Name, "Photon room recorded for this score-history session.");
_scoreHistoryConfig.Bind<string>(_scoreHistorySessionSection, "Started Eastern Time", GetEasternTime().ToString("O"), "When this client joined the Photon room, in Eastern time.");
Player[] playerList = PhotonNetwork.PlayerList;
foreach (Player player in playerList)
{
SaveScoreHistory(player, save: false);
}
_scoreHistoryConfig.Bind<int>("Score History", "Next Session Number", _nextScoreHistorySessionNumber, "Internal counter used to distinguish score-history sessions.").Value = _nextScoreHistorySessionNumber;
_scoreHistoryConfig.Save();
Plugin.Log.LogInfo((object)("Started " + _scoreHistorySessionSection + " for room " + PhotonNetwork.CurrentRoom.Name + "."));
}
}
public void SaveScoreHistory(Player player)
{
if (_scoreHistorySessionSection == null)
{
StartScoreHistorySession();
}
SaveScoreHistory(player, save: true);
}
public void EndScoreHistorySession()
{
_scoreHistorySessionSection = null;
}
private void SaveScoreHistory(Player player, bool save)
{
if (_scoreHistorySessionSection != null && player != null)
{
string text = $"Player {player.ActorNumber}";
string text2 = (string.IsNullOrWhiteSpace(player.UserId) ? "(unavailable)" : player.UserId);
string text3 = (string.IsNullOrWhiteSpace(player.NickName) ? "(unnamed)" : player.NickName);
int bounceCount = MushroomBounceCounter.GetBounceCount(player);
int explosionCount = JungleMushroomSporeExplosionCounter.GetExplosionCount(player);
int? frisbeeScore = TargetFlag.GetFrisbeeScore(player);
int? frisbeeToPoleDistance = TargetFlag.GetFrisbeeToPoleDistance(player);
_scoreHistoryConfig.Bind<string>(_scoreHistorySessionSection, text + " User ID", text2, (ConfigDescription)null).Value = text2;
_scoreHistoryConfig.Bind<string>(_scoreHistorySessionSection, text + " Name", text3, (ConfigDescription)null).Value = text3;
_scoreHistoryConfig.Bind<int>(_scoreHistorySessionSection, text + " Mushroom Bounces", bounceCount, (ConfigDescription)null).Value = bounceCount;
_scoreHistoryConfig.Bind<int>(_scoreHistorySessionSection, text + " Bombshroom Explosions", explosionCount, (ConfigDescription)null).Value = explosionCount;
_scoreHistoryConfig.Bind<string>(_scoreHistorySessionSection, text + " Farthest Frisbee", frisbeeScore?.ToString() ?? "-", (ConfigDescription)null).Value = frisbeeScore?.ToString() ?? "-";
_scoreHistoryConfig.Bind<string>(_scoreHistorySessionSection, text + " Farthest Frisbee to Pole", frisbeeToPoleDistance?.ToString() ?? "-", (ConfigDescription)null).Value = frisbeeToPoleDistance?.ToString() ?? "-";
if (save)
{
_scoreHistoryConfig.Save();
}
}
}
private static DateTimeOffset GetEasternTime()
{
return TimeZoneInfo.ConvertTime(DateTimeOffset.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
}
public void Update()
{
if (_textConfigChanged)
{
_textConfigChanged = false;
_reloadTime = Time.unscaledTime + 0.25f;
}
if (_reloadTime < 0f || Time.unscaledTime < _reloadTime)
{
return;
}
_reloadTime = -1f;
bool saveOnConfigSet = _textConfig.SaveOnConfigSet;
_textConfig.SaveOnConfigSet = false;
try
{
_textConfig.Reload();
}
finally
{
_textConfig.SaveOnConfigSet = saveOnConfigSet;
}
}
public ConfigurationHandler(ConfigFile configFile)
{
//IL_0036: 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_0048: Expected O, but got Unknown
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Expected O, but got Unknown
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f5: Expected O, but got Unknown
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_032f: Expected O, but got Unknown
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_0369: Expected O, but got Unknown
_config = configFile;
_scoreHistoryConfig = new ConfigFile(Path.Combine(Paths.ConfigPath, "HersysMod.ScoreHistory.cfg"), false)
{
SaveOnConfigSet = false
};
_nextScoreHistorySessionNumber = _scoreHistoryConfig.Bind<int>("Score History", "Next Session Number", 0, "Internal counter used to distinguish score-history sessions.").Value;
_scoreHistoryConfig.Save();
ConfigMenuKey = _config.Bind<string>("General", "Config Menu Key", "<Keyboard>/f8", "Control for opening the mod configuration menu (e.g. <Keyboard>/f2, <Keyboard>/space, <Keyboard>/escape)");
Plugin.Log.LogInfo((object)("ConfigurationHandler: Config Menu Key: " + ConfigMenuKey.Value));
MenuAction = SetupInputAction(ConfigMenuKey.Value);
ConfigMenuKey.SettingChanged += OnMenuKeyChanged;
ConfigScoreboardKey = _config.Bind<string>("General", "Config Score Board Key", "<Keyboard>/tab", "Control path for opening the mod score board (e.g. <Keyboard>/f2, <Keyboard>/space, <Keyboard>/escape)");
Plugin.Log.LogInfo((object)("ConfigurationHandler: Config Score Board Key: " + ConfigScoreboardKey.Value));
ScoreBoardAction = SetupInputAction(ConfigScoreboardKey.Value);
ConfigScoreboardKey.SettingChanged += OnScoreboardKeyChanged;
ConfigTargetFlagMessageKey = _config.Bind<string>("General", "Toggle Target Flag Message Key", "<Keyboard>/f7", "Control for hiding or showing the target flag message.");
TargetFlagMessageAction = SetupInputAction(ConfigTargetFlagMessageKey.Value);
ConfigTargetFlagMessageKey.SettingChanged += OnTargetFlagMessageKeyChanged;
ConfigCalderaHazeEnabled = _config.Bind<bool>("Gameplay", "Haze Enabled", true, "If enabled, the haze-y fog will be visible. Does not effect the timed fog.");
Plugin.Log.LogInfo((object)("ConfigurationHandler: Caldera Haze Enabled: " + ConfigCalderaHazeEnabled.Value));
ConfigCalderaHazeEnabled.SettingChanged += OnCalderaHazeChanged;
ConfigHiderGracePeriod = _config.Bind<int>("Gameplay", "Hider Grace Period", 20, "The time before hiders can be caught in seconds.");
Plugin.Log.LogInfo((object)("ConfigurationHandler: Hider Grace Period: " + ConfigHiderGracePeriod.Value));
ConfigTargetFlagRadiusInMetres = _config.Bind<int>("Gameplay", "Target Flag Radius (metres)", 15, new ConfigDescription("Radius of the target flag's visible area in metres.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 50), Array.Empty<object>()));
ConfigTargetFlagRadiusInMetres.SettingChanged += delegate
{
TargetFlag.RefreshRadius();
Plugin.Instance?.PublishTargetFlagRadius();
};
NameColourR = _config.Bind<int>("Visual", "Name Colour R", 85, new ConfigDescription("Name colour red (0-255)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
NameColourG = _config.Bind<int>("Visual", "Name Colour G", 170, new ConfigDescription("Name colour green (0-255)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
NameColourB = _config.Bind<int>("Visual", "Name Colour B", 255, new ConfigDescription("Name colour blue (0-255)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
NameColourR.SettingChanged += delegate
{
PushNameColourToPhoton();
};
NameColourG.SettingChanged += delegate
{
PushNameColourToPhoton();
};
NameColourB.SettingChanged += delegate
{
PushNameColourToPhoton();
};
SetupTextConfiguration();
}
private void OnCalderaHazeChanged(object sender, EventArgs e)
{
PostFogToggle.TogglePostFog(ConfigCalderaHazeEnabled.Value);
}
private void OnMenuKeyChanged(object sender, EventArgs e)
{
InputAction menuAction = MenuAction;
if (menuAction != null)
{
menuAction.Dispose();
}
MenuAction = SetupInputAction(ConfigMenuKey.Value);
}
private void OnScoreboardKeyChanged(object sender, EventArgs e)
{
InputAction scoreBoardAction = ScoreBoardAction;
if (scoreBoardAction != null)
{
scoreBoardAction.Dispose();
}
ScoreBoardAction = SetupInputAction(ConfigScoreboardKey.Value);
}
private void OnTargetFlagMessageKeyChanged(object sender, EventArgs e)
{
InputAction targetFlagMessageAction = TargetFlagMessageAction;
if (targetFlagMessageAction != null)
{
targetFlagMessageAction.Dispose();
}
TargetFlagMessageAction = SetupInputAction(ConfigTargetFlagMessageKey.Value);
}
private InputAction SetupInputAction(string binding)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
InputAction val = new InputAction((string)null, (InputActionType)1, (string)null, (string)null, (string)null, (string)null);
InputActionSetupExtensions.AddBinding(val, binding, (string)null, (string)null, (string)null);
val.Enable();
return val;
}
public string GetHexColourRGB()
{
int num = Mathf.Clamp(NameColourR.Value, 0, 255);
int num2 = Mathf.Clamp(NameColourG.Value, 0, 255);
int num3 = Mathf.Clamp(NameColourB.Value, 0, 255);
return num.ToString("X2") + num2.ToString("X2") + num3.ToString("X2");
}
public void PushNameColourToPhoton()
{
//IL_0021: 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_0032: Expected O, but got Unknown
//IL_0034: Expected O, but got Unknown
try
{
if (PhotonNetwork.InRoom && PhotonNetwork.LocalPlayer != null)
{
string hexColourRGB = GetHexColourRGB();
Hashtable val = new Hashtable();
((Dictionary<object, object>)val).Add((object)"NameColour", (object)hexColourRGB);
Hashtable val2 = val;
PhotonNetwork.LocalPlayer.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
Plugin.Log.LogInfo((object)("[Config] Updated NameColour to #" + hexColourRGB));
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"[Config] Failed to update NameColour: {arg}");
}
}
}
public class ModConfigurationUI : MenuWindow
{
private List<Option> _options = new List<Option>();
public bool _visible;
private int _selectedIndex;
private bool _waitingForBinding = false;
private Option _bindingTarget;
private Texture2D _whiteTex;
private Texture2D _rainbowTex;
private GUIStyle _titleStyle;
private GUIStyle _rowStyle;
private GUIStyle _textAreaStyle;
private GUIStyle _hintStyle;
private GUIStyle _buttonStyle;
private string titleText;
private string hintText;
private string _textSearch = "";
private Vector2 _textScrollPosition;
private int RowHeight = 32;
private int PanelWidth = 460;
private int Pad = 12;
private int TitleFontSize = 22;
private int OptionFontSize = 16;
private int HintFontSize = 14;
private const int ButtonWidth = 30;
private const int ButtonHeight = 30;
private const int ButtonHintSpacing = 4;
public static ModConfigurationUI Instance;
private void Awake()
{
if ((Object)(object)Instance != (Object)null)
{
Object.Destroy((Object)(object)Instance);
}
Instance = this;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
((MenuWindow)this).StartClosed();
titleText = Plugin.Name + " Settings | v" + Plugin.Version;
hintText = "Open/Close • Click: Change • Scroll Wheel: Adjust Numerical Values";
}
public void Init(List<Option> options)
{
_options = options ?? new List<Option>();
_selectedIndex = 0;
}
private void EnsureStyles()
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00ad: Expected O, but got Unknown
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Expected O, but got Unknown
//IL_00f1: Expected O, but got Unknown
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_whiteTex == (Object)null)
{
_whiteTex = new Texture2D(1, 1);
_whiteTex.SetPixel(0, 0, Color.white);
_whiteTex.Apply();
}
_titleStyle = new GUIStyle(GUI.skin.label)
{
fontSize = TitleFontSize,
alignment = (TextAnchor)3,
fontStyle = (FontStyle)1
};
_rowStyle = new GUIStyle(GUI.skin.label)
{
alignment = (TextAnchor)3,
fontSize = OptionFontSize,
padding = new RectOffset(10, 10, 4, 4)
};
_textAreaStyle = new GUIStyle(GUI.skin.textArea)
{
alignment = (TextAnchor)0,
fontSize = OptionFontSize,
wordWrap = true,
padding = new RectOffset(10, 10, 6, 6)
};
_hintStyle = new GUIStyle(GUI.skin.label)
{
fontSize = HintFontSize,
alignment = (TextAnchor)3,
wordWrap = true
};
_buttonStyle = new GUIStyle(GUI.skin.button)
{
fontSize = OptionFontSize,
alignment = (TextAnchor)4
};
}
private void CalculatePanelWidth()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
float num = _titleStyle.CalcSize(new GUIContent(titleText)).x;
foreach (Option option in _options)
{
float x = _rowStyle.CalcSize(new GUIContent(option.Label + ": " + option.DisplayValue())).x;
if (x > num)
{
num = x;
}
}
if (!string.IsNullOrEmpty(_textSearch))
{
foreach (Option item in Plugin.ConfigurationHandler.FindTextOptions(_textSearch))
{
float x2 = _rowStyle.CalcSize(new GUIContent(item.Label)).x;
if (x2 > num)
{
num = x2;
}
}
}
int num2 = CalculateHintWidth();
num = Mathf.Max(num, (float)num2);
PanelWidth = Mathf.Clamp((int)num + Pad * 2, 460, Screen.width - Pad * 2);
}
private int CalculateHintWidth()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
float num = _hintStyle.CalcHeight(new GUIContent("Test"), 9999f);
float num2 = num * 2f;
for (int i = 200; i < Screen.width - Pad * 2; i += 20)
{
float num3 = _hintStyle.CalcHeight(new GUIContent(hintText), (float)i);
if (num3 <= num2)
{
return i;
}
}
return Screen.width - Pad * 2;
}
private void Scale(int scale)
{
if (scale >= 0 || HintFontSize >= 2)
{
TitleFontSize += scale * 2;
OptionFontSize += scale * 2;
HintFontSize += scale * 2;
RowHeight = OptionFontSize + 16;
CalculatePanelWidth();
}
}
public void ToggleMenu()
{
_visible = !_visible;
if (_visible)
{
((MenuWindow)this).Open();
}
else
{
((MenuWindow)this).Close();
}
}
private void Update()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
if (!_visible || _options.Count == 0)
{
return;
}
if (_waitingForBinding && ((ButtonControl)Keyboard.current.anyKey).wasPressedThisFrame)
{
Enumerator<KeyControl> enumerator = Keyboard.current.allKeys.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
KeyControl current = enumerator.Current;
if (((ButtonControl)current).wasPressedThisFrame)
{
_bindingTarget.StringEntry.Value = ((InputControl)current).path;
_waitingForBinding = false;
_bindingTarget = null;
break;
}
}
return;
}
finally
{
((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
}
}
if (!GUI.GetNameOfFocusedControl().StartsWith("TextConfiguration", StringComparison.Ordinal))
{
if (Input.GetKeyDown((KeyCode)9))
{
bool flag = Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303);
CycleSelection((!flag) ? 1 : (-1));
}
if (Input.GetKeyDown((KeyCode)273))
{
CycleSelection(-1);
}
if (Input.GetKeyDown((KeyCode)274))
{
CycleSelection(1);
}
if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
{
ToggleSelected();
}
if (Input.GetKeyDown((KeyCode)276))
{
AdjustInt(-1);
}
if (Input.GetKeyDown((KeyCode)275))
{
AdjustInt(1);
}
float axis = Input.GetAxis("Mouse ScrollWheel");
if (axis > 0f)
{
AdjustInt(1);
}
else if (axis < 0f)
{
AdjustInt(-1);
}
}
}
private void ToggleSelected()
{
Option option = _options[_selectedIndex];
if (option.IsDisabled())
{
return;
}
switch (option.Type)
{
case Option.OptionType.Bool:
option.BoolEntry.Value = !option.BoolEntry.Value;
break;
case Option.OptionType.Int:
{
int num = option.IntEntry.Value + option.Step;
if (num > option.MaxInt)
{
num = option.MinInt;
}
option.IntEntry.Value = num;
break;
}
case Option.OptionType.InputAction:
_waitingForBinding = true;
_bindingTarget = option;
break;
case Option.OptionType.String:
break;
}
}
private void AdjustInt(int delta)
{
Option option = _options[_selectedIndex];
if (!option.IsDisabled() && option.Type == Option.OptionType.Int)
{
option.IntEntry.Value = Mathf.Clamp(option.IntEntry.Value + delta * option.Step, option.MinInt, option.MaxInt);
}
}
private void CycleSelection(int delta)
{
if (_options.Count == 0)
{
return;
}
int selectedIndex = _selectedIndex;
do
{
_selectedIndex = (_selectedIndex + delta) % _options.Count;
if (_selectedIndex < 0)
{
_selectedIndex += _options.Count;
}
}
while (_options[_selectedIndex].IsDisabled() && _selectedIndex != selectedIndex);
}
private void OnGUI()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0884: Unknown result type (might be due to invalid IL or missing references)
//IL_088f: Unknown result type (might be due to invalid IL or missing references)
//IL_089d: Unknown result type (might be due to invalid IL or missing references)
//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0979: Unknown result type (might be due to invalid IL or missing references)
//IL_09bd: Unknown result type (might be due to invalid IL or missing references)
//IL_0a01: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Expected O, but got Unknown
//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
//IL_08ee: Unknown result type (might be due to invalid IL or missing references)
//IL_08f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_03da: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Unknown result type (might be due to invalid IL or missing references)
//IL_0452: Unknown result type (might be due to invalid IL or missing references)
//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
//IL_051b: Unknown result type (might be due to invalid IL or missing references)
//IL_0787: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_0354: Unknown result type (might be due to invalid IL or missing references)
//IL_0361: Unknown result type (might be due to invalid IL or missing references)
//IL_036e: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Unknown result type (might be due to invalid IL or missing references)
//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
//IL_05ae: Expected O, but got Unknown
//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0614: Unknown result type (might be due to invalid IL or missing references)
//IL_0619: Unknown result type (might be due to invalid IL or missing references)
//IL_061e: Unknown result type (might be due to invalid IL or missing references)
//IL_066e: Unknown result type (might be due to invalid IL or missing references)
//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
if (!_visible)
{
return;
}
EnsureStyles();
CalculatePanelWidth();
float num = _titleStyle.CalcHeight(new GUIContent(titleText), (float)(PanelWidth - Pad * 2));
float num2 = _hintStyle.CalcHeight(new GUIContent(hintText), (float)(PanelWidth - Pad * 2));
List<float> list = new List<float>();
float num3 = 0f;
foreach (Option option3 in _options)
{
float num4 = RowHeight;
if (option3.Type == Option.OptionType.Colour)
{
float num5 = _rowStyle.CalcHeight(new GUIContent("Name Color"), (float)(PanelWidth - Pad * 2));
float num6 = 16f;
num4 = num5 + num6 + 4f;
}
list.Add(num4);
num3 += num4 + 4f;
}
List<Option> list2 = (string.IsNullOrEmpty(_textSearch) ? new List<Option>() : Plugin.ConfigurationHandler.FindTextOptions(_textSearch));
int num7 = (string.IsNullOrEmpty(_textSearch) ? RowHeight : Mathf.Max(RowHeight * 3, Mathf.Min(list2.Count, 8) * (RowHeight + 4)));
int num8 = RowHeight * 2 + num7 + 12;
int num9 = Pad + (int)num + 8 + (int)num3 + num8 + RowHeight * 2 + 16 + Pad + (int)num2 + 30 + 4;
Rect val = default(Rect);
((Rect)(ref val))..ctor(20f, 20f, (float)PanelWidth, (float)num9);
GUI.color = new Color(0f, 0f, 0f, 0.75f);
GUI.DrawTexture(val, (Texture)(object)_whiteTex);
GUI.color = Color.white;
GUI.Label(new Rect(((Rect)(ref val)).x + (float)Pad, ((Rect)(ref val)).y + (float)Pad, ((Rect)(ref val)).width - (float)(Pad * 2), num), titleText, _titleStyle);
float num10 = ((Rect)(ref val)).y + (float)Pad + num + 8f;
Rect val2 = default(Rect);
for (int i = 0; i < _options.Count; i++)
{
Option option = _options[i];
float num11 = list[i];
((Rect)(ref val2))..ctor(((Rect)(ref val)).x + (float)Pad, num10, ((Rect)(ref val)).width - (float)(Pad * 2), num11);
if (((Rect)(ref val2)).Contains(Event.current.mousePosition) && !option.IsDisabled())
{
GUI.color = new Color(1f, 1f, 1f, 0.24f);
GUI.DrawTexture(val2, (Texture)(object)_whiteTex);
GUI.color = Color.white;
_selectedIndex = i;
}
switch (option.Type)
{
case Option.OptionType.Bool:
DrawBoolOption(option, val2);
break;
case Option.OptionType.Int:
DrawIntOption(option, val2);
break;
case Option.OptionType.InputAction:
DrawInputActionOption(option, val2);
break;
case Option.OptionType.Colour:
DrawColourOption(option, val2);
break;
}
num10 += num11 + 4f;
}
GUI.Label(new Rect(((Rect)(ref val)).x + (float)Pad, num10, ((Rect)(ref val)).width - (float)(Pad * 2), (float)RowHeight), $"Text Configuration ({LocalizedText.CURRENT_LANGUAGE})", _titleStyle);
num10 += (float)(RowHeight + 4);
GUI.SetNextControlName("TextConfigurationSearch");
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(((Rect)(ref val)).x + (float)Pad, num10, ((Rect)(ref val)).width - (float)(Pad * 2), (float)RowHeight);
DrawTextFieldBackground(val3);
_textSearch = GUI.TextField(val3, _textSearch, _rowStyle);
num10 += (float)(RowHeight + 4);
if (string.IsNullOrEmpty(_textSearch))
{
GUI.Label(new Rect(((Rect)(ref val)).x + (float)Pad, num10, ((Rect)(ref val)).width - (float)(Pad * 2), (float)RowHeight), "Search text...", _hintStyle);
num10 += (float)(RowHeight + 4);
}
else
{
Rect val4 = default(Rect);
((Rect)(ref val4))..ctor(((Rect)(ref val)).x + (float)Pad, num10, ((Rect)(ref val)).width - (float)(Pad * 2), (float)num7);
if (list2.Count == 0)
{
GUI.Label(val4, "No matching text keys.", _hintStyle);
num10 += (float)(num7 + 4);
}
else
{
float num12 = ((Rect)(ref val4)).width - 16f;
float num13 = num12 * 0.32f;
float num14 = num12 - num13 - 4f;
List<float> list3 = new List<float>(list2.Count);
float num15 = 0f;
foreach (Option item in list2)
{
float num16 = _textAreaStyle.CalcHeight(new GUIContent(item.StringEntry.Value), num14);
float num17 = Mathf.Max((float)RowHeight, num16);
list3.Add(num17);
num15 += num17 + 4f;
}
_textScrollPosition = GUI.BeginScrollView(val4, _textScrollPosition, new Rect(0f, 0f, ((Rect)(ref val4)).width - 16f, num15));
float num18 = 0f;
Rect val5 = default(Rect);
Rect val6 = default(Rect);
for (int j = 0; j < list2.Count; j++)
{
Option option2 = list2[j];
((Rect)(ref val5))..ctor(0f, num18, num12, list3[j]);
GUI.Label(new Rect(((Rect)(ref val5)).x, ((Rect)(ref val5)).y, num13, ((Rect)(ref val5)).height), option2.Label, _rowStyle);
((Rect)(ref val6))..ctor(((Rect)(ref val5)).x + num13 + 4f, ((Rect)(ref val5)).y, num14, ((Rect)(ref val5)).height);
GUI.SetNextControlName($"TextConfigurationValue{j}");
string text = GUI.TextArea(val6, option2.StringEntry.Value, _textAreaStyle);
if (text != option2.StringEntry.Value)
{
option2.StringEntry.Value = text;
Plugin.ConfigurationHandler.SaveTextConfiguration();
}
num18 += ((Rect)(ref val5)).height + 4f;
}
GUI.EndScrollView();
num10 += (float)(num7 + 4);
}
}
float num19 = RowHeight;
Rect val7 = default(Rect);
((Rect)(ref val7))..ctor(((Rect)(ref val)).x + (float)Pad, num10, ((Rect)(ref val)).width - (float)(Pad * 2), num19);
GUI.Label(val7, "Jump to Segment", _titleStyle);
num10 += num19 + 4f;
string[] names = Enum.GetNames(typeof(Segment));
List<string> list4 = new List<string>();
string[] array = names;
foreach (string text2 in array)
{
if (!text2.Equals("Peak", StringComparison.OrdinalIgnoreCase))
{
list4.Add(text2);
}
}
int count = list4.Count;
float num20 = (float)RowHeight * 1.1f;
float num21 = 10f;
float num22 = ((Rect)(ref val)).width - (float)(Pad * 2);
float num23 = (num22 - (float)(count - 1) * num21) / (float)count;
float num24 = ((Rect)(ref val)).x + (float)Pad;
float num25 = num10;
Rect val8 = default(Rect);
for (int l = 0; l < count; l++)
{
((Rect)(ref val8))..ctor(num24, num25, num23, num20);
GUI.color = new Color(0.3f, 0.3f, 0.3f, 0.8f);
GUI.DrawTexture(val8, (Texture)(object)_whiteTex);
GUI.color = Color.white;
if (GUI.Button(val8, list4[l], _buttonStyle))
{
try
{
if (PhotonNetwork.IsMasterClient)
{
Segment val9 = (Segment)Enum.Parse(typeof(Segment), list4[l]);
MapHandler.JumpToSegment(val9);
}
}
catch (Exception arg)
{
Plugin.Log.LogError((object)$"Failed to jump to segment {list4[l]}: {arg}");
}
}
num24 += num23 + num21;
}
num10 = num25 + num20 + 8f;
Rect val10 = default(Rect);
((Rect)(ref val10))..ctor(((Rect)(ref val)).x + (float)Pad, num10, ((Rect)(ref val)).width - (float)(Pad * 2), num2);
GUI.Label(val10, hintText, _hintStyle);
num25 = ((Rect)(ref val10)).yMax + 4f;
if (GUI.Button(new Rect(((Rect)(ref val)).xMax - 60f - (float)Pad, num25, 30f, 30f), "+", _buttonStyle))
{
Scale(1);
}
if (GUI.Button(new Rect(((Rect)(ref val)).xMax - 30f - (float)Pad, num25, 30f, 30f), "-", _buttonStyle))
{
Scale(-1);
}
}
private void DrawTextFieldBackground(Rect rect)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
GUI.color = new Color(0f, 0f, 0f, 0.55f);
GUI.DrawTexture(rect, (Texture)(object)_whiteTex);
GUI.color = Color.white;
}
private void DrawBoolOption(Option option, Rect rect)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
GUI.color = new Color(0.3f, 0.3f, 0.3f, 0.8f);
GUI.DrawTexture(rect, (Texture)(object)_whiteTex);
GUI.color = Color.white;
if (GUI.Button(rect, option.Label + ": " + (option.BoolEntry.Value ? "On" : "Off"), _rowStyle))
{
option.BoolEntry.Value = !option.BoolEntry.Value;
}
}
private void DrawIntOption(Option option, Rect rect)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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)
GUI.color = new Color(0.3f, 0.3f, 0.3f, 0.8f);
GUI.DrawTexture(rect, (Texture)(object)_whiteTex);
GUI.color = Color.white;
if (GUI.Button(rect, $"{option.Label}: {option.IntEntry.Value}", _rowStyle))
{
ConfigEntry<int> intEntry = option.IntEntry;
intEntry.Value += option.Step;
}
}
private void DrawInputActionOption(Option option, Rect rect)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
GUI.color = new Color(0.3f, 0.3f, 0.3f, 0.8f);
GUI.DrawTexture(rect, (Texture)(object)_whiteTex);
GUI.color = Color.white;
string text = ((_waitingForBinding && option == _bindingTarget) ? "Press any key..." : option.StringEntry.Value.Split("/")[^1].ToUpper());
if (GUI.Button(rect, option.Label + ": " + text, _rowStyle) && !_waitingForBinding)
{
_waitingForBinding = true;
_bindingTarget = option;
}
}
private void DrawColourOption(Option option, Rect rowRect)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Invalid comparison between Unknown and I4
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
ConfigEntry<int> nameColourR = Plugin.ConfigurationHandler.NameColourR;
ConfigEntry<int> nameColourG = Plugin.ConfigurationHandler.NameColourG;
ConfigEntry<int> nameColourB = Plugin.ConfigurationHandler.NameColourB;
GUI.color = new Color(0.3f, 0.3f, 0.3f, 0.8f);
GUI.DrawTexture(rowRect, (Texture)(object)_whiteTex);
GUI.color = Color.white;
float num = _rowStyle.CalcHeight(new GUIContent("Name Colour"), ((Rect)(ref rowRect)).width);
Rect val = default(Rect);
((Rect)(ref val))..ctor(((Rect)(ref rowRect)).x + 4f, ((Rect)(ref rowRect)).y + 2f, ((Rect)(ref rowRect)).width - 8f, num);
GUI.Label(val, "Name Colour", _rowStyle);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(((Rect)(ref rowRect)).x + 4f, ((Rect)(ref rowRect)).y + num + 2f, ((Rect)(ref rowRect)).width - 48f, 16f);
EnsureRainbowTexture((int)((Rect)(ref val2)).width);
GUI.DrawTexture(val2, (Texture)(object)_rainbowTex);
Rect val3 = default(Rect);
((Rect)(ref val3))..ctor(((Rect)(ref rowRect)).x + ((Rect)(ref rowRect)).width - 40f, ((Rect)(ref val2)).y, 36f, ((Rect)(ref val2)).height);
GUI.color = new Color((float)nameColourR.Value / 255f, (float)nameColourG.Value / 255f, (float)nameColourB.Value / 255f);
GUI.DrawTexture(val3, (Texture)(object)_whiteTex);
GUI.color = Color.white;
Event current = Event.current;
if (((int)current.type == 0 || (int)current.type == 3) && ((Rect)(ref val2)).Contains(current.mousePosition))
{
float t = Mathf.Clamp01((current.mousePosition.x - ((Rect)(ref val2)).x) / ((Rect)(ref val2)).width);
Color val4 = ColourFromRainbow(t);
nameColourR.Value = Mathf.RoundToInt(val4.r * 255f);
nameColourG.Value = Mathf.RoundToInt(val4.g * 255f);
nameColourB.Value = Mathf.RoundToInt(val4.b * 255f);
current.Use();
}
}
private void EnsureRainbowTexture(int width = 256)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_rainbowTex != (Object)null))
{
_rainbowTex = new Texture2D(width, 1);
for (int i = 0; i < width; i++)
{
float t = (float)i / (float)(width - 1);
_rainbowTex.SetPixel(i, 0, ColourFromRainbow(t));
}
_rainbowTex.Apply();
}
}
private Color ColourFromRainbow(float t)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
return Color.HSVToRGB(t, 1f, 1f);
}
private void OnDestroy()
{
if ((Object)(object)_whiteTex != (Object)null)
{
Object.Destroy((Object)(object)_whiteTex);
}
if ((Object)(object)_rainbowTex != (Object)null)
{
Object.Destroy((Object)(object)_rainbowTex);
}
}
}
public class Option
{
public enum OptionType
{
Bool,
Int,
String,
InputAction,
Colour,
Float
}
public string Label { get; set; }
public OptionType Type { get; set; }
public ConfigEntry<bool> BoolEntry { get; set; }
public ConfigEntry<int> IntEntry { get; set; }
public ConfigEntry<string> StringEntry { get; set; }
public int MinInt { get; set; }
public int MaxInt { get; set; }
public int Step { get; set; }
public ConfigEntry<float> FloatEntry { get; set; }
public float MinFloat { get; set; }
public float MaxFloat { get; set; }
public float StepFloat { get; set; }
public Func<bool> IsDisabled { get; set; } = () => false;
public Func<string> DisplayValue { get; set; } = () => "";
private Option(string label, OptionType type)
{
Label = label;
Type = type;
}
public static Option Bool(string label, ConfigEntry<bool> entry, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.Bool)
{
BoolEntry = entry,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value ? "ON" : "OFF"
};
}
public static Option Colour(string label, ConfigEntry<int> rEntry, ConfigEntry<int> gEntry, ConfigEntry<int> bEntry, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.Colour)
{
IntEntry = rEntry,
DisplayValue = () => $"R:{rEntry.Value} G:{gEntry.Value} B:{bEntry.Value}",
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false)))
};
}
public static Option InputAction(string label, ConfigEntry<string> entry, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.InputAction)
{
StringEntry = entry,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = delegate
{
string[] array = entry.Value.Split("/");
return (array.Length > 1) ? array[^1].ToUpper() : entry.Value;
}
};
}
public static Option String(string label, ConfigEntry<string> entry, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.String)
{
StringEntry = entry,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value
};
}
public static Option Int(string label, ConfigEntry<int> entry, int min, int max, int step = 1, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.Int)
{
IntEntry = entry,
MinInt = min,
MaxInt = max,
Step = step,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value.ToString()
};
}
public static Option Float(string label, ConfigEntry<float> entry, float min, float max, float step = 0.1f, Func<bool>? isDisabled = null)
{
return new Option(label, OptionType.Float)
{
FloatEntry = entry,
MinFloat = min,
MaxFloat = max,
StepFloat = step,
IsDisabled = (isDisabled ?? ((Func<bool>)(() => false))),
DisplayValue = () => entry.Value.ToString()
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}