Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ReBallista v1.0.431
ReBallista.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ReBallista")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.427.0")] [assembly: AssemblyInformationalVersion("1.0.427+386aee85c96197fd0a4a3031799c457837f3648d")] [assembly: AssemblyProduct("ReBallista")] [assembly: AssemblyTitle("ReBallista")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.427.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SmartBallista { internal static class BallistaAim { internal static float Alignment(float quaternionDot) { return Math.Min(1f, Math.Abs(quaternionDot)); } } internal static class BallistaAmmo { internal static int GetCapacity(int originalCapacity, int configuredCapacity) { if (originalCapacity <= 0 || configuredCapacity <= 0) { return originalCapacity; } return configuredCapacity; } } [BepInPlugin("com.skarif.reballista", "Better Ballista AI", "1.0.427")] public class SmartBallistaPlugin : BaseUnityPlugin { internal static ConfigEntry<bool> EnableAshlandsBallistas; internal static ConfigEntry<float> BallistaRange; internal static ConfigEntry<bool> EnableFriendlyFire; internal static ConfigEntry<int> MaxAmmo; private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) EnableAshlandsBallistas = ((BaseUnityPlugin)this).Config.Bind<bool>("Ballistas", "EnableAshlandsBallistas", false, "Apply improved aiming, accuracy and homing bolts to hostile Ashlands bone ballistas (Skugg). They will still attack players and tamed creatures. Restart the game after changing this setting."); BallistaRange = ((BaseUnityPlugin)this).Config.Bind<float>("Ballistas", "BallistaRange", 0f, new ConfigDescription("Target acquisition range in meters for all ballistas, including Ashlands bone ballistas. 0 keeps each ballista's vanilla range. Restart the game after changing this setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), Array.Empty<object>())); EnableFriendlyFire = ((BaseUnityPlugin)this).Config.Bind<bool>("Ballistas", "EnableFriendlyFire", false, "Allow non-Ashlands ballistas, including custom structures, to target players and tamed creatures. False keeps ReBallista's friendly-target protection. Ashlands bone ballistas remain hostile regardless of this setting. This controls target selection, not damage from stray bolts. Restart the game after changing this setting."); MaxAmmo = ((BaseUnityPlugin)this).Config.Bind<int>("Ballistas", "MaxAmmo", 0, new ConfigDescription("Maximum number of bolts that can be loaded into a ballista (1-10000). 0 keeps each ballista's original capacity. Ballistas with unlimited ammo, including Ashlands bone ballistas, keep unlimited ammo. This does not add or remove loaded bolts. Restart the game after changing this setting.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10000), Array.Empty<object>())); new Harmony("com.skarif.reballista").PatchAll(); } internal static bool IsAshlandsBallista(Turret turret) { if (!((Object)turret).name.Equals("piece_Charred_Balista", StringComparison.OrdinalIgnoreCase) && !((Object)turret).name.Equals("piece_Charred_Balista(Clone)", StringComparison.OrdinalIgnoreCase)) { return turret.m_name == "$piece_charredballista"; } return true; } internal static bool UsesImprovedBehavior(Turret turret) { if (IsAshlandsBallista(turret)) { return EnableAshlandsBallistas.Value; } return true; } public static Vector3 CalculateTargetPoint(Character target) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) Vector3 centerPoint = target.GetCenterPoint(); float y = ((Component)target).transform.position.y; float num = centerPoint.y - y; if (num < 0.55f) { centerPoint.y = y + num * 0.65f; } return centerPoint; } } [HarmonyPatch(typeof(Turret), "Awake")] public static class Turret_Awake_Patch { public static void Postfix(Turret __instance) { __instance.m_maxAmmo = BallistaAmmo.GetCapacity(__instance.m_maxAmmo, SmartBallistaPlugin.MaxAmmo.Value); bool flag = SmartBallistaPlugin.IsAshlandsBallista(__instance); if (flag) { __instance.m_targetPlayers = true; __instance.m_targetTamed = true; __instance.m_targetEnemies = false; } float value = SmartBallistaPlugin.BallistaRange.Value; if (value > 0f && !float.IsNaN(value) && !float.IsInfinity(value)) { __instance.m_viewDistance = value; if ((Object)(object)__instance.m_marker != (Object)null) { __instance.m_marker.m_radius = value; } } if (SmartBallistaPlugin.UsesImprovedBehavior(__instance)) { __instance.m_turnRate = 45f; __instance.m_lookAcceleration = 8f; __instance.m_lookDeacceleration = 8f; __instance.m_lookMinDegreesDelta = 0.01f; __instance.m_shootWhenAimDiff = 0.999f; if (!flag) { __instance.m_targetTamedConfig = (__instance.m_targetTamed = (__instance.m_targetPlayers = SmartBallistaPlugin.EnableFriendlyFire.Value)); } } } } [HarmonyPatch(typeof(Turret), "UpdateTurretRotation")] public static class Turret_UpdateTurretRotation_Patch { public static bool Prefix(Turret __instance) { //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: 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_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03f7: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_025e: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) if (!SmartBallistaPlugin.UsesImprovedBehavior(__instance)) { return true; } if (__instance.IsCoolingDown()) { return false; } float fixedDeltaTime = Time.fixedDeltaTime; Character value = Traverse.Create((object)__instance).Field("m_target").GetValue<Character>(); bool flag = (Object)(object)value != (Object)null && !value.IsDead() && __instance.HasAmmo(); Vector3 val3; Quaternion rotation; if (flag) { ItemData value2 = Traverse.Create((object)__instance).Field("m_lastAmmo").GetValue<ItemData>(); if (value2 == null) { value2 = Traverse.Create((object)__instance).Method("GetAmmoItem", Array.Empty<object>()).GetValue<ItemData>(); Traverse.Create((object)__instance).Field("m_lastAmmo").SetValue((object)value2); } if (value2 == null) { return true; } float num = value2.m_shared.m_attack.m_projectileVel; if (num <= 0.1f) { num = 50f; } Vector3 val = SmartBallistaPlugin.CalculateTargetPoint(value); Vector3 position = __instance.m_turretBody.transform.position; float num2 = Mathf.Clamp(Vector3.Distance(val, position) / num, 0f, 0.35f); Vector3 val2 = value.GetVelocity() * num2 * __instance.m_predictionModifier; val3 = val + val2 - position; } else if (!__instance.HasAmmo()) { val3 = ((Component)__instance).transform.forward + new Vector3(0f, -0.3f, 0f); } else { float value3 = Traverse.Create((object)__instance).Field("m_scan").GetValue<float>(); value3 += fixedDeltaTime; if (value3 > __instance.m_noTargetScanRate * 2f) { value3 = 0f; } Traverse.Create((object)__instance).Field("m_scan").SetValue((object)value3); rotation = ((Component)__instance).transform.rotation; val3 = Quaternion.Euler(0f, ((Quaternion)(ref rotation)).eulerAngles.y + ((value3 - __instance.m_noTargetScanRate > 0f) ? 1f : (-1f)) * __instance.m_horizontalAngle, 0f) * Vector3.forward; } ((Vector3)(ref val3)).Normalize(); Quaternion val4 = Quaternion.LookRotation(val3, Vector3.up); Quaternion val5 = val4; Vector3 eulerAngles = ((Quaternion)(ref val4)).eulerAngles; rotation = ((Component)__instance).transform.rotation; float y = ((Quaternion)(ref rotation)).eulerAngles.y; eulerAngles.y -= y; if (__instance.m_horizontalAngle >= 0f) { float num3 = eulerAngles.y; if (num3 > 180f) { num3 -= 360f; } else if (num3 < -180f) { num3 += 360f; } if (num3 > __instance.m_horizontalAngle) { ((Vector3)(ref eulerAngles))..ctor(eulerAngles.x, __instance.m_horizontalAngle + y, eulerAngles.z); ((Quaternion)(ref val4)).eulerAngles = eulerAngles; } else if (num3 < 0f - __instance.m_horizontalAngle) { ((Vector3)(ref eulerAngles))..ctor(eulerAngles.x, 0f - __instance.m_horizontalAngle + y, eulerAngles.z); ((Quaternion)(ref val4)).eulerAngles = eulerAngles; } } Quaternion value4 = Traverse.Create((object)__instance).Field("m_lastRotation").GetValue<Quaternion>(); Quaternion val6 = Utils.RotateTorwardsSmooth(__instance.m_turretBody.transform.rotation, val4, value4, __instance.m_turnRate * fixedDeltaTime, __instance.m_lookAcceleration, __instance.m_lookDeacceleration, __instance.m_lookMinDegreesDelta); Traverse.Create((object)__instance).Field("m_lastRotation").SetValue((object)__instance.m_turretBody.transform.rotation); Quaternion value5 = Traverse.Create((object)__instance).Field("m_baseBodyRotation").GetValue<Quaternion>(); Quaternion value6 = Traverse.Create((object)__instance).Field("m_baseNeckRotation").GetValue<Quaternion>(); __instance.m_turretBody.transform.rotation = value5 * val6; Transform transform = __instance.m_turretNeck.transform; rotation = __instance.m_turretBody.transform.rotation; float y2 = ((Quaternion)(ref rotation)).eulerAngles.y; rotation = __instance.m_turretBody.transform.rotation; transform.rotation = value6 * Quaternion.Euler(0f, y2, ((Quaternion)(ref rotation)).eulerAngles.z); float num4 = (flag ? BallistaAim.Alignment(Quaternion.Dot(val6, val5)) : (-1f)); Traverse.Create((object)__instance).Field("m_aimDiffToTarget").SetValue((object)num4); return false; } } [HarmonyPatch(typeof(Turret), "ShootProjectile")] public static class Turret_ShootProjectile_Patch { public sealed class AccuracyState { public Attack Attack; public float Accuracy; } public static void Prefix(Turret __instance, out AccuracyState __state) { __state = null; if (SmartBallistaPlugin.UsesImprovedBehavior(__instance)) { ItemData value = Traverse.Create((object)__instance).Method("GetAmmoItem", Array.Empty<object>()).GetValue<ItemData>(); if (value != null) { Attack attack = value.m_shared.m_attack; __state = new AccuracyState { Attack = attack, Accuracy = attack.m_projectileAccuracy }; attack.m_projectileAccuracy = 0f; } } } public static void Postfix(Turret __instance) { if (SmartBallistaPlugin.UsesImprovedBehavior(__instance)) { GameObject value = Traverse.Create((object)__instance).Field("m_lastProjectile").GetValue<GameObject>(); Character value2 = Traverse.Create((object)__instance).Field("m_target").GetValue<Character>(); if ((Object)(object)value != (Object)null && (Object)(object)value2 != (Object)null) { value.AddComponent<SmartBoltTracker>().Init(value2); } } } public static Exception Finalizer(Exception __exception, AccuracyState __state) { if (__state != null) { __state.Attack.m_projectileAccuracy = __state.Accuracy; } return __exception; } } public class SmartBoltTracker : MonoBehaviour { private static readonly FieldInfo VelField = typeof(Projectile).GetField("m_vel", BindingFlags.Instance | BindingFlags.NonPublic); private Character m_target; private Projectile m_projectile; private const float TurnSpeedDeg = 65f; public void Init(Character target) { m_target = target; m_projectile = ((Component)this).GetComponent<Projectile>(); } private void FixedUpdate() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00da: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_target == (Object)null || m_target.IsDead() || (Object)(object)m_projectile == (Object)null || VelField == null) { return; } Vector3 val = (Vector3)VelField.GetValue(m_projectile); float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 1f)) { Vector3 val2 = SmartBallistaPlugin.CalculateTargetPoint(m_target) - ((Component)this).transform.position; float magnitude2 = ((Vector3)(ref val2)).magnitude; if (magnitude2 > 0.4f && magnitude2 < 25f) { Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val3 = Vector3.RotateTowards(val, normalized * magnitude, MathF.PI * 13f / 36f * Time.fixedDeltaTime, 0f); VelField.SetValue(m_projectile, val3); ((Component)this).transform.rotation = Quaternion.LookRotation(val3); } } } } [HarmonyPatch] public static class BallistaWelcomeMessage { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__8_1; public static UnityAction <>9__8_2; internal void <ShowWelcomePanel>b__8_1() { Application.OpenURL("https://discord.com/users/1084209564653727804"); } internal void <ShowWelcomePanel>b__8_2() { Application.OpenURL("https://steamcommunity.com/id/Skarif_W/"); } } private static bool _shown; private const string PREFS_KEY = "SmartBallista_HideWelcome"; private static Sprite _discordSprite; private static Sprite _steamSprite; private static void LoadExternalLogos() { if ((Object)(object)_discordSprite == (Object)null) { _discordSprite = LoadEmbeddedIcon("discord-logo.ico") ?? LoadEmbeddedIcon("discord-logo.png"); } if ((Object)(object)_steamSprite == (Object)null) { _steamSprite = LoadEmbeddedIcon("steam-logo.ico") ?? LoadEmbeddedIcon("steam-logo.png"); } } private static Sprite LoadEmbeddedIcon(string fileName) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) try { Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = executingAssembly.GetManifestResourceNames().FirstOrDefault((string r) => r.EndsWith(fileName, StringComparison.OrdinalIgnoreCase)); byte[] array = null; if (!string.IsNullOrEmpty(text)) { using Stream stream = executingAssembly.GetManifestResourceStream(text); if (stream != null) { array = new byte[stream.Length]; stream.Read(array, 0, array.Length); } } if (array == null) { string directoryName = Path.GetDirectoryName(executingAssembly.Location); string[] array2 = new string[4] { Path.Combine(directoryName, "logos", fileName), Path.Combine(directoryName, fileName), Path.Combine(Paths.PluginPath, "logos", fileName), Path.Combine(Paths.PluginPath, fileName) }; for (int num = 0; num < array2.Length; num++) { if (File.Exists(array2[num])) { array = File.ReadAllBytes(array2[num]); break; } } } if (array != null && array.Length != 0) { byte[] data = ExtractIconImagePayload(array); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; if (TryLoadTexture(val, data)) { return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } } catch { } return null; } private static bool TryLoadTexture(Texture2D tex, byte[] data) { if ((Object)(object)tex == (Object)null || data == null || data.Length == 0) { return false; } try { Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule") ?? Type.GetType("UnityEngine.ImageConversion, UnityEngine"); if (type != null) { MethodInfo method = type.GetMethod("LoadImage", BindingFlags.Static | BindingFlags.Public, null, new Type[2] { typeof(Texture2D), typeof(byte[]) }, null); if (method != null) { return (bool)method.Invoke(null, new object[2] { tex, data }); } } MethodInfo method2 = typeof(Texture2D).GetMethod("LoadImage", BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(byte[]) }, null); if (method2 != null) { return (bool)method2.Invoke(tex, new object[1] { data }); } } catch { } return false; } private static byte[] ExtractIconImagePayload(byte[] icoBytes) { if (icoBytes == null || icoBytes.Length < 22) { return icoBytes; } if (icoBytes[0] == 137 && icoBytes[1] == 80 && icoBytes[2] == 78 && icoBytes[3] == 71) { return icoBytes; } try { int num = BitConverter.ToUInt16(icoBytes, 4); if (num == 0) { return icoBytes; } int num2 = 0; int num3 = -1; for (int i = 0; i < num; i++) { int num4 = 6 + i * 16; int num5 = icoBytes[num4]; int num6 = icoBytes[num4 + 1]; if (num5 == 0) { num5 = 256; } if (num6 == 0) { num6 = 256; } int num7 = num5 * num6; if (num7 > num3) { num3 = num7; num2 = i; } } int num8 = 6 + num2 * 16; int num9 = BitConverter.ToInt32(icoBytes, num8 + 8); int num10 = BitConverter.ToInt32(icoBytes, num8 + 12); if (num10 + num9 <= icoBytes.Length) { byte[] array = new byte[num9]; Buffer.BlockCopy(icoBytes, num10, array, 0, num9); if (array.Length > 8 && array[0] == 137 && array[1] == 80 && array[2] == 78 && array[3] == 71) { return array; } if (array.Length > 40 && BitConverter.ToInt32(array, 0) == 40) { byte[] array2 = new byte[14 + array.Length]; array2[0] = 66; array2[1] = 77; Buffer.BlockCopy(BitConverter.GetBytes(array2.Length), 0, array2, 2, 4); Buffer.BlockCopy(BitConverter.GetBytes(54), 0, array2, 10, 4); Buffer.BlockCopy(array, 0, array2, 14, array.Length); return array2; } return array; } } catch { } return icoBytes; } [HarmonyPatch(typeof(FejdStartup), "Start")] [HarmonyPostfix] public static void ShowWelcomePanel() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_00a6: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: 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) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Expected O, but got Unknown //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Expected O, but got Unknown //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_049e: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Expected O, but got Unknown //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0548: 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_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05de: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Expected O, but got Unknown //IL_0628: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_0654: Unknown result type (might be due to invalid IL or missing references) //IL_0659: Unknown result type (might be due to invalid IL or missing references) //IL_0683: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) //IL_06a7: Unknown result type (might be due to invalid IL or missing references) //IL_06b6: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06e4: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_0751: Unknown result type (might be due to invalid IL or missing references) //IL_0760: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_0774: Unknown result type (might be due to invalid IL or missing references) //IL_0793: 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_0717: Expected O, but got Unknown //IL_07eb: Unknown result type (might be due to invalid IL or missing references) //IL_0803: Unknown result type (might be due to invalid IL or missing references) //IL_0812: Unknown result type (might be due to invalid IL or missing references) //IL_0821: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_07c0: Unknown result type (might be due to invalid IL or missing references) //IL_07c6: Expected O, but got Unknown //IL_085a: Unknown result type (might be due to invalid IL or missing references) //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_0883: Expected O, but got Unknown if (_shown || PlayerPrefs.GetInt("SmartBallista_HideWelcome", 0) == 1) { return; } _shown = true; LoadExternalLogos(); GameObject canvasGO = new GameObject("WelcomeCanvas_SmartBallista"); canvasGO.layer = 5; Canvas obj = canvasGO.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 9999; canvasGO.AddComponent<CanvasScaler>(); canvasGO.AddComponent<GraphicRaycaster>(); Object.DontDestroyOnLoad((Object)(object)canvasGO); GameObject val = MakeRect("Background", canvasGO.transform, new Color(0.06f, 0.06f, 0.07f, 0.98f)); SetRect(val, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(640f, 420f), Vector2.zero); Outline obj2 = val.AddComponent<Outline>(); ((Shadow)obj2).effectColor = new Color(0.25f, 0.25f, 0.25f, 1f); ((Shadow)obj2).effectDistance = new Vector2(2f, -2f); string text = "ReBallista"; SetRect(((Component)MakeText("Header", val.transform, text, 24, new Color(1f, 0.72f, 0.15f), (FontStyle)1)).gameObject, new Vector2(0f, 0.85f), new Vector2(1f, 1f), Vector2.zero, new Vector2(0f, -10f)); GameObject val2 = MakeRect("ContentBox", val.transform, new Color(0f, 0f, 0f, 0.45f)); SetRect(val2, new Vector2(0.05f, 0.28f), new Vector2(0.95f, 0.83f), Vector2.zero, Vector2.zero); Outline obj3 = val2.AddComponent<Outline>(); ((Shadow)obj3).effectColor = new Color(1f, 1f, 1f, 0.05f); ((Shadow)obj3).effectDistance = new Vector2(1f, -1f); bool num = PlayerPrefs.GetString("language", "English").Equals("Russian", StringComparison.OrdinalIgnoreCase); string text2 = (num ? "Переделанный <color=#55AAFF>ИИ</color> баллисты: <color=#FF4444>сверхточные</color> выстрелы и полезный <color=#55FF88>друг</color>." : "Redesigned Ballista <color=#55AAFF>AI</color>: <color=#FF4444>Super-accurate</color> shots and a helpful <color=#55FF88>friend</color>."); GameObject val3 = new GameObject("BodyText") { layer = 5 }; val3.transform.SetParent(val2.transform, false); Text obj4 = val3.AddComponent<Text>(); obj4.text = text2; obj4.font = GetValheimFont(); obj4.fontSize = 18; ((Graphic)obj4).color = new Color(0.92f, 0.92f, 0.92f, 1f); obj4.lineSpacing = 1.35f; obj4.supportRichText = true; obj4.alignment = (TextAnchor)4; obj4.horizontalOverflow = (HorizontalWrapMode)0; obj4.verticalOverflow = (VerticalWrapMode)1; RectTransform component = val3.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = new Vector2(-40f, -40f); component.anchoredPosition = Vector2.zero; bool dontShow = false; GameObject val4 = new GameObject("CheckRow"); val4.layer = 5; val4.transform.SetParent(val.transform, false); RectTransform obj5 = val4.AddComponent<RectTransform>(); obj5.anchorMin = new Vector2(0.5f, 0.2f); obj5.anchorMax = new Vector2(0.5f, 0.2f); obj5.pivot = new Vector2(0.5f, 0.5f); obj5.anchoredPosition = Vector2.zero; HorizontalLayoutGroup obj6 = val4.AddComponent<HorizontalLayoutGroup>(); ((LayoutGroup)obj6).childAlignment = (TextAnchor)4; ((HorizontalOrVerticalLayoutGroup)obj6).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)obj6).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj6).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)obj6).spacing = 10f; ContentSizeFitter obj7 = val4.AddComponent<ContentSizeFitter>(); obj7.horizontalFit = (FitMode)2; obj7.verticalFit = (FitMode)2; GameObject val5 = new GameObject("Box"); val5.layer = 5; val5.transform.SetParent(val4.transform, false); Image boxImg = val5.AddComponent<Image>(); ((Graphic)boxImg).color = new Color(0.18f, 0.18f, 0.2f, 1f); val5.GetComponent<RectTransform>().sizeDelta = new Vector2(20f, 20f); LayoutElement obj8 = val5.AddComponent<LayoutElement>(); obj8.minWidth = 20f; obj8.preferredWidth = 20f; obj8.minHeight = 20f; obj8.preferredHeight = 20f; obj8.flexibleWidth = 0f; Outline obj9 = val5.AddComponent<Outline>(); ((Shadow)obj9).effectColor = new Color(0.45f, 0.45f, 0.45f, 0.8f); ((Shadow)obj9).effectDistance = new Vector2(1f, -1f); GameObject tickGO = new GameObject("Tick"); tickGO.layer = 5; tickGO.transform.SetParent(val5.transform, false); Text obj10 = tickGO.AddComponent<Text>(); obj10.text = "✓"; obj10.font = GetValheimFont(); obj10.fontSize = 15; ((Graphic)obj10).color = Color.white; obj10.fontStyle = (FontStyle)1; obj10.alignment = (TextAnchor)4; RectTransform component2 = tickGO.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; component2.anchoredPosition = Vector2.zero; tickGO.SetActive(false); string text3 = (num ? "Больше не показывать" : "Don't show this again"); GameObject val6 = new GameObject("Label") { layer = 5 }; val6.transform.SetParent(val4.transform, false); Text obj11 = val6.AddComponent<Text>(); obj11.text = text3; obj11.font = GetValheimFont(); obj11.fontSize = 15; ((Graphic)obj11).color = new Color(0.85f, 0.85f, 0.85f, 1f); obj11.alignment = (TextAnchor)3; ContentSizeFitter obj12 = val6.AddComponent<ContentSizeFitter>(); obj12.horizontalFit = (FitMode)2; obj12.verticalFit = (FitMode)2; ((UnityEvent)val4.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) dontShow = !dontShow; tickGO.SetActive(dontShow); ((Graphic)boxImg).color = (dontShow ? new Color(0.18f, 0.55f, 0.95f, 1f) : new Color(0.18f, 0.18f, 0.2f, 1f)); }); GameObject val7 = MakeRect("BottomBar", val.transform, Color.clear); SetRect(val7, new Vector2(0.05f, 0.05f), new Vector2(0.95f, 0.15f), Vector2.zero, Vector2.zero); GameObject obj13 = MakeRect("DiscordBtn", val7.transform, new Color(0.345f, 0.396f, 0.949f, 1f)); SetRect(obj13, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(180f, 44f), new Vector2(90f, 0f)); CreateSocialButtonContent(obj13.transform, _discordSprite, new Vector2(29f, 29f)); ButtonClickedEvent onClick = obj13.AddComponent<Button>().onClick; object obj14 = <>c.<>9__8_1; if (obj14 == null) { UnityAction val8 = delegate { Application.OpenURL("https://discord.com/users/1084209564653727804"); }; <>c.<>9__8_1 = val8; obj14 = (object)val8; } ((UnityEvent)onClick).AddListener((UnityAction)obj14); GameObject obj15 = MakeRect("SteamBtn", val7.transform, new Color(0.12f, 0.22f, 0.36f, 1f)); SetRect(obj15, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(180f, 44f), Vector2.zero); CreateSocialButtonContent(obj15.transform, _steamSprite, new Vector2(24f, 24f)); ButtonClickedEvent onClick2 = obj15.AddComponent<Button>().onClick; object obj16 = <>c.<>9__8_2; if (obj16 == null) { UnityAction val9 = delegate { Application.OpenURL("https://steamcommunity.com/id/Skarif_W/"); }; <>c.<>9__8_2 = val9; obj16 = (object)val9; } ((UnityEvent)onClick2).AddListener((UnityAction)obj16); GameObject val10 = MakeRect("CloseBtn", val7.transform, new Color(0.75f, 0.2f, 0.2f, 1f)); SetRect(val10, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(180f, 44f), new Vector2(-90f, 0f)); string text4 = (num ? "ЗАКРЫТЬ" : "CLOSE"); MakeText("CloseTxt", val10.transform, text4, 15, Color.white, (FontStyle)1); ((UnityEvent)val10.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { if (dontShow) { PlayerPrefs.SetInt("SmartBallista_HideWelcome", 1); PlayerPrefs.Save(); } Object.Destroy((Object)(object)canvasGO); }); } private static void CreateSocialButtonContent(Transform parent, Sprite iconSprite, Vector2 iconSize) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_007c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)iconSprite == (Object)null)) { GameObject val = MakeRect("Content", parent, Color.clear); SetRect(val, Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero); GameObject obj = MakeRect("Icon", val.transform, Color.white); Image component = obj.GetComponent<Image>(); component.sprite = iconSprite; component.preserveAspect = true; SetRect(obj, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), iconSize, Vector2.zero); } } public static GameObject MakeRect(string name, Transform parent, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown GameObject val = new GameObject(name) { layer = 5 }; val.transform.SetParent(parent, false); ((Graphic)val.AddComponent<Image>()).color = color; return val; } public static Text MakeText(string name, Transform parent, string text, int size, Color color, FontStyle style = (FontStyle)0) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: 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) GameObject val = new GameObject(name); val.layer = 5; val.transform.SetParent(parent, false); Text obj = val.AddComponent<Text>(); obj.text = text; obj.font = GetValheimFont(); obj.fontSize = size; ((Graphic)obj).color = color; obj.fontStyle = style; obj.alignment = (TextAnchor)4; RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.sizeDelta = Vector2.zero; component.anchoredPosition = Vector2.zero; return obj; } public static void SetRect(GameObject go, Vector2 anchorMin, Vector2 anchorMax, Vector2 sizeDelta, Vector2 anchoredPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) RectTransform component = go.GetComponent<RectTransform>(); component.anchorMin = anchorMin; component.anchorMax = anchorMax; component.sizeDelta = sizeDelta; component.anchoredPosition = anchoredPos; } public static Font GetValheimFont() { Font[] array = Object.FindObjectsByType<Font>((FindObjectsSortMode)0); foreach (Font val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name.Contains("Averia")) { return val; } } return Resources.GetBuiltinResource<Font>("Arial.ttf"); } } }