using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Bounce.Singletons;
using ModdingTales;
using Newtonsoft.Json;
using RadialUI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("TurnCountersPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("TurnCountersPlugin")]
[assembly: AssemblyProduct("TurnCountersPlugin")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("TurnCountersPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.turncounters", "Turn Counters Plugin (CCM)", "2.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class TurnCounterPlugin : BaseUnityPlugin
{
public static class Utility
{
public static bool isBoardLoaded()
{
return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
}
public static float ParseFloat(string value)
{
return float.Parse(value, CultureInfo.InvariantCulture);
}
public static GameObject FindInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject FindInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done, partial: true);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done);
return results.ToArray();
}
public static GameObject[] FindAllInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done, partial: true);
return results.ToArray();
}
public static GameObject FindWithComponentInHierarchy(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllWithComponentInHierarchy<T>(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: false, ref results, ref done);
return results.ToArray();
}
public static void Traverse(Transform root, string seekName, string seekType, bool single, ref List<GameObject> results, ref bool done, bool partial = false)
{
try
{
if ((seekName == null || seekName == ((Object)((Component)root).gameObject).name || (partial && ((Object)((Component)root).gameObject).name.Contains(seekName))) && (seekType == null || (Object)(object)((Component)root).GetComponent(seekType) != (Object)null))
{
LoggingPlugin.LogTrace("Matched '" + ((Object)((Component)root).gameObject).name + "'");
results.Add(((Component)root).gameObject);
if (single)
{
done = true;
return;
}
}
foreach (Transform item in ExtensionMethods.Children(root))
{
if (!done)
{
Traverse(item, seekName, seekType, single, ref results, ref done, partial);
}
}
}
catch
{
}
}
public static object LookUp(in Dictionary<string, object> dictionary, string key)
{
foreach (KeyValuePair<string, object> item in dictionary)
{
if (item.Key.ToUpper() == key.ToUpper())
{
return item.Value;
}
}
return null;
}
public static void PostOnMainPage(BaseUnityPlugin plugin)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
string text = "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s");
ModdingUtils.Initialize(plugin, new ManualLogSource("Turn Counters Plugin (CCM)"), text, false);
}
}
private enum CounterAction
{
add = 1,
remove,
edit
}
private enum CounterToDisplay
{
all = 1,
forMiniOnly
}
public class Counter
{
public string name { get; set; } = "Counter";
public int current { get; set; } = 1;
public int start { get; set; } = 1;
public int end { get; set; } = 10;
}
[CompilerGenerated]
private sealed class <RegisterAssets>d__17 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ReadOnlyDictionary<string, AssetInfo> existingAssets;
public Func<Dictionary<string, AssetInfo>, string, IEnumerator> callback;
public TurnCounterPlugin <>4__this;
private string <cacheFolder>5__1;
private Texture2D <portrait>5__2;
private byte[] <pngData>5__3;
private Dictionary<string, AssetInfo> <assets>5__4;
private string[] <>s__5;
private int <>s__6;
private string <counter>5__7;
private string <pack>5__8;
private string[] <parts>5__9;
private AssetInfo <assetInfo>5__10;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RegisterAssets>d__17(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<cacheFolder>5__1 = null;
<portrait>5__2 = null;
<pngData>5__3 = null;
<assets>5__4 = null;
<>s__5 = null;
<counter>5__7 = null;
<pack>5__8 = null;
<parts>5__9 = null;
<assetInfo>5__10 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: Expected O, but got Unknown
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<cacheFolder>5__1 = Paths.PluginPath + "/.cache/org.lordashes.plugins.commoncustomsmenu/";
<portrait>5__2 = Image.LoadTexture("org.lordashes.plugins.turncounters.portrait.png", (CacheType)999);
<pngData>5__3 = ImageConversion.EncodeToPNG(<portrait>5__2);
<assets>5__4 = new Dictionary<string, AssetInfo>();
<>s__5 = File.Find("org.lordashes.plugins.turncounters.Counter.", (CacheType)999);
<>s__6 = 0;
break;
case 1:
<>1__state = -1;
File.WriteAllBytes(<cacheFolder>5__1 + "/Portrait." + <assetInfo>5__10.prefab + ".png", <pngData>5__3, (CacheType)999);
<pack>5__8 = null;
<parts>5__9 = null;
<assetInfo>5__10 = null;
<counter>5__7 = null;
<>s__6++;
break;
}
if (<>s__6 < <>s__5.Length)
{
<counter>5__7 = <>s__5[<>s__6];
<pack>5__8 = (<pack>5__8 = <counter>5__7.Substring(Paths.PluginPath.Length).Replace("\\", "/"));
<pack>5__8 = <pack>5__8.Substring(0, <pack>5__8.IndexOf("/"));
<parts>5__9 = File.ReadAllText(<counter>5__7, (CacheType)999).Split(new char[1] { '|' });
AssetInfo val = new AssetInfo();
val.provider = "TurnCounter";
val.filename = <parts>5__9[0] + "|" + <parts>5__9[1] + "|" + <parts>5__9[2];
val.pack = <pack>5__8;
val.prefab = <parts>5__9[0];
val.name = <parts>5__9[0];
val.kind = "Creature";
val.category = "Counter";
val.header = "Turn Counters";
val.groupName = "Asset Counters";
val.description = <parts>5__9[0] + " from " + <parts>5__9[1] + " to " + <parts>5__9[2];
val.author = "Lord Ashes";
val.comment = "Turn Counters Plugin";
val.hasAnimations = false;
val.hasAudio = false;
val.hasBlendshapes = false;
val.tags = "Turn,Count,Plugin";
val.version = ((<parts>5__9.Length >= 4) ? <parts>5__9[3] : "");
<assetInfo>5__10 = val;
<assets>5__4.Add(<assetInfo>5__10.prefab, <assetInfo>5__10);
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
}
<>s__5 = null;
LoggingPlugin.LogDebug("Sending CCM Registration For " + <assets>5__4.Count + " Turn Counter Assets");
((MonoBehaviour)_self).StartCoroutine(callback(<assets>5__4, "TurnCounter"));
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();
}
}
[CompilerGenerated]
private sealed class <WarnAboutLogLevel>d__24 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public TurnCounterPlugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WarnAboutLogLevel>d__24(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Expected O, but got Unknown
//IL_0029: 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)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
try
{
DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
SystemMessage.DisplayInfoText("Turn Counters Plugin (CCM): Using '" + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + "' diagnostics.\r\nUse 'Info' for better performance", 10f, 0f);
SystemMessage.DisplayInfoText("Turn Counters Plugin (CCM): Use 'Debug' or 'Trace' for\r\ntroubleshooting only.", 10f, 0f);
}
catch
{
goto IL_0072;
}
return false;
IL_0072:
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public const string Name = "Turn Counters Plugin (CCM)";
public const string Guid = "org.lordashes.plugins.turncounters";
public const string Version = "2.0.0.0";
public const string Author = "Lord Ashes";
public static TurnCounterPlugin _self = null;
private static CreatureGuid creatureInInitiative = default(CreatureGuid);
private static Dictionary<CreatureGuid, List<Counter>> counterDictionary = new Dictionary<CreatureGuid, List<Counter>>();
private Dictionary<string, int> positions = new Dictionary<string, int>();
private CounterToDisplay showCounters = CounterToDisplay.forMiniOnly;
private GUIStyle counterText = new GUIStyle();
private Texture2D legend = null;
private Texture2D backplate = null;
private void Awake()
{
//IL_001e: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_048d: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Invalid comparison between Unknown and I4
_self = this;
LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
LoggingPlugin.LogDebug(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")");
positions.Add("Left", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Counter Left Position", 1580, (ConfigDescription)null).Value);
positions.Add("Top", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Counter Top Position", 110, (ConfigDescription)null).Value);
positions.Add("Offset X To Counter Tile", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Offset X To Tile", 20, (ConfigDescription)null).Value);
positions.Add("Offset Y To Counter Tile", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "offsey Y To Tile", -5, (ConfigDescription)null).Value);
positions.Add("Counter Tile Width", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Counter Tile Width", 200, (ConfigDescription)null).Value);
positions.Add("Counter Tile Height", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Counter Tile Height", 30, (ConfigDescription)null).Value);
positions.Add("Offset X To Counter Name", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Offset X To Counter Name", 30, (ConfigDescription)null).Value);
positions.Add("Offset X To Counter Start", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Offset X To Counter Start", 125, (ConfigDescription)null).Value);
positions.Add("Offset X To Counter Current", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Offset X To Counter Current", 158, (ConfigDescription)null).Value);
positions.Add("Offset X To Counter End", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Offset X To Counter End", 192, (ConfigDescription)null).Value);
positions.Add("Offset Y", ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Offset Y Per Counter", 30, (ConfigDescription)null).Value);
showCounters = ((BaseUnityPlugin)this).Config.Bind<CounterToDisplay>("Settings", "Counters To Display", CounterToDisplay.forMiniOnly, (ConfigDescription)null).Value;
Color textColor = default(Color);
ColorUtility.TryParseHtmlString(((BaseUnityPlugin)this).Config.Bind<string>("Setting", "Counter Text Color", "#000000FF", (ConfigDescription)null).Value, ref textColor);
counterText.active.textColor = textColor;
counterText.normal.textColor = textColor;
counterText.fontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Font Size", 16, (ConfigDescription)null).Value;
legend = Image.LoadTexture("org.lordashes.plugins.turncounters.legend.png", (CacheType)999);
backplate = Image.LoadTexture("org.lordashes.plugins.turncounters.background.png", (CacheType)999);
RadialSubmenu.EnsureMainMenuItem("org.lordashes.plugins.turncounters", (MenuType)1, "Counters", Image.LoadSprite("org.lordashes.plugins.turncounters.icon.png", (CacheType)999));
RadialSubmenu.CreateSubMenuItem("org.lordashes.plugins.turncounters", "Add Counter", Image.LoadSprite("org.lordashes.plugins.turncounters.add.png", (CacheType)999), (Action<CreatureGuid, string, MapMenuItem>)delegate
{
CounterHandler(CounterAction.add);
}, true, (Func<bool>)(() => true));
RadialSubmenu.CreateSubMenuItem("org.lordashes.plugins.turncounters", "Edit Counter Value", Image.LoadSprite("org.lordashes.plugins.turncounters.edit.png", (CacheType)999), (Action<CreatureGuid, string, MapMenuItem>)delegate
{
CounterHandler(CounterAction.edit);
}, true, (Func<bool>)(() => true));
RadialSubmenu.CreateSubMenuItem("org.lordashes.plugins.turncounters", "Remove Counter", Image.LoadSprite("org.lordashes.plugins.turncounters.remove.png", (CacheType)999), (Action<CreatureGuid, string, MapMenuItem>)delegate
{
CounterHandler(CounterAction.remove);
}, true, (Func<bool>)(() => true));
InitiativeManager.OnTurnSwitch += TurnSwitchHandler;
AssetDataPlugin.Subscribe("org.lordashes.plugins.turncounters", (Action<DatumChange>)delegate(DatumChange change)
{
//IL_0004: 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)
CreatureGuid val = default(CreatureGuid);
if (((object)(CreatureGuid)(ref val)).ToString() != change.source)
{
LoggingPlugin.LogDebug("Obtained Counters For Creature " + change.source + " (" + change.value?.ToString() + ")");
EnsureCountersLoaded(new CreatureGuid(change.source), change.value.ToString());
}
});
string text = CommonCustomsMenuPlugin.RegisterProviderV2("TurnCounter", "Turn Counters", "2.0.0.0", (Func<ReadOnlyDictionary<string, AssetInfo>, Func<Dictionary<string, AssetInfo>, string, IEnumerator>, IEnumerator>)RegisterAssets, (Action<AssetInfo>)delegate(AssetInfo assetInfo)
{
LoggingPlugin.LogInfo("CCM Selection");
LoggingPlugin.LogInfo(JsonConvert.SerializeObject((object)assetInfo));
ProcessAssetSelection(assetInfo);
});
if ((int)LoggingPlugin.GetLogLevel() >= 4)
{
((MonoBehaviour)this).StartCoroutine(WarnAboutLogLevel());
}
}
[IteratorStateMachine(typeof(<RegisterAssets>d__17))]
private IEnumerator RegisterAssets(ReadOnlyDictionary<string, AssetInfo> existingAssets, Func<Dictionary<string, AssetInfo>, string, IEnumerator> callback)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RegisterAssets>d__17(0)
{
<>4__this = this,
existingAssets = existingAssets,
callback = callback
};
}
private void ProcessAssetSelection(AssetInfo assetInfo)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_0238: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
CreatureGuid selectedCreatureId = LocalClient.SelectedCreatureId;
if (!counterDictionary.ContainsKey(selectedCreatureId))
{
counterDictionary.Add(selectedCreatureId, new List<Counter>());
}
string[] parts = assetInfo.filename.Split(new char[1] { '|' });
Counter item = new Counter
{
name = parts[0],
start = int.Parse(parts[1]),
current = int.Parse(parts[1]),
end = int.Parse(parts[2])
};
if (counterDictionary[selectedCreatureId].Any((Counter c) => c.name == parts[0]))
{
for (int i = 0; i < counterDictionary[selectedCreatureId].Count; i++)
{
if (counterDictionary[selectedCreatureId][i].name.ToLower() == parts[0].ToLower())
{
counterDictionary[selectedCreatureId].RemoveAt(i);
break;
}
}
LoggingPlugin.LogDebug("Removed Counter " + parts[0] + " From Creature " + ((object)(CreatureGuid)(ref selectedCreatureId)).ToString());
AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref selectedCreatureId)).ToString(), "org.lordashes.plugins.turncounters", JsonConvert.SerializeObject((object)counterDictionary[selectedCreatureId]), false);
LoggingPlugin.LogDebug("Posted Counter Updates For Creaure " + ((object)(CreatureGuid)(ref selectedCreatureId)).ToString() + " (With " + counterDictionary[selectedCreatureId].Count + " Counters)");
}
else
{
LoggingPlugin.LogDebug("Added Counter " + parts[0] + " To Creature " + ((object)(CreatureGuid)(ref selectedCreatureId)).ToString());
counterDictionary[selectedCreatureId].Add(item);
AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref selectedCreatureId)).ToString(), "org.lordashes.plugins.turncounters", JsonConvert.SerializeObject((object)counterDictionary[selectedCreatureId]), false);
LoggingPlugin.LogDebug("Posted Counter Updates For Creaure " + ((object)(CreatureGuid)(ref selectedCreatureId)).ToString() + " (With " + counterDictionary[selectedCreatureId].Count + " Counters)");
}
}
private void TurnSwitchHandler(QueueElement element)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
AdjustCreatureCounters(creatureInInitiative);
creatureInInitiative = element.CreatureGuid;
}
private void CounterHandler(CounterAction action)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//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)
CreatureGuid radialAsset = new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature());
switch (action)
{
case CounterAction.add:
SystemMessage.AskForTextInput("Add Counter", "Name|Start|End", "Add", (Action<string>)delegate(string str)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
string[] array = str.Split(new char[1] { '|' });
Counter item = new Counter
{
name = array[0],
start = int.Parse(array[1]),
current = int.Parse(array[1]),
end = int.Parse(array[2])
};
LoggingPlugin.LogDebug("Added Counter " + array[0] + " To Creature " + ((object)(CreatureGuid)(ref radialAsset)).ToString());
if (!counterDictionary.ContainsKey(radialAsset))
{
counterDictionary.Add(radialAsset, new List<Counter>());
}
counterDictionary[radialAsset].Add(item);
AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref radialAsset)).ToString(), "org.lordashes.plugins.turncounters", JsonConvert.SerializeObject((object)counterDictionary[radialAsset]), false);
LoggingPlugin.LogDebug("Posted Counter Updates For Creaure " + ((object)(CreatureGuid)(ref radialAsset)).ToString() + " (With " + counterDictionary[radialAsset].Count + " Counters)");
}, (Action)null, "Cancel", (Action)null, "");
break;
case CounterAction.remove:
SystemMessage.AskForTextInput("Remove Counter", "Name Of Counter To Remove:", "Remove", (Action<string>)delegate(string str)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if (!counterDictionary.ContainsKey(radialAsset))
{
counterDictionary.Add(radialAsset, new List<Counter>());
}
for (int i = 0; i < counterDictionary[radialAsset].Count; i++)
{
if (counterDictionary[radialAsset][i].name.ToLower() == str.ToLower())
{
counterDictionary[radialAsset].RemoveAt(i);
break;
}
}
LoggingPlugin.LogDebug("Removed Counter " + str + " From Creature " + ((object)(CreatureGuid)(ref radialAsset)).ToString());
AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref radialAsset)).ToString(), "org.lordashes.plugins.turncounters", JsonConvert.SerializeObject((object)counterDictionary[radialAsset]), false);
LoggingPlugin.LogDebug("Posted Counter Updates For Creaure " + ((object)(CreatureGuid)(ref radialAsset)).ToString() + " (With " + counterDictionary[radialAsset].Count + " Counters)");
}, (Action)null, "Cancel", (Action)null, "");
break;
case CounterAction.edit:
SystemMessage.AskForTextInput("Edit Counter Value", "Name|Value", "Remove", (Action<string>)delegate(string str)
{
//IL_0019: 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_00ab: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
string[] array2 = str.Split(new char[1] { '|' });
if (!counterDictionary.ContainsKey(radialAsset))
{
counterDictionary.Add(radialAsset, new List<Counter>());
}
for (int j = 0; j < counterDictionary[radialAsset].Count; j++)
{
if (counterDictionary[radialAsset][j].name.ToLower() == array2[0].ToLower())
{
counterDictionary[radialAsset][j].current = int.Parse(array2[1]);
break;
}
}
LoggingPlugin.LogDebug("Edited Counter " + str.Substring(0, str.IndexOf("|")) + " On Creature " + ((object)(CreatureGuid)(ref radialAsset)).ToString());
AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref radialAsset)).ToString(), "org.lordashes.plugins.turncounters", JsonConvert.SerializeObject((object)counterDictionary[radialAsset]), false);
LoggingPlugin.LogDebug("Posted Counter Updates For Creaure " + ((object)(CreatureGuid)(ref radialAsset)).ToString() + " (With " + counterDictionary[radialAsset].Count + " Counters)");
}, (Action)null, "Cancel", (Action)null, "");
break;
}
}
private void AdjustCreatureCounters(CreatureGuid creatureInInitiative)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: 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)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: 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_006d: 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)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
_ = LocalClient.SelectedCreatureId;
if (LocalClient.SelectedCreatureId == default(CreatureGuid))
{
return;
}
try
{
List<Counter> list = counterDictionary[creatureInInitiative];
for (int i = 0; i < counterDictionary[creatureInInitiative].Count; i++)
{
if (counterDictionary[creatureInInitiative][i].start < counterDictionary[creatureInInitiative][i].end && counterDictionary[creatureInInitiative][i].current < counterDictionary[creatureInInitiative][i].end)
{
counterDictionary[creatureInInitiative][i].current++;
}
if (counterDictionary[creatureInInitiative][i].start > counterDictionary[creatureInInitiative][i].end && counterDictionary[creatureInInitiative][i].current > counterDictionary[creatureInInitiative][i].end)
{
counterDictionary[creatureInInitiative][i].current--;
}
}
AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref creatureInInitiative)).ToString(), "org.lordashes.plugins.turncounters", JsonConvert.SerializeObject((object)counterDictionary[creatureInInitiative]), false);
LoggingPlugin.LogDebug("Posted " + counterDictionary[creatureInInitiative].Count + " Counter Updates For Creaure " + ((object)(CreatureGuid)(ref creatureInInitiative)).ToString());
}
catch
{
}
}
private void OnGUI()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0482: Unknown result type (might be due to invalid IL or missing references)
//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
//IL_054e: Unknown result type (might be due to invalid IL or missing references)
//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Unknown result type (might be due to invalid IL or missing references)
if (counterDictionary == null)
{
return;
}
_ = LocalClient.SelectedCreatureId;
if (!(LocalClient.SelectedCreatureId != default(CreatureGuid)))
{
return;
}
GUI.DrawTexture(new Rect((float)(positions["Left"] + positions["Offset X To Counter Tile"]), (float)(positions["Top"] + positions["Offset Y To Counter Tile"]), (float)positions["Counter Tile Width"], (float)positions["Counter Tile Height"]), (Texture)(object)legend, (ScaleMode)0);
if (showCounters == CounterToDisplay.all)
{
int num = 1;
{
foreach (Counter item in counterDictionary.Values.SelectMany((List<Counter> list) => list).ToList())
{
if (!item.name.EndsWith("*") || LocalClient.IsInGmMode)
{
GUI.DrawTexture(new Rect((float)(positions["Left"] + positions["Offset X To Counter Tile"]), (float)(positions["Top"] + positions["Offset Y To Counter Tile"] + positions["Offset Y"] * num), (float)positions["Counter Tile Width"], (float)positions["Counter Tile Height"]), (Texture)(object)backplate, (ScaleMode)0);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter Name"]), (float)(positions["Top"] + positions["Offset Y"] * num), 1920f, 30f), item.name, counterText);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter Start"]), (float)(positions["Top"] + positions["Offset Y"] * num), 1920f, 30f), item.start.ToString(), counterText);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter Current"]), (float)(positions["Top"] + positions["Offset Y"] * num), 1920f, 30f), item.current.ToString(), counterText);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter End"]), (float)(positions["Top"] + positions["Offset Y"] * num), 1920f, 30f), item.end.ToString(), counterText);
num++;
}
}
return;
}
}
if (showCounters != CounterToDisplay.forMiniOnly || !counterDictionary.ContainsKey(LocalClient.SelectedCreatureId))
{
return;
}
int num2 = 1;
foreach (Counter item2 in counterDictionary[LocalClient.SelectedCreatureId])
{
if (!item2.name.EndsWith("*") || LocalClient.IsInGmMode)
{
GUI.DrawTexture(new Rect((float)(positions["Left"] + positions["Offset X To Counter Tile"]), (float)(positions["Top"] + positions["Offset Y To Counter Tile"] + positions["Offset Y"] * num2), (float)positions["Counter Tile Width"], (float)positions["Counter Tile Height"]), (Texture)(object)backplate, (ScaleMode)0);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter Name"]), (float)(positions["Top"] + positions["Offset Y"] * num2), 1920f, 30f), item2.name, counterText);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter Start"]), (float)(positions["Top"] + positions["Offset Y"] * num2), 1920f, 30f), item2.start.ToString(), counterText);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter Current"]), (float)(positions["Top"] + positions["Offset Y"] * num2), 1920f, 30f), item2.current.ToString(), counterText);
GUI.Label(new Rect((float)(positions["Left"] + positions["Offset X To Counter End"]), (float)(positions["Top"] + positions["Offset Y"] * num2), 1920f, 30f), item2.end.ToString(), counterText);
num2++;
}
}
}
private static void EnsureCountersLoaded(CreatureGuid guid, string assetData = null)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
if (counterDictionary.ContainsKey(guid))
{
return;
}
LoggingPlugin.LogDebug("Loading Counters For Creaure " + ((object)(CreatureGuid)(ref guid)).ToString());
List<Counter> list = new List<Counter>();
if (assetData == null)
{
assetData = AssetDataPlugin.ReadInfo(((object)(CreatureGuid)(ref guid)).ToString(), "org.lordashes.plugins.turncounters");
}
LoggingPlugin.LogDebug("AssetData: " + assetData);
if (assetData != null || assetData != "")
{
try
{
list = JsonConvert.DeserializeObject<List<Counter>>(assetData);
}
catch (Exception)
{
list = new List<Counter>();
}
}
if (list == null)
{
list = new List<Counter>();
}
counterDictionary.Add(guid, new List<Counter>());
foreach (Counter item in list)
{
counterDictionary[guid].Add(item);
}
LoggingPlugin.LogDebug("Creature " + ((object)(CreatureGuid)(ref guid)).ToString() + " Has " + counterDictionary[guid].Count + " Counters");
}
[IteratorStateMachine(typeof(<WarnAboutLogLevel>d__24))]
private IEnumerator WarnAboutLogLevel()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WarnAboutLogLevel>d__24(0)
{
<>4__this = this
};
}
}