using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Dynamic.Core; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Bounce.ManagedCollections; using Bounce.Singletons; using Bounce.Unmanaged; using Dice; using GameChat.UI; using HarmonyLib; using ModdingTales; using Newtonsoft.Json; using RadialUI; using TMPro; using Unity.Mathematics; using UnityEngine; 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: AssemblyTitle("D20Plugin")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Nth Dimension")] [assembly: AssemblyProduct("D20Plugin")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("D20Plugin")] [assembly: ComVisible(false)] [assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")] [assembly: AssemblyFileVersion("2.5.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("2.5.0.0")] namespace LordAshes; [BepInPlugin("org.lordashes.plugins.d20", "D20 Plugin", "2.5.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.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class PluginD20 : BaseUnityPlugin { public static class Characters { public class SpecPair { public string key { get; set; } = "key"; public string value { get; set; } = "Undefined"; public SpecPair() { } public SpecPair(string key) { this.key = key; value = "Undefined"; } public SpecPair(string key, string value) { this.key = key; this.value = value; } } public class Spec { public string name { get; set; } = "Skill"; public string formula { get; set; } = null; public List extra { get; set; } = null; public string menu { get; set; } = null; public Spec(string name, string formula, List extra = null, string menu = null) { this.name = name; this.formula = formula; this.extra = extra; this.menu = menu; } public string Extra(string name) { return extra.Where((SpecPair e) => e.key == name).FirstOrDefault()?.value; } } public class CharacterSpecs { public string name { get; set; } = "Unnamed"; public string chainSources { get; set; } = null; public List specs { get; set; } = new List(); public void AddAbilityScore(string name, string value, string menu = null) { specs.Add(new Spec(name, ((int.Parse(value) >= 10) ? ((int.Parse(value) - 10) / 2) : ((int.Parse(value) - 11) / 2)).ToString(), new List { new SpecPair("type", "ability"), new SpecPair("value", value) }, menu)); } public void AddValue(string name, string value, string menu = null) { specs.Add(new Spec(name, value, new List { new SpecPair("type", "value") }, menu)); } public void AddSave(string name, string formula, string menu = null) { specs.Add(new Spec(name, formula, new List { new SpecPair("type", "save") }, menu)); } public void AddSkill(string name, string formula, string menu = null) { specs.Add(new Spec(name, formula, new List { new SpecPair("type", "skill") }, menu)); } public void AddSkill(string name, string formula, string opposed, string menu = null) { specs.Add(new Spec(name, formula, new List { new SpecPair("type", "skill"), new SpecPair("opposed", opposed) }, menu)); } public void AddAttack(string name, string formula, string opposed, string menu = null) { specs.Add(new Spec(name, formula, new List { new SpecPair("type", "attack"), new SpecPair("opposed", opposed) }, menu)); } public void AddDamage(string name, string formula, string damageType, string menu = null) { specs.Add(new Spec(name, formula, new List { new SpecPair("type", "damage"), new SpecPair("damageType", damageType) }, menu)); } public void AddHealing(string name, string formula, string menu = null) { specs.Add(new Spec(name, formula, new List { new SpecPair("type", "heal") }, menu)); } public void AddResistances(string name, string list, string damageType, string menu = null) { List list2 = new List(); string[] array = list.Split(new char[1] { ',' }); foreach (string text in array) { list2.Add(new SpecPair(text, text)); } specs.Add(new Spec("Resistances", list, list2, menu)); } public void AddImmunities(string name, string list, string damageType, string menu = null) { List list2 = new List(); string[] array = list.Split(new char[1] { ',' }); foreach (string text in array) { list2.Add(new SpecPair(text, text)); } specs.Add(new Spec("Immunities", list, list2, menu)); } public void AddVulnerabilities(string name, string list, string damageType, string menu = null) { List list2 = new List(); string[] array = list.Split(new char[1] { ',' }); foreach (string text in array) { list2.Add(new SpecPair(text, text)); } specs.Add(new Spec("Resistances", list, list2, menu)); } public void AddOrModifyValue(string name, string value, string menu = null) { Spec spec = FindFirst(name); if (spec == null) { specs.Add(new Spec(name, value, new List { new SpecPair("type", "value") }, menu)); } else { spec.formula = value; } } public string Resolve(string formula, int replacements = 0) { LoggingPlugin.LogTrace("Processing Resolve: Formula=" + (formula ?? "Empty Formula") + ", Max Replacements=" + replacements); if (formula == null || formula.Trim() == "") { return ""; } int num = 0; string text = ""; for (int i = 0; i < nestedResolve; i++) { foreach (Spec spec in specs) { foreach (SpecPair item in spec.extra) { LoggingPlugin.LogTrace("Processing Resolve: Replacing [" + spec.name + "." + item.key + "] With " + item.value); text = formula; formula = formula.Replace("[" + spec.name + "." + item.key + "]", item.value); if (text != formula) { num++; } if (replacements > 0 && num >= replacements) { LoggingPlugin.LogTrace("Processing Resolve: Max Replacement " + replacements + " Resolve: " + formula); return formula; } LoggingPlugin.LogTrace("Processing Resolve: Formula=" + formula + ", Replacements Count=" + num); } LoggingPlugin.LogTrace("Processing Resolve: Replacing [" + spec.name + "] With " + spec.formula.ToString()); text = formula; formula = formula.Replace("[" + spec.name + "]", spec.formula.ToString()); formula = formula.Replace("+-", "-").Replace("-+", "-").Replace("--", "+") .Replace("++", "+"); if (text != formula) { num++; } if (replacements > 0 && num >= replacements) { LoggingPlugin.LogTrace("Processing Resolve: Max Replacement " + replacements + " Resolve: " + formula); return formula; } LoggingPlugin.LogTrace("Processing Resolve: Formula=" + formula + ", Replacements Count=" + num); } } LoggingPlugin.LogTrace("Processing Resolve: Full Resolve: " + formula); return formula; } public Spec[] Find(string whereClause) { if (specs == null || specs.Count == 0 || string.IsNullOrWhiteSpace(whereClause)) { return null; } if (whereClause.IndexOf("=") < 0 && whereClause.IndexOf("<") < 0 && whereClause.IndexOf(">") < 0) { whereClause = "name==\"" + whereClause + "\""; } LoggingPlugin.LogTrace("Find: " + whereClause); return DynamicQueryableExtensions.Where(specs.AsQueryable(), whereClause, Array.Empty()).ToArray(); } public Spec FindFirst(string whereClause) { Spec[] array = Find(whereClause); LoggingPlugin.LogTrace("FindFirst: " + ((array != null) ? array.Length.ToString() : "0") + " Matches"); return (array != null && array.Count() > 0) ? array[0] : null; } public string FindFirstValue(string whereClause) { Spec spec = FindFirst(whereClause); LoggingPlugin.LogTrace("FindFirstValue: " + ((spec != null) ? (spec.name + "=" + spec.formula) : "Null")); return (spec != null) ? spec.formula : ""; } public string FindFirstExtraValue(string whereClause, string property) { Spec spec = FindFirst(whereClause); return (spec != null) ? spec.extra.Where((SpecPair p) => p.key == property).FirstOrDefault().value : ""; } public CreatureBoardAsset FindAsset() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((IEnumerable)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).Where((CreatureBoardAsset a) => a.Name.Contains(name)).FirstOrDefault(); } public CreatureBoardAsset[] FindAssets() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return ((IEnumerable)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).Where((CreatureBoardAsset a) => a.Name.Contains(name)).ToArray(); } } public class CharactersSpecs { public enum CheckType { Regular = 1, Opposed, Attack, Damage, Effect, Heal, Generic } private List sheets = new List(); private List builtPaths = new List(); public static Sprite fallbackSprite = Image.LoadSprite("org.lordashes.plugins.d20.character.png", (CacheType)999); public List All() { return sheets; } public void Add(CharacterSpecs specs) { sheets.Add(specs); } public void Remove(string name) { for (int i = 0; i < sheets.Count; i++) { if (sheets[i].name == name) { sheets.RemoveAt(i); i--; } } } public void LoadCharacters(bool reload = false) { //IL_00a0: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown sheets.Clear(); builtPaths.Clear(); string[] array = File.Find("org.lordashes.plugins.d20.character.", (CacheType)999); foreach (string text in array) { if (text.ToLower().EndsWith(".json")) { LoadCharacter(text); } } LoggingPlugin.LogInfo("Loaded " + _self.characters.sheets.Count + " Character Sheets"); if (!reload) { RadialUIPlugin.AddCustomButtonOnCharacter("org.lordashes.plugins.d20", new ItemArgs { Action = delegate { //IL_000e: Unknown result type (might be due to invalid IL or missing references) LoggingPlugin.LogTrace("Selected Character Menu. Triggering Deep Menu..."); CreatureBoardAsset val = null; CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val); DeepMenusPlugin.NavigateTo(DiceRoller.StripTrailingInteger(val.Name)); }, CloseMenuOnActivate = true, FadeName = true, Icon = LoadSpriteOrDefault("org.lordashes.plugins.d20.character.png", fallbackSprite), Title = "Actions" }, (Func)delegate { //IL_000e: Unknown result type (might be due to invalid IL or missing references) CreatureBoardAsset instigator = null; CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref instigator); if ((Object)(object)instigator != (Object)null) { LoggingPlugin.LogDebug("Looking for Sheet For '" + DiceRoller.StripTrailingInteger(instigator.Name) + "'"); return _self.characters.sheets.Any((CharacterSpecs c) => c.name == DiceRoller.StripTrailingInteger(instigator.Name)); } return false; }); } foreach (CharacterSpecs character in sheets) { DeepMenusPlugin._self.CreateSubMenuItem("/" + character.name, DeepMenusPlugin._self.MakeItemEntry("Edit", (Action)delegate { LoadUserSettings(_self.characters.FindFirst(character.name)); menuEditOpen = true; GameInputEnabled(!menuEditOpen); }, LoadSpriteOrDefault("org.lordashes.plugins.d20.edit.png", fallbackSprite), false, true), (Func)(() => true)); foreach (Spec spec in character.specs) { LoggingPlugin.LogTrace("Considering Entry " + spec.name + " (" + spec.menu + ")"); if (spec.menu != null && spec.menu.Trim() != "") { BuildMenu(character.name, spec.menu); } } } } private static void LoadCharacter(string characterSheet) { string text = File.ReadAllText(characterSheet, (CacheType)999); text = text.TrimStart('\ufeff', '\u200b'); LoggingPlugin.LogInfo("Loading Character Sheet From " + characterSheet); try { CharacterSpecs characterSpecs = JsonConvert.DeserializeObject(text); string characterName = characterSpecs.name; if (!_self.characters.All().Any((CharacterSpecs cs) => cs.name == characterName)) { _self.characters.Add(characterSpecs); if (characterSpecs.chainSources == null || !(characterSpecs.chainSources != "")) { return; } LoggingPlugin.LogDebug("Chain Loading Set To " + characterSpecs.chainSources); string[] array = characterSpecs.chainSources.Split(new char[1] { ',' }); string[] array2 = array; foreach (string text2 in array2) { LoggingPlugin.LogDebug("Chain Loading org.lordashes.plugins.d20.character." + text2); LoggingPlugin.LogDebug(JsonConvert.SerializeObject((object)_self.characters)); CharacterSpecs characterSpecs2 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(characterName)); text = File.ReadAllText("org.lordashes.plugins.d20.common." + text2, (CacheType)999); text = text.TrimStart('\ufeff', '\u200b'); characterSpecs = JsonConvert.DeserializeObject(text); foreach (Spec spec in characterSpecs.specs) { characterSpecs2.specs.Add(spec); } } } else { LoggingPlugin.LogWarning("Duplicated Character Sheet For '" + characterName + "'"); SystemMessage.DisplayInfoText("D20 Plugin:\r\nDuplicate Character " + characterName, 2.5f, 0f, (Action)null); } } catch (Exception ex) { string fileName = Path.GetFileName(characterSheet); if (ex.Message.IndexOf("line") > -1) { string text3 = ex.Message.Substring(ex.Message.IndexOf("line") + 4).Trim(); text3 = text3.Substring(0, text3.IndexOf(",")).Trim(); LoggingPlugin.LogError("Error On Line " + text3.Substring(1) + " Of " + fileName + " (" + ex.Message + ")"); try { int num = int.Parse(text3); string[] array3 = text.Split(new string[1] { "\r\n" }, StringSplitOptions.None); LoggingPlugin.LogError("Problem Line: " + array3[num].Trim()); } catch (Exception ex2) { LoggingPlugin.LogError("'" + text3 + "'"); LoggingPlugin.LogError(ex2.Message); } } else { LoggingPlugin.LogError(ex.Message); } string[] source = text.Split(new string[1] { "\r\n" }, StringSplitOptions.None); string text4 = string.Join("\r\n", source.Select((string line, int index) => $"Line {index + 1:0000}: {line}")); LoggingPlugin.LogInfo("Fault JSON:\r\n" + text4); } } public CharacterSpecs[] Find(string name) { if (name == "") { return null; } return DynamicQueryableExtensions.Where(sheets.AsQueryable(), "name==\"" + name + "\"", Array.Empty()).ToArray(); } public CharacterSpecs FindFirst(string name) { if (name == "") { return null; } return DynamicQueryableExtensions.Where(sheets.AsQueryable(), "name==\"" + name + "\"", Array.Empty()).FirstOrDefault(); } public string FindValue(string name, string whereClause) { return FindFirst(name)?.FindFirstValue(whereClause); } public static Sprite LoadSpriteOrDefault(string seekSprite, Sprite fallBackSprite) { if (File.Find(seekSprite, (CacheType)999).Any()) { return Image.LoadSprite(seekSprite, (CacheType)999); } return fallBackSprite; } private void BuildMenu(string characterName, string menu) { menu = "/" + characterName + menu; string text = menu.Substring(menu.LastIndexOf("/") + 1); string text2 = menu.Substring(0, menu.LastIndexOf("/")); string[] array = text2.Substring(1).Split(new char[1] { '/' }); string text3 = ""; for (int j = 0; j < array.Length; j++) { if (!builtPaths.Contains(text3 + ":" + array[j])) { LoggingPlugin.LogDebug("Building Path " + text3 + "/" + array[j]); DeepMenusPlugin._self.CreateSubMenu(text3, DeepMenusPlugin._self.MakeSubMenuEntry(array[j], (text3 != "") ? LoadSpriteOrDefault("org.lordashes.plugins.d20." + array[j] + ".png", fallbackSprite) : null, false, true), (Func)(() => true)); builtPaths.Add(text3 + ":" + array[j]); } text3 = text3 + "/" + array[j]; } LoggingPlugin.LogDebug("Building Leaf " + text3 + "/" + text); DeepMenusPlugin._self.CreateSubMenuItem(text3, DeepMenusPlugin._self.MakeItemEntry(text, (Action)delegate(string i, string m) { ((MonoBehaviour)_self).StartCoroutine(InitiateMenuAction(i, m)); }, LoadSpriteOrDefault("org.lordashes.plugins.d20." + text + ".png", fallbackSprite), false, true), (Func)(() => true)); } } [CompilerGenerated] private sealed class <>c__DisplayClass7_0 { public string menu; public string item; public Func <>9__3; public Func <>9__4; public Func <>9__5; public Func <>9__6; public Func <>9__7; internal bool b__3(Spec s) { return s.menu == menu + "/" + item; } internal bool b__4(Spec s) { return s.menu == menu + "/" + item; } internal bool b__5(Spec s) { return s.menu == menu + "/" + item; } internal bool b__6(Spec s) { return s.menu == menu + "/" + item; } internal bool b__7(Spec s) { return s.menu == menu + "/" + item; } } [CompilerGenerated] private sealed class d__7 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string item; public string menu; public CreatureBoardAsset[] instigators; public CreatureBoardAsset[] targets; private <>c__DisplayClass7_0 <>8__1; private CreatureGuid[] 5__2; private CreatureBoardAsset[] <>s__3; private int <>s__4; private CreatureBoardAsset 5__5; private CharacterSpecs 5__6; private CharacterSpecs 5__7; private Spec 5__8; private string 5__9; private string 5__10; private Scripts.MessagePublicity 5__11; private string <>s__12; private string 5__13; private int 5__14; private string <>s__15; private CreatureBoardAsset 5__16; private string 5__17; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; <>s__3 = null; 5__5 = null; 5__6 = null; 5__7 = null; 5__8 = null; 5__9 = null; 5__10 = null; <>s__12 = null; 5__13 = null; <>s__15 = null; 5__16 = null; 5__17 = null; <>1__state = -2; } private bool MoveNext() { //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass7_0(); <>8__1.menu = menu; <>8__1.item = item; LoggingPlugin.LogDebug("---[ACTION SELECTED: " + <>8__1.item + " (" + <>8__1.menu + ")]---"); ((MonoBehaviour)_self).StartCoroutine(PatchCallCameraClick.preventClickCollection(1f)); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; 5__2 = null; LocalClient.TryGetLassoedCreatureIds(ref 5__2); if (5__2 == null) { instigators = GetCreatureAssets(5__2); } if (5__2 == null) { instigators = GetCreatureAssets((CreatureGuid[])(object)new CreatureGuid[1] { LocalClient.SelectedCreatureId }); } if (targets == null) { targets = GetAffectedCreatures(); } LoggingPlugin.LogDebug("Instagators (" + instigators.Length + ") = " + string.Join(",", instigators.Select((CreatureBoardAsset a) => a.Name))); LoggingPlugin.LogDebug("Targets (" + targets.Length + ") = " + string.Join(",", targets.Select((CreatureBoardAsset a) => a.Name))); <>8__1.menu = <>8__1.menu.Substring(1); <>8__1.menu = <>8__1.menu.Substring(<>8__1.menu.IndexOf("/")); <>s__3 = instigators; <>s__4 = 0; goto IL_0e5f; case 2: <>1__state = -1; 5__16 = null; goto IL_0e16; case 3: <>1__state = -1; goto IL_0e16; case 4: <>1__state = -1; goto IL_0e16; case 5: <>1__state = -1; goto IL_0e16; case 6: <>1__state = -1; goto IL_0e16; case 7: { <>1__state = -1; goto IL_0e16; } IL_0e2c: 5__6 = null; 5__7 = null; 5__8 = null; 5__9 = null; goto IL_0e49; IL_0e16: 5__13 = null; <>s__15 = null; 5__10 = null; goto IL_0e2c; IL_0e49: 5__5 = null; <>s__4++; goto IL_0e5f; IL_0e5f: if (<>s__4 < <>s__3.Length) { 5__5 = <>s__3[<>s__4]; LoggingPlugin.LogDebug("Current Pass Instinagtor: " + 5__5.Name); LoggingPlugin.LogDebug("Current Targets (" + targets.Length + ") = " + string.Join(",", targets.Select((CreatureBoardAsset a) => a.Name))); if ((Object)(object)5__5 != (Object)null) { 5__6 = new CharacterSpecs(); 5__7 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(5__5.Name)); 5__8 = null; 5__9 = 5__7.FindFirstExtraValue("menu==\"" + <>8__1.menu + "/" + <>8__1.item + "\"", "type"); LoggingPlugin.LogDebug("Action: " + ((5__9 != null) ? 5__9 : "Null")); if (5__9 == null || 5__9.Trim() == "") { 5__9 = "skill"; } 5__8 = 5__7.specs.Where((Spec s) => s.menu == <>8__1.menu + "/" + <>8__1.item).FirstOrDefault(); if (5__8 != null) { LoggingPlugin.LogTrace("Getting Publicity"); 5__10 = 5__8.Extra("message"); 5__11 = Scripts.MessagePublicity.publicMessage; string text = 5__10; <>s__12 = text; string text2 = <>s__12; if (!(text2 == "private")) { if (text2 == "semiprivate") { 5__11 = Scripts.MessagePublicity.semiPrivateMessage; } else { 5__11 = Scripts.MessagePublicity.publicMessage; } } else { 5__11 = Scripts.MessagePublicity.privateMessage; } <>s__12 = null; string text3 = 5__9; <>s__15 = text3; switch (<>s__15) { case "info": case "skill": case "attack": case "save": case "spell": break; case "effect": 5__8 = 5__7.specs.Where((Spec s) => s.menu == <>8__1.menu + "/" + <>8__1.item).FirstOrDefault(); LoggingPlugin.LogDebug("Found Spec: " + (5__8 != null)); LoggingPlugin.LogDebug("Processing " + 5__5.Name + "'s " + <>8__1.item + " (" + 5__9 + ") As Damage"); <>2__current = Scripts.ProcessEffectOnTarget(5__6, CharactersSpecs.CheckType.Effect, 5__8, 5__5, (targets.Length != 0) ? targets[0] : 5__5, "Hit", 5__11, 5__8.name); <>1__state = 4; return true; case "damage": 5__8 = 5__7.specs.Where((Spec s) => s.menu == <>8__1.menu + "/" + <>8__1.item).FirstOrDefault(); LoggingPlugin.LogDebug("Found Spec: " + (5__8 != null)); LoggingPlugin.LogDebug("Processing " + 5__5.Name + "'s " + <>8__1.item + " (" + 5__9 + ") As Damage"); <>2__current = Scripts.ProcessDamageOnTarget(5__6, CharactersSpecs.CheckType.Damage, 5__8, 5__5, (targets.Length != 0) ? targets[0] : 5__5, "Hit", 5__11, 5__8.name); <>1__state = 5; return true; case "heal": 5__8 = 5__7.specs.Where((Spec s) => s.menu == <>8__1.menu + "/" + <>8__1.item).FirstOrDefault(); LoggingPlugin.LogDebug("Found Spec: " + (5__8 != null)); LoggingPlugin.LogDebug("Processing " + 5__5.Name + "'s " + <>8__1.item + " (" + 5__9 + ") As Heal"); <>2__current = Scripts.ProcessHealOnTarget(5__6, CharactersSpecs.CheckType.Heal, 5__8, 5__5, (targets.Length != 0) ? targets[0] : 5__5, 5__11); <>1__state = 6; return true; default: 5__8 = 5__7.specs.Where((Spec s) => s.menu == <>8__1.menu + "/" + <>8__1.item).FirstOrDefault(); LoggingPlugin.LogDebug("Found Spec: " + (5__8 != null)); LoggingPlugin.LogDebug("Processing " + 5__5.Name + "'s " + <>8__1.item + " (" + 5__9 + ") As Generic"); <>2__current = Scripts.ProcessGeneric(5__6, CharactersSpecs.CheckType.Generic, 5__8, 5__5, (targets.Length != 0) ? targets[0] : 5__5, 5__11); <>1__state = 7; return true; } LoggingPlugin.LogDebug("Found Spec: " + (5__8 != null)); 5__13 = 5__8.Extra("opposed"); LoggingPlugin.LogDebug("Found Opposed: " + (5__13 != null)); 5__14 = ((5__8.Extra("targets") != null) ? int.Parse(5__8.Extra("targets")) : 0); LoggingPlugin.LogDebug("Expected Targets: " + 5__14); if (5__13 != null && 5__13 != "" && new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()) != LocalClient.SelectedCreatureId) { LoggingPlugin.LogDebug("Processing " + 5__5.Name + "'s " + <>8__1.item + " (" + 5__9 + ") As Opposed Skill With Selected Target."); 5__16 = null; CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref 5__16); <>2__current = Scripts.ProcessSequence(5__6, (5__9 == "attack" || 5__9 == "spell") ? CharactersSpecs.CheckType.Attack : CharactersSpecs.CheckType.Opposed, 5__8, 5__5, (CreatureBoardAsset[])(object)new CreatureBoardAsset[1] { 5__16 }, 5__11); <>1__state = 2; return true; } if (5__13 != null && 5__13 != "") { LoggingPlugin.LogDebug("Processing " + 5__5.Name + "'s " + <>8__1.item + " (" + 5__9 + ") As Opposed Skill. Collecting Targets."); TargetsCollection obj = new TargetsCollection { targetsCollectingSpecType = 5__9, targetsCollectingSpec = 5__8, targetsCollectingInstigator = 5__5, targetsCollectingPublicity = 5__11 }; 5__17 = 5__8.Extra("targets"); obj.targetsCollecting = int.Parse((5__17 != null) ? 5__17 : int.MaxValue.ToString()); targetsCollection = obj; 5__17 = null; goto IL_0e16; } LoggingPlugin.LogDebug("Processing " + 5__5.Name + "'s " + <>8__1.item + " (" + 5__9 + ") As Skill"); <>2__current = Scripts.ProcessSequence(5__6, CharactersSpecs.CheckType.Regular, 5__8, 5__5, null, 5__11); <>1__state = 3; return true; } goto IL_0e2c; } goto IL_0e49; } <>s__3 = null; LoggingPlugin.LogDebug("Action Processing Completed"); 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(); } } public static CreatureBoardAsset[] GetCreatureAssets(CreatureGuid[] cids) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) List list = new List(); if (cids != null) { foreach (CreatureGuid val in cids) { CreatureBoardAsset val2 = null; CreaturePresenter.TryGetAsset(val, ref val2); if ((Object)(object)val2 != (Object)null) { list.Add(val2); } } } return list.ToArray(); } public static string[] GetCreatureNames(CreatureGuid[] cids) { return (from a in GetCreatureAssets(cids) select a.Name).ToArray(); } private static CreatureBoardAsset[] GetAffectedCreatures() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) List list = new List(); FieldInfo fieldInfo = (from i in typeof(CreatureBoardAsset).GetRuntimeFields() where i.Name == "_selected" select i).FirstOrDefault(); if (fieldInfo != null) { foreach (CreatureBoardAsset item2 in (IEnumerable)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()) { if ((Object)(object)item2 != (Object)null && (bool)fieldInfo.GetValue(item2)) { list.Add(item2); } } } if (!list.Any((CreatureBoardAsset c) => c.CreatureId == new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()))) { CreatureBoardAsset val = null; CreaturePresenter.TryGetAsset(new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()), ref val); if ((Object)(object)val != (Object)null) { list.Add(val); } } CreatureBoardAsset item = default(CreatureBoardAsset); CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref item); if (list.Contains(item)) { list.Remove(item); } return list.ToArray(); } [IteratorStateMachine(typeof(d__7))] public static IEnumerator InitiateMenuAction(string item, string menu, CreatureBoardAsset[] instigators = null, CreatureBoardAsset[] targets = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { item = item, menu = menu, instigators = instigators, targets = targets }; } } public static class DiceRoller { public class RollResult { public string name { get; set; } public string formula { get; set; } public string formulaResolved { get; set; } public string formulaDice { get; set; } public int total { get; set; } public int[] dice { get; set; } } public enum RollingMethod { randomGeneratorDice = 1, talespireDice } public static class RollSimplifier { public class RollParseResult { public string RollString { get; set; } public List AllDiceValues { get; set; } public List Totals { get; set; } } public static RollParseResult ParseRollResults(RollResults rollResults) { //IL_0028: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) List allDiceValues = new List(); List list = new List(); List list2 = new List(); RollGroup[] array = rollResults.ResultsGroups.ToArray(); foreach (RollGroup val in array) { var (item, item2) = ProcessOperand(val.Result, allDiceValues); list.Add(item); list2.Add(item2); } return new RollParseResult { RollString = string.Join(" / ", list), AllDiceValues = allDiceValues, Totals = list2 }; } private static (string str, int total) ProcessOperand(RollOperand operand, List allDiceValues) { //IL_0009: 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I8 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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_015e: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) RollOperation val = default(RollOperation); RollResult val2 = default(RollResult); RollValue val3 = default(RollValue); Which val4 = ((RollOperand)(ref operand)).Get(ref val, ref val2, ref val3); Which val5 = val4; Which val6 = val5; if ((long)val6 <= 2L) { switch ((uint)val6) { case 0u: { RollOperand[] array2 = val.Operands.ToArray(); if (array2.Length != 2) { throw new InvalidOperationException("Unexpected number of operands in RollOperation (expected 2)."); } (string, int) tuple = ProcessOperand(array2[0], allDiceValues); (string, int) tuple2 = ProcessOperand(array2[1], allDiceValues); int item2 = (((int)val.Operator == 0) ? (tuple.Item2 + tuple2.Item2) : (tuple.Item2 - tuple2.Item2)); string text = (((int)val.Operator == 0) ? "+" : "-"); return (tuple.Item1 + text + tuple2.Item1, item2); } case 1u: { int num = ((IEnumerable)val2.Results).Count(); string registeredName = ((DieKind)(ref val2.Kind)).RegisteredName; short[] array = val2.Results.ToArray(); allDiceValues.AddRange(array); int item = array.Sum((short r) => r); return ($"{num}{registeredName}", item); } case 2u: { short value = val3.Value; return (value.ToString(), val3.Value); } } } throw new InvalidOperationException("Unknown RollOperand type encountered."); } } private static readonly Random _rng = new Random(); private static readonly Regex TokenRegex = new Regex("(\\d+[dD]\\d+[aAdD]?|\\d+|[+\\-*/])", RegexOptions.Compiled); private static readonly Regex DiceRegex = new Regex("(\\d+)[dD](\\d+)([aAdD]?)", RegexOptions.Compiled); private static readonly string TermPattern = "(?:\\d+[dD]\\d+[aAdD]?|\\d+|[A-Za-z_][A-Za-z0-9_]*)"; public static TaskCompletionSource pendingRoll; public static async Task Roll(Characters.CharacterSpecs instigatorSheet, string rollName, string expression, RollingMethod? rollingStyle = null) { RollingMethod useRollingStyle = (rollingStyle.HasValue ? rollingStyle.Value : rollingStyleOffensive); RollResult rollResult = new RollResult { name = rollName, formula = expression, formulaResolved = SimplifyExpression(ComputeConstants(instigatorSheet.Resolve(expression))) }; RollResult rawRollResult; switch (useRollingStyle) { case RollingMethod.randomGeneratorDice: rawRollResult = RollRandomGeneratorDice(instigatorSheet, rollResult.formulaResolved); break; case RollingMethod.talespireDice: { string justDice = ExtractTalespireDiceRolls(rollResult.formulaResolved); rawRollResult = ((!(justDice.Trim() != "")) ? new RollResult { dice = new int[0] } : (await RollTalespireDice(instigatorSheet, rollName, justDice.Trim()))); break; } default: return null; } rollResult.formulaDice = ResolveDiceValues(rollResult.formulaResolved, rawRollResult.dice); rollResult.total = ResolveTotal(rollResult.formulaResolved, rawRollResult.dice); rollResult.dice = rawRollResult.dice; LoggingPlugin.LogDebug("Dice Roller: Name: " + rollResult.name); LoggingPlugin.LogDebug("Dice Roller: Formula: " + rollResult.formula); LoggingPlugin.LogDebug("Dice Roller: Roll: " + rollResult.formulaResolved); LoggingPlugin.LogDebug("Dice Roller: Dice: " + rollResult.formulaDice); LoggingPlugin.LogDebug("Dice Roller: Total: " + rollResult.total); return rollResult; } public static Task RollTalespireDice(Characters.CharacterSpecs instigatorSheet, string rollName, string expression) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) LoggingPlugin.LogDebug("Using Talespire Dice"); if (pendingRoll != null) { throw new InvalidOperationException("A virtual dice roll is already in progress."); } LoggingPlugin.LogDebug("Setting Dice Expecting Flag"); pendingRoll = new TaskCompletionSource(); string text = "talespire://dice/" + rollName + ":" + expression; LoggingPlugin.LogDebug("Requesting: " + text); LocalConnectionManager.ProcessTaleSpireUrl(text); return pendingRoll.Task; } public static RollResult RollRandomGeneratorDice(Characters.CharacterSpecs instigatorSheet, string expression) { LoggingPlugin.LogDebug("Using Random Generator Dice"); if (string.IsNullOrWhiteSpace(expression)) { throw new ArgumentException("Expression cannot be empty."); } List diceRolls = new List(); string expression2 = DiceRegex.Replace(expression, delegate(Match match) { int count = int.Parse(match.Groups[1].Value); int sides = int.Parse(match.Groups[2].Value); char c = ((match.Groups[3].Value.Length > 0) ? char.ToUpperInvariant(match.Groups[3].Value[0]) : '\0'); if (c == '\0') { return RollOnce().ToString(); } int val = RollOnce(); int val2 = RollOnce(); return ((c == 'A') ? Math.Max(val, val2) : Math.Min(val, val2)).ToString(); }); int total = EvaluateIntegerExpression(expression2); return new RollResult { formula = expression, formulaResolved = SimplifyExpression(ComputeConstants(instigatorSheet.Resolve(expression))), formulaDice = SimplifyExpression(ResolveDiceValues(ComputeConstants(instigatorSheet.Resolve(expression)), diceRolls.ToArray())), total = total, dice = diceRolls.ToArray() }; int RollOnce() { int num = 0; for (int i = 0; i < P_0.count; i++) { int num2 = _rng.Next(1, P_0.sides + 1); diceRolls.Add(num2); num += num2; } return num; } } public static string ResolveDiceValues(string formula, int[] dice) { if (string.IsNullOrWhiteSpace(formula)) { throw new ArgumentException("Expression cannot be empty."); } if (dice == null) { throw new ArgumentNullException("dice"); } int num = 0; StringBuilder stringBuilder = new StringBuilder(); int num2 = 0; foreach (Match item in DiceRegex.Matches(formula)) { stringBuilder.Append(formula.Substring(num2, item.Index - num2)); int num3 = int.Parse(item.Groups[1].Value); char c = ((item.Groups[3].Value.Length > 0) ? char.ToUpperInvariant(item.Groups[3].Value[0]) : '\0'); int num4 = ((c != 'A' && c != 'D') ? 1 : 2); int num5 = num3 * num4; if (num + num5 > dice.Length) { throw new ArgumentException("Not enough dice values provided."); } if (num4 > 1) { stringBuilder.Append("("); for (int i = 0; i < num5; i++) { if (i > 0) { stringBuilder.Append(","); } stringBuilder.Append(dice[num + i]); } stringBuilder.Append(")"); stringBuilder.Append(c); } else if (num3 == 1) { stringBuilder.Append(dice[num]); } else { stringBuilder.Append("("); for (int j = 0; j < num3; j++) { if (j > 0) { stringBuilder.Append(","); } stringBuilder.Append(dice[num + j]); } stringBuilder.Append(")"); } num += num5; num2 = item.Index + item.Length; } stringBuilder.Append(formula.Substring(num2)); return stringBuilder.ToString(); } public static int ResolveTotal(string formula, int[] dice) { int num = 0; StringBuilder stringBuilder = new StringBuilder(); foreach (Match item in TokenRegex.Matches(formula)) { string value = item.Value; Match match2 = DiceRegex.Match(value); if (match2.Success) { int num2 = int.Parse(match2.Groups[1].Value); char c = ((match2.Groups[3].Length > 0) ? char.ToUpperInvariant(match2.Groups[3].Value[0]) : '\0'); if (c == '\0') { if (num + num2 > dice.Length) { throw new ArgumentException("Not enough dice values supplied."); } int num3 = 0; for (int i = 0; i < num2; i++) { num3 += dice[num++]; } stringBuilder.Append(num3); continue; } int num4 = num2 * 2; if (num + num4 > dice.Length) { throw new ArgumentException("Not enough dice values supplied."); } int num5 = 0; for (int j = 0; j < num2; j++) { num5 += dice[num++]; } int num6 = 0; for (int k = 0; k < num2; k++) { num6 += dice[num++]; } int value2 = ((c == 'A') ? Math.Max(num5, num6) : Math.Min(num5, num6)); stringBuilder.Append(value2); } else { stringBuilder.Append(value); } } object value3 = new DataTable().Compute(stringBuilder.ToString(), null); return Convert.ToInt32(value3); } public static int ResolveMaxTotal(string expression) { if (string.IsNullOrWhiteSpace(expression)) { throw new ArgumentException("Expression cannot be empty."); } List list = new List(); foreach (Match item2 in DiceRegex.Matches(expression)) { int num = int.Parse(item2.Groups[1].Value); int num2 = int.Parse(item2.Groups[2].Value); string value = item2.Groups[3].Value; int item = num * num2; list.Add(item); if (!string.IsNullOrEmpty(value)) { list.Add(item); } } return ResolveTotal(expression, list.ToArray()); } public static string ExtractTalespireDiceRolls(string expression) { Regex regex = new Regex("(?[+\\-*/]?)\\s*(?\\d+[dD]\\d+)(?[aAdD]?)|\\d+", RegexOptions.Compiled); StringBuilder stringBuilder = new StringBuilder(); bool flag = true; foreach (Match item in regex.Matches(expression)) { if (!item.Groups["dice"].Success) { continue; } string value = item.Groups["op"].Value; string value2 = item.Groups["dice"].Value; string value3 = item.Groups["rep"].Value; int num = ((value3.Length <= 0) ? 1 : 2); for (int i = 0; i < num; i++) { if (!flag) { stringBuilder.Append((value.Length > 0) ? value : "+"); } stringBuilder.Append(value2); flag = false; } } return stringBuilder.ToString().Replace("-", "+").Replace("/", "+") .Replace("*", "+"); } public static string SimplifyExpression(string formula) { if (string.IsNullOrWhiteSpace(formula)) { return formula; } formula = Regex.Replace(formula, "(? targetsCollected = new List(); } [HarmonyPatch(typeof(UI_DiceRollGroup), "DisplayGroup")] public static class PatchSetResult { public static bool Prefix(UI_DiceRollGroup __instance, RollGroup resultsGroup, bool isFirst, TMP_Text ____headerText, FactoryInspectorSetup ____operatorFactory, RectTransform ____content, int ____contentGridWrapWidth, GridLayoutGroup ____contentGrid, RectTransform ____transform) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (DiceRoller.pendingRoll != null) { string text = (isFirst ? "Rolled" : "And"); string name = resultsGroup.Name; if (!string.IsNullOrWhiteSpace(name)) { text = text + " " + name; } ____headerText.text = text; int num = (int)(from m in typeof(UI_DiceRollGroup).GetRuntimeMethods() where m.Name == "DisplayOperand" select m).FirstOrDefault().Invoke(__instance, new object[2] { resultsGroup.Result, true }); UI_DiceOperator val = ____operatorFactory.Hire(true); ((Component)val).transform.SetAsLastSibling(); if (((Transform)____content).childCount <= ____contentGridWrapWidth) { ____contentGrid.constraint = (Constraint)2; ____contentGrid.constraintCount = 1; RectTransformExtensions.SetHeight(____transform, 25f + ____contentGrid.cellSize.y); return false; } ____contentGrid.constraint = (Constraint)1; ____contentGrid.constraintCount = ____contentGridWrapWidth; float num2 = math.ceil((float)((Transform)____content).childCount / (float)____contentGrid.constraintCount) * (____contentGrid.cellSize.y + ____contentGrid.spacing.y); RectTransformExtensions.SetHeight(____transform, 25f + num2); return false; } return true; } } [HarmonyPatch(typeof(GUIManager), "PlayMode_OnStateChange")] public static class GUIManagerPlayModeOnStateChange { public static bool Prefix(State obj) { //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) if (((object)obj).ToString() == "PlayMode+TurnBased") { LoggingPlugin.LogDebug("Initiative Mode Selected"); AssetDataPlugin.SendInfo("org.lordashes.plugins.d20", "action:initiative"); ChatManager.SendChatMessageToBoard("[Roll Initiative!]\r\nCollecting Initiatives", LocalPlayer.Id.Value, (float3?)null, false); initiativeOrder.Clear(); } return true; } } [HarmonyPatch(typeof(UI_InitativeManager), "OpenEdit")] public class InitiativeManagerApplyEditPatch { private static void Postfix(bool value) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0113: Unknown result type (might be due to invalid IL or missing references) LoggingPlugin.LogDebug("Applying Stored Initiatives"); InitiativeManager.SetEditQueue(initiativeOrder.Values.ToArray()); LoggingPlugin.LogDebug("Ending Initiative Collection"); if (collectingInitiative && summarizeInitiative) { string text = ""; foreach (KeyValuePair item in initiativeOrder) { CreatureBoardAsset val = null; CreaturePresenter.TryGetAsset(item.Value.CreatureGuid, ref val); if ((Object)(object)val != (Object)null) { text = text + item.Key + ": " + val.Name + "\r\n"; } } if (text != "") { text = text.Substring(0, text.Length - 2); ChatManager.SendChatMessageToBoard("[Initiative]\r\n" + text, LocalPlayer.Id.Value, (float3?)null, false); } } collectingInitiative = false; } } [HarmonyPatch(typeof(UIChatMessageManager), "AddChatMessage")] public static class PatchAddMessage { public static bool Prefix(string creatureName, Texture2D icon, string chatMessage, IChatFocusable focus = null) { //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) LoggingPlugin.LogDebug("Initiative Collection: " + collectingInitiative); if (collectingInitiative) { LoggingPlugin.LogDebug("Initiative Collection: Active"); LoggingPlugin.LogDebug("Initiative Collection: Caption: " + ((creatureName != null) ? creatureName : "None")); LoggingPlugin.LogDebug("Initiative Collection: Icon: " + (((Object)(object)icon != (Object)null && ((Object)icon).name != null) ? ((Object)icon).name : "None")); LoggingPlugin.LogDebug("Initiative Collection: Message: " + ((chatMessage != null) ? chatMessage.Replace("\r\n", "|") : "None")); CreatureBoardAsset val = null; CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val); if (LocalClient.IsPartyGm) { LoggingPlugin.LogDebug("Initiative Collection: GM Client"); try { string text = chatMessage.Substring(chatMessage.LastIndexOf(" ") + 1); LoggingPlugin.LogDebug("Initiative Collection: Adding Roll: " + text + " For " + creatureName); initiativeOrder.Add(int.Parse(text), new QueueElement((ElementType)0, LocalClient.SelectedCreatureId)); } catch { SystemMessage.DisplayInfoText("D20 Plugin:\r\nRoll may be set to value instead of skill.", 2.5f, 0f, (Action)null); } } else { LoggingPlugin.LogDebug("Initiative Collection: Non-GM Client"); } } return true; } } [HarmonyPatch(typeof(UIChatMessageManager), "AddDiceResultMessage")] public static class PatchAddDiceResultMessage { public static bool Prefix(RollResults diceResult, ResultsOrigin origin, ClientGuid sender, bool hidden, IChatFocusable focus = null) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) if (DiceRoller.pendingRoll != null) { DiceRoller.RollSimplifier.RollParseResult rollParseResult = DiceRoller.RollSimplifier.ParseRollResults(diceResult); int num = rollParseResult.Totals.Sum(); DiceRoller.RollResult result = new DiceRoller.RollResult { total = rollParseResult.Totals.Sum(), dice = ((IEnumerable)rollParseResult.AllDiceValues).Select((Func)((short s) => s)).ToArray() }; DiceRoller.pendingRoll?.TrySetResult(result); DiceRoller.pendingRoll = null; DiceRollManager val = Object.FindObjectOfType(); if ((Object)(object)val != (Object)null) { val.RemoveRoll(diceResult.RollId); } return false; } return true; } } [HarmonyPatch(typeof(BoardTool), "CallCameraClick")] public static class PatchCallCameraClick { [CompilerGenerated] private sealed class d__3 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float delay; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; targetsCollection.targetsCollecting = 0; targetsCollection.targetsCollected.Clear(); 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 d__4 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float delay; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; preventClickCalls = true; <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; preventClickCalls = false; 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(); } } public static bool preventClickCalls; public static bool Prefix(CameraClickEvent click) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //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) if (!preventClickCalls && targetsCollection.targetsCollecting > 0 && !((object)BoardToolManager.CurrentTool).ToString().Contains("RulerBoardTool")) { string[] obj = new string[6] { "Generic Click: User Click At ", null, null, null, null, null }; Vector2 position = click.position; obj[1] = ((object)(Vector2)(ref position)).ToString(); obj[2] = " With Tool "; obj[3] = ((object)BoardToolManager.CurrentTool).ToString(); obj[4] = " And Collecting "; obj[5] = collecting; LoggingPlugin.LogDebug(string.Concat(obj)); preventClickCalls = true; ((MonoBehaviour)_self).StartCoroutine(preventClickCollection(1f)); CreatureBoardAsset val = null; float3 val2 = default(float3); PixelPickingManager.TryGetPickedCreature(ref val2, ref val); if ((Object)(object)val != (Object)null) { LoggingPlugin.LogDebug("Generic Click: Added Asset " + val.Name + " At " + ((object)(float3)(ref val2)).ToString()); targetsCollection.targetsCollected.Add(val); if (targetsCollection.targetsCollected.Count >= targetsCollection.targetsCollecting) { ProcessSelection(); } } if (Input.GetMouseButtonDown(2)) { ProcessSelection(); } } return true; } public static void ProcessSelection() { Characters.CharacterSpecs stack = new Characters.CharacterSpecs(); ((MonoBehaviour)_self).StartCoroutine(preventClickCollection(2f)); ((MonoBehaviour)_self).StartCoroutine(Scripts.ProcessSequence(stack, (targetsCollection.targetsCollectingSpecType == "attack" || targetsCollection.targetsCollectingSpecType == "spell") ? Characters.CharactersSpecs.CheckType.Attack : Characters.CharactersSpecs.CheckType.Opposed, targetsCollection.targetsCollectingSpec, targetsCollection.targetsCollectingInstigator, targetsCollection.targetsCollected.ToArray(), targetsCollection.targetsCollectingPublicity)); ((MonoBehaviour)_self).StartCoroutine(holdAndClear(2f)); } [IteratorStateMachine(typeof(d__3))] public static IEnumerator holdAndClear(float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { delay = delay }; } [IteratorStateMachine(typeof(d__4))] public static IEnumerator preventClickCollection(float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { delay = delay }; } } [HarmonyPatch(typeof(Ruler), "SetNewMode")] public static class PatchSetNewMode { public static bool Prefix(int newModeIndex, bool forceRecreate) { if (targetsCollection.targetsCollecting > 0) { LoggingPlugin.LogDebug("D20 Plugin: Ruler Mode Change To Type " + rulerTypes[newModeIndex] + " (" + newModeIndex + ")"); collecting = rulerTypes[newModeIndex]; } return true; } } [HarmonyPatch(typeof(Ruler), "OnClick")] public static class PatchOnClick { [CompilerGenerated] private sealed class d__2 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; UI_Rulers.EnableRulers(false); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; UI_Rulers.EnableRulers(true); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; case 2: <>1__state = -1; UI_Rulers.EnableRulers(false); 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(); } } public static bool Prefix(Ruler __instance, int buttonId) { return true; } public static void Postfix(Ruler __instance, int buttonId) { //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0553: Unknown result type (might be due to invalid IL or missing references) //IL_0558: Unknown result type (might be due to invalid IL or missing references) //IL_0369: 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_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05cd: Unknown result type (might be due to invalid IL or missing references) //IL_05f3: Unknown result type (might be due to invalid IL or missing references) //IL_05f8: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: 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_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0673: Unknown result type (might be due to invalid IL or missing references) //IL_0678: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) LoggingPlugin.LogDebug("Ruler " + ((Object)__instance).name + " Click: Button " + buttonId + ", Targets: " + targetsCollection.targetsCollecting + ", Collecting: " + PluginD20.collecting); if (PatchCallCameraClick.preventClickCalls || targetsCollection.targetsCollecting <= 0) { return; } List list = new List(); if (!(PluginD20.collecting != "")) { return; } List list2 = new List(); GameObject val = GameObject.Find(((Object)__instance).name); Vector3 val2; if ((Object)(object)val != (Object)null) { foreach (Transform item in ExtensionMethods.Children(val.transform)) { LoggingPlugin.LogDebug("Ruler " + ((Object)__instance).name + ": Found Child: " + ((Object)item).name + " While Searching For " + PluginD20.collecting + "Indicator(Clone)"); if (!(((Object)item).name == PluginD20.collecting + "Indicator(Clone)")) { continue; } LoggingPlugin.LogDebug("Ruler " + ((Object)__instance).name + ": Found " + ((Object)item).name + " With " + ExtensionMethods.Children(((Component)item).transform).Count() + " Children"); foreach (Transform item2 in ExtensionMethods.Children(((Component)item).transform)) { string collecting = PluginD20.collecting; val2 = item2.position; LoggingPlugin.LogDebug(collecting + " Point: " + ((object)(Vector3)(ref val2)).ToString()); if (item2.position != Vector3.zero) { list.Add(item2.position); } } } } LoggingPlugin.LogDebug("Ruler " + ((Object)__instance).name + ": Collecting: " + PluginD20.collecting + ", Points: " + list.Count); string collecting2 = PluginD20.collecting; string text = collecting2; CreatureGuid creatureId; if (!(text == "Sphere")) { if (!(text == "Box") || list.Count != 2) { return; } LoggingPlugin.LogDebug("Ruler " + ((Object)__instance).name + ": Applying Selection Based On " + PluginD20.collecting); foreach (CreatureBoardAsset item3 in (IEnumerable)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()) { if (item3.CreatureId != LocalClient.SelectedCreatureId) { string[] obj = new string[8] { "Ruler ", ((Object)__instance).name, ": Asset ", item3.Name, " (", null, null, null }; creatureId = item3.CreatureId; obj[5] = ((object)(CreatureGuid)(ref creatureId)).ToString(); obj[6] = ") At "; val2 = ((Component)((MovableBoardAsset)item3).Rotator).transform.position; obj[7] = ((object)(Vector3)(ref val2)).ToString(); LoggingPlugin.LogDebug(string.Concat(obj)); if (IsPointInsideBox(list[0], list[1], ((Component)((MovableBoardAsset)item3).Rotator).transform.position)) { string[] obj2 = new string[7] { "Ruler ", ((Object)__instance).name, ": Asset ", item3.Name, " (", null, null }; creatureId = item3.CreatureId; obj2[5] = ((object)(CreatureGuid)(ref creatureId)).ToString(); obj2[6] = ") Is Selected"; LoggingPlugin.LogDebug(string.Concat(obj2)); targetsCollection.targetsCollected.Add(item3); } } } PatchCallCameraClick.preventClickCalls = true; ((MonoBehaviour)_self).StartCoroutine(PatchCallCameraClick.preventClickCollection(1f)); ((MonoBehaviour)_self).StartCoroutine(closeRuler()); PluginD20.collecting = ""; } else { if (list.Count != 2) { return; } LoggingPlugin.LogDebug("Ruler " + ((Object)__instance).name + ": Applying Selection Based On " + PluginD20.collecting); val2 = list[0] - list[1]; float magnitude = ((Vector3)(ref val2)).magnitude; LoggingPlugin.LogDebug("Radius = " + magnitude); foreach (CreatureBoardAsset item4 in (IEnumerable)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()) { if (item4.CreatureId != LocalClient.SelectedCreatureId) { val2 = ((Component)((MovableBoardAsset)item4).Rotator).transform.position - list[0]; float magnitude2 = ((Vector3)(ref val2)).magnitude; string[] obj3 = new string[11] { "Ruler ", ((Object)__instance).name, ": Asset ", item4.Name, " (", null, null, null, null, null, null }; creatureId = item4.CreatureId; obj3[5] = ((object)(CreatureGuid)(ref creatureId)).ToString(); obj3[6] = ") At "; val2 = ((Component)((MovableBoardAsset)item4).Rotator).transform.position; obj3[7] = ((object)(Vector3)(ref val2)).ToString(); obj3[8] = " Is "; obj3[9] = magnitude2.ToString(); obj3[10] = " away"; LoggingPlugin.LogDebug(string.Concat(obj3)); if (magnitude2 <= magnitude) { string[] obj4 = new string[7] { "Ruler ", ((Object)__instance).name, ": Asset ", item4.Name, " (", null, null }; creatureId = item4.CreatureId; obj4[5] = ((object)(CreatureGuid)(ref creatureId)).ToString(); obj4[6] = ") Is Selected"; LoggingPlugin.LogDebug(string.Concat(obj4)); targetsCollection.targetsCollected.Add(item4); } } } PatchCallCameraClick.preventClickCalls = true; ((MonoBehaviour)_self).StartCoroutine(PatchCallCameraClick.preventClickCollection(1f)); ((MonoBehaviour)_self).StartCoroutine(closeRuler()); PluginD20.collecting = ""; } } [IteratorStateMachine(typeof(d__2))] public static IEnumerator closeRuler() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__2(0); } public static bool IsPointInsideBox(Vector3 cornerA, Vector3 cornerB, Vector3 point) { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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) float num = Mathf.Min(cornerA.x, cornerB.x); float num2 = Mathf.Max(cornerA.x, cornerB.x); float num3 = Mathf.Min(cornerA.y, cornerB.y); float num4 = Mathf.Max(cornerA.y, cornerB.y); float num5 = Mathf.Min(cornerA.z, cornerB.z); float num6 = Mathf.Max(cornerA.z, cornerB.z); return point.x >= num && point.x <= num2 && point.y >= num3 && point.y <= num4 && point.z >= num5 && point.z <= num6; } } public class RemoteQuerySpecs { public string name { get; set; } public string item { get; set; } } public class RemoteQueryRequest { public Guid id { get; set; } public RemoteQuerySpecs query { get; set; } public string requestor { get; set; } public string[] targetClients { get; set; } public string[] targetPlayers { get; set; } } public class RemoteQueryResponse { public Guid id { get; set; } public string response { get; set; } public string requestor { get; set; } public string client { get; set; } public string player { get; set; } } public static class RemoteQuery { [CompilerGenerated] private sealed class d__5 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Guid id; public TaskCompletionSource> token; public float delay; private List 5__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogDebug("Wait: Waiting For Responses: Started Wait For Timeout Of " + delay); <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; LoggingPlugin.LogDebug("Wait: Triggering Set Delay Callback With " + results[id].Count + " results"); 5__1 = results[id]; results.Remove(id); LoggingPlugin.LogDebug("Wait: Results Removed From Queue. Posting Results (Token: " + ((token == null) ? "Null" : "Ready") + ")"); token?.TrySetResult(5__1); token = null; 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 d__6 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Guid id; public TaskCompletionSource> token; public int expectedResult; public int delay; private List 5__1; private ulong 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__6(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (delay == 0) { delay = int.MaxValue; } LoggingPlugin.LogDebug("Wait: Waiting For Responses: Started Wait For " + expectedResult + " Responses With Timeout Of " + delay); 5__2 = 0uL; break; case 1: <>1__state = -1; 5__2++; break; } if (5__2 < (ulong)((long)delay * 2L) && results[id].Count < expectedResult) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; } LoggingPlugin.LogDebug("Wait: Triggering Set Responses Callback With " + results[id].Count + " results"); 5__1 = results[id]; results.Remove(id); LoggingPlugin.LogDebug("Wait: Results Removed From Queue. Posting Results (Token: " + ((token == null) ? "Null" : "Ready") + ")"); token?.TrySetResult(5__1); token = null; 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(); } } public static string hold; public static TaskCompletionSource reactionToken; public static Task> MakeRequest(RemoteQuerySpecs query, TaskCompletionSource> token, string[] specificClients = null, string[] specificPlayers = null, int expectedResult = 0, int expectedResultsTimeout = 0) { //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) Guid guid = System.Guid.NewGuid(); results.Add(guid, new List()); RemoteQueryRequest obj = new RemoteQueryRequest { id = guid, query = query }; ClientGuid id = LocalClient.Id; obj.requestor = ((object)(ClientGuid)(ref id)).ToString(); obj.targetClients = specificClients; obj.targetPlayers = specificPlayers; string text = JsonConvert.SerializeObject((object)obj); LoggingPlugin.LogDebug("Sending Remote Request:" + text); AssetDataPlugin.SendInfo("org.lordashes.plugins.d20", text); if (expectedResult == 0 && expectedResultsTimeout > 0) { ((MonoBehaviour)_self).StartCoroutine(ProcessResultsAfterSetDelay(guid, token, expectedResultsTimeout)); } else if (expectedResult == 0 && expectedResultsTimeout == 0) { ((MonoBehaviour)_self).StartCoroutine(ProcessResultsAfterSetResponses(guid, token, expectedResult, 10)); } else { ((MonoBehaviour)_self).StartCoroutine(ProcessResultsAfterSetResponses(guid, token, expectedResult, expectedResultsTimeout)); } return token.Task; } public static async void ReceiveRemoteQueryResult(DatumChange datum) { LoggingPlugin.LogDebug("Remote Message:" + JsonConvert.SerializeObject((object)datum)); ChangeAction action2 = datum.action; ChangeAction val = action2; ChangeAction val2 = val; if ((int)val2 != 0 && val2 - 2 > 1) { return; } LoggingPlugin.LogDebug("Remote Message: Checking Message Type"); ClientGuid id; if (datum.value.ToString().Contains("message:")) { SystemMessage.DisplayInfoText("D20 Plugin:\r\n" + datum.value.ToString().Substring("message:".Length), 2.5f, 0f, (Action)null); } else if (datum.value.ToString().Contains("action:")) { string action = datum.value.ToString().Substring("action:".Length); string text = action; if (text == "initiative") { LoggingPlugin.LogDebug("Remote Message: Starting Initiative Collection"); collectingInitiative = true; } } else if (datum.value.ToString().Contains("query")) { LoggingPlugin.LogDebug("Remote Message: Is A Request"); RemoteQueryRequest request = JsonConvert.DeserializeObject(datum.value.ToString()); int num; if (request.targetClients != null) { string[] targetClients = request.targetClients; id = LocalClient.Id; num = ((!targetClients.Contains(((object)(ClientGuid)(ref id)).ToString())) ? 1 : 0); } else { num = 0; } if (num != 0) { return; } PlayerGuid id2; int num2; if (request.targetPlayers != null) { string[] targetPlayers = request.targetPlayers; id2 = LocalPlayer.Id; num2 = ((!targetPlayers.Contains(((object)(PlayerGuid)(ref id2)).ToString())) ? 1 : 0); } else { num2 = 0; } if (num2 != 0) { return; } LoggingPlugin.LogDebug("Remote Message: Seeking Sheets Matching " + request.query.name); Characters.CharacterSpecs[] queryResults = _self.characters.Find(DiceRoller.StripTrailingInteger(request.query.name)); LoggingPlugin.LogDebug("Remote Message: Found " + ((queryResults == null) ? "0" : queryResults.Length.ToString()) + " Sheets"); bool foundMatch = false; if (queryResults == null || queryResults.Length == 0) { return; } Characters.CharacterSpecs[] array = queryResults; foreach (Characters.CharacterSpecs sheet in array) { LoggingPlugin.LogDebug("Remote Message: Opposed Options " + request.query.item); string msg = ""; string opposedOption = request.query.item; if (opposedOption.StartsWith("damage:")) { if (queryResults[0].FindFirstValue("Reaction") == "1") { LoggingPlugin.LogDebug("Delaying Response Until Opposing User Click Continue"); hold = "Damage Reaction"; await WaitForReaction(); } LoggingPlugin.LogDebug("Remote Message: Looking For Damage Adjustments"); string matchKeword = opposedOption.Substring("damage:".Length); LoggingPlugin.LogDebug("Remote Message: Looking For '" + matchKeword + "' Damage Adjustments"); Characters.Spec immunitiesSpec = sheet.specs.Where((Characters.Spec e) => e.name == "Immunities").FirstOrDefault(); Characters.Spec resistancesSpec = sheet.specs.Where((Characters.Spec e) => e.name == "Resistances").FirstOrDefault(); Characters.Spec reductionsSpec = sheet.specs.Where((Characters.Spec e) => e.name == "Reductions").FirstOrDefault(); Characters.Spec vulnerabilitiesSpec = sheet.specs.Where((Characters.Spec e) => e.name == "Vulnerabilities").FirstOrDefault(); string immunities = ((immunitiesSpec != null) ? sheet.Resolve(immunitiesSpec.formula) : ""); string resistances = ((resistancesSpec != null) ? sheet.Resolve(resistancesSpec.formula) : ""); string reductions = ((reductionsSpec != null) ? sheet.Resolve(reductionsSpec.formula) : ""); string vulnerabilities = ((vulnerabilitiesSpec != null) ? sheet.Resolve(vulnerabilitiesSpec.formula) : ""); LoggingPlugin.LogDebug("Remote Message: Collected Possible Damage Adjustments"); LoggingPlugin.LogDebug("Remote Message: Immunities = " + immunities); LoggingPlugin.LogDebug("Remote Message: Resistances = " + resistances); LoggingPlugin.LogDebug("Remote Message: Reductions = " + reductions); LoggingPlugin.LogDebug("Remote Message: Vulnerabilities = " + vulnerabilities); if (immunities != null && (immunities.Contains(matchKeword) || immunities.Contains("*"))) { msg = msg + opposedOption + "=Immunity,"; } else if (resistances != null && (resistances.Contains(matchKeword) || resistances.Contains("*"))) { msg = msg + opposedOption + "=Resistance,"; } else if (reductions == null || (!reductions.Contains(matchKeword) && !resistances.Contains("*"))) { msg = ((vulnerabilities == null || (!vulnerabilities.Contains(matchKeword) && !vulnerabilities.Contains("*"))) ? (msg + opposedOption + "=Regular,") : (msg + opposedOption + "=Vulnerability,")); } else { string amount3 = reductions.Substring(reductions.IndexOf(matchKeword)); amount3 = amount3.Substring(amount3.IndexOf("(") + 1); amount3 = amount3.Substring(0, amount3.IndexOf(")")); msg = msg + opposedOption + "=" + amount3 + ","; } } else { int bestScore = 0; string bestOptionName = ""; Characters.Spec bestOption = null; string[] array2 = opposedOption.Split(new char[1] { ',' }); foreach (string opposedOptionItem in array2) { if (queryResults[0].FindFirstValue("Reaction") == "1") { LoggingPlugin.LogDebug("Delaying Response Until Opposing User Click Continue"); hold = "Defense Reaction"; await WaitForReaction(); } LoggingPlugin.LogDebug("Remote Message: Trying To Find " + opposedOption); Characters.Spec seekResult = sheet.specs.Where((Characters.Spec e) => e.name == opposedOption).FirstOrDefault(); if (seekResult != null) { LoggingPlugin.LogDebug("Remote Message: Found " + seekResult.name + " (" + seekResult.formula + ")"); int score = DiceRoller.ResolveMaxTotal(sheet.Resolve(seekResult.formula)); if (score > bestScore) { bestScore = score; bestOptionName = opposedOptionItem; bestOption = seekResult; } } } CreatureBoardAsset target = null; try { target = ((IEnumerable)(object)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets()).Where((CreatureBoardAsset cba) => cba.Name == request.query.name).FirstOrDefault(); } catch { } DiceRoller.RollResult rollResult = await DiceRoller.Roll(sheet, bestOptionName, bestOption.formula, rollingStyleDefensive); Scripts.ProcessExtensions(Scripts.ExtensionType.targetSkillResult, null, target, null, sheet, null, bestOptionName, null, rollResult, delegate(DiceRoller.RollResult r) { rollResult = r; }); msg = msg + JsonConvert.SerializeObject((object)rollResult) + ","; } if (msg != "") { if (msg.IndexOf("=") < 0) { msg = "[" + msg.Substring(0, msg.Length - 1) + "]"; } foundMatch = true; if (msg.EndsWith(",")) { msg = msg.Substring(0, msg.Length - 1); } LoggingPlugin.LogDebug("Remote Message: Sending Result To Requestor " + request.requestor.ToString() + " Message '" + msg + "'"); RemoteQueryResponse obj2 = new RemoteQueryResponse { id = request.id, requestor = request.requestor.ToString(), response = msg }; id = LocalClient.Id; obj2.client = ((object)(ClientGuid)(ref id)).ToString(); id2 = LocalPlayer.Id; obj2.player = ((object)(PlayerGuid)(ref id2)).ToString(); RemoteQueryResponse response = obj2; AssetDataPlugin.SendInfo("org.lordashes.plugins.d20", JsonConvert.SerializeObject((object)response)); } } if (!foundMatch) { SystemMessage.DisplayInfoText("Characte Sheet For " + request.query.name + " Is Missing " + request.query.item, 2.5f, 0f, (Action)null); } } else { LoggingPlugin.LogDebug("Remote Message: Is A Response"); RemoteQueryResponse result = JsonConvert.DeserializeObject(datum.value.ToString()); LoggingPlugin.LogDebug("Remote Message: Message Destined For Requestor " + result.requestor.ToString()); string[] obj3 = new string[6] { "Remote Message: Check: ", result.requestor, "=", null, null, null }; id = LocalClient.Id; obj3[3] = ((object)(ClientGuid)(ref id)).ToString(); obj3[4] = ", Expecting Id="; obj3[5] = results.ContainsKey(result.id).ToString(); LoggingPlugin.LogDebug(string.Concat(obj3)); string requestor = result.requestor; id = LocalClient.Id; if (requestor == ((object)(ClientGuid)(ref id)).ToString() && results.ContainsKey(result.id)) { LoggingPlugin.LogDebug("Remote Message: Adding Response To Results List (" + result.response + ")"); results[result.id].Add(result); LoggingPlugin.LogDebug("Remote Message: Collected " + results[result.id].Count() + " Responses"); } } } public static async Task WaitForReaction() { try { reactionToken = new TaskCompletionSource(); await reactionToken.Task; LoggingPlugin.LogDebug("Reaction " + hold + " finished"); } catch (OperationCanceledException) { LoggingPlugin.LogDebug("Reaction " + hold + " was canceled"); } catch (Exception ex3) { Exception ex = ex3; Debug.LogException(ex); } } [IteratorStateMachine(typeof(d__5))] public static IEnumerator ProcessResultsAfterSetDelay(Guid id, TaskCompletionSource> token, float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { id = id, token = token, delay = delay }; } [IteratorStateMachine(typeof(d__6))] public static IEnumerator ProcessResultsAfterSetResponses(Guid id, TaskCompletionSource> token, int expectedResult, int delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__6(0) { id = id, token = token, expectedResult = expectedResult, delay = delay }; } } public static class Scripts { public class Script { public string use { get; set; } public string gm { get; set; } public string instigator { get; set; } public string target { get; set; } public string others { get; set; } public string instigator_speech { get; set; } public string target_speech { get; set; } } public enum ExtensionType { instigatorSkillResult = 1, targetSkillResult, damageResult } public class ToggleCallaback { public ToggleRequired toggleOnWho { get; set; } public string toggleName { get; set; } public Func> callback { get; set; } } public enum ToggleRequired { instigator, target } public enum MessagePublicity { publicMessage, semiPrivateMessage, privateMessage } [CompilerGenerated] private sealed class <>c__DisplayClass11_0 { public Task extensionTask; internal bool b__0() { return extensionTask.IsCompleted; } } [CompilerGenerated] private sealed class <>c__DisplayClass12_0 { public Task> queryTask; internal bool b__0() { return queryTask.IsCompleted; } } [CompilerGenerated] private sealed class <>c__DisplayClass13_0 { public Task> queryTask; internal bool b__0() { return queryTask.IsCompleted; } } [CompilerGenerated] private sealed class <>c__DisplayClass14_0 { public Task rollTask; internal bool b__0() { return rollTask.IsCompleted; } } [CompilerGenerated] private sealed class <>c__DisplayClass16_0 { public DiceRoller.RollResult rollResult; internal void b__0(DiceRoller.RollResult r) { rollResult = r; } internal void b__1(DiceRoller.RollResult r) { rollResult = r; } } [CompilerGenerated] private sealed class <>c__DisplayClass17_0 { public DiceRoller.RollResult opposedRoll; internal void b__0(DiceRoller.RollResult r) { opposedRoll = r; } internal void b__1(DiceRoller.RollResult r) { opposedRoll = r; } } [CompilerGenerated] private sealed class <>c__DisplayClass18_0 { public string adjustor; public DiceRoller.RollResult damage; internal void b__0(string r) { adjustor = r; } internal void b__1(DiceRoller.RollResult r) { damage = r; } internal void b__2(DiceRoller.RollResult r) { damage = r; } } [CompilerGenerated] private sealed class <>c__DisplayClass20_0 { public DiceRoller.RollResult heal; internal void b__0(DiceRoller.RollResult r) { heal = r; } } [CompilerGenerated] private sealed class d__22 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.Spec check; public CreatureBoardAsset instigator; public CreatureBoardAsset target; public bool firstTarget; public bool success; private float 5__1; private string 5__2; private AttackEmotes 5__3; private Transform 5__4; private Projectile 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__22(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; 5__4 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Expected O, but got Unknown //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Expected O, but got Unknown //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) if (<>1__state != 0) { return false; } <>1__state = -1; LoggingPlugin.LogDebug("Starting AnimateAttack..."); if (useAnimations.Value) { 5__1 = (int)Math.Floor(Vector3.Distance(((Component)((MovableBoardAsset)instigator).Rotator).transform.position, ((Component)((MovableBoardAsset)target).Rotator).transform.position) * 5f); if (!success) { LoggingPlugin.LogDebug("Miss: Doing Wiggle Animation"); target.PlayEmote(missAnimation.Value.ToString()); } else { 5__2 = check.Extra("animOnce"); LoggingPlugin.LogDebug("Target " + (firstTarget ? "is" : "is not") + " first target. AnimOnce is " + ((5__2 == null) ? "Null" : 5__2)); if (5__2 != null && !firstTarget) { LoggingPlugin.LogDebug("AnimOnce set but this not the first target. Supressing animation."); 5__2 = ""; } if (5__2 == null) { LoggingPlugin.LogDebug("AnimOnce not set. Checking Anim."); 5__2 = check.Extra("anim"); } if (5__2 == null) { LoggingPlugin.LogDebug("Anim not set. Using defaut."); AttackEmotes value; string? text; if (!(5__1 < 10f)) { value = hitRangedAnimation.Value; text = ((object)(AttackEmotes)(ref value)).ToString(); } else { value = hitMeleeAnimation.Value; text = ((object)(AttackEmotes)(ref value)).ToString(); } 5__2 = text; } if (5__2 != null && 5__2 != "") { LoggingPlugin.LogDebug(instigator.Name + " and " + target.Name + " Are " + 5__1 + "' Apart. Doing A " + 5__2 + " Animation"); 5__3 = (AttackEmotes)0; if (Enum.TryParse(5__2, out 5__3)) { LoggingPlugin.LogDebug("Using Core Animation " + 5__2); 5__4 = ((EmotingMovableBoardAsset)target).GetHook((HookTransform)2) ?? ((Component)((MovableBoardAsset)target).Rotator).transform; CreaturePresenter.OnCreatureAttack(5__3, instigator.CreatureId, target.CreatureId, float3.op_Implicit(5__4.position)); 5__4 = null; } else { LoggingPlugin.LogDebug("Using Projectile Animation " + 5__2); if (projectiles.ContainsKey(5__2)) { 5__5 = projectiles[5__2]; 5__5.targets = 1; 5__5.sources = new List { new P3(((EmotingMovableBoardAsset)instigator).GetHook((HookTransform)1).position), new P3(((EmotingMovableBoardAsset)target).GetHook((HookTransform)2).position) }; 5__5.targetArea = "HIT"; AssetDataPlugin.SendInfo("org.lordashes.plugins.projectile", JsonConvert.SerializeObject((object)5__5)); 5__5 = null; } else { LoggingPlugin.LogDebug(check.name + " Using Projectile Animation " + 5__2 + " But It Is Not Defined."); } } } 5__2 = null; } } LoggingPlugin.LogDebug("Ended AnimateAttack..."); 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 d__23 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CreatureGuid cid; public float removeDeadMinisAfterSeconds; private List.Enumerator <>s__1; private EmoteCollectionItem 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__23(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__1 = default(List.Enumerator); 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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) //IL_0139: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogDebug("Starting DelayedCreatureRemove..."); LoggingPlugin.LogDebug("Removing Creature " + ((object)(CreatureGuid)(ref cid)).ToString() + " After " + removeDeadMinisAfterSeconds + " Seconds"); <>2__current = (object)new WaitForSeconds(removeDeadMinisAfterSeconds); <>1__state = 1; return true; case 1: <>1__state = -1; <>s__1 = EmoteManager.GetCollection().Emotes.GetEnumerator(); try { while (<>s__1.MoveNext()) { 5__2 = <>s__1.Current; CreatureManager.RemovePersistentEmote(cid, 5__2.Id); 5__2 = null; } } finally { ((IDisposable)<>s__1).Dispose(); } <>s__1 = default(List.Enumerator); CreatureManager.SetCreatureExplicitHideState(cid, true); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; case 2: <>1__state = -1; CreatureManager.DeleteCreature(cid, default(UniqueCreatureGuid), false); LoggingPlugin.LogDebug("Ended DelayedCreatureRemove..."); 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 d__18 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs stack; public Characters.CharactersSpecs.CheckType action; public Characters.Spec check; public CreatureBoardAsset instigator; public CreatureBoardAsset target; public string severity; public MessagePublicity publicity; public string overrideDamage; private Characters.CharacterSpecs 5__1; private Characters.CharacterSpecs 5__2; private string[] 5__3; private string 5__4; private string[] <>s__5; private int <>s__6; private string 5__7; private string 5__8; private <>c__DisplayClass18_0 <>8__9; private Characters.Spec 5__10; private string 5__11; private bool 5__12; private string 5__13; private string 5__14; private string 5__15; private int 5__16; private int 5__17; private string
5__18; private CreatureDataV4 5__19; private float 5__20; private string <>s__21; private EmoteCollectionItem 5__22; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__18(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) 5__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; <>s__5 = null; 5__7 = null; 5__8 = null; <>8__9 = null; 5__10 = null; 5__11 = null; 5__13 = null; 5__14 = null; 5__15 = null;
5__18 = null; 5__19 = default(CreatureDataV4); <>s__21 = null; 5__22 = null; <>1__state = -2; } private bool MoveNext() { //IL_0e50: Unknown result type (might be due to invalid IL or missing references) //IL_0e5a: Expected O, but got Unknown //IL_0adc: Unknown result type (might be due to invalid IL or missing references) //IL_0b82: Unknown result type (might be due to invalid IL or missing references) //IL_0dd3: Unknown result type (might be due to invalid IL or missing references) //IL_0dde: Unknown result type (might be due to invalid IL or missing references) //IL_0df6: Unknown result type (might be due to invalid IL or missing references) //IL_0e00: Unknown result type (might be due to invalid IL or missing references) //IL_0e44: Unknown result type (might be due to invalid IL or missing references) //IL_0d93: Unknown result type (might be due to invalid IL or missing references) //IL_0d24: Unknown result type (might be due to invalid IL or missing references) //IL_0d2f: Unknown result type (might be due to invalid IL or missing references) string adjustor; string[] obj; Characters.CharacterSpecs characterSpecs; Characters.CharacterSpecs characterSpecs2; float value; switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogDebug("Starting ProcessDamageOnTarget..." + instigator.Name + " To " + (((Object)(object)target != (Object)null) ? target.Name : "None")); stack.AddOrModifyValue("instigatorName", ((Object)(object)instigator != (Object)null) ? instigator.Name : "None"); stack.AddOrModifyValue("targetName", ((Object)(object)target != (Object)null) ? target.Name : "None"); 5__1 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(instigator.Name)); 5__2 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(target.Name)); 5__4 = check.Extra("damage"); 5__3 = ((5__4 != null) ? 5__4.Replace("[", "").Replace("]", "").Replace("'", "") .Split(new char[1] { ',' }) : new string[0]); if (overrideDamage != null) { 5__3 = overrideDamage.Split(new char[1] { ',' }); } LoggingPlugin.LogDebug("Damages: " + string.Join(",", 5__3)); <>s__5 = 5__3; <>s__6 = 0; goto IL_0e87; case 1: <>1__state = -1; waitingOnRemoteAction = false; <>8__9.adjustor = <>8__9.adjustor.Substring(<>8__9.adjustor.IndexOf("=") + 1); 5__11 = stack.FindFirstValue("crit"); 5__12 = ((5__11 != null && 5__11 != "" && bool.Parse(5__11)) ? true : false); 5__14 = 5__10.Extra("critFormula"); 5__13 = ((5__14 != null) ? 5__14 : 5__10.formula); 5__15 = ""; if (5__12) { LoggingPlugin.LogDebug("Using Crit Damage: \"" + Convert.ToString(5__13) + "\""); 5__15 = 5__13; } else { LoggingPlugin.LogDebug("Using Regular Damage: \"" + Convert.ToString(5__10.formula) + "\""); 5__15 = 5__10.formula; } <>8__9.damage = null; if (commonDamage == null) { <>2__current = RollDice(5__1, 5__10.name, 5__15, delegate(DiceRoller.RollResult r) { <>8__9.damage = r; }); <>1__state = 2; return true; } <>8__9.damage = commonDamage; goto IL_06b1; case 2: <>1__state = -1; stack.AddOrModifyValue("damageName", 5__10.name); stack.AddOrModifyValue("damageType", 5__1.Resolve(5__10.Extra("damageType"))); stack.AddOrModifyValue("damageFormula", <>8__9.damage.formula); stack.AddOrModifyValue("damageRoll", <>8__9.damage.formulaResolved); stack.AddOrModifyValue("damageDice", <>8__9.damage.formulaDice); stack.AddOrModifyValue("damageTotal", <>8__9.damage.total.ToString()); <>2__current = ProcessExtensions(ExtensionType.damageResult, instigator, target, 5__1, 5__2, check, null, 5__10, <>8__9.damage, delegate(DiceRoller.RollResult r) { <>8__9.damage = r; }); <>1__state = 3; return true; case 3: <>1__state = -1; if (!ResolvePlaceHolders(5__1, check.formula).Contains("1D20")) { LoggingPlugin.LogDebug("Storing Common Damage"); commonDamage = <>8__9.damage; } else { LoggingPlugin.LogDebug("Using Individual Damage"); } goto IL_06b1; case 4: { <>1__state = -1; 5__8 = null; 5__7 = null; <>s__6++; goto IL_0e87; } IL_0e4a: <>2__current = (object)new WaitForSeconds(0.01f); <>1__state = 4; return true; IL_06b1: stack.AddOrModifyValue("damageName", 5__10.name); stack.AddOrModifyValue("damageType", 5__1.Resolve(5__10.Extra("damageType"))); stack.AddOrModifyValue("damageFormula", <>8__9.damage.formula); stack.AddOrModifyValue("damageRoll", <>8__9.damage.formulaResolved); stack.AddOrModifyValue("damageDice", <>8__9.damage.formulaDice); stack.AddOrModifyValue("damageTotal", <>8__9.damage.total.ToString()); 5__16 = <>8__9.damage.total; if (5__10.Extra("damageType").ToUpper() == "NON-RESISTED") { <>8__9.adjustor = "Regular"; } LoggingPlugin.LogDebug("Damage Total: " + 5__16); if (severity.ToUpper() == "HIT") { 5__16 = <>8__9.damage.total; } else { 5__16 = Convert.ToInt32(<>8__9.damage.total / 2); } LoggingPlugin.LogDebug("Damage Total After Save-For-Half Adjustment: " + 5__16); adjustor = <>8__9.adjustor; <>s__21 = adjustor; switch (<>s__21) { case "Vulnerability": LoggingPlugin.LogDebug("Applying Vulnerability"); 5__16 *= 2; break; case "Resistance": LoggingPlugin.LogDebug("Applying Resistance"); 5__16 = Convert.ToInt32(5__16 / 2); break; case "Immunity": LoggingPlugin.LogDebug("Applying Immunity"); 5__16 = 0; break; } <>s__21 = null; LoggingPlugin.LogDebug("Damage Total After V/R/I Adjustment: " + 5__16); 5__17 = 0; if (int.TryParse(<>8__9.adjustor, out 5__17)) { LoggingPlugin.LogDebug("Applying Reduction " + <>8__9.adjustor); 5__16 -= 5__17; <>8__9.adjustor = "Reduction(" + <>8__9.adjustor + ")"; } 5__16 = Math.Max(5__16, 0); obj = new string[8] { instigator.Name, "'s ", check.name, " does ", 5__16.ToString(), " ", null, null };
5__18 = 5__10.Extra("damageType"); obj[6] = ((
5__18 != null) ?
5__18 : "Generic"); obj[7] = " damage"; LoggingPlugin.LogInfo(string.Concat(obj)); stack.AddOrModifyValue("damageAdjusted", 5__16.ToString()); if (severity == "Half") { if (<>8__9.adjustor == "Regular") { <>8__9.adjustor = "Save"; } else { <>8__9.adjustor = "Save With " + <>8__9.adjustor; } } stack.AddOrModifyValue("damageAdjustor", <>8__9.adjustor); CreatureManager.TryGetCreatureData(target.CreatureId, ref 5__19); characterSpecs = stack; value = 5__19.Hp.Value; characterSpecs.AddOrModifyValue("targetOldHP", value.ToString()); stack.AddOrModifyValue("targetHP", (5__19.Hp.Value - (float)5__16).ToString()); characterSpecs2 = stack; value = 5__19.Hp.Max; characterSpecs2.AddOrModifyValue("targetMaxHP", value.ToString()); 5__20 = 100f * (target.Hp.Value - (float)5__16) / 5__19.Hp.Max; if (5__20 == 100f) { stack.AddOrModifyValue("targetState", "Unhurt"); } else if (5__20 >= 75f) { stack.AddOrModifyValue("targetState", "Scratched"); } else if (5__20 >= 50f) { stack.AddOrModifyValue("targetState", "Wounded"); } else if (5__20 >= 25f) { stack.AddOrModifyValue("targetState", "Bloodied"); } else if (5__20 > 0f) { stack.AddOrModifyValue("targetState", "Critical"); } else { stack.AddOrModifyValue("targetState", "Dying"); if (useAnimations.Value) { 5__22 = EmoteManager.GetCollection().Emotes.Where((EmoteCollectionItem e) => ((Object)e.Emote).name.Contains(deadAnimation.Value.ToString()) || e.Emote.DisplayName.Contains(deadAnimation.Value.ToString())).FirstOrDefault(); if (5__22 != null) { CreatureManager.AddPersistentEmote(target.CreatureId, 5__22.Id); } else { LoggingPlugin.LogDebug("Unable to find the `" + deadAnimation.Value.ToString() + "` emote"); } 5__22 = null; } if (removeDeadMinisAfterSeconds > 0f) { ((MonoBehaviour)_self).StartCoroutine(DelayedCreatureRemove(target.CreatureId, removeDeadMinisAfterSeconds)); } } SendMessages("Damage", stack, instigator, target, publicity); CreatureManager.SetCreatureStatByIndex(target.CreatureId, new CreatureStat(target.Hp.Value - (float)5__16, target.Hp.Max), -1); <>8__9 = null; 5__10 = null; 5__11 = null; 5__13 = null; 5__14 = null; 5__15 = null;
5__18 = null; 5__19 = default(CreatureDataV4); goto IL_0e4a; IL_0e87: if (<>s__6 < <>s__5.Length) { 5__7 = <>s__5[<>s__6]; 5__8 = 5__7.Trim(); if (5__8.Trim() != "" || 5__8.ToUpper() != "NONE") { <>8__9 = new <>c__DisplayClass18_0(); LoggingPlugin.LogDebug("Damage: '" + 5__8 + "'"); 5__10 = 5__1.FindFirst(5__8); LoggingPlugin.LogDebug("Found damage spec '" + 5__8 + "': " + (5__10 != null)); LoggingPlugin.LogDebug("Querying " + target.Name + " For Modifiers To " + 5__10.Extra("damageType")); <>8__9.adjustor = null; waitingOnRemoteAction = true; <>2__current = QueryRemotesForDamage(new RemoteQuerySpecs { name = target.Name, item = "damage:" + 5__10.Extra("damageType") }, new TaskCompletionSource>(), null, null, 1, 0, delegate(string r) { <>8__9.adjustor = r; }); <>1__state = 1; return true; } goto IL_0e4a; } <>s__5 = null; LoggingPlugin.LogDebug("Ended ProcessDamageOnTarget..."); 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 d__19 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs stack; public Characters.CharactersSpecs.CheckType action; public Characters.Spec check; public CreatureBoardAsset instigator; public CreatureBoardAsset target; public string severity; public MessagePublicity publicity; public string overrideEffect; private Characters.CharacterSpecs 5__1; private string[] 5__2; private string 5__3; private string[] <>s__4; private int <>s__5; private string 5__6; private string 5__7; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__1 = null; 5__2 = null; 5__3 = null; <>s__4 = null; 5__6 = null; 5__7 = null; <>1__state = -2; } private bool MoveNext() { //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogDebug("Starting ProcessEffectOnTarget..." + instigator.Name + " To " + (((Object)(object)target != (Object)null) ? target.Name : "None")); stack.AddOrModifyValue("instigatorName", instigator.Name); stack.AddOrModifyValue("targetName", target.Name); 5__1 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(instigator.Name)); 5__3 = check.Extra("effect"); 5__2 = ((5__3 != null) ? 5__3.Replace("[", "").Replace("]", "").Replace("'", "") .Split(new char[1] { ',' }) : new string[0]); if (overrideEffect != null) { 5__2 = overrideEffect.Split(new char[1] { ',' }); } LoggingPlugin.LogDebug("Effects: " + string.Join(", ", 5__2)); <>s__4 = 5__2; <>s__5 = 0; break; case 1: <>1__state = -1; 5__7 = null; 5__6 = null; <>s__5++; break; } if (<>s__5 < <>s__4.Length) { 5__6 = <>s__4[<>s__5]; 5__7 = 5__6.Trim(); if (5__7.Trim() != "" || 5__7.ToUpper() != "NONE") { LoggingPlugin.LogDebug("Effect: '" + 5__7 + "'"); stack.AddOrModifyValue("effect", 5__1.FindFirstValue(5__7)); if (severity == "Hit") { LoggingPlugin.LogInfo(instigator.Name + " inflicts " + 5__7 + " hit effect on " + target.Name); SendMessages("Effect.Hit", stack, instigator, target, publicity); } else { LoggingPlugin.LogInfo(instigator.Name + " inflicts " + 5__7 + " miss effect on " + target.Name); SendMessages("Effect.Miss", stack, instigator, target, publicity); } } <>2__current = (object)new WaitForSeconds(0.01f); <>1__state = 1; return true; } <>s__4 = null; LoggingPlugin.LogDebug("Ended ProcessEffectOnTarget..."); 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 d__11 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public ExtensionType extensionType; public CreatureBoardAsset instigator; public CreatureBoardAsset target; public Characters.CharacterSpecs instigatorSheet; public Characters.CharacterSpecs targetSheet; public Characters.Spec instigatorCheck; public string targetCheck; public Characters.Spec spec; public DiceRoller.RollResult rollResult; public Action onComplete; private List.Enumerator <>s__1; private ToggleCallaback 5__2; private <>c__DisplayClass11_0 <>8__3; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__11(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>s__1 = default(List.Enumerator); 5__2 = null; <>8__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown try { int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -3; rollResult = <>8__3.extensionTask.Result; <>8__3 = null; goto IL_018c; } <>1__state = -1; <>s__1 = extensions[extensionType].GetEnumerator(); <>1__state = -3; goto IL_0194; IL_018c: 5__2 = null; goto IL_0194; IL_0194: if (<>s__1.MoveNext()) { 5__2 = <>s__1.Current; if ((5__2.toggleOnWho == ToggleRequired.instigator && instigatorSheet.FindFirstValue(5__2.toggleName) == "1") || (5__2.toggleOnWho == ToggleRequired.target && targetSheet.FindFirstValue(5__2.toggleName) == "1")) { <>8__3 = new <>c__DisplayClass11_0(); LoggingPlugin.LogDebug("Executing Extension For " + 5__2.toggleName); <>8__3.extensionTask = 5__2.callback(instigator, target, instigatorSheet, targetSheet, instigatorCheck, targetCheck, spec, rollResult); <>2__current = (object)new WaitUntil((Func)(() => <>8__3.extensionTask.IsCompleted)); <>1__state = 1; return true; } goto IL_018c; } <>m__Finally1(); <>s__1 = default(List.Enumerator); onComplete?.Invoke(rollResult); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__21 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs stack; public Characters.CharactersSpecs.CheckType action; public Characters.Spec check; public CreatureBoardAsset instigator; public CreatureBoardAsset target; public MessagePublicity publicity; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogDebug("Starting ProcessGeneric..."); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; stack.AddOrModifyValue("instigatorName", instigator.Name); stack.AddOrModifyValue("targetName", target.Name); stack.AddOrModifyValue("name", check.name); SendMessages("Generic", stack, instigator, target, publicity); LoggingPlugin.LogDebug("Ended ProcessGeneric..."); 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 d__20 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs stack; public Characters.CharactersSpecs.CheckType action; public Characters.Spec check; public CreatureBoardAsset instigator; public CreatureBoardAsset target; public MessagePublicity publicity; private <>c__DisplayClass20_0 <>8__1; private Characters.CharacterSpecs 5__2; private CreatureDataV4 5__3; private float 5__4; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) <>8__1 = null; 5__2 = null; 5__3 = default(CreatureDataV4); <>1__state = -2; } private bool MoveNext() { //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass20_0(); LoggingPlugin.LogDebug("Starting ProcessHealOnTarget..." + instigator.Name + " To " + (((Object)(object)target != (Object)null) ? target.Name : "None")); stack.AddOrModifyValue("instigatorName", instigator.Name); stack.AddOrModifyValue("targetName", target.Name); 5__2 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(instigator.Name)); <>8__1.heal = null; <>2__current = RollDice(5__2, check.name, check.formula, delegate(DiceRoller.RollResult r) { <>8__1.heal = r; }); <>1__state = 1; return true; case 1: { <>1__state = -1; stack.AddOrModifyValue("healName", check.name); stack.AddOrModifyValue("healFormula", <>8__1.heal.formula); stack.AddOrModifyValue("healRoll", <>8__1.heal.formulaResolved); stack.AddOrModifyValue("healDice", <>8__1.heal.formulaDice); stack.AddOrModifyValue("healTotal", <>8__1.heal.total.ToString()); CreatureManager.TryGetCreatureData(target.CreatureId, ref 5__3); Characters.CharacterSpecs characterSpecs = stack; float value = 5__3.Hp.Value; characterSpecs.AddOrModifyValue("targetOldHP", value.ToString()); stack.AddOrModifyValue("targetHP", (5__3.Hp.Value + (float)<>8__1.heal.total).ToString()); Characters.CharacterSpecs characterSpecs2 = stack; value = 5__3.Hp.Max; characterSpecs2.AddOrModifyValue("targetMaxHP", value.ToString()); 5__4 = 100f * Math.Min(Math.Max(5__3.Hp.Value, 0f) + (float)<>8__1.heal.total, 5__3.Hp.Max) / 5__3.Hp.Max; if (5__4 == 100f) { stack.AddOrModifyValue("targetState", "Unhurt"); } else if (5__4 >= 75f) { stack.AddOrModifyValue("targetState", "Scratched"); } else if (5__4 >= 50f) { stack.AddOrModifyValue("targetState", "Wounded"); } else if (5__4 >= 25f) { stack.AddOrModifyValue("targetState", "Bloodied"); } else if (5__4 >= 0f) { stack.AddOrModifyValue("targetState", "Critical"); } else { stack.AddOrModifyValue("targetState", "Dying"); } LoggingPlugin.LogInfo(instigator.Name + "'s " + check.name + " does " + <>8__1.heal.total + " points of healing"); SendMessages("Heal", stack, instigator, target, publicity); CreatureManager.SetCreatureStatByIndex(target.CreatureId, new CreatureStat(Math.Min(Math.Max(5__3.Hp.Value, 0f) + (float)<>8__1.heal.total, 5__3.Hp.Max), target.Hp.Max), -1); LoggingPlugin.LogDebug("Ended ProcessHealOnTarget..."); 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 d__16 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs stack; public Characters.CharactersSpecs.CheckType action; public Characters.Spec check; public CreatureBoardAsset instigator; public MessagePublicity publicity; private <>c__DisplayClass16_0 <>8__1; private Characters.CharacterSpecs 5__2; private int 5__3; private string 5__4; private bool 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogDebug("Starting ProcessInstigatorRoll..."); if ((Object)(object)instigator != (Object)null) { <>8__1 = new <>c__DisplayClass16_0(); LoggingPlugin.LogDebug("Instigator: " + instigator.Name); LoggingPlugin.LogTrace("Getting " + DiceRoller.StripTrailingInteger(instigator.Name) + " Sheet"); 5__2 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(instigator.Name)); <>8__1.rollResult = null; <>2__current = RollDice(5__2, check.name, check.formula, delegate(DiceRoller.RollResult r) { <>8__1.rollResult = r; }); <>1__state = 1; return true; } break; case 1: <>1__state = -1; LoggingPlugin.LogDebug("Instigator Roll: Name: " + <>8__1.rollResult.name); LoggingPlugin.LogDebug("Instigator Roll: Formula: " + <>8__1.rollResult.formula); LoggingPlugin.LogDebug("Instigator Roll: Roll: " + <>8__1.rollResult.formulaResolved); LoggingPlugin.LogDebug("Instigator Roll: Dice: " + <>8__1.rollResult.formulaDice); LoggingPlugin.LogDebug("Instigator Roll: Total: " + <>8__1.rollResult.total); <>2__current = ProcessExtensions(ExtensionType.instigatorSkillResult, instigator, null, 5__2, null, check, null, null, <>8__1.rollResult, delegate(DiceRoller.RollResult r) { <>8__1.rollResult = r; }); <>1__state = 2; return true; case 2: <>1__state = -1; stack.AddOrModifyValue("instigatorName", instigator.Name); stack.AddOrModifyValue("name", <>8__1.rollResult.name); stack.AddOrModifyValue("formula", <>8__1.rollResult.formula); stack.AddOrModifyValue("roll", <>8__1.rollResult.formulaResolved); stack.AddOrModifyValue("dice", <>8__1.rollResult.formulaDice); stack.AddOrModifyValue("total", <>8__1.rollResult.total.ToString()); LoggingPlugin.LogInfo(instigator.Name + "'s " + check.name + " = " + <>8__1.rollResult.total); LoggingPlugin.LogDebug("Setting up crit value"); 5__4 = check.Extra("critOn"); 5__3 = ((5__4 != null) ? int.Parse(5__4) : 20); 5__5 = false; if (<>8__1.rollResult.dice != null && <>8__1.rollResult.dice.Length != 0) { 5__5 = <>8__1.rollResult.dice[0] >= 5__3 && 5__3 > 0; LoggingPlugin.LogDebug("Die: " + <>8__1.rollResult.dice[0] + ", Crit On: " + 5__3 + ", Crit: " + 5__5); } stack.AddOrModifyValue("crit", 5__5.ToString()); LoggingPlugin.LogDebug("Sending notifications"); stack.AddOrModifyValue("instigatorName", instigator.Name); stack.AddOrModifyValue("name", <>8__1.rollResult.name); stack.AddOrModifyValue("formula", <>8__1.rollResult.formula); stack.AddOrModifyValue("roll", <>8__1.rollResult.formulaResolved); stack.AddOrModifyValue("dice", <>8__1.rollResult.formulaDice); stack.AddOrModifyValue("total", <>8__1.rollResult.total.ToString()); SendMessages(action.ToString() + ".Instigation", stack, instigator, null, publicity); <>8__1 = null; 5__2 = null; 5__4 = null; break; } 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 d__15 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs stack; public Characters.CharactersSpecs.CheckType action; public Characters.Spec check; public CreatureBoardAsset instigator; public CreatureBoardAsset[] targets; public MessagePublicity publicity; private bool 5__1; private CreatureBoardAsset[] <>s__2; private int <>s__3; private CreatureBoardAsset 5__4; private Characters.CharacterSpecs 5__5; private string 5__6; private string 5__7; private string 5__8; private string 5__9; private string 5__10; private string 5__11; private string 5__12; private object[] 5__13; private int

5__14; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__15(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__2 = null; 5__4 = null; 5__5 = null; 5__6 = null; 5__7 = null; 5__8 = null; 5__9 = null; 5__10 = null; 5__11 = null; 5__12 = null; 5__13 = null; <>1__state = -2; } private bool MoveNext() { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogInfo("--------------------------------------------------------------------------------"); LoggingPlugin.LogInfo(" Started " + instigator.Name + "'s " + check.name + " (" + action.ToString() + ")"); LoggingPlugin.LogInfo("--------------------------------------------------------------------------------"); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 1; return true; case 1: <>1__state = -1; if (action == Characters.CharactersSpecs.CheckType.Attack || action == Characters.CharactersSpecs.CheckType.Opposed || action == Characters.CharactersSpecs.CheckType.Regular) { <>2__current = ProcessInstigatorRoll(stack, action, check, instigator, publicity); <>1__state = 2; return true; } goto IL_018b; case 2: <>1__state = -1; if (action != Characters.CharactersSpecs.CheckType.Regular && (targets == null || targets.Length == 0)) { LoggingPlugin.LogDebug("No Target Selected For Opposed Check. Processing As Regular Check."); action = Characters.CharactersSpecs.CheckType.Regular; } goto IL_018b; case 3: <>1__state = -1; if (int.Parse(stack.FindFirstValue("total")) >= int.Parse(stack.FindFirstValue("opposedTotal"))) { stack.AddOrModifyValue("result", "Hit"); } else if (check.Extra("half") != null) { stack.AddOrModifyValue("result", "Half"); } else { stack.AddOrModifyValue("result", "Miss"); } SendMessages(action.ToString() + "." + stack.FindFirstValue("result"), stack, instigator, null, publicity); if (action == Characters.CharactersSpecs.CheckType.Attack && stack.FindFirstValue("result").ToUpper() != "MISS") { <>2__current = AnimateAttack(check, instigator, 5__4, 5__1, success: true); <>1__state = 4; return true; } if (action == Characters.CharactersSpecs.CheckType.Attack) { <>2__current = AnimateAttack(check, instigator, 5__4, 5__1, success: false); <>1__state = 7; return true; } goto IL_04ca; case 4: <>1__state = -1; <>2__current = ProcessDamageOnTarget(stack, action, check, instigator, 5__4, stack.FindFirstValue("result"), publicity); <>1__state = 5; return true; case 5: <>1__state = -1; <>2__current = ProcessEffectOnTarget(stack, action, check, instigator, 5__4, stack.FindFirstValue("result"), publicity); <>1__state = 6; return true; case 6: <>1__state = -1; goto IL_04ca; case 7: { <>1__state = -1; goto IL_04ca; } IL_018b: if (targets == null) { break; } 5__1 = true; <>s__2 = targets; <>s__3 = 0; goto IL_088c; IL_088c: if (<>s__3 < <>s__2.Length) { 5__4 = <>s__2[<>s__3]; LoggingPlugin.LogDebug("--------------------------------------------------------------------------------"); LoggingPlugin.LogDebug(" Processing " + instigator.Name + "'s " + check.name + " Vs " + 5__4.Name); LoggingPlugin.LogDebug("--------------------------------------------------------------------------------"); if (action == Characters.CharactersSpecs.CheckType.Attack || action == Characters.CharactersSpecs.CheckType.Opposed) { <>2__current = ProcessTargetRoll(stack, action, check, instigator, 5__4, publicity); <>1__state = 3; return true; } goto IL_04ca; } <>s__2 = null; break; IL_04ca: LoggingPlugin.LogDebug("Staring etting Instigator Sheet..."); LoggingPlugin.LogDebug(instigator.Name); LoggingPlugin.LogDebug(DiceRoller.StripTrailingInteger(instigator.Name)); 5__5 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(instigator.Name)); LoggingPlugin.LogDebug("Ended Getting Instigator Sheet..."); LoggingPlugin.LogDebug("Looking For Chains"); 5__6 = check.Extra("chainAlways"); if (5__6 != null) { LoggingPlugin.LogDebug("Adding chainAlways chain: " + 5__6); 5__7 = 5__6.Substring(5__6.LastIndexOf("/") + 1); 5__8 = 5__6.Substring(0, 5__6.LastIndexOf("/")); chainList.Add(new object[5] { 5__7, "/" + instigator.Name + 5__8, new CreatureBoardAsset[1] { instigator }, new CreatureBoardAsset[1] { 5__4 }, publicity }); 5__7 = null; 5__8 = null; } else if (stack.FindFirstValue("result") == "Hit") { 5__6 = check.Extra("chainSuccess"); if (5__6 != null) { LoggingPlugin.LogDebug("Adding chainSuccess chain: " + 5__6); 5__9 = 5__6.Substring(5__6.LastIndexOf("/") + 1); 5__10 = 5__6.Substring(0, 5__6.LastIndexOf("/")); chainList.Add(new object[5] { 5__9, "/" + instigator.Name + 5__10, new CreatureBoardAsset[1] { instigator }, new CreatureBoardAsset[1] { 5__4 }, publicity }); 5__9 = null; 5__10 = null; } } else { 5__6 = check.Extra("chainFailure"); if (5__6 != null) { LoggingPlugin.LogDebug("Adding chainFailure chain: " + 5__6); 5__11 = 5__6.Substring(5__6.LastIndexOf("/") + 1); 5__12 = 5__6.Substring(0, 5__6.LastIndexOf("/")); chainList.Add(new object[5] { 5__11, "/" + instigator.Name + 5__12, new CreatureBoardAsset[1] { instigator }, new CreatureBoardAsset[1] { 5__4 }, publicity }); 5__11 = null; 5__12 = null; } } 5__1 = false; 5__5 = null; 5__6 = null; 5__4 = null; <>s__3++; goto IL_088c; } if (chainList.Count > 0) { LoggingPlugin.LogDebug("Processing next chain"); 5__13 = chainList.ElementAt(0); chainList.RemoveAt(0);

5__14 = 0; while (

5__14 <= 3) { LoggingPlugin.LogDebug("Parameter " +

5__14 + ": " + 5__13[

5__14].GetType()?.ToString() + ": " + 5__13[

5__14].ToString());

5__14++; } ((MonoBehaviour)_self).StartCoroutine(Characters.InitiateMenuAction((string)5__13[0], (string)5__13[1], (CreatureBoardAsset[])5__13[2], (CreatureBoardAsset[])5__13[3])); 5__13 = null; } commonDamage = null; LoggingPlugin.LogTrace("--------------------------------------------------------------------------------"); LoggingPlugin.LogTrace(" Completed " + instigator.Name + "'s " + check.name + " (" + action.ToString() + ")"); LoggingPlugin.LogTrace("--------------------------------------------------------------------------------"); 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 d__17 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs stack; public Characters.CharactersSpecs.CheckType action; public Characters.Spec instigatorCheck; public CreatureBoardAsset instigator; public CreatureBoardAsset target; public MessagePublicity publicity; private <>c__DisplayClass17_0 <>8__1; private string 5__2; private string 5__3; private Characters.CharacterSpecs 5__4; private Characters.CharacterSpecs 5__5; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; LoggingPlugin.LogDebug("Starting ProcessTargetRoll..."); if ((Object)(object)target != (Object)null) { <>8__1 = new <>c__DisplayClass17_0(); LoggingPlugin.LogDebug("Target: " + target.Name); 5__3 = instigatorCheck.Extra("opposed"); 5__2 = ((5__3 != null) ? 5__3 : "AC"); LoggingPlugin.LogDebug(instigatorCheck.name + " is opposed by " + 5__2); waitingOnRemoteAction = true; <>8__1.opposedRoll = null; <>2__current = QueryRemotes(new RemoteQuerySpecs { name = target.Name, item = 5__2 }, new TaskCompletionSource>(), null, null, 1, 0, delegate(DiceRoller.RollResult r) { <>8__1.opposedRoll = r; }); <>1__state = 1; return true; } break; case 1: <>1__state = -1; waitingOnRemoteAction = false; stack.AddOrModifyValue("targetName", target.Name); stack.AddOrModifyValue("opposedName", <>8__1.opposedRoll.name); stack.AddOrModifyValue("opposedFormula", <>8__1.opposedRoll.formula); stack.AddOrModifyValue("opposedRoll", <>8__1.opposedRoll.formulaResolved); stack.AddOrModifyValue("opposedDice", <>8__1.opposedRoll.formulaDice); stack.AddOrModifyValue("opposedTotal", <>8__1.opposedRoll.total.ToString()); 5__4 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(instigator.Name)); 5__5 = _self.characters.FindFirst(DiceRoller.StripTrailingInteger(target.Name)); <>2__current = ProcessExtensions(ExtensionType.targetSkillResult, instigator, target, 5__4, 5__5, instigatorCheck, <>8__1.opposedRoll.name, null, <>8__1.opposedRoll, delegate(DiceRoller.RollResult r) { <>8__1.opposedRoll = r; }); <>1__state = 2; return true; case 2: <>1__state = -1; stack.AddOrModifyValue("opposedName", <>8__1.opposedRoll.name); stack.AddOrModifyValue("opposedFormula", <>8__1.opposedRoll.formula); stack.AddOrModifyValue("opposedRoll", <>8__1.opposedRoll.formulaResolved); stack.AddOrModifyValue("opposedDice", <>8__1.opposedRoll.formulaDice); stack.AddOrModifyValue("opposedTotal", <>8__1.opposedRoll.total.ToString()); LoggingPlugin.LogInfo(target.Name + "'s " + <>8__1.opposedRoll.name + " = " + <>8__1.opposedRoll.total); SendMessages(action.ToString() + ".Opposition", stack, instigator, target, publicity); <>8__1 = null; 5__2 = null; 5__3 = null; 5__4 = null; 5__5 = null; break; } LoggingPlugin.LogDebug("Ended ProcessTargetRoll..."); 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 d__12 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public RemoteQuerySpecs query; public TaskCompletionSource> token; public string[] specificClients; public string[] specificPlayers; public int expectedResults; public int expectedResultsTimeout; public Action onComplete; private <>c__DisplayClass12_0 <>8__1; private DiceRoller.RollResult 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass12_0(); <>8__1.queryTask = RemoteQuery.MakeRequest(query, token, specificClients, specificPlayers, expectedResults, expectedResultsTimeout); <>2__current = (object)new WaitUntil((Func)(() => <>8__1.queryTask.IsCompleted)); <>1__state = 1; return true; case 1: <>1__state = -1; 5__2 = JsonConvert.DeserializeObject>(<>8__1.queryTask.Result[0].response).ToArray()[0]; onComplete?.Invoke(5__2); 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 d__13 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public RemoteQuerySpecs query; public TaskCompletionSource> token; public string[] specificClients; public string[] specificPlayers; public int expectedResults; public int expectedResultsTimeout; public Action onComplete; private <>c__DisplayClass13_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass13_0(); <>8__1.queryTask = RemoteQuery.MakeRequest(query, token, specificClients, specificPlayers, expectedResults, expectedResultsTimeout); <>2__current = (object)new WaitUntil((Func)(() => <>8__1.queryTask.IsCompleted)); <>1__state = 1; return true; case 1: <>1__state = -1; onComplete?.Invoke(<>8__1.queryTask.Result[0].response); 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 d__14 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public Characters.CharacterSpecs instigatorSheet; public string rollName; public string rollFormula; public Action onComplete; private <>c__DisplayClass14_0 <>8__1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__14(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass14_0(); <>8__1.rollTask = DiceRoller.Roll(instigatorSheet, rollName, rollFormula, rollingStyleOffensive); <>2__current = (object)new WaitUntil((Func)(() => <>8__1.rollTask.IsCompleted)); <>1__state = 1; return true; case 1: <>1__state = -1; onComplete?.Invoke(<>8__1.rollTask.Result); 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(); } } public static List