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 Helmr v0.1.2
plugins/Helmr/DarklightCreations.Helmr.dll
Decompiled 3 minutes ago
The result has been truncated due to the large size, download it to view full contents!
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.Versioning; using System.Text; using System.Threading; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; [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("DarklightCreations.Helmr")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("DarklightCreations.Helmr")] [assembly: AssemblyTitle("DarklightCreations.Helmr")] [assembly: AssemblyVersion("1.0.0.0")] [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 Fred.FieldArtillery { internal static class Plugin { internal const string PluginId = "fred.fieldartillery"; internal const string Ballista = "fred_flint_ballista"; internal const string Polybolos = "fred_bronze_polybolos"; internal static CarriageSpec StandardCarriage() { //IL_0020: 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) return new CarriageSpec { WheelRadius = 0.56f, Wheel = new Vector3(0.91f, 0.56f, 0.1f), WheelModel = "wheel", HitchZ = -1.66f }; } } internal static class AmmoArt { internal static void Fit(ObjectDB db, IModHost host, GameObject item, AmmoSpec ammo) { //IL_00b0: 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_00ef: 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) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0211: 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_0248: 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_0281: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = item.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } Collider[] componentsInChildren2 = item.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { componentsInChildren2[i].enabled = false; } if (ammo.Prefab != "bf_maxim_belt") { GameObject obj = ItemModel.BuildModel(db, host, item.transform, ammo.Model); Mesh sharedMesh = obj.GetComponent<MeshFilter>().sharedMesh; Transform transform = obj.transform; Vector3 up = Vector3.up; Bounds bounds = sharedMesh.bounds; transform.localPosition = up * (0.015f - ((Bounds)(ref bounds)).min.y); return; } Transform val = WagonModel.Child(item.transform, "Cartridge leather pack", Vector3.zero); WagonModel wagonModel = new WagonModel(db, val); wagonModel.Box("leather", 0f, 0.069f, -0.015f, 0.386f, 0.13f, 0.226f); wagonModel.Box("rawwood", 0f, 0.027f, -0.015f, 0.389f, 0.046f, 0.23f); wagonModel.Box("finewood", 0f, 0.131f, -0.042f, 0.386f, 0.035f, 0.171f); for (int j = -2; j <= 2; j++) { float x = (float)j * 0.067f; wagonModel.Cylinder("aged_bronze", x, 0.135f, 0.05f, 0.029f, 0.162f, new Vector3(90f, 0f, 0f)); wagonModel.Cylinder("iron", x, 0.135f, 0.132f, 0.025f, 0.057f, new Vector3(90f, 0f, 0f)); } for (int k = -1; k <= 1; k += 2) { wagonModel.Box("dark", (float)k * 0.173f, 0.154f, -0.018f, 0.044f, 0.022f, 0.227f); wagonModel.Box("bronze", (float)k * 0.173f, 0.117f, 0.11f, 0.052f, 0.059f, 0.021f); } wagonModel.Commit(); BoxCollider obj2 = ((Component)val).gameObject.AddComponent<BoxCollider>(); obj2.center = new Vector3(0f, 0.085f, 0.018f); obj2.size = new Vector3(0.39f, 0.17f, 0.29f); } } internal static class AmmoText { internal const string FlintBoltId = "fred_light_ammo"; internal const string BronzeBoltId = "fred_bronze_bolt"; internal const string CartridgeId = "bf_maxim_belt"; internal const string ShotId = "fred_heavy_ammo"; internal const string MagazineId = "fred_flint_bolt_magazine"; internal const string FireMagazineId = "fred_fire_arrow_magazine"; internal const string FlintBolt = "Flint Bolt"; internal const string BronzeBolt = "Bronze Bolt"; internal const string Cartridges = "Cartridge Pack"; internal const string Shot = "Heavy Shot"; internal const string Magazine = "Flint Bolt Magazine"; internal const string FireMagazine = "Fire Arrow Magazine"; internal const string Bolts = "Flint Bolt or Bronze Bolt"; internal static string ForMount(MountedGun gun) { if (!(gun.Prefab == "fred_surtling_speedboat")) { if (!StaticTurrets.UsesBolts(gun.Prefab)) { return gun.Feed.Item.Name; } return "Flint Bolt or Bronze Bolt"; } return "Iron Bolt, Flint Bolt or Bronze Bolt"; } internal static string MountedDescription(MountedGun gun) { string text = ForMount(gun); if (gun.CoalFlame) { return $"Fuel: {text}. Holds up to {gun.Feed.Most} and burns it at one eighth of a smelter's rate while firing."; } if (gun.Feed.RoundsPerItem > 1) { return $"Ammo: {text}. Each pack loads {gun.Feed.RoundsPerItem} rounds."; } return "Ammo: " + text + ". Uses one per shot."; } internal static string HandheldDescription(string family, int magazineCapacity, int burstCount) { return family switch { "FieldArtillery bolts" => "Ammo: Flint Bolt or Bronze Bolt. Uses one bolt per shot.", "FieldArtillery light ammo" => "Ammo: Cartridge Pack. Uses one inventory pack per shot.", "FieldArtillery heavy ammo" => "Ammo: Heavy Shot. Uses one per trigger pull.", "fred_flint_bolt_magazine" => "Ammo: Flint Bolt Magazine or Fire Arrow Magazine. Each magazine loads " + ((burstCount > 1) ? $"{magazineCapacity / burstCount} bursts of {burstCount} ({magazineCapacity} bolts)." : $"{magazineCapacity} shots.") + " Equip a magazine in the inventory before reloading to choose it.", _ => "", }; } } internal sealed class MountedGun { public string Prefab; public string Keys; public string Name; public string Description; public string Icon; public string Station; public Func<string> Cost; public PieceCategory Category; public float Health = 1000f; public float Scale = 1f; public Dictionary<string, Color> Tints = new Dictionary<string, Color>(); public Action<GunBuilder> Build; public Action<GameObject, GameObject> ConfigurePrefab; public Action<ObjectDB, Gun> BuildArt; public CarriageSpec Carriage; public TraverseSpec Traverse; public FireSpec Fire; public RoundSpec Round; public HeatSpec Heat; public FeedSpec Feed; public SoundSpec Sounds; public bool CoalFlame; } internal sealed class CarriageSpec { public float WheelRadius; public float HitchZ; public Vector3 Wheel; public string WheelModel; } internal sealed class TraverseSpec { public float Up; public float Down; public float Side; public float Speed; } internal sealed class FireSpec { public Func<float> RoundsPerMinute; public float Range; public float Spread; public float MovingSpread; } internal sealed class RoundSpec { public Func<float> Damage; public bool Blunt; public (float Damage, float Radius, float Push) Splash; public float Speed; public float Gravity = 9.8f; public float PushForce; public float TracerLength = 2f; public float TracerWidth = 0.03f; public Color Glow = new Color(0.85f, 0.58f, 0.27f); } internal sealed class HeatSpec { public float SteamFrom = 300f; public float BurnFrom = 600f; public float JamAt = 800f; public float CoolAfter = 3f; public float JamSeconds = 20f; public float CoolPerSecond = 25f; } internal sealed class FeedSpec { public AmmoSpec Item; public int Most; public int RoundsPerItem; } internal sealed class AmmoSpec { public string Prefab; public string Name; public string Description; public string Look; public string Model; public string Icon; public string Station; public Func<string> Cost; public float Weight; public int MaxStack; public int Batch = 1; public bool Stock; } internal sealed class SoundSpec { public string Shot; public string Tail; public int Voices = 2; public float MaxDistance = 60f; } internal interface IGunExtra { bool Busy { get; } void OnLoadShow(); void Tick(bool loaded); } internal static class ArtilleryFirebombArt { private static readonly Dictionary<string, (Material Material, Rect Uv)> Finishes = new Dictionary<string, (Material, Rect)>(); private static readonly Dictionary<string, GameObject> Models = new Dictionary<string, GameObject>(); internal static GameObject ReplaceModel(ObjectDB db, Transform root, Transform attach, string id, bool reinforced) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) MeshRenderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshRenderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Renderer)componentsInChildren[i]).enabled = false; } if (Models.TryGetValue(id, out var value)) { return Object.Instantiate<GameObject>(value, attach, false); } Transform val = WagonModel.Child(attach, id + " model", Vector3.zero); RegisterFinishes(db); ClayPot(db, val, reinforced); Models.Add(id, ((Component)val).gameObject); return ((Component)val).gameObject; } private static void RegisterFinishes(ObjectDB db) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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) if (Finishes.Count == 0) { Material[] source = Resources.FindObjectsOfTypeAll<Material>(); Material val = ((IEnumerable<Material>)source).FirstOrDefault((Func<Material, bool>)((Material material) => ((Object)material).name == "Ceramicpotsredbroken_mat")); Material val2 = ((IEnumerable<Material>)source).FirstOrDefault((Func<Material, bool>)((Material material) => ((Object)material).name == "Ceramicpotsred_mat")); Finish("earthen clay", "leather", new Color(1.35f, 1.62f, 1.19f), 0.06f, val2 ?? val); Finish("red ceramic", "leather", new Color(1.12f, 0.79f, 0.72f), 0.12f, val ?? val2); Finish("red cloth", "leather", new Color(0.72f, 0.23f, 0.13f), 0.1f); Finish("charred band", "dark", new Color(0.27f, 0.24f, 0.22f), 0.16f); Finish("cast iron", "iron", new Color(0.53f, 0.58f, 0.56f), 0.22f); Finish("bronze lip", "aged_bronze", new Color(0.94f, 0.8f, 0.56f), 0.26f); } void Finish(string name, string key, Color color, float gloss, Material stockPottery = null) { //IL_0014: 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_002a: 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_0032: Expected O, but got Unknown //IL_0055: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) (Material, Rect) tuple = ItemModel.NativeSurface(db, key); Material val3 = new Material(tuple.Item1) { name = "Gunnr " + name, color = color }; val3.SetFloat("_Glossiness", gloss); if (Object.op_Implicit((Object)(object)stockPottery)) { val3.mainTexture = stockPottery.mainTexture; val3.mainTextureScale = Vector2.one; val3.mainTextureOffset = Vector2.zero; val3.SetTexture("_BumpMap", (Texture)null); val3.DisableKeyword("_NORMALMAP"); } Rect item = (Object.op_Implicit((Object)(object)stockPottery) ? Rect.MinMaxRect(0.045f, 0.055f, 0.955f, 0.945f) : tuple.Item2); Finishes.Add(name, (val3, item)); } } private static void ClayPot(ObjectDB db, Transform model, bool reinforced) { //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) Shell(model, reinforced ? "red ceramic" : "earthen clay", 10, 1f, 9f, (-0.124f, 0.001f), (-0.124f, 0.06f), (-0.1f, 0.08f), (-0.056f, 0.104f), (0.012f, 0.105f), (0.058f, 0.087f), (0.084f, 0.056f), (0.096f, 0.037f), (0.127f, 0.037f), (0.127f, 0.001f)); Shell(model, reinforced ? "charred band" : "bronze lip", 10, 1f, 9f, (-0.055f, 0.102f), (-0.048f, 0.111f), (-0.022f, 0.111f), (-0.015f, 0.105f)); Shell(model, "cast iron", 10, 1f, 9f, (0.095f, 0.034f), (0.102f, 0.047f), (0.125f, 0.047f), (0.13f, 0.04f), (0.13f, 0.001f)); Shell(model, "red cloth", 10, 1f, 9f, (0.112f, 0.045f), (0.118f, 0.05f), (0.127f, 0.05f), (0.137f, 0.03f), (0.14f, 0.001f)); Rag(model, "red cloth", 0.123f, 0.043f, 35f, 0.022f, 0.081f); Rag(model, "red cloth", 0.125f, 0.041f, 108f, 0.017f, 0.062f); if (reinforced) { WagonModel wagonModel = new WagonModel(db, model); for (int i = 0; i < 5; i++) { float num = 63f - 72f * (float)i; Vector3 val = Quaternion.Euler(0f, num, 0f) * Vector3.forward * 0.1065f; wagonModel.Box("aged_bronze", val.x, -0.035f, val.z, 0.019f, 0.016f, 0.01f, new Vector3(0f, num, 23f)); } wagonModel.Commit(); } } private static void Shell(Transform parent, string finish, int sides, float width, float turn, params (float Height, float Radius)[] profile) { //IL_00c5: 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) (Material, Rect) tuple = Finishes[finish]; List<Vector3> list = new List<Vector3>(profile.Length * sides * 2); List<Vector2> list2 = new List<Vector2>(list.Capacity); List<int> list3 = new List<int>((profile.Length - 1) * sides * 6); float num = profile[^1].Height - profile[0].Height; for (int i = 0; i < sides; i++) { int count = list.Count; for (int j = 0; j < profile.Length; j++) { (float, float) tuple2 = profile[j]; for (int k = 0; k < 2; k++) { float num2 = ((float)(i + k) * 360f / (float)sides + turn) * (MathF.PI / 180f); list.Add(new Vector3(Mathf.Cos(num2) * tuple2.Item2 * width, tuple2.Item1, Mathf.Sin(num2) * tuple2.Item2)); float num3 = (tuple2.Item1 - profile[0].Height) / num; list2.Add(new Vector2(Mathf.Lerp(((Rect)(ref tuple.Item2)).xMin, ((Rect)(ref tuple.Item2)).xMax, (float)(i + k) / (float)sides), Mathf.Lerp(((Rect)(ref tuple.Item2)).yMin, ((Rect)(ref tuple.Item2)).yMax, num3))); } if (j != 0) { int num4 = count + 2 * (j - 1); list3.AddRange(new int[6] { num4, num4 + 2, num4 + 1, num4 + 1, num4 + 2, num4 + 3 }); } } } AddMesh(parent, finish, list, list2, list3); } private static void Rag(Transform parent, string finish, float top, float rootRadius, float turn, float width, float length) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_00d3: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) (Material, Rect) tuple = Finishes[finish]; Quaternion val = Quaternion.Euler(0f, turn, 0f); List<Vector3> list = new List<Vector3>(16); List<Vector2> list2 = new List<Vector2>(16); List<int> list3 = new List<int>(36); Vector3 val2 = default(Vector3); for (int i = 0; i < 4; i++) { float num = (float)i / 3f; float num2 = rootRadius + length * Mathf.Sin(num * 1.1f) * 0.63f; float num3 = top + length * (0.46f * Mathf.Sin(num * 2.7f) - 0.75f * num); ((Vector3)(ref val2))..ctor(length * num * 0.09f, num3, num2); list.Add(val * (val2 + Vector3.left * width * (0.5f - 0.28f * num))); list.Add(val * (val2 + Vector3.right * width * (0.5f - 0.18f * num) + Vector3.up * 0.004f * num)); float num4 = Mathf.Lerp(((Rect)(ref tuple.Item2)).yMin, ((Rect)(ref tuple.Item2)).yMax, num); list2.Add(new Vector2(((Rect)(ref tuple.Item2)).xMin, num4)); list2.Add(new Vector2(((Rect)(ref tuple.Item2)).xMax, num4)); if (i != 0) { int num5 = 2 * (i - 1); list3.AddRange(new int[12] { num5, num5 + 1, num5 + 2, num5 + 2, num5 + 1, num5 + 3, num5 + 8, num5 + 10, num5 + 9, num5 + 10, num5 + 11, num5 + 9 }); } } list.AddRange(list.GetRange(0, 8)); list2.AddRange(list2.GetRange(0, 8)); AddMesh(parent, finish, list, list2, list3); } private static void AddMesh(Transform parent, string finish, List<Vector3> vertices, List<Vector2> uv, List<int> indices) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown Transform obj = WagonModel.Child(parent, finish, Vector3.zero); Mesh val = new Mesh { name = ((Object)parent).name + " " + finish }; val.SetVertices(vertices); val.SetUVs(0, uv); val.SetTriangles(indices, 0); val.RecalculateNormals(); val.RecalculateTangents(); ((Component)obj).gameObject.AddComponent<MeshFilter>().sharedMesh = val; ((Renderer)((Component)obj).gameObject.AddComponent<MeshRenderer>()).sharedMaterial = Finishes[finish].Material; } } internal static class ArtilleryFirebombs { private sealed class Firebomb(string id, string name, float radius, float fire, float blunt, float push, float weight, float stamina, int stationLevel, (string Item, int Count)[] cost) { internal readonly string Id = id; internal readonly string Name = name; internal readonly float Radius = radius; internal readonly float Fire = fire; internal readonly float Blunt = blunt; internal readonly float Push = push; internal readonly float Weight = weight; internal readonly float Stamina = stamina; internal readonly int StationLevel = stationLevel; internal readonly (string Item, int Count)[] Cost = cost; } private const string ResinFirebomb = "fred_resin_firebomb"; private const string FlintFirebomb = "fred_flint_firebomb"; private static readonly Firebomb[] Roster = new Firebomb[2] { new Firebomb("fred_resin_firebomb", "Resin Firebomb", 4f, 35f, 10f, 55f, 0.35f, 10f, 1, new(string, int)[2] { ("Resin", 3), ("Stone", 2) }), new Firebomb("fred_flint_firebomb", "Flint Firebomb", 6f, 75f, 20f, 80f, 0.55f, 14f, 2, new(string, int)[3] { ("Resin", 5), ("Flint", 2), ("Coal", 2) }) }; private static readonly Dictionary<string, GameObject> Items = new Dictionary<string, GameObject>(); private static readonly List<GameObject> NetworkPrefabs = new List<GameObject>(); private static Transform holder; private static IModHost host; private static int coverMask; internal static void Apply(Harmony harmony, IModHost modHost) { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown host = modHost; coverMask = LayerMask.GetMask(new string[4] { "terrain", "piece", "static_solid", "Default" }); string[] array = new string[2] { "Awake", "CopyOtherDB" }; foreach (string text in array) { harmony.Patch((MethodBase)AccessTools.Method(typeof(ObjectDB), text, (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ArtilleryFirebombs), "RegisterItems", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } harmony.Patch((MethodBase)AccessTools.Method(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(ArtilleryFirebombs), "RegisterScene", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); harmony.Patch((MethodBase)AccessTools.Method(typeof(Aoe), "OnHit", (Type[])null, (Type[])null), new HarmonyMethod(typeof(ArtilleryFirebombs), "FilterBlastTarget", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void RegisterScene(ZNetScene __instance) { if ((Object)(object)ObjectDB.instance != (Object)null) { RegisterItems(ObjectDB.instance); } host.AddPrefabs(__instance, NetworkPrefabs); } private static void RegisterItems(ObjectDB __instance) { GameObject itemPrefab = __instance.GetItemPrefab("Hammer"); ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); GameObject itemPrefab2 = __instance.GetItemPrefab("BombDynamite"); if ((Object)(object)val == (Object)null || (Object)(object)itemPrefab2 == (Object)null) { return; } List<GameObject> pieces = val.m_itemData.m_shared.m_buildPieces.m_pieces; Firebomb[] roster = Roster; foreach (Firebomb firebomb in roster) { if (!Items.TryGetValue(firebomb.id, out var value)) { value = BuildItem(__instance, itemPrefab2, firebomb); Items.Add(firebomb.id, value); NetworkPrefabs.Add(value); } if (!__instance.m_items.Contains(value)) { __instance.m_items.Add(value); } ItemRegistration.RegisterRecipe(__instance, value, "piece_workbench", firebomb.cost, pieces, firebomb.stationLevel); } ItemRegistration.Refresh(__instance); if ((Object)(object)ZNetScene.instance != (Object)null) { host.AddPrefabs(ZNetScene.instance, NetworkPrefabs); } } private static GameObject BuildItem(ObjectDB db, GameObject template, Firebomb spec) { //IL_0077: 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) SharedData shared; GameObject val = ItemRegistration.CloneItem(template, spec.id, out shared); shared.m_name = spec.name; shared.m_description = $"Bursts on impact. The {spec.radius:0} m blast deals {ShotPresentation.WeaponDamage(spec.fire):0.#} fire and {ShotPresentation.WeaponDamage(spec.blunt):0.#} blunt damage to enemies. Terrain and buildings are safe."; shared.m_maxQuality = 1; shared.m_maxStackSize = 10; shared.m_weight = spec.weight; shared.m_damages = default(DamageTypes); shared.m_damagesPerLevel = default(DamageTypes); shared.m_attackForce = 0f; shared.m_attackStatusEffect = null; shared.m_backstabBonus = 1f; shared.m_attack = shared.m_attack.Clone(); shared.m_attack.m_attackStamina = spec.stamina; shared.m_attack.m_projectileVel = 13f; shared.m_attack.m_projectileVelMin = 13f; shared.m_attack.m_attackProjectile = BuildThrow(db, shared.m_attack.m_attackProjectile, spec); shared.m_icons = (Sprite[])(object)new Sprite[1] { Files.PrefabIcon(host, spec.id, shared.m_icons.FirstOrDefault()) }; ArtilleryFirebombArt.ReplaceModel(db, val.transform, val.transform.Find("attach") ?? val.transform, spec.id, spec.id == "fred_flint_firebomb"); return val; } private static GameObject BuildThrow(ObjectDB db, GameObject template, Firebomb spec) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Expected O, but got Unknown //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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown if ((Object)(object)holder == (Object)null) { GameObject val = new GameObject("Gunnr firebomb prefabs"); val.SetActive(false); Object.DontDestroyOnLoad((Object)val); holder = val.transform; } GameObject val2 = Object.Instantiate<GameObject>(template, holder, false); ((Object)val2).name = spec.id + "_projectile"; Projectile component = val2.GetComponent<Projectile>(); GameObject val3 = Object.Instantiate<GameObject>(component.m_spawnOnHit, holder, false); ((Object)val3).name = spec.id + "_blast"; Aoe component2 = val3.GetComponent<Aoe>(); component2.m_name = spec.id; component2.m_useAttackSettings = false; component2.m_damage = new DamageTypes { m_fire = spec.fire, m_blunt = spec.blunt }; component2.m_damagePerLevel = default(DamageTypes); component2.m_attackForce = spec.push; component2.m_backstabBonus = 1f; component2.m_statusEffect = ""; component2.m_canRaiseSkill = false; component2.m_hitOwner = false; component2.m_hitFriendly = false; component2.m_ignorePVP = true; component2.m_hitProps = false; component2.m_hitTerrain = false; component2.m_spawnOnHitTerrain = null; component2.m_groundLavaValue = -1f; component2.m_radius = spec.radius; component2.m_maxTargetsFromCenter = 0; component2.m_useCollider = null; component2.m_hitAfterTtl = false; component2.m_activationDelay = 0f; component2.m_hitInterval = 0f; component2.m_ttl = 0.5f; WidenBlastEffect(component2, spec); GameObject visual = ArtilleryFirebombArt.ReplaceModel(db, val2.transform, val2.transform, spec.id, spec.id == "fred_flint_firebomb"); component.m_visual = visual; component.m_gravity = 20f; component.m_ttl = 12f; component.m_spawnOnTtl = false; component.m_stayAfterHitStatic = false; component.m_stayAfterHitDynamic = false; component.m_hitEffects = new EffectList(); component.m_hitWaterEffects = new EffectList(); component.m_spawnOnHit = val3; component.m_onlySpawnedProjectilesDealDamage = true; NetworkPrefabs.Add(val2); NetworkPrefabs.Add(val3); return val2; } private static void WidenBlastEffect(Aoe blast, Firebomb spec) { //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown EffectData[] array = blast.m_initiateEffect.m_effectPrefabs.ToArray(); for (int i = 0; i < array.Length; i++) { EffectData val = array[i]; if (!((Object)(object)val.m_prefab == (Object)null) && !(((Object)val.m_prefab).name != "fx_dynamite_explosion")) { GameObject val2 = Object.Instantiate<GameObject>(val.m_prefab, holder, false); ((Object)val2).name = spec.id + "_explosion_fx"; Transform transform = val2.transform; transform.localScale *= spec.radius / 4f; ParticleSystem[] componentsInChildren = val2.GetComponentsInChildren<ParticleSystem>(true); for (int j = 0; j < componentsInChildren.Length; j++) { MainModule main = componentsInChildren[j].main; ((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0; } array[i] = new EffectData { m_enabled = val.m_enabled, m_prefab = val2 }; NetworkPrefabs.Add(val2); } } blast.m_initiateEffect = new EffectList { m_effectPrefabs = array }; } private static bool FilterBlastTarget(Aoe __instance, Collider collider, Character ___m_owner, ref bool __result) { //IL_0060: 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_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_007a: Unknown result type (might be due to invalid IL or missing references) string name = __instance.m_name; if (!(name == "fred_resin_firebomb") && !(name == "fred_flint_firebomb")) { return true; } Character component = Projectile.FindHitObject(collider).GetComponent<Character>(); if ((Object)(object)___m_owner != (Object)null && (Object)(object)component != (Object)null && !component.IsPlayer() && !component.IsTamed() && BaseAI.IsEnemy(___m_owner, component) && !Physics.Linecast(((Component)__instance).transform.position + Vector3.up * 0.18f, component.GetCenterPoint(), coverMask, (QueryTriggerInteraction)1)) { return true; } __result = false; return false; } } internal sealed class MountedFlame : MonoBehaviour, IFurnacePower { internal const string Prefab = "fred_surtling_flame_carriage"; private const float HalfAngle = 43f; private const float Reach = 18f; private const float BurnRateFactor = 8f; private static readonly float ConeDot = Mathf.Cos(MathF.PI * 43f / 180f); private static readonly int Characters = LayerMask.GetMask(new string[4] { "character", "character_net", "character_noenv", "hitbox" }); private static readonly int Cover = LayerMask.GetMask(new string[6] { "terrain", "piece", "Default", "static_solid", "vehicle", "tree" }); private readonly Collider[] targets = (Collider[])(object)new Collider[128]; private readonly RaycastHit[] obstacles = (RaycastHit[])(object)new RaycastHit[24]; private readonly HashSet<Character> hitThisPulse = new HashSet<Character>(); private Gun gun; [SerializeField] private GameObject jet; private int progressKey; private float secondsPerCoal; public bool IsBurning { get { if ((Object)(object)gun != (Object)null) { return gun.Firing; } return false; } } public bool Occupied { get { if ((Object)(object)gun != (Object)null) { return gun.User != 0; } return false; } } public bool HasFuel { get { if ((Object)(object)gun != (Object)null) { return gun.Rounds > 0; } return false; } } public bool Marine => false; public float EngineLoad { get { if (!IsBurning) { return 0f; } return 1f; } } internal static bool IsMount(string id) { return StaticTurrets.SourceOf(id) == "fred_surtling_flame_carriage"; } internal static void Register(IModHost host, Dictionary<string, Color> tints, CarriageSpec carriage) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) MountedGun mountedGun = new MountedGun { Prefab = "fred_surtling_flame_carriage", Keys = "fred_surtling_flame_carriage", Name = "Surtling Flamethrower", Description = "Hold attack to project a broad stream of flame that clears brush. The fire stops at solid cover.", Icon = "surtling-flamethrower", Station = "forge", Category = (PieceCategory)1, Cost = () => "Iron:22,Bronze:12,RoundLog:16,SurtlingCore:4,LeatherScraps:6", Health = 900f, Tints = tints, Build = Build, BuildArt = BuildArt, Carriage = carriage, Traverse = new TraverseSpec { Up = 30f, Down = 22f, Side = 62f, Speed = 95f }, Fire = new FireSpec { RoundsPerMinute = () => 240f, Range = 18f }, Round = new RoundSpec { Damage = () => 24f }, Feed = new FeedSpec { Item = new AmmoSpec { Prefab = "Coal", Name = "Coal" }, Most = 20, RoundsPerItem = 1 }, Sounds = new SoundSpec { Voices = 0 }, CoalFlame = true }; Guns.Register(host, mountedGun); StaticTurrets.Register(host, mountedGun, "carriage", "rawwood", "bronze", 12); } private static void Build(GunBuilder parts) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_0076: 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_00bc: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0168: Unknown result type (might be due to invalid IL or missing references) Transform root = parts.Root; parts.Part(root, "carriage", Vector3.zero, Quaternion.identity); Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(0f, 1.45f, -0.06f); parts.Swivel = parts.Point(root, "swivel", position); parts.Barrel = parts.Point(root, "barrel", position); parts.Muzzle = parts.Point(parts.Barrel, "Flame nozzle", new Vector3(0f, 0.1f, 1.38f)); parts.Seat = parts.Point(root, "seat", new Vector3(0f, 0.08f, -0.96f)); parts.Solid(root, new Vector3(0f, 0.6f, 0f), new Vector3(1.49f, 0.28f, 1.4f), Quaternion.identity); parts.Handle(root, new Vector3(0f, 0.62f, -1.65f), new Vector3(0.65f, 0.27f, 0.3f)); parts.GripsAt(parts.Swivel, new Vector3(0f, -0.05f, -0.82f), new Vector3(0.64f, 0.38f, 0.49f)); parts.SlotAt(root, new Vector3(0.81f, 1.2f, 0.19f), new Vector3(0.55f, 0.61f, 0.58f)); ((Component)root).gameObject.AddComponent<MountedFlame>(); } private void Awake() { gun = ((Component)this).GetComponent<Gun>(); MountedGun mountedGun = (Object.op_Implicit((Object)(object)gun) ? Guns.Find(gun.m_prefab) : null); if (mountedGun != null) { progressKey = StringExtensionMethods.GetStableHashCode(mountedGun.Keys + "_coal_burn_seconds"); ZNetScene instance = ZNetScene.instance; object obj; if (instance == null) { obj = null; } else { GameObject prefab = instance.GetPrefab("smelter"); obj = ((prefab != null) ? prefab.GetComponent<Smelter>() : null); } Smelter val = (Smelter)obj; secondsPerCoal = 8f * ((Object.op_Implicit((Object)(object)val) && val.m_fuelPerProduct > 0) ? (val.m_secPerProduct / (float)val.m_fuelPerProduct) : 15f); } } private static void BuildArt(ObjectDB database, Gun gun) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0043: 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_00b3: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) if ((int)SystemInfo.graphicsDeviceType != 4) { WagonModel wagonModel = new WagonModel(database, gun.m_barrel); wagonModel.Cylinder("bronze", 0f, 0.08f, 0.52f, 0.135f, 1.31f, new Vector3(90f, 0f, 0f)); wagonModel.Cylinder("dark", 0f, 0.08f, 0.19f, 0.19f, 0.37f, new Vector3(90f, 0f, 0f)); wagonModel.Cylinder("iron", 0f, 0.08f, 0.77f, 0.169f, 0.12f, new Vector3(90f, 0f, 0f)); wagonModel.Cylinder("iron", 0f, 0.08f, 1.15f, 0.22f, 0.2f, new Vector3(90f, 0f, 0f)); wagonModel.Cylinder("dark", 0f, 0.08f, 1.263f, 0.164f, 0.025f, new Vector3(90f, 0f, 0f)); wagonModel.Beam("bronze", new Vector3(-0.21f, -0.17f, -0.44f), new Vector3(-0.12f, 0.06f, 0.63f), 0.075f, 0.075f); wagonModel.Beam("bronze", new Vector3(0.21f, -0.17f, -0.44f), new Vector3(0.12f, 0.06f, 0.63f), 0.075f, 0.075f); wagonModel.Commit(); MountedFlame component = ((Component)gun).GetComponent<MountedFlame>(); SurtlingFurnace.Fit(gun.m_swivel, new Vector3(0f, -0.44f, -0.44f), 0.77f, null, (MonoBehaviour)(object)component, exposedWheel: true, database); GameObject val = (component.jet = ((Component)WagonModel.Child(gun.m_muzzle, "Mounted furnace flame", Vector3.zero)).gameObject); val.SetActive(false); Material val2 = HandheldFlameJet.FindMaterial(ZNetScene.instance, smoke: false); if (Object.op_Implicit((Object)(object)val2)) { HandheldFlameJet.AddParticles(val.transform, "Wide flame", val2, 43f, 245f, 1.21f, 0.58f, new Color(1f, 0.69f, 0.22f, 0.92f), new Color(1f, 0.22f, 0.018f, 0.56f), 25f, 32f); HandheldFlameJet.AddParticles(val.transform, "Hot core", val2, 17f, 90f, 0.71f, 0.52f, new Color(1f, 0.96f, 0.58f, 0.94f), new Color(1f, 0.43f, 0.065f, 0.69f), 30f, 34f); } Light obj = val.AddComponent<Light>(); obj.color = new Color(1f, 0.49f, 0.15f); obj.range = 5f; obj.intensity = 1.45f; obj.shadows = (LightShadows)0; } } private void LateUpdate() { if (Object.op_Implicit((Object)(object)jet) && jet.activeSelf != IsBurning) { jet.SetActive(IsBurning); } } internal bool SpendPulse(ZDO state, float seconds) { float num = state.GetFloat(progressKey, 0f) + seconds; bool flag = num >= secondsPerCoal; state.Set(progressKey, flag ? (num - secondsPerCoal) : num); return flag; } internal void Burn(Player player) { //IL_000b: 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_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_00eb: 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_010f: 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) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0152: 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_0159: 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) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Expected O, but got Unknown Vector3 position = gun.m_muzzle.position; Vector3 forward = gun.m_muzzle.forward; hitThisPulse.Clear(); int num = Physics.OverlapSphereNonAlloc(position, 18f, targets, Characters, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { Collider val = targets[i]; Character componentInParent = ((Component)val).GetComponentInParent<Character>(); if (!((Object)(object)componentInParent == (Object)null) && !hitThisPulse.Contains(componentInParent) && ShotPresentation.CanHit(player, componentInParent)) { float num2 = Mathf.Clamp(Vector3.Dot(componentInParent.GetCenterPoint() - position, forward), 0f, 18f); Vector3 val2 = val.ClosestPoint(position + forward * num2); Vector3 val3 = val2 - position; if (((Vector3)(ref val3)).sqrMagnitude < 0.001f) { val3 = componentInParent.GetCenterPoint() - position; } float magnitude = ((Vector3)(ref val3)).magnitude; if (!(magnitude > 18f) && !(magnitude < 0.001f) && !(Vector3.Dot(forward, val3 / magnitude) < ConeDot) && !HasCover(position, val3 / magnitude, magnitude)) { hitThisPulse.Add(componentInParent); HitData val4 = new HitData { m_point = val2, m_dir = val3 / magnitude, m_hitCollider = val, m_hitType = (HitType)2, m_ranged = true, m_damage = new DamageTypes { m_fire = ShotPresentation.WeaponDamage(gun.Spec.Round.Damage()) } }; val4.SetAttacker((Character)(object)player); componentInParent.Damage(val4); } } } } private bool HasCover(Vector3 origin, Vector3 direction, float distance) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) int num = Physics.RaycastNonAlloc(origin, direction, obstacles, distance, Cover, (QueryTriggerInteraction)1); for (int i = 0; i < num; i++) { if (!((Component)((RaycastHit)(ref obstacles[i])).collider).transform.IsChildOf(((Component)this).transform)) { return true; } } return false; } } internal abstract class ArtilleryStation : MonoBehaviour, Hoverable, Interactable { protected Gun Gun { get; private set; } protected virtual void Awake() { Gun = ((Component)this).GetComponentInParent<Gun>(); } public string GetHoverName() { return Gun?.Spec?.Name ?? ""; } public virtual string GetHoverText() { return GetHoverName(); } public abstract bool Interact(Humanoid user, bool hold, bool alt); public virtual bool UseItem(Humanoid user, ItemData item) { return false; } public float GetHoverOffset() { return 0.2f; } } internal sealed class Grips : ArtilleryStation { public override string GetHoverText() { return Localization.instance.Localize(((Object)(object)base.Gun != (Object)null && StaticTurrets.IsStatic(base.Gun.m_prefab)) ? "Turret controls\n[<color=yellow><b>$KEY_Use</b></color>] Take control" : "Gunner controls\n[<color=yellow><b>$KEY_Use</b></color>] Aim or dismount"); } public override bool Interact(Humanoid user, bool hold, bool alt) { if (hold || (Object)(object)base.Gun == (Object)null) { return false; } base.Gun.Take(user); return true; } } internal sealed class Slot : ArtilleryStation { private CarriageLoading Loading { get { if (!((Object)(object)base.Gun == (Object)null)) { return ((Component)base.Gun).GetComponent<CarriageLoading>(); } return null; } } public override string GetHoverText() { FeedSpec feedSpec = base.Gun?.Spec?.Feed; if (feedSpec == null) { return ""; } string text = AmmoText.ForMount(base.Gun.Spec); if (base.Gun.Spec.CoalFlame) { return Localization.instance.Localize($"Coal hatch · {base.Gun.Rounds}/{feedSpec.Most}\n" + "[<color=yellow><b>$KEY_Use</b></color>] Add Coal"); } float drawTimeLeft = base.Gun.DrawTimeLeft; string arg = ((drawTimeLeft > 0f) ? $"Drawing {drawTimeLeft:F1}s" : (base.Gun.Busy ? "Reloading" : ((base.Gun.Rounds + feedSpec.RoundsPerItem > feedSpec.Most) ? "Full" : "Ready"))); return Localization.instance.Localize($"Loading point · {base.Gun.Rounds}/{feedSpec.Most} · {arg}\n" + "[<color=yellow><b>$KEY_Use</b></color>] Load " + text); } public override bool Interact(Humanoid user, bool hold, bool alt) { if (!hold) { return Loading?.Request(user, null) ?? false; } return false; } public override bool UseItem(Humanoid user, ItemData item) { if (item != null) { return Loading?.Request(user, item) ?? false; } return false; } } internal sealed class Handle : ArtilleryStation { private Vagon wagon; protected override void Awake() { base.Awake(); wagon = ((Component)this).GetComponentInParent<Vagon>(); } public override string GetHoverText() { return Localization.instance.Localize("Tow handle\n[<color=yellow><b>$KEY_Use</b></color>] Pull or let go"); } public override bool Interact(Humanoid user, bool hold, bool alt) { if ((Object)(object)wagon != (Object)null) { return wagon.Interact(user, hold, alt); } return false; } } internal static class BallistaBolts { internal static void Register(IModHost host) { Guns.RegisterAmmo(host, new AmmoSpec { Prefab = "fred_bronze_bolt", Name = "Bronze Bolt", Description = "For the Flint Hunting Crossbow, Meadows Siege Crossbow, Troll Hunter Crossbow, Flint Ballista, Bronze Polybolos, their fixed turrets, and the Surtling Speedboat's bow gun.", Look = "BoltIron", Model = "bronze-ammo", Icon = "bronze-ammo", Weight = 0.1f, MaxStack = 100, Batch = 10, Station = "forge", Cost = () => "Wood:10,Bronze:10" }); } } public sealed class BoltDraw : MonoBehaviour, IGunExtra { private const string StartedKey = "fred.fieldartillery.draw.started"; private const string ReadyKey = "fred.fieldartillery.draw.ready"; [SerializeField] private Transform bolt; [SerializeField] private Transform leftCord; [SerializeField] private Transform rightCord; [SerializeField] private Transform crank; [SerializeField] private Vector3 boltHome; [SerializeField] private float scale; [SerializeField] private float seconds; private ZNetView view; private long heardCycle; private bool wasDrawing; private bool lastLoaded; private float lastProgress = -1f; private static long Now => (long)((((Object)(object)ZNet.instance == (Object)null) ? Time.timeAsDouble : ZNet.instance.GetTimeSeconds()) * 1000.0); private ZDO State { get { if (!((Object)(object)view != (Object)null) || !view.IsValid()) { return null; } return view.GetZDO(); } } public bool Busy { get { ZDO state = State; if (state != null) { return state.GetLong("fred.fieldartillery.draw.ready", 0L) > Now; } return false; } } internal float SecondsLeft { get { ZDO state = State; if (state == null) { return 0f; } return Mathf.Max(0f, (float)(state.GetLong("fred.fieldartillery.draw.ready", 0L) - Now) * 0.001f); } } internal static void Add(GunBuilder builder, Transform display, float modelScale, bool repeating) { //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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) BoltDraw boltDraw = ((Component)builder.Root).gameObject.AddComponent<BoltDraw>(); boltDraw.bolt = display; boltDraw.boltHome = display.localPosition; boltDraw.scale = modelScale; boltDraw.seconds = (repeating ? 1.65f : 3.6f); boltDraw.leftCord = builder.Part(builder.Barrel, "bowstring-link", Vector3.zero, Quaternion.identity); boltDraw.rightCord = builder.Part(builder.Barrel, "bowstring-link", Vector3.zero, Quaternion.identity); boltDraw.crank = builder.Part(builder.Barrel, "bow-draw-crank", new Vector3(0.28f, 0.03f, -0.7f) * modelScale, Quaternion.identity); boltDraw.crank.localScale = Vector3.one * modelScale; boltDraw.Pose(0f, loaded: false); } private void Awake() { view = ((Component)this).GetComponent<ZNetView>(); } internal void StartDraw() { long now = Now; State.Set("fred.fieldartillery.draw.started", now); State.Set("fred.fieldartillery.draw.ready", now + (long)(seconds * 1000f)); } internal void AfterShot(int remaining) { if (remaining > 0) { StartDraw(); } else { State.Set("fred.fieldartillery.draw.ready", 0L); } } public void OnLoadShow() { } public void Tick(bool loaded) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) ZDO state = State; if (state != null) { if (loaded && state.GetLong("fred.fieldartillery.draw.ready", 0L) == 0L && view.IsOwner()) { StartDraw(); } long num = state.GetLong("fred.fieldartillery.draw.started", 0L); long num2 = state.GetLong("fred.fieldartillery.draw.ready", 0L); long now = Now; bool flag = loaded && num2 > now; if (flag && heardCycle != num2) { heardCycle = num2; ShotPresentation.DrawCue(crank.position, ready: false); } else if (loaded && wasDrawing && !flag) { ShotPresentation.DrawCue(crank.position, ready: true); } wasDrawing = flag; float num3 = ((!loaded || num2 == 0L) ? 0f : (flag ? Mathf.Clamp01((float)(now - num) / Mathf.Max(1f, (float)(num2 - num))) : 1f)); if (loaded != lastLoaded || !Mathf.Approximately(num3, lastProgress)) { lastLoaded = loaded; lastProgress = num3; Pose(num3, loaded); } } } private void Pose(float progress, bool loaded) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0050: 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_0060: 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) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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) Vector3 target = new Vector3(0f, 0.17f, Mathf.Lerp(0.335f, -0.21f, Mathf.SmoothStep(0f, 1f, progress))) * scale; FitCord(leftCord, new Vector3(-0.94f, 0.17f, 0.34f) * scale, target); FitCord(rightCord, new Vector3(0.94f, 0.17f, 0.34f) * scale, target); crank.localRotation = Quaternion.Euler(-720f * progress, 0f, 0f); bool flag = loaded && progress >= 0.72f; if (((Component)bolt).gameObject.activeSelf != flag) { ((Component)bolt).gameObject.SetActive(flag); } if (flag) { bolt.localPosition = boltHome + Vector3.forward * (0.19f * scale * (1f - Mathf.InverseLerp(0.72f, 1f, progress))); } } private void FitCord(Transform cord, Vector3 attach, Vector3 target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) Vector3 val = target - attach; cord.SetLocalPositionAndRotation(attach, Quaternion.LookRotation(val)); cord.localScale = new Vector3(scale, scale, ((Vector3)(ref val)).magnitude); } } public sealed class CarriageControls : MonoBehaviour { private Gun gun; private ZNetView view; private Rigidbody body; private Vagon wagon; private ConfigurableJoint[] wheelJoints; private JointDrive[] originalWheelDrives; private bool wheelsBraked; private bool parked; private RigidbodyConstraints unparkedConstraints; private Transform[] interactions; private Vector3[] interactionOffsets; private readonly RaycastHit[] groundHits = (RaycastHit[])(object)new RaycastHit[12]; private static Vagon activeTow; private static int consumedUseFrame = -1; private static Action<Vagon> detach; private static FieldRef<Player, Vector3> detachOffset; private static int exitMask; internal static void Apply(string id) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown Harmony val = new Harmony(id); detach = AccessTools.MethodDelegate<Action<Vagon>>(AccessTools.Method(typeof(Vagon), "Detach", (Type[])null, (Type[])null), (object)null, true); exitMask = LayerMask.GetMask(new string[6] { "terrain", "Default", "static_solid", "Default_small", "piece", "vehicle" }); val.Patch((MethodBase)AccessTools.Method(typeof(Vagon), "AttachTo", (Type[])null, (Type[])null), (HarmonyMethod)null, Method("TrackTow"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Vagon), "Detach", (Type[])null, (Type[])null), Method("TowReleaseCue"), Method("ClearTow"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Player), "Update", (Type[])null, (Type[])null), Method("ReleaseInput"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Player), "Interact", (Type[])null, (Type[])null), Method("SuppressInteraction"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); detachOffset = AccessTools.FieldRefAccess<Player, Vector3>("m_detachOffset"); HarmonyMethod val2 = Method("ReloadWhileMounted"); val2.priority = 800; val.Patch((MethodBase)AccessTools.Method(typeof(Player), "SetControls", (Type[])null, (Type[])null), val2, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Gun), "OnGrant", (Type[])null, (Type[])null), (HarmonyMethod)null, Method("AimHint"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Gun), "OnUseStop", (Type[])null, (Type[])null), Method("PrepareDismount"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)AccessTools.Method(typeof(Vagon), "Interact", (Type[])null, (Type[])null), Method("CheckTowAccess"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); static HarmonyMethod Method(string name) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return new HarmonyMethod(typeof(CarriageControls), name, (Type[])null); } } private static bool Supported(string prefab) { switch (StaticTurrets.SourceOf(prefab)) { case "fred_flametal_pak40": case "fred_flint_ballista": case "fred_blackmetal_gatling": case "fred_surtling_speedboat": case "fred_bronze_polybolos": case "fred_iron_cannon": case "fred_silver_puckle": case "bf_maxim": case "fred_surtling_flame_carriage": return true; default: return false; } } internal static void Configure(GameObject __result) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0105: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_0196: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00ba: 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) if ((Object)(object)__result == (Object)null) { return; } Gun component = __result.GetComponent<Gun>(); Vagon component2 = __result.GetComponent<Vagon>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component2 == (Object)null) && Supported(component.m_prefab)) { Transform transform = __result.transform; Vector3 localPosition = ((Component)component2.m_wheels[0]).transform.localPosition; float num = Mathf.Abs(localPosition.x) + 0.21f; Vector3 localPosition2 = component2.m_attachPoint.localPosition; if ((Object)(object)component.m_seat != (Object)null) { Vector3 val = transform.InverseTransformPoint(component.m_seat.position); val.z = Mathf.Min(val.z, localPosition2.z + 0.86f); component.m_seat.position = transform.TransformPoint(val); } Handle componentInChildren = __result.GetComponentInChildren<Handle>(true); Grips componentInChildren2 = __result.GetComponentInChildren<Grips>(true); Slot componentInChildren3 = __result.GetComponentInChildren<Slot>(true); __result.AddComponent<CarriageControls>(); __result.AddComponent<CarriageLoading>(); GroundedHitch.ConfigureControl((Component)(object)componentInChildren, transform, new Vector3(0f, 1.19f, localPosition2.z + 0.13f), new Vector3(1.13f, 0.86f, 0.71f)); GroundedHitch.ConfigureControl((Component)(object)componentInChildren2, transform, new Vector3(0f - num, Mathf.Max(1.34f, localPosition.y + 0.7f), -0.51f), new Vector3(0.86f, 0.88f, 0.81f)); GroundedHitch.ConfigureControl((Component)(object)componentInChildren3, transform, new Vector3(num, Mathf.Max(1.25f, localPosition.y + 0.65f), 0.35f), new Vector3(0.87f, 0.86f, 0.83f)); } } private void Awake() { gun = ((Component)this).GetComponent<Gun>(); view = ((Component)this).GetComponent<ZNetView>(); body = ((Component)this).GetComponent<Rigidbody>(); wagon = ((Component)this).GetComponent<Vagon>(); wheelJoints = wagon.m_wheels.Select((Rigidbody wheel) => ((Component)wheel).GetComponent<ConfigurableJoint>()).ToArray(); originalWheelDrives = wheelJoints.Select((ConfigurableJoint joint) => joint.angularYZDrive).ToArray(); interactions = (from control in ((Component)this).GetComponentsInChildren<ArtilleryStation>(true) select ((Component)control).transform).ToArray(); interactionOffsets = interactions.Select((Transform control) => control.localPosition).ToArray(); } private void LateUpdate() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_007d: 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_0087: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: 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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 val = ((Component)localPlayer).transform.position - ((Component)this).transform.position; if (((Vector3)(ref val)).sqrMagnitude > 225f) { return; } Quaternion val2 = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f); for (int i = 0; i < interactions.Length; i++) { Vector3 val3 = interactionOffsets[i]; Vector3 val4 = ((Component)this).transform.position + val2 * val3; int num = Physics.RaycastNonAlloc(val4 + Vector3.up * 0.62f, Vector3.down, groundHits, 2.3f, exitMask, (QueryTriggerInteraction)1); for (int j = 0; j < num; j++) { RaycastHit val5 = groundHits[j]; if (((RaycastHit)(ref val5)).normal.y >= 0.42f && !((Component)((RaycastHit)(ref val5)).collider).transform.IsChildOf(((Component)this).transform)) { val4.y = Mathf.Max(val4.y, ((RaycastHit)(ref val5)).point.y + val3.y); } } interactions[i].SetPositionAndRotation(val4, val2); } } private void FixedUpdate() { bool flag = view.IsValid() && view.IsOwner() && gun.User != 0L && !wagon.IsAttached(); SetWheelBrake(flag); SetParkingHold(flag && BothWheelsSupported()); } private bool BothWheelsSupported() { //IL_0032: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_007c: Unknown result type (might be due to invalid IL or missing references) float num = gun.Spec.Carriage.WheelRadius + 0.24f; Rigidbody[] wheels = wagon.m_wheels; for (int i = 0; i < wheels.Length; i++) { int num2 = Physics.RaycastNonAlloc(wheels[i].position + Vector3.up * 0.08f, Vector3.down, groundHits, num, exitMask, (QueryTriggerInteraction)1); bool flag = false; for (int j = 0; j < num2; j++) { RaycastHit val = groundHits[j]; if (!(((RaycastHit)(ref val)).normal.y < 0.45f) && !Object.op_Implicit((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody) && !((Component)((RaycastHit)(ref val)).collider).transform.IsChildOf(((Component)this).transform)) { flag = true; break; } } if (!flag) { return false; } } return true; } private void SetParkingHold(bool enabled) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (parked != enabled) { parked = enabled; if (enabled) { unparkedConstraints = body.constraints; Rigidbody obj = body; obj.constraints = (RigidbodyConstraints)(obj.constraints | 0x7A); } else { body.constraints = unparkedConstraints; } } } private void OnDisable() { if (Object.op_Implicit((Object)(object)body)) { SetParkingHold(enabled: false); SetWheelBrake(enabled: false); } } private void SetWheelBrake(bool enabled) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (wheelsBraked == enabled) { return; } wheelsBraked = enabled; for (int i = 0; i < wheelJoints.Length; i++) { ConfigurableJoint obj = wheelJoints[i]; ? angularYZDrive; if (!enabled) { angularYZDrive = originalWheelDrives[i]; } else { JointDrive val = default(JointDrive); ((JointDrive)(ref val)).positionDamper = body.mass * 8f; ((JointDrive)(ref val)).maximumForce = body.mass * 10f; angularYZDrive = val; } obj.angularYZDrive = (JointDrive)angularYZDrive; } } private static void TrackTow(Vagon __instance) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && __instance.IsAttached((Character)(object)localPlayer) && !((Object)(object)((Component)__instance).GetComponent<CarriageControls>() == (Object)null)) { VehicleUse.HitchCue(__instance, attached: true); activeTow = __instance; ((Character)localPlayer).Message((MessageType)2, Localization.instance.Localize("$KEY_Use to unhitch."), 0, (Sprite)null, false); } } private static void TowReleaseCue(Vagon __instance) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null && __instance.IsAttached((Character)(object)localPlayer) && (Object)(object)((Component)__instance).GetComponent<CarriageControls>() != (Object)null) { VehicleUse.HitchCue(__instance, attached: false); } } private static void ClearTow(Vagon __instance) { if (!((Object)(object)activeTow != (Object)(object)__instance)) { activeTow = null; } } private static void ReleaseInput(Player __instance) { if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer && ((Object)(object)activeTow != (Object)null || Supported(Gun.Manned?.m_prefab)) && (ZInput.GetButtonDown("Use") || ZInput.GetButtonDown("JoyUse"))) { HandleUsePress(__instance); } } internal static bool InputBlocked() { return VehicleUse.InputBlocked(); } private static void HandleUsePress(Player player) { if (!InputBlocked()) { if (TryReleaseTow(player)) { consumedUseFrame = Time.frameCount; } else if (Supported(Gun.Manned?.m_prefab)) { consumedUseFrame = Time.frameCount; player.StopDoodadControl(); } } } private static void AimHint(Gun __instance) { if (!((Object)(object)Gun.Manned != (Object)(object)__instance) && Supported(__instance.m_prefab) && !((Object)(object)Player.m_localPlayer == (Object)null)) { ((Character)Player.m_localPlayer).Message((MessageType)2, Localization.instance.Localize("$KEY_SecondaryAttack to load. $KEY_Use to dismount."), 0, (Sprite)null, false); } } private static bool CheckTowAccess(Vagon __instance, Humanoid character, bool hold) { CarriageControls component = ((Component)__instance).GetComponent<CarriageControls>(); if (hold || (Object)(object)component == (Object)null || (Object)(object)component.gun == (Object)null || component.gun.User == 0L || (Object)(object)Player.GetPlayer(component.gun.User) == (Object)null) { return true; } ((Character)character).Message((MessageType)2, "The gunner must dismount before towing.", 0, (Sprite)null, false); return false; } private static void PrepareDismount(Gun __instance, Player player) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) Transform seat = __instance.m_seat; if ((Object)(object)player != (Object)(object)Player.m_localPlayer || (Object)(object)seat == (Object)null || (Object)(object)player.GetAttachPoint() != (Object)(object)seat) { return; } CarriageControls component = ((Component)__instance).GetComponent<CarriageControls>(); Transform transform = ((Component)__instance).transform; Transform heading; float width; if ((Object)(object)component != (Object)null) { heading = transform; width = Mathf.Abs(((Component)component.wagon.m_wheels[0]).transform.localPosition.x) + 0.72f; } else { if (!StaticTurrets.IsStatic(__instance.m_prefab)) { return; } heading = seat; width = 0.76f; } if (TryFindExit(player, seat, transform, heading, width, out var exit)) { detachOffset.Invoke(player) = seat.InverseTransformPoint(exit); } } private static bool TryFindExit(Player player, Transform seat, Transform root, Transform heading, float width, out Vector3 exit) { //IL_0015: 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_001f: 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_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.ProjectOnPlane(heading.right, Vector3.up); Vector3 normalized = ((Vector3)(ref val)).normalized; val = Vector3.ProjectOnPlane(heading.forward, Vector3.up); Vector3 val2 = -((Vector3)(ref val)).normalized; Vector3[] array = (Vector3[])(object)new Vector3[3] { -normalized * width + val2 * 0.24f, normalized * width + val2 * 0.24f, val2 * 1.15f }; foreach (Vector3 val3 in array) { RaycastHit val4 = (from hit in Physics.RaycastAll(seat.position + val3 + Vector3.up, Vector3.down, 2.1f, exitMask, (QueryTriggerInteraction)1) where !((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(root) && !((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(((Component)player).transform) orderby ((RaycastHit)(ref hit)).distance select hit).FirstOrDefault(); if ((Object)(object)((RaycastHit)(ref val4)).collider == (Object)null || ((RaycastHit)(ref val4)).normal.y < 0.65f) { continue; } Vector3 val5 = ((RaycastHit)(ref val4)).point + Vector3.up * 0.055f; Vector3 val6 = val5 + Vector3.up * 0.44f; if (!Physics.OverlapCapsule(val6, val5 + Vector3.up * 1.42f, 0.32f, exitMask, (QueryTriggerInteraction)1).Any((Collider collider) => !((Component)collider).transform.IsChildOf(((Component)player).transform))) { Vector3 val7 = val6 - (seat.position + Vector3.up * 0.44f); if (!Physics.RaycastAll(val6 - val7, ((Vector3)(ref val7)).normalized, ((Vector3)(ref val7)).magnitude, exitMask, (QueryTriggerInteraction)1).Any((RaycastHit hit) => !((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(root) && !((Component)((RaycastHit)(ref hit)).collider).transform.IsChildOf(((Component)player).transform))) { exit = val5; return true; } } } exit = Vector3.zero; return false; } private static void ReloadWhileMounted(Player __instance, ref bool secondaryAttack, ref bool secondaryAttackHold) { Gun manned = Gun.Manned; if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !((Object)(object)manned == (Object)null) && Supported(manned.m_prefab)) { bool num = secondaryAttack; secondaryAttack = false; secondaryAttackHold = false; if (num && !InputBlocked()) { manned.LoadFrom((Humanoid)(object)__instance); } } } internal static bool TryReleaseTow(Player player) { if ((Object)(object)activeTow == (Object)null || !activeTow.IsAttached((Character)(object)player)) { return false; } detach(activeTow); activeTow = null; return true; } private static bool SuppressInteraction(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { return Time.frameCount != consumedUseFrame; } return true; } } internal sealed class CarriageLoading : MonoBehaviour { private const string RequestRpc = "fred_fieldartillery_load_request_v2"; private const string ReplyRpc = "fred_fieldartillery_load_reply"; private static readonly Func<Container, bool> RefreshCrate = AccessTools.MethodDelegate<Func<Container, bool>>(AccessTools.Method(typeof(Container), "Load", (Type[])null, (Type[])null), (object)null, true); private static readonly Action<Container> RefreshCrateLid = AccessTools.MethodDelegate<Action<Container>>(AccessTools.Method(typeof(Container), "UpdateUseVisual", (Type[])null, (Type[])null), (object)null, true); private static readonly FieldRef<InventoryGui, Container> CurrentContainer = AccessTools.FieldRefAccess<InventoryGui, Container>("m_currentContainer"); private static long nextRequest = DateTime.UtcNow.Ticks; private Gun gun; private ZNetView view; private Container crate; private Player loader; private ItemData pending; private long pendingId; private double retryAt; private double checkCrateAt; private string reservationKey; private FeedSpec Feed => gun?.Spec?.Feed; private void Awake() { gun = ((Component)this).GetComponent<Gun>(); view = ((Component)this).GetComponent<ZNetView>(); if (StaticTurrets.IsStatic(gun.m_prefab)) { crate = ((Component)this).GetComponentInChildren<Container>(); } if (view.IsValid()) { view.Register<ZDOID, long>("fred_fieldartillery_load_request_v2", (Action<long, ZDOID, long>)OnLoadRequest); view.Register<long, bool>("fred_fieldartillery_load_reply", (Action<long, long, bool>)OnLoadReply); } } private void Update() { if (!view.IsValid()) { return; } double unscaledTimeAsDouble = Time.unscaledTimeAsDouble; if ((Object)(object)crate != (Object)null && view.IsOwner() && unscaledTimeAsDouble >= checkCrateAt) { checkCrateAt = unscaledTimeAsDouble + 0.2; LoadFromCrate(); } if (unscaledTimeAsDouble < retryAt) { return; } retryAt = unscaledTimeAsDouble + 1.0; if (pending == null) { Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { RestoreReservation(localPlayer); } } if (pending != null && (Object)(object)loader == (Object)(object)Player.m_localPlayer) { Send(); } } internal bool Request(Humanoid user, ItemData selected) { //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Expected O, but got Unknown Player val = (Player)(object)((user is Player) ? user : null); if (val == null || (Object)(object)val != (Object)(object)Player.m_localPlayer || !view.IsValid() || Feed == null) { return false; } bool flag = StaticTurrets.UsesBolts(gun.m_prefab); string prefab = Feed.Item.Prefab; Inventory inventory = ((Humanoid)val).GetInventory(); if (pending == null) { RestoreReservation(val); } if (selected != null) { GameObject dropPrefab = selected.m_dropPrefab; if (((dropPrefab != null) ? ((Object)dropPrefab).name : null) != prefab) { if (flag) { GameObject dropPrefab2 = selected.m_dropPrefab; string text = ((dropPrefab2 != null) ? ((Object)dropPrefab2).name : null); if (text == "fred_light_ammo" || text == "fred_bronze_bolt") { goto IL_00b8; } } return false; } } goto IL_00b8; IL_00b8: if (selected == null) { selected = inventory.GetItem(prefab, -1, true) ?? (flag ? (inventory.GetItem("fred_light_ammo", -1, true) ?? inventory.GetItem("fred_bronze_bolt", -1, true)) : null); } if (pending != null) { return Message(val, "Waiting for the carriage to confirm the load."); } if (gun.LoadingBlocked) { return Message(val, "Reloading."); } if (!HasRoom()) { return Message(val, "Ammunition is full."); } if (selected == null || !inventory.ContainsItem(selected)) { return Message(val, "Required ammo: " + AmmoText.ForMount(gun.Spec) + "."); } ItemData val2 = selected.Clone(); val2.m_stack = 1; val2.m_equipped = false; long num = Interlocked.Increment(ref nextRequest); Inventory val3 = new Inventory("Artillery loading", (Sprite)null, 1, 1); val3.AddItem(val2); ZPackage val4 = new ZPackage(); val4.Write(num); val3.Save(val4); if (!inventory.RemoveItem(selected, 1)) { return false; } val.m_customData[ReservationKey()] = val4.GetBase64(); loader = val; pending = val2; pendingId = num; Send(); return true; } private void Send() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) retryAt = Time.unscaledTimeAsDouble + 1.0; view.InvokeRPC("fred_fieldartillery_load_request_v2", new object[2] { ((Character)loader).GetZDOID(), pendingId }); } private string ReservationKey() { //IL_000b: 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) ZDOID uid = view.GetZDO().m_uid; return reservationKey ?? (reservationKey = $"fred.fieldartillery.load.{ZNet.instance.GetWorldUID()}.{((ZDOID)(ref uid)).UserID}.{((ZDOID)(ref uid)).ID}"); } private void RestoreReservation(Player player) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (player.m_customData.TryGetValue(ReservationKey(), out var value)) { ZPackage val = new ZPackage(value); long num = val.ReadLong(); Inventory val2 = new Inventory("Artillery loading", (Sprite)null, 1, 1); val2.Load(val); List<ItemData> allItems = val2.GetAllItems(); if (allItems.Count == 1 && allItems[0].m_stack == 1) { pendingId = num; pending = allItems[0]; loader = player; } } } private bool HasRoom() { return gun.Rounds + Feed.RoundsPerItem <= Feed.Most; } private void LoadFromCrate() { if (crate.IsInUse() || ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)CurrentContainer.Invoke(InventoryGui.instance) == (Object)(object)crate)) { return; } if (view.GetZDO().GetInt(ZDOVars.s_inUse, 0) != 0) { RefreshCrateLid(crate); } if (Feed != null && gun.User != 0L && gun.Rounds == 0 && !gun.LoadingBlocked) { RefreshCrate(crate); Inventory inventory = crate.GetInventory(); ItemData item = inventory.GetItem(Feed.Item.Prefab, -1, true); if (item == null && StaticTurrets.UsesBolts(gun.m_prefab)) { item = inventory.GetItem("fred_bronze_bolt", -1, true); } if (item != null && inventory.RemoveItem(item, 1)) { CompleteLoad(); } } } private void OnLoadRequest(long sender, ZDOID actor, long request) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (!view.IsOwner() || request <= 0 || Feed == null) { return; } ZDO zDO = ZDOMan.instance.GetZDO(actor); if (zDO == null || zDO.GetOwner() != sender || zDO.GetPrefab() != StringExtensionMethods.GetStableHashCode("Player")) { return; } long num = zDO.GetLong(ZDOVars.s_playerID, 0L); if (num == 0L) { return; } ZDO zDO2 = view.GetZDO(); string text = $"fred_fieldartillery_load_v2_{num}"; long num2 = zDO2.GetLong(text, 0L); if (Math.Abs(num2) >= request) { view.InvokeRPC(sender, "fred_fieldartillery_load_reply", new object[2] { request, num2 == request }); return; } bool flag = !gun.LoadingBlocked && HasRoom(); zDO2.Set(text, flag ? request : (-request)); if (flag) { CompleteLoad(); } view.InvokeRPC(sender, "fred_fieldartillery_load_reply", new object[2] { request, flag }); } private void CompleteLoad() { int rounds = gun.Rounds; view.GetZDO().Set(gun.Spec.Keys + "_rounds", rounds + Feed.RoundsPerItem); gun.OnAmmoAdded(rounds); view.InvokeRPC(ZNetView.Everybody, gun.LoadShowRpc, Array.Empty<object>()); } private void OnLoadReply(long sender, long request, bool accepted) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) if (request != pendingId || pending == null || sender != view.GetZDO().GetOwner()) { return; } ItemData val = pending; Player val2 = loader; pending = null; loader = null; if ((Object)(object)val2 == (Object)null) { return; } val2.m_customData.Remove(ReservationKey()); if (accepted) { Message(val2, "Loaded " + val.m_shared.m_name + "."); return; } if (!((Humanoid)val2).GetInventory().AddItem(val)) { ItemDrop.DropItem(val, 1, ((Component)val2).transform.position + Vector3.up, Quaternion.identity); } Message(val2, "The weapon is already loaded or reloading. Ammunition returned."); } private static bool Message(Player player, string text) { ((Character)player).Message((MessageType)2, text, 0, (Sprite)null, false); return false; } } internal sealed class Gun : MonoBehaviour, IDoodadController { internal static readonly int Mask = LayerMask.GetMask(new string[12] { "Default", "Default_small", "static_solid", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_noenv", "hitbox", "vehicle", "tree" }); [SerializeField] internal string m_prefab; [SerializeField] internal Transform m_swivel; [SerializeField] internal Transform m_barrel; [SerializeField] internal Transform m_muzzle; [SerializeField] internal Transform m_seat; [SerializeField] internal Transform m_grips; [SerializeField] private Light flash; [SerializeField] internal AudioSource[] m_voices; [SerializeField] internal AudioSource m_tail; private ZNetView view; private Rigidbody body; private IGunExtra[] modules; private BoltDraw boltDraw; private MountedFlame flame; private ShotPresentation presentation; private GameObject heatSteam; private Player requestedBy; private float yaw; private float pitch; private float nextState; private float lastCommand; private float nextShot; private float pendingUntil; private float lampUntil; private float nextEmptyHint; private float nextBurn; private int voice; private bool automatic; private bool trigger; private bool triggerSent; private bool triggerHeld; private bool shotSincePress; private bool pendingTap; private bool ownedLastTick; private Vector3 look; private string takeRpc; private string grantRpc; private string releaseRpc; private string inputRpc; private string fireRpc; private string userKey; private string ammoKey; private string yawKey; private string pitchKey; private string firingKey; private string heatKey; private string heatSinceKey; private string jamKey; private string shotReadyKey; internal static Gun Manned { get; private set; } internal MountedGun Spec { get; private set; } internal bool Busy { get { if (modules != null) { return modules.Any((IGunExtra module) => module.Busy); } return false; } } internal bool LoadingBlocked { get { if (modules != null) { return modules.Any((IGunExtra module) => !(module is BoltDraw) && module.Busy); } return false; } } internal float DrawTimeLeft => boltDraw?.SecondsLeft ?? 0f; internal int Rounds { get { if (!IsValid()) { return 0; } return view.GetZDO().GetInt(ammoKey, 0); } } internal long User {