using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using Bounce.Unmanaged;
using HarmonyLib;
using ModdingTales;
using Newtonsoft.Json;
using RadialUI;
using Unity.Mathematics;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ProjectilePlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ProjectilePlugin")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("ProjectilePlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("3.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("3.1.0.0")]
namespace LordAshes;
[BepInPlugin("org.lordashes.plugins.projectile", "Projectile Plug-In", "3.1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ProjectilePlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(BoardTool), "CallCameraClick")]
public static class PatchClick
{
public static bool Prefix(CameraClickEvent click)
{
//IL_0011: 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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
string[] obj = new string[7] { "User Click At ", null, null, null, null, null, null };
Vector2 position = click.position;
obj[1] = ((object)(Vector2)(ref position)).ToString();
obj[2] = " (AvoidClick=";
obj[3] = avoidClickRepeat.ToString();
obj[4] = ", activeProjectile==";
obj[5] = (activeProjectile != null).ToString();
obj[6] = ")";
LoggingPlugin.LogDebug(string.Concat(obj));
if (!avoidClickRepeat && activeProjectile != null)
{
((MonoBehaviour)self).StartCoroutine(preventClickCollection(1000f));
LoggingPlugin.LogTrace("Click While Selection Mode Active");
CreatureBoardAsset val = null;
float3 val2 = default(float3);
PixelPickingManager.TryGetPickedCreature(ref val2, ref val);
if (Input.GetMouseButtonDown(2))
{
LoggingPlugin.LogDebug("Triggering Projectile " + activeProjectile.name + " With Less Targets");
fire();
}
else if ((Object)(object)val != (Object)null)
{
string[] obj2 = new string[5] { "Selection of Creature ", val.Name, " (", null, null };
CreatureGuid creatureId = val.CreatureId;
obj2[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj2[4] = ")";
LoggingPlugin.LogDebug(string.Concat(obj2));
addAttackTarget(val);
}
else
{
LoggingPlugin.LogDebug("Selection of Location " + ((object)(float3)(ref val2)).ToString());
ProjectilePlugin.addAttackTarget(new Vector3(val2.x, val2.y, val2.z));
}
return false;
}
return true;
}
}
public class Projectile
{
public string name { get; set; }
public string iconName { get; set; }
public string assetBundleName { get; set; }
public string prefabName { get; set; } = "";
public string morphName { get; set; } = "";
public float morphDuration { get; set; } = 3f;
public int targets { get; set; }
public string pathType { get; set; } = "Arc";
public string pathParameterString { get; set; } = "";
public string targetArea { get; set; } = "SPELL";
public List<P3> sources { get; set; }
}
public class P3
{
public float x { get; set; }
public float y { get; set; }
public float z { get; set; }
public P3()
{
}
public P3(Vector3 source)
{
//IL_0009: 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_0023: Unknown result type (might be due to invalid IL or missing references)
x = source.x;
y = source.y;
z = source.z;
}
public Vector3 ToVector3()
{
//IL_0013: 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: Unknown result type (might be due to invalid IL or missing references)
return new Vector3(x, y, z);
}
}
public static class Utility
{
public static void PostOnMainPage(BaseUnityPlugin plugin)
{
string text = "Lord Ashes" + ("Lord Ashes".ToUpper().EndsWith("S") ? "'" : "'s");
ModdingUtils.AddPluginToMenuList(plugin, text);
}
public static bool isBoardLoaded()
{
return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
}
public static GameObject FindInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject FindInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: true, ref results, ref done, partial: true);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllInHierarchy(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done);
return results.ToArray();
}
public static GameObject[] FindAllInHierarchyViaPartialName(GameObject start, string seekName)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, seekName, null, single: false, ref results, ref done, partial: true);
return results.ToArray();
}
public static GameObject FindWithComponentInHierarchy(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: true, ref results, ref done);
return (results.Count > 0) ? results.ElementAt(0) : null;
}
public static GameObject[] FindAllWithComponentInHierarchy<T>(GameObject start, string seekType)
{
List<GameObject> results = new List<GameObject>();
bool done = false;
Traverse(start.transform, null, seekType, single: false, ref results, ref done);
return results.ToArray();
}
public static void Traverse(Transform root, string seekName, string seekType, bool single, ref List<GameObject> results, ref bool done, bool partial = false)
{
try
{
LoggingPlugin.LogTrace("Found '" + ((Object)((Component)root).gameObject).name + "' While Seeking Component Type '" + Convert.ToString(seekType) + "' And Name '" + Convert.ToString(seekName) + "' With Partial " + partial);
if ((seekName == null || seekName == ((Object)((Component)root).gameObject).name || (partial && ((Object)((Component)root).gameObject).name.Contains(seekName))) && (seekType == null || (Object)(object)((Component)root).GetComponent(seekType) != (Object)null))
{
LoggingPlugin.LogTrace("Matched '" + ((Object)((Component)root).gameObject).name + "'");
results.Add(((Component)root).gameObject);
if (single)
{
done = true;
return;
}
}
foreach (Transform item in ExtensionMethods.Children(root))
{
if (!done)
{
Traverse(item, seekName, seekType, single, ref results, ref done, partial);
}
}
}
catch
{
}
}
}
[CompilerGenerated]
private sealed class <AnimateProjectile>d__0 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public Guid id;
public Projectile projectile;
public AssetBundle ab;
public List<P3> targets;
public int target;
public ProjectilePlugin <>4__this;
private GameObject <projectileItem>5__1;
private string <builderName>5__2;
private GameObject <prefab>5__3;
private string[] <>s__4;
private int <>s__5;
private string <obj>5__6;
private List<Vector3> <path>5__7;
private Vector3 <delayPos>5__8;
private int <d>5__9;
private Vector3 <pos>5__10;
private Quaternion <rot>5__11;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <AnimateProjectile>d__0(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<projectileItem>5__1 = null;
<builderName>5__2 = null;
<prefab>5__3 = null;
<>s__4 = null;
<obj>5__6 = null;
<path>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: 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_05ab: Unknown result type (might be due to invalid IL or missing references)
//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
//IL_05de: Expected O, but got Unknown
//IL_063c: Unknown result type (might be due to invalid IL or missing references)
//IL_0641: Unknown result type (might be due to invalid IL or missing references)
//IL_0652: Unknown result type (might be due to invalid IL or missing references)
//IL_0657: Unknown result type (might be due to invalid IL or missing references)
//IL_0695: Unknown result type (might be due to invalid IL or missing references)
//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
//IL_06f6: Expected O, but got Unknown
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0431: Unknown result type (might be due to invalid IL or missing references)
//IL_0436: Unknown result type (might be due to invalid IL or missing references)
//IL_0458: Unknown result type (might be due to invalid IL or missing references)
//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
//IL_04de: Unknown result type (might be due to invalid IL or missing references)
//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0501: Unknown result type (might be due to invalid IL or missing references)
//IL_0535: Unknown result type (might be due to invalid IL or missing references)
//IL_0541: Unknown result type (might be due to invalid IL or missing references)
//IL_0546: Unknown result type (might be due to invalid IL or missing references)
//IL_0555: Unknown result type (might be due to invalid IL or missing references)
//IL_055a: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
LoggingPlugin.LogDebug("Creating " + projectile.name + " Target " + target + " Using " + projectile.prefabName);
LoggingPlugin.LogTrace("AB = " + Convert.ToString(Object.op_Implicit((Object)(object)ab)));
<projectileItem>5__1 = null;
try
{
LoggingPlugin.LogTrace("Getting prefab");
<prefab>5__3 = ab.LoadAsset<GameObject>(projectile.prefabName);
LoggingPlugin.LogTrace("PF = " + Convert.ToString(Object.op_Implicit((Object)(object)<prefab>5__3)));
LoggingPlugin.LogTrace("Making prefab instance");
<projectileItem>5__1 = Object.Instantiate<GameObject>(<prefab>5__3);
<projectileItem>5__1.transform.localPosition = Vector3.zero;
<projectileItem>5__1.transform.localRotation = Quaternion.Euler(Vector3.zero);
<prefab>5__3 = null;
}
catch
{
<>s__4 = ab.GetAllAssetNames();
for (<>s__5 = 0; <>s__5 < <>s__4.Length; <>s__5++)
{
<obj>5__6 = <>s__4[<>s__5];
LoggingPlugin.LogTrace("AB contains " + <obj>5__6);
<obj>5__6 = null;
}
<>s__4 = null;
}
LoggingPlugin.LogTrace("GO = " + Convert.ToString(Object.op_Implicit((Object)(object)<projectileItem>5__1)));
LoggingPlugin.LogTrace("Adding Animation From " + Convert.ToString(targets[0].ToVector3()) + " To " + Convert.ToString(targets[target].ToVector3()) + " In " + ((object)<>4__this.animationLength)?.ToString() + " Frames");
<builderName>5__2 = projectile.pathType.ToUpper();
if (!<>4__this.pathBuilders.ContainsKey(<builderName>5__2))
{
LoggingPlugin.LogTrace("Did not file Path Builder '" + <builderName>5__2 + "'. Using Path Builder '" + <>4__this.pathBuilders.ElementAt(0).Key + "' Instead.");
<builderName>5__2 = <>4__this.pathBuilders.ElementAt(0).Key;
}
else
{
LoggingPlugin.LogTrace("Using Path Builder " + <builderName>5__2);
}
if (<>4__this.pathBuilders[<builderName>5__2] != null)
{
LoggingPlugin.LogTrace("Buiding Path");
<path>5__7 = (List<Vector3>)<>4__this.pathBuilders[<builderName>5__2].GetMethod("MakePath").Invoke(null, new object[4]
{
targets[0].ToVector3(),
targets[target].ToVector3(),
projectile.pathParameterString,
(int)(<>4__this.animationLength.Value / <>4__this.animationSmoothness.Value)
});
<delayPos>5__8 = targets[0].ToVector3();
LoggingPlugin.LogTrace("Staggering Target If Applicable");
<d>5__9 = 0;
while ((float)<d>5__9 < <>4__this.animationStagger.Value * (float)(target - 1) / <>4__this.animationSmoothness.Value)
{
<path>5__7.Insert(0, <delayPos>5__8);
<d>5__9++;
}
LoggingPlugin.LogTrace("Setting Initial Animation Position");
<projectileItem>5__1.transform.position = new Vector3(<path>5__7.ElementAt(0).x, <path>5__7.ElementAt(0).y, <path>5__7.ElementAt(0).z + (float)target);
<projectileItem>5__1.transform.rotation = Quaternion.Euler(new Vector3(0f, <>4__this.GetAngle(<path>5__7.ElementAt(<path>5__7.Count - 1) - <path>5__7.ElementAt(0)), 0f));
LoggingPlugin.LogTrace("Animating Projectile");
goto IL_05ef;
}
LoggingPlugin.LogWarning("Builder Is Null");
break;
case 2:
<>1__state = -1;
goto IL_05ef;
case 3:
{
<>1__state = -1;
goto IL_0707;
}
IL_0707:
LoggingPlugin.LogTrace("Animation Complete. Destroying Projectile");
Object.Destroy((Object)(object)<projectileItem>5__1);
<path>5__7 = null;
break;
IL_05ef:
if (<path>5__7.Count > 0)
{
LoggingPlugin.LogTrace("Animating To Pos " + Convert.ToString(<path>5__7.ElementAt(0)));
<projectileItem>5__1.transform.position = <path>5__7.ElementAt(0);
<path>5__7.RemoveAt(0);
<>2__current = (object)new WaitForSeconds(<>4__this.animationSmoothness.Value);
<>1__state = 2;
return true;
}
if (projectile.morphName != "")
{
LoggingPlugin.LogInfo("Applying Morph");
<pos>5__10 = <projectileItem>5__1.transform.position;
<rot>5__11 = <projectileItem>5__1.transform.rotation;
Object.Destroy((Object)(object)<projectileItem>5__1);
<projectileItem>5__1 = Object.Instantiate<GameObject>(ab.LoadAsset<GameObject>(projectile.morphName));
<projectileItem>5__1.transform.position = <pos>5__10;
<projectileItem>5__1.transform.rotation = <rot>5__11;
LoggingPlugin.LogTrace("Waiting Morph Duration (" + projectile.morphDuration + "s)");
<>2__current = (object)new WaitForSeconds(projectile.morphDuration);
<>1__state = 3;
return true;
}
goto IL_0707;
}
runningAnimations.Remove(id);
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 <UnloadAssetBundle>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public AssetBundle ab;
public ProjectilePlugin <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <UnloadAssetBundle>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (runningAnimations.Count > 0)
{
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
}
LoggingPlugin.LogTrace("Animation Complete. Unloading Asset Bundle");
ab.Unload(true);
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 <preventClickCollection>d__5 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float delay;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <preventClickCollection>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
LoggingPlugin.LogTrace("Preventing click");
avoidClickRepeat = true;
<>2__current = (object)new WaitForSeconds(delay / 1000f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
avoidClickRepeat = false;
LoggingPlugin.LogTrace("Allowing click");
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();
}
}
private static bool avoidClickRepeat = false;
public const string Name = "Projectile Plug-In";
public const string Guid = "org.lordashes.plugins.projectile";
public const string Version = "3.1.0.0";
public const string Author = "Lord Ashes";
private ConfigEntry<float> animationLength;
private ConfigEntry<float> animationSmoothness;
private ConfigEntry<float> animationStagger;
private ConfigEntry<bool> dependencyModeOnly;
private List<Projectile> projectiles = new List<Projectile>();
private Dictionary<string, Type> pathBuilders = new Dictionary<string, Type>();
private static List<Guid> runningAnimations = new List<Guid>();
private static Dictionary<CreatureGuid, bool> creaturePermissions = new Dictionary<CreatureGuid, bool>();
private static ProjectilePlugin self = null;
private static Projectile activeProjectile = null;
private static Dictionary<string, Texture2D[]> icons = new Dictionary<string, Texture2D[]>();
[IteratorStateMachine(typeof(<AnimateProjectile>d__0))]
private IEnumerator AnimateProjectile(Guid id, Projectile projectile, AssetBundle ab, List<P3> targets, int target)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <AnimateProjectile>d__0(0)
{
<>4__this = this,
id = id,
projectile = projectile,
ab = ab,
targets = targets,
target = target
};
}
[IteratorStateMachine(typeof(<UnloadAssetBundle>d__1))]
private IEnumerator UnloadAssetBundle(AssetBundle ab)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <UnloadAssetBundle>d__1(0)
{
<>4__this = this,
ab = ab
};
}
private float GetAngle(Vector3 delta)
{
//IL_000b: 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)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
double num = 0.0;
switch (((delta.x >= 0f) ? "+" : "-") + ((delta.z >= 0f) ? "+" : "-"))
{
case "--":
num = Math.Atan(delta.x / delta.z) * 180.0 / Math.PI;
num += 180.0;
break;
case "-+":
num = Math.Atan(delta.x / delta.z) * 180.0 / Math.PI;
break;
case "+-":
num = Math.Atan(delta.x / delta.z) * 180.0 / Math.PI;
num += 180.0;
break;
case "++":
num = Math.Atan(delta.x / delta.z) * 180.0 / Math.PI;
break;
}
return (float)num;
}
[IteratorStateMachine(typeof(<preventClickCollection>d__5))]
private static IEnumerator preventClickCollection(float delay)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <preventClickCollection>d__5(0)
{
delay = delay
};
}
private void Awake()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0591: Unknown result type (might be due to invalid IL or missing references)
//IL_0597: Expected O, but got Unknown
self = this;
LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
LoggingPlugin.LogInfo(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")");
animationLength = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Projectile Animation Length In Frames", 3f, (ConfigDescription)null);
animationSmoothness = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Projectile Animation Interval Between Updates In Seconds", 0.1f, (ConfigDescription)null);
animationStagger = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Projectile Animation Stagger For Muliple Targets In Seconds", 0.25f, (ConfigDescription)null);
dependencyModeOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Dependency Mode Only", false, (ConfigDescription)null);
foreach (string item in from file in File.Catalog(false)
where file.ToUpper().EndsWith(".PROJECTILE")
select file)
{
LoggingPlugin.LogInfo("Found " + item);
string text = File.ReadAllText(item, (CacheType)999);
LoggingPlugin.LogInfo(text ?? "");
try
{
projectiles.Add(JsonConvert.DeserializeObject<Projectile>(text));
}
catch (Exception ex)
{
LoggingPlugin.LogError("Unable To Process " + item);
LoggingPlugin.LogError(ex.ToString());
}
}
if (!dependencyModeOnly.Value)
{
RadialSubmenu.EnsureMainMenuItem("org.lordashes.plugins.projectile", (MenuType)1, "Projectiles", Image.LoadSprite("Projectile.png", (CacheType)999));
foreach (Projectile projectile in projectiles)
{
string text2 = ((projectile.targets > 0) ? projectile.targets.ToString() : "Unlimited");
RadialSubmenu.CreateSubMenuItem("org.lordashes.plugins.projectile", projectile.name + " (" + text2 + " Target" + ((projectile.targets > 1) ? "s" : "") + ")", Image.LoadSprite(projectile.iconName, (CacheType)999), (Action<CreatureGuid, string, MapMenuItem>)delegate(CreatureGuid c, string n, MapMenuItem i)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
startAttackSelection(c, projectile);
}, true, (Func<bool>)null);
}
}
foreach (string item2 in from file in File.Catalog(true)
where file.ToUpper().Contains("_PATHBUILDER.DLL")
select file)
{
string text3 = item2.Substring(item2.LastIndexOf("(") + 1).Trim();
text3 = text3.Substring(0, text3.Length - 1);
string text4 = item2.Substring(0, item2.LastIndexOf("(")).Trim();
string text5 = text3 + text4;
Assembly assembly = Assembly.LoadFrom(text5);
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text5);
fileNameWithoutExtension = fileNameWithoutExtension.Substring(0, fileNameWithoutExtension.LastIndexOf("_"));
Type[] types = assembly.GetTypes();
foreach (Type type in types)
{
MethodInfo[] methods = type.GetMethods();
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name == "MakePath")
{
pathBuilders.Add(fileNameWithoutExtension.ToUpper(), type);
}
LoggingPlugin.LogInfo("PathBuilder " + fileNameWithoutExtension.ToUpper() + " Version " + assembly.ImageRuntimeVersion + " => " + Convert.ToString(type));
}
}
}
icons.Add("D", (Texture2D[])(object)new Texture2D[10]);
icons.Add("L", (Texture2D[])(object)new Texture2D[10]);
for (int l = 0; l < 10; l++)
{
if (l == 0)
{
icons["D"][l] = Image.LoadTexture("UD.png", (CacheType)999);
icons["L"][l] = Image.LoadTexture("UD.png", (CacheType)999);
}
else
{
icons["D"][l] = Image.LoadTexture(l + "D.png", (CacheType)999);
icons["L"][l] = Image.LoadTexture(l + "L.png", (CacheType)999);
}
}
LoggingPlugin.LogDebug("Subscribing to projectile (org.lordashes.plugins.projectile) requests.");
AssetDataPlugin.Subscribe("org.lordashes.plugins.projectile", (Action<DatumChange>)handleRequest);
Harmony val = new Harmony("org.lordashes.plugins.projectile");
val.PatchAll();
Utility.PostOnMainPage((BaseUnityPlugin)(object)this);
}
private void OnGUI()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if (activeProjectile == null)
{
return;
}
if (activeProjectile.targets <= 0)
{
GUI.DrawTexture(new Rect((float)(Screen.width - 32), 60f, 16f, 16f), (Texture)(object)icons["D"][0], (ScaleMode)2);
return;
}
for (int i = 1; i <= activeProjectile.targets; i++)
{
if (activeProjectile.sources.Count > i)
{
GUI.DrawTexture(new Rect((float)(Screen.width - 32), (float)(60 + (i - 1) * 20), 16f, 16f), (Texture)(object)icons["L"][i], (ScaleMode)2);
}
else
{
GUI.DrawTexture(new Rect((float)(Screen.width - 32), (float)(60 + (i - 1) * 20), 16f, 16f), (Texture)(object)icons["D"][i], (ScaleMode)2);
}
}
}
private static void startAttackSelection(CreatureGuid selectedCreatureId, Projectile projectile)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
LoggingPlugin.LogInfo("Initiated Projectile Attack " + projectile.name + " (" + projectile.targets + " Targets)");
((MonoBehaviour)self).StartCoroutine(preventClickCollection(1000f));
CreatureBoardAsset val = null;
NGuid lastRadialTargetCreature = RadialUIPlugin.GetLastRadialTargetCreature();
CreaturePresenter.TryGetAsset(new CreatureGuid(lastRadialTargetCreature), ref val);
if ((Object)(object)val == (Object)null)
{
CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val);
}
if ((Object)(object)val != (Object)null)
{
string[] obj = new string[5] { "Attacking Creature Is ", val.Name, " (", null, null };
CreatureGuid creatureId = val.CreatureId;
obj[3] = ((object)(CreatureGuid)(ref creatureId)).ToString();
obj[4] = ")";
LoggingPlugin.LogDebug(string.Concat(obj));
Vector3 position = ((EmotingMovableBoardAsset)val).GetHook((HookTransform)1).position;
activeProjectile = projectile;
activeProjectile.sources = new List<P3>
{
new P3(((EmotingMovableBoardAsset)val).GetHook((HookTransform)1).position)
};
}
else
{
LoggingPlugin.LogWarning("Attacking CreatureId Is Not Null");
}
}
private static void addAttackTarget(CreatureBoardAsset asset)
{
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
LoggingPlugin.LogDebug("Projectile Attack " + activeProjectile.name + " Target Selection (" + activeProjectile.sources.Count + " of " + activeProjectile.targets + ")");
if ((Object)(object)asset != (Object)null)
{
switch (activeProjectile.targetArea.ToUpper())
{
case "HEAD":
activeProjectile.sources.Add(new P3(asset.HookHead.position));
break;
case "CAST":
case "SPELL":
activeProjectile.sources.Add(new P3(((EmotingMovableBoardAsset)asset).GetHook((HookTransform)1).position));
break;
case "TORCH":
activeProjectile.sources.Add(new P3(((EmotingMovableBoardAsset)asset).GetHook((HookTransform)3).position));
break;
default:
activeProjectile.sources.Add(new P3(((EmotingMovableBoardAsset)asset).GetHook((HookTransform)2).position));
break;
}
}
if (activeProjectile.targets > 0 && activeProjectile.sources.Count > activeProjectile.targets)
{
fire();
}
}
private static void addAttackTarget(Vector3 position)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
LoggingPlugin.LogDebug("Projectile Attack " + activeProjectile.name + " Target Selection (Location " + ((object)(Vector3)(ref position)).ToString() + ")");
activeProjectile.sources.Add(new P3(position));
if (activeProjectile.targets > 0 && activeProjectile.sources.Count > activeProjectile.targets)
{
fire();
}
}
private static void fire()
{
LoggingPlugin.LogInfo("Projectile Attack " + activeProjectile.name + " Triggered");
AssetDataPlugin.SendInfo("org.lordashes.plugins.projectile", JsonConvert.SerializeObject((object)activeProjectile));
activeProjectile = null;
}
private void handleRequest(DatumChange change)
{
try
{
Projectile projectile = JsonConvert.DeserializeObject<Projectile>(change.value.ToString());
LoggingPlugin.LogDebug("Getting Projectile Name " + projectile.name);
List<P3> sources = projectile.sources;
if (projectile.prefabName == "")
{
projectile.prefabName = projectile.assetBundleName;
}
LoggingPlugin.LogTrace("Getting Projectile Asset Bundle " + projectile.assetBundleName + " Prefab " + projectile.prefabName + " Morph " + ((projectile.morphName == "") ? "None" : projectile.morphName));
AssetBundle val = AssetBundle.Load(projectile.assetBundleName + ".assetBundle", (CacheType)999);
if ((Object)(object)val != (Object)null)
{
runningAnimations = new List<Guid>();
for (int i = 1; i < sources.Count; i++)
{
runningAnimations.Add(System.Guid.NewGuid());
((MonoBehaviour)this).StartCoroutine(AnimateProjectile(runningAnimations.ElementAt(runningAnimations.Count - 1), projectile, val, sources, i));
}
((MonoBehaviour)this).StartCoroutine(UnloadAssetBundle(val));
}
else
{
LoggingPlugin.LogWarning("Error Loading Asset Bundle " + projectile.assetBundleName);
}
}
catch (Exception ex)
{
LoggingPlugin.LogInfo("Exception Processing Projectile");
LoggingPlugin.LogWarning(ex.ToString());
}
}
}