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 Skyherd v0.1.0
Skyherd.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using MyMods.Web; using Newtonsoft.Json; using UnityEngine; 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("Skyherd")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0+e57aebb909ff1473378d17b85f55faff357e5b1f")] [assembly: AssemblyProduct("Skyherd")] [assembly: AssemblyTitle("Skyherd")] [assembly: AssemblyVersion("0.1.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 MyMods.Web { public static class WebNav { public sealed class Link { public readonly string Id; public readonly string Label; public readonly int Port; public string Url => "http://127.0.0.1:" + Port + "/"; public Link(string id, string label, int port) { Id = id; Label = label; Port = port; } } public static readonly Link[] Links = new Link[18] { new Link("monsters", "Monsters", 8777), new Link("searoute", "SeaRoute", 8778), new Link("longboat", "Harpoon Longboat", 8779), new Link("tradewind", "TradeWind", 8780), new Link("safeharbor", "Safe Harbor", 8781), new Link("hub", "DFG Hub", 8782), new Link("vault", "Viking Vault", 8783), new Link("qolvault", "QoL Vault Buttons", 8784), new Link("qolinventory", "QoL Inventory Buttons", 8785), new Link("cacophony", "Cacophony", 8787), new Link("ominous", "Ominous", 8788), new Link("pebble", "Pebble", 8789), new Link("trolls", "Trolls", 8790), new Link("transporter", "Transporter", 8791), new Link("skytram", "Sky-Tram", 8792), new Link("dockfortress", "Dock Fortress", 8793), new Link("odinseye", "Odin's Eye", 8794), new Link("skyherd", "Skyherd", 8795) }; public const string Style = "nav.top{position:sticky;top:0;z-index:20;font-family:Segoe UI,Arial,sans-serif;background:#0d1219;border-bottom:1px solid #2b3b4c;padding:6px 14px;display:flex;align-items:center;gap:6px;flex-wrap:wrap}\nnav.top .brand{color:#7f8fa0;font-size:11px;text-transform:uppercase;letter-spacing:.6px;margin-right:8px}\nnav.top a{color:#9fc3dd;text-decoration:none;font-size:13px;padding:4px 9px;border-radius:5px}\nnav.top a:hover{background:#1a2530}\nnav.top a.here{background:#3a2b4c;border:1px solid #55406b;color:#efe0ff}\n"; public static string Html(string currentId) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<nav class='top'><span class='brand'>MyMods</span>"); Link[] links = Links; foreach (Link link in links) { stringBuilder.Append("<a class='"); if (link.Id == currentId) { stringBuilder.Append("here"); } stringBuilder.Append("' href='").Append(link.Url).Append("'>") .Append(link.Label) .Append("</a>"); } stringBuilder.Append("</nav>"); return stringBuilder.ToString(); } public static Link Find(string id) { Link[] links = Links; foreach (Link link in links) { if (link.Id == id) { return link; } } return null; } } } namespace Skyherd { public enum HeliState { Docked, LiftOff, FlyOut, Hoist, Carry, Lower, Return, Land } public class HerdHeli : MonoBehaviour { public HerdTransport Transport; public Transform Pad; public Vector3 ParkScale; public Vector3 ParkPosition; public float YawOffset; private HeliState m_state; private Character m_target; private Vector3 m_aim; private float m_stateTime; private float m_rotor; private float m_rotorSpeed; private Transform m_rotorPart; private LineRenderer m_sling; private Light m_light; private bool m_carried; private float m_pilotCooldown; private float m_idleTimer; private bool m_winching; private bool m_payingOut; private bool m_passenger; private HerdPassenger m_rider; private float m_winchStart; private Vector3 m_winchFrom; private Vector3 m_dropPoint; private bool m_linedUp; private static readonly string[] QuotesLaunch = new string[8] { "Laugh it up, fuzzball. Just get in the cage before I drop you in the Swamp.", "Get that squealing pig in the wagon! I'm burning premium Surtling fuel hovering here!", "Don't look at me like that, kid. I'm a pilot, not a zookeeper.", "We've got company! Get those animals loaded before those flying bug things swarm us.", "You want me to drop a Lox into a wooden cart? What do I look like, a miracle worker?", "Boring conversation anyway. Chewie, secure the boar pen and let's get out of here.", "Never tell me the drop odds! I can thread this wolf right through the wagon hatch.", "Don't get cocky, pig! You're going in the wagon whether you like it or not." }; private static readonly string[] QuotesHoist = new string[8] { "I don't care if it's a two-star Lox! Hook the straps under its belly and stand clear!", "Who's scruffy-looking? Have you seen this wolf? It's shedding all over my cargo hook.", "You said you tamed it! Then why is it trying to bite my landing skids?!", "Chewie, lower the cage. No, the big cage. This thing looks like a Bantha that skipped a haircut.", "That's a lot of teeth. Reminds me of a Trandoshan, only furrier. Put it in the reinforced cart.", "Good against a Greydwarf is one thing, but good against a cranky boar? Drop the net!", "I know, I know, they're your pets. Just keep them from chewing through the hoist cable.", "Watch the horns! Watch the horns! You scratch my paint, the transport fee doubles!" }; private static readonly string[] QuotesCarry = new string[9] { "I charge extra for live cargo. Especially when it smells like wet neck-tail.", "Hold her steady! If this Lox shifts its weight, we're going down in the Plains!", "I'm telling you, this winch can't take another Lox! The stabilizers are whining!", "Easy with the winch! You're gonna make the wolf spacesick before we even hit the dirt.", "Look, I've hauled Rathtars that were better behaved than your tamed wolves.", "Look at the size of that thing! It's gonna need two carts and a lot of turnip paste to stay calm.", "I've flown from one side of this realm to the other, and I've never seen anything as stubborn as a Valheim boar.", "If they get loose in the wagon, I'm not turning this chopper around. That's your problem.", "Chewie, lock down the rear stabilizers. This two-star is kicking like a cornered Gundark." }; private static readonly string[] QuotesDrop = new string[4] { "What a piece of junk... and I'm talking about your wagon. I hope those wooden bars hold.", "It's not my fault the boar threw up on the cart! Maybe don't feed it cloudberries before a flight!", "You owe me a new cargo net. That big lizard-cow thing chewed right through the starboard rigging.", "I take orders from one person: me. But I'll lower the crate if you get that barking beast out of my ear." }; private static readonly string[] QuotesDone = new string[1] { "Job's done. Cargo is caged. Now, let's talk about my hazard pay for dealing with the smell." }; private static readonly string[] QuotesMiss = new string[2] { "You said you tamed it! Then why is it trying to bite my landing skids?!", "Good against a Greydwarf is one thing, but good against a cranky boar? Drop the net!" }; private static readonly string[] QuotesIdle = new string[5] { "Don't look at me like that, kid. I'm a pilot, not a zookeeper.", "What a piece of junk... and I'm talking about your wagon. I hope those wooden bars hold.", "I charge extra for live cargo. Especially when it smells like wet neck-tail.", "I've flown from one side of this realm to the other, and I've never seen anything as stubborn as a Valheim boar.", "I take orders from one person: me. But I'll lower the crate if you get that barking beast out of my ear." }; public HeliState State => m_state; public bool IsDocked => m_state == HeliState.Docked; public string Status => m_state switch { HeliState.LiftOff => "lifting off", HeliState.FlyOut => "flying out", HeliState.Hoist => "hoisting", HeliState.Carry => "carrying", HeliState.Lower => "lowering", HeliState.Return => "returning", HeliState.Land => "landing", _ => "on the pad", }; public void Initialize() { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_0096: 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) m_rotorPart = FindChild(((Component)this).transform, "tripo_part_1"); if ((Object)(object)m_rotorPart == (Object)null) { MeshFilter[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshFilter>(true); float num = 0.6f; foreach (MeshFilter val in componentsInChildren) { if (!((Object)(object)val == (Object)null) && !((Object)(object)val.sharedMesh == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)(object)((Component)this).gameObject)) { Bounds bounds = val.sharedMesh.bounds; if (((Bounds)(ref bounds)).max.y > num) { bounds = val.sharedMesh.bounds; num = ((Bounds)(ref bounds)).max.y; m_rotorPart = ((Component)val).transform; } } } } GameObject val2 = new GameObject("Sling"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = new Vector3(0f, -0.15f, 0f); m_sling = val2.AddComponent<LineRenderer>(); m_sling.useWorldSpace = true; m_sling.positionCount = 2; m_sling.startWidth = 0.06f; m_sling.endWidth = 0.04f; ((Renderer)m_sling).sharedMaterial = HerdLines.Material(new Color(0.35f, 0.32f, 0.28f, 0.95f)); ((Renderer)m_sling).enabled = false; GameObject val3 = new GameObject("Searchlight"); val3.transform.SetParent(((Component)this).transform, false); val3.transform.localPosition = new Vector3(0f, -0.05f, 0f); m_light = val3.AddComponent<Light>(); m_light.type = (LightType)2; m_light.range = 18f; m_light.intensity = 1.1f; m_light.color = new Color(1f, 0.93f, 0.78f); m_light.shadows = (LightShadows)0; ((Behaviour)m_light).enabled = false; Park(); } public void Launch(Character animal) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)animal == (Object)null) && m_state == HeliState.Docked && !((Object)(object)Pad == (Object)null)) { m_target = animal; m_carried = false; m_passenger = false; m_rider = null; m_winching = false; m_payingOut = false; m_linedUp = false; m_stateTime = 0f; m_aim = Cruise(((Component)this).transform.position); ((Component)this).transform.SetParent((Transform)null, true); m_state = HeliState.LiftOff; PilotSay(QuotesLaunch, force: true); } } public void LaunchPassenger(Player player) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)player == (Object)null) && m_state == HeliState.Docked && !((Object)(object)Pad == (Object)null)) { m_target = (Character)(object)player; m_carried = false; m_passenger = true; m_rider = null; m_winching = false; m_payingOut = false; m_linedUp = false; m_stateTime = 0f; m_aim = Cruise(((Component)this).transform.position); ((Component)this).transform.SetParent((Transform)null, true); m_state = HeliState.LiftOff; } } private void Update() { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_05a0: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05e8: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05fc: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_0767: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_079a: Unknown result type (might be due to invalid IL or missing references) //IL_07ab: Unknown result type (might be due to invalid IL or missing references) //IL_07bd: Unknown result type (might be due to invalid IL or missing references) //IL_07c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06a8: Unknown result type (might be due to invalid IL or missing references) //IL_06b0: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0631: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_0669: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_06fd: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_055b: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0569: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Expected O, but got Unknown //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; bool flag = m_state != HeliState.Docked; float num = (flag ? 1080f : 160f); m_rotorSpeed = Mathf.MoveTowards(m_rotorSpeed, num, deltaTime * (flag ? 700f : 220f)); m_rotor = Mathf.Repeat(m_rotor + m_rotorSpeed * deltaTime, 360f); if ((Object)(object)m_rotorPart != (Object)null) { m_rotorPart.localRotation = Quaternion.Euler(0f, m_rotor, 0f); } if ((Object)(object)m_light != (Object)null) { ((Behaviour)m_light).enabled = flag; } if (m_pilotCooldown > 0f) { m_pilotCooldown -= deltaTime; } if (!flag || (Object)(object)Transport == (Object)null) { if (!flag) { TickIdle(deltaTime); } SetSling(on: false, Vector3.zero); return; } if (!m_passenger) { Transport.ConsumeFuel(deltaTime); } m_stateTime += deltaTime; switch (m_state) { case HeliState.LiftOff: FlyToward(Cruise(Pad.position), deltaTime, carrying: false); if (CloseTo(Cruise(Pad.position), 1.2f) || m_stateTime > 8f) { Enter(HeliState.FlyOut); } break; case HeliState.FlyOut: { if (!AnimalAlive(m_target)) { if ((Object)(object)Transport != (Object)null) { Transport.CancelWagonLift(); } Transport.Say("The animal is gone. Coming home."); Enter(HeliState.Return); break; } Vector3 position = ((Component)m_target).transform.position; float num2 = Horizontal(position); if (!m_linedUp) { FlyToward(Cruise(position), deltaTime, carrying: false); PayLine(position + Vector3.up * 0.8f); if (num2 < 4f || (num2 < 10f && m_stateTime > 8f)) { m_linedUp = true; m_dropPoint = position; m_stateTime = 0f; } } else { Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(m_dropPoint.x, m_dropPoint.y + 5.5f, m_dropPoint.z); Descend(val, deltaTime); PayLine(position + Vector3.up * 0.8f); if (Mathf.Abs(((Component)this).transform.position.y - val.y) < 1.2f || m_stateTime > 8f) { Enter(HeliState.Hoist); } } break; } case HeliState.Hoist: { if (!m_winching && !AnimalAlive(m_target)) { Transport.CancelWagonLift(); Transport.Say("The sling came back empty."); Enter(HeliState.Return); break; } if (m_winching && !m_passenger && !AnimalAlive(Transport.CarriedAnimal)) { Transport.StowCarry(); Transport.CancelWagonLift(); m_winching = false; m_carried = false; Enter(HeliState.Return); break; } Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(m_dropPoint.x, m_dropPoint.y + 5.5f, m_dropPoint.z); float num3 = (m_winching ? Mathf.Clamp01((m_stateTime - m_winchStart) / 4.6f) : 0f); HoverAt(Vector3.Lerp(val2, Cruise(val2), num3), deltaTime); if (!m_winching) { Vector3 end = ((Component)m_target).transform.position + Vector3.up * 0.6f; SetSling(on: true, end); if (m_stateTime < 0.8f) { break; } if (m_target is Player) { m_rider = HerdPassenger.Attach((Player)m_target, ((Component)this).transform); m_passenger = true; m_carried = true; m_winching = true; m_winchStart = m_stateTime; m_winchFrom = m_rider.WorldOffset; m_target = null; break; } switch (Transport.BeginCarry(m_target)) { case CarryResult.Done: Transport.ClaimWagonLift(); m_carried = true; m_winching = true; m_winchStart = m_stateTime; m_winchFrom = Transport.CarryOffset; m_target = null; break; default: if (!(m_stateTime > 6f)) { break; } goto case CarryResult.Failed; case CarryResult.Failed: Transport.CancelWagonLift(); Transport.Say("The sling could not take hold. Coming home."); Enter(HeliState.Return); break; } } else { float num4 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((m_stateTime - m_winchStart) / 4.6f)); Vector3 val3 = (m_passenger ? (Vector3.down * 2.4f) : Transport.CarryHangOffset); SetPayload(Vector3.Lerp(m_winchFrom, val3, num4)); SetSling(on: true, PayloadPoint()); if (num4 >= 1f) { m_winching = false; Enter(HeliState.Carry); } } break; } case HeliState.Carry: { Vector3 val6 = DeliveryPoint(); FlyToward(Cruise(val6), deltaTime, carrying: true); SetSling(on: true, PayloadPoint()); if (Horizontal(val6) < 2.5f) { Enter(HeliState.Lower); } break; } case HeliState.Lower: { Vector3 val4 = DeliveryPoint(); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(val4.x, val4.y + 8f, val4.z); if (!m_payingOut) { Descend(val5, deltaTime); SetSling(on: true, PayloadPoint()); if (Vector3.Distance(((Component)this).transform.position, val5) < 1.4f || m_stateTime > 8f) { m_payingOut = true; m_winchStart = m_stateTime; m_winchFrom = PayloadOffset(); } break; } HoverAt(val5, deltaTime); float num5 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((m_stateTime - m_winchStart) / 3.6f)); SetPayload(Vector3.Lerp(m_winchFrom, val4 - ((Component)this).transform.position, num5)); SetSling(on: true, PayloadPoint()); if (num5 >= 1f) { if (m_passenger && (Object)(object)m_rider != (Object)null) { m_rider.Drop(val4 + Vector3.up * 0.4f); m_rider = null; m_passenger = false; } else { Transport.StowCarry(); } m_carried = false; m_payingOut = false; PilotSay(QuotesDone, force: true); Enter(HeliState.Return); } break; } case HeliState.Return: SetSling(on: false, Vector3.zero); FlyToward(Cruise(Pad.position), deltaTime, carrying: false); if (Horizontal(Pad.position) < 2.5f) { Enter(HeliState.Land); } break; case HeliState.Land: SetSling(on: false, Vector3.zero); FlyToward(Pad.position, deltaTime, carrying: false); if (Vector3.Distance(((Component)this).transform.position, Pad.position) < 0.8f || m_stateTime > 6f) { Park(); } break; } } private void Enter(HeliState state) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) HeliState state2 = m_state; m_state = state; m_stateTime = 0f; switch (state) { case HeliState.Hoist: PilotSay(QuotesHoist); break; case HeliState.Carry: PilotSay(QuotesCarry); break; case HeliState.Lower: m_payingOut = false; m_dropPoint = DeliveryPoint(); PilotSay(QuotesDrop); break; case HeliState.Return: if (state2 != HeliState.Carry) { PilotSay(QuotesMiss); } break; } } private void Park() { //IL_00a2: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (m_carried && (Object)(object)Transport != (Object)null) { if (m_passenger && (Object)(object)m_rider != (Object)null) { m_rider.Drop(Transport.BoardingPoint() + Vector3.up * 0.4f); m_rider = null; m_passenger = false; } else { Transport.StowCarry(); } m_carried = false; PilotSay(QuotesDone, force: true); } m_state = HeliState.Docked; m_target = null; m_winching = false; m_payingOut = false; SetSling(on: false, Vector3.zero); if (!((Object)(object)Pad == (Object)null)) { ((Component)this).transform.SetParent(Pad, false); ((Component)this).transform.localPosition = ParkPosition; ((Component)this).transform.localRotation = Quaternion.Euler(0f, YawOffset, 0f); if (((Vector3)(ref ParkScale)).sqrMagnitude > 0.0001f) { ((Component)this).transform.localScale = ParkScale; } } } private Vector3 DeliveryPoint() { //IL_0042: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Transport == (Object)null) { if (!((Object)(object)Pad != (Object)null)) { return ((Component)this).transform.position; } return Pad.position; } if (m_passenger) { return Transport.BoardingPoint(); } if (Transport.CarryCagePoint(out var point)) { return point; } return Transport.BoardingPoint(); } private void Descend(Vector3 aim, float dt) { //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_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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) m_aim = aim; float num = SkyherdPlugin.FlightSpeed.Value * dt; Vector3 position = ((Component)this).transform.position; position.x = Mathf.MoveTowards(position.x, aim.x, num); position.y = Mathf.MoveTowards(position.y, aim.y, num); position.z = Mathf.MoveTowards(position.z, aim.z, num); Face(new Vector3(aim.x - ((Component)this).transform.position.x, 0f, aim.z - ((Component)this).transform.position.z), dt); ((Component)this).transform.position = position; } private void FlyToward(Vector3 aim, float dt, bool carrying) { //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_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_0046: 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_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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) m_aim = Vector3.Lerp(m_aim, aim, 1f - Mathf.Exp((0f - dt) * 1.3f)); float num = SkyherdPlugin.FlightSpeed.Value * (carrying ? 0.75f : 1f); Vector3 val = Vector3.MoveTowards(((Component)this).transform.position, m_aim, num * dt); Face(val - ((Component)this).transform.position, dt); ((Component)this).transform.position = val; } private void HoverAt(Vector3 aim, float dt) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_004a: Unknown result type (might be due to invalid IL or missing references) m_aim = aim; Vector3 position = Vector3.Lerp(((Component)this).transform.position, aim, 1f - Mathf.Exp((0f - dt) * 3f)); Face(aim - ((Component)this).transform.position, dt); ((Component)this).transform.position = position; } private void Face(Vector3 velocity, float dt) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_003c: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) velocity.y = 0f; if (!(((Vector3)(ref velocity)).sqrMagnitude < 0.04f)) { Quaternion val = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized, Vector3.up) * Quaternion.Euler(0f, YawOffset, 0f); ((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val, 140f * dt); } } private Vector3 Cruise(Vector3 over) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) return new Vector3(over.x, Surface(over) + SkyherdPlugin.FlightAltitude.Value, over.z); } private static float Surface(Vector3 p) { //IL_0000: 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) float num = p.y; if ((Object)(object)ZoneSystem.instance != (Object)null) { float num2 = default(float); if (ZoneSystem.instance.GetGroundHeight(p, ref num2)) { num = num2; } num = Mathf.Max(num, ZoneSystem.instance.m_waterLevel); } return num; } private float Horizontal(Vector3 world) { //IL_0000: 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_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) Vector3 val = world - ((Component)this).transform.position; val.y = 0f; return ((Vector3)(ref val)).magnitude; } private bool CloseTo(Vector3 world, float radius) { //IL_0006: 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) return Vector3.Distance(((Component)this).transform.position, world) <= radius; } private static bool AnimalAlive(Character animal) { if ((Object)(object)animal == (Object)null || (Object)(object)((Component)animal).gameObject == (Object)null) { return false; } if ((Object)(object)((Component)animal).GetComponent<HerdMark>() != (Object)null || (Object)(object)((Component)animal).GetComponentInParent<HerdMark>() != (Object)null) { return true; } return !animal.IsDead(); } private Vector3 SlingEnd() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) if ((Object)(object)Transport != (Object)null && (Object)(object)Transport.CarriedAnimal != (Object)null) { return ((Component)Transport.CarriedAnimal).transform.position + Vector3.up * 0.6f; } return ((Component)this).transform.position + Vector3.down * 2f; } private Vector3 PayloadOffset() { //IL_0014: 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_0028: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_rider != (Object)null) { return m_rider.WorldOffset; } if (!((Object)(object)Transport != (Object)null)) { return Vector3.zero; } return Transport.CarryOffset; } private void SetPayload(Vector3 offset) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_rider != (Object)null) { m_rider.WorldOffset = offset; } else if ((Object)(object)Transport != (Object)null) { Transport.MoveCarry(offset); } } private Vector3 PayloadPoint() { //IL_0034: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_rider != (Object)null) { return ((Component)m_rider).transform.position + Vector3.up * 0.9f; } return SlingEnd(); } private void SetSling(bool on, Vector3 end) { //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) //IL_003b: 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_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_sling == (Object)null)) { ((Renderer)m_sling).enabled = on; if (on) { m_sling.SetPosition(0, ((Component)this).transform.position + Vector3.down * 0.2f); m_sling.SetPosition(1, end); } } } private void PayLine(Vector3 animalPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_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_0012: Unknown result type (might be due to invalid IL or missing references) float num = Horizontal(animalPoint); if (num > 22f) { SetSling(on: false, Vector3.zero); return; } Vector3 val = ((Component)this).transform.position + Vector3.down * 0.4f; float num2 = Mathf.InverseLerp(22f, 3.2f, num); Vector3 end = Vector3.Lerp(val + Vector3.down * 2f, animalPoint, Mathf.SmoothStep(0f, 1f, num2)); SetSling(on: true, end); } private static Transform FindChild(Transform parent, string childName) { if (((Object)parent).name == childName) { return parent; } for (int i = 0; i < parent.childCount; i++) { Transform val = FindChild(parent.GetChild(i), childName); if ((Object)(object)val != (Object)null) { return val; } } return null; } private void OnDestroy() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_rider != (Object)null) { m_rider.Drop(((Component)m_rider).transform.position); m_rider = null; } else if (m_carried && (Object)(object)Transport != (Object)null) { Transport.StowCarry(); } } private void TickIdle(float dt) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (!CanSpeak() || (Object)(object)Player.m_localPlayer == (Object)null) { m_idleTimer = 0f; return; } if (Vector3.Distance(((Component)this).transform.position, ((Component)Player.m_localPlayer).transform.position) > 22f) { m_idleTimer = 0f; return; } m_idleTimer += dt; if (m_idleTimer >= 70f) { m_idleTimer = 0f; PilotSay(QuotesIdle); } } private bool CanSpeak() { if ((Object)(object)Transport != (Object)null && Transport.Kind == HerdKind.Wagon && SkyherdPlugin.PilotVoice != null) { return SkyherdPlugin.PilotVoice.Value; } return false; } private void PilotSay(string[] pool, bool force = false) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (!CanSpeak() || pool == null || pool.Length == 0 || (!force && m_pilotCooldown > 0f)) { return; } string text = pool[Random.Range(0, pool.Length)]; m_pilotCooldown = 6f; Vector3 val = Vector3.up * Mathf.Max(2.4f, 0.45f * ((Component)this).transform.lossyScale.y); if ((Object)(object)Chat.instance != (Object)null) { Chat.instance.SetNpcText(((Component)this).gameObject, val, 70f, 6.5f, "Herd Pilot", text, false); } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { bool num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayer).transform.position) < 80f; bool flag = Vector3.Distance(((Component)Transport).transform.position, ((Component)localPlayer).transform.position) < 45f; if (num || flag) { ((Character)localPlayer).Message((MessageType)1, "<color=#FFD760>Herd Pilot:</color> \"" + text + "\"", 0, (Sprite)null, false); } } } } internal static class HerdLines { private static Material s_mat; public static Material Material(Color color) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0049: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_mat == (Object)null) { s_mat = new Material(SkyherdGlb.FindValidShader()); ((Object)s_mat).name = "SkyherdLine"; } Material val = new Material(s_mat); if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } return val; } } public class HerdConsole : MonoBehaviour, Hoverable, Interactable { public HerdTransport Transport; public string GetHoverName() { if (!((Object)(object)Transport != (Object)null)) { return "Skyherd"; } return Transport.DisplayName; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { if (!((Object)(object)Transport != (Object)null)) { return ""; } return Transport.HoverText(cage: false); } public bool Interact(Humanoid user, bool hold, bool alt) { if ((Object)(object)Transport == (Object)null) { Transport = ((Component)this).GetComponentInParent<HerdTransport>(); } if ((Object)(object)Transport == (Object)null) { return false; } Player player = (Player)(object)((user is Player) ? user : null); if (alt) { Transport.TryStoke(player); return true; } if (Transport.Kind == HerdKind.Wagon) { Transport.ToggleFollow(player); } else { Transport.AnnounceStatus(player); } return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } } public class HerdCageLatch : MonoBehaviour, Hoverable, Interactable { public HerdTransport Transport; public int Slot; public string GetHoverName() { return "Cage"; } public float GetHoverOffset() { return 0.6f; } public string GetHoverText() { if ((Object)(object)Transport == (Object)null) { return ""; } return Transport.HoverText(cage: true, Slot); } public bool Interact(Humanoid user, bool hold, bool alt) { if ((Object)(object)Transport == (Object)null) { return false; } Player player = (Player)(object)((user is Player) ? user : null); if (alt) { Transport.TryStoke(player); return true; } Transport.ReleaseSlot(Slot, player); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } } public class HerdMark : MonoBehaviour { } public class HerdPin : MonoBehaviour { public Vector3 LocalPosition; public Quaternion LocalRotation; public Vector3 LocalScale; private void LateUpdate() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.localPosition = LocalPosition; ((Component)this).transform.localRotation = LocalRotation; ((Component)this).transform.localScale = LocalScale; } } public class HerdCarry : MonoBehaviour { public Transform Target; public Vector3 WorldOffset; public Vector3 HangOffset; private void LateUpdate() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Target == (Object)null)) { ((Component)this).transform.position = Target.position + WorldOffset; ((Component)this).transform.rotation = Target.rotation; } } } public class HerdPassenger : MonoBehaviour { public Transform Target; public Vector3 WorldOffset; private bool m_gravitySaved; private bool m_hadGravity; private static FieldRef<Character, float> s_air; public static HerdPassenger Attach(Player player, Transform heli) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) HerdPassenger herdPassenger = ((Component)player).GetComponent<HerdPassenger>(); if ((Object)(object)herdPassenger == (Object)null) { herdPassenger = ((Component)player).gameObject.AddComponent<HerdPassenger>(); } herdPassenger.Target = heli; herdPassenger.WorldOffset = ((Component)player).transform.position - heli.position; herdPassenger.Place(((Component)player).transform.position); return herdPassenger; } public void Drop(Vector3 deck) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) Target = null; Place(deck); Rigidbody component = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null && m_gravitySaved) { component.useGravity = m_hadGravity; } Object.Destroy((Object)(object)this); } private void LateUpdate() { //IL_0016: 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) if (!((Object)(object)Target == (Object)null)) { Place(Target.position + WorldOffset); } } private void Place(Vector3 pos) { //IL_005c: 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_003a: 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_0050: 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) Player component = ((Component)this).GetComponent<Player>(); Rigidbody component2 = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { if (!m_gravitySaved) { m_hadGravity = component2.useGravity; m_gravitySaved = true; } component2.useGravity = false; component2.linearVelocity = Vector3.zero; component2.angularVelocity = Vector3.zero; component2.position = pos; } ((Component)this).transform.position = pos; if ((Object)(object)component != (Object)null) { ((Character)component).StopMovement(); AirAltitude((Character)(object)component) = pos.y; ZNetView component3 = ((Component)component).GetComponent<ZNetView>(); if ((Object)(object)component3 != (Object)null && component3.IsValid() && component3.IsOwner()) { component3.GetZDO().SetPosition(pos); } } } private static ref float AirAltitude(Character character) { if (s_air == null) { s_air = AccessTools.FieldRefAccess<Character, float>("m_maxAirAltitude"); } return ref s_air.Invoke(character); } } [HarmonyPatch(typeof(Character), "UpdateMotion")] internal static class PassengerMotionPatch { private static bool Prefix(Character __instance) { HerdPassenger component = ((Component)__instance).GetComponent<HerdPassenger>(); if (!((Object)(object)component == (Object)null)) { return (Object)(object)component.Target == (Object)null; } return true; } } internal static class HerdPersist { internal static void MakeNonPersistent(GameObject go) { if ((Object)(object)go == (Object)null) { return; } ZNetView component = go.GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { ZDO zDO = component.GetZDO(); if (zDO != null) { zDO.Persistent = false; } } } internal static void Quiet(GameObject go) { if ((Object)(object)go == (Object)null) { return; } MakeNonPersistent(go); MonoBehaviour[] componentsInChildren = go.GetComponentsInChildren<MonoBehaviour>(true); foreach (MonoBehaviour val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { switch (((object)val).GetType().Name) { case "Character": case "BaseAI": case "MonsterAI": case "AnimalAI": case "Tameable": case "CharacterDrop": case "CharacterTimedDestruction": case "Procreation": case "Growup": case "ZSyncTransform": case "ZSyncAnimation": ((Behaviour)val).enabled = false; break; } } } Collider[] componentsInChildren2 = go.GetComponentsInChildren<Collider>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if ((Object)(object)componentsInChildren2[j] != (Object)null) { componentsInChildren2[j].enabled = false; } } Rigidbody[] componentsInChildren3 = go.GetComponentsInChildren<Rigidbody>(true); for (int k = 0; k < componentsInChildren3.Length; k++) { if (!((Object)(object)componentsInChildren3[k] == (Object)null)) { componentsInChildren3[k].isKinematic = true; componentsInChildren3[k].useGravity = false; } } if ((Object)(object)go.GetComponent<HerdMark>() == (Object)null) { go.AddComponent<HerdMark>(); } } } public enum HerdKind { Wagon, Knarr, Drakkar } internal struct HerdRecord { public string Prefab; public float Health; public float MaxHealth; public int Level; public long UserId; public uint ZdoId; public string Name; public bool Occupied => !string.IsNullOrEmpty(Prefab); public ZDOID Origin { get { //IL_0022: 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) if (UserId == 0L && ZdoId == 0) { return ZDOID.None; } return new ZDOID(UserId, ZdoId); } } public static string Format(HerdRecord record) { if (!record.Occupied) { return ""; } string text = record.Name ?? ""; text = text.Replace("\n", " ").Replace("|", "/"); return string.Join("|", record.Prefab, record.Health.ToString("0.###", CultureInfo.InvariantCulture), record.MaxHealth.ToString("0.###", CultureInfo.InvariantCulture), record.Level.ToString(CultureInfo.InvariantCulture), record.UserId.ToString(CultureInfo.InvariantCulture), record.ZdoId.ToString(CultureInfo.InvariantCulture), text); } public static bool TryParse(string raw, out HerdRecord record) { record = default(HerdRecord); if (string.IsNullOrEmpty(raw)) { return false; } string[] array = raw.Split('|'); if (array.Length < 7) { return false; } if (!float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || !float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) || !int.TryParse(array[3], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result3) || !long.TryParse(array[4], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result4) || !uint.TryParse(array[5], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result5)) { return false; } record.Prefab = array[0]; record.Health = result; record.MaxHealth = result2; record.Level = result3; record.UserId = result4; record.ZdoId = result5; record.Name = string.Join("|", array, 6, array.Length - 6); return record.Occupied; } } public class HerdTransport : MonoBehaviour { public const string FuelKey = "skyherd_fuel"; public const string FollowKey = "skyherd_follow"; public static readonly List<HerdTransport> All = new List<HerdTransport>(); public HerdKind Kind; public int CageCount; private ZNetView m_nview; private Rigidbody m_body; private bool m_built; private bool m_reaped; private float m_speed; private float m_leadYaw; private Transform[] m_anchors; private Transform m_pad; private HerdHeli m_heli; private string m_bodyFile = ""; private int m_carrySlot = -1; private Character m_carryAnimal; private HerdTransport m_liftFrom; private int m_liftSlot = -1; private float m_fuelNag; private readonly List<ZDOID> m_queue = new List<ZDOID>(); private static MethodInfo s_tame; private static readonly string[][] WagonCageGroups = new string[3][] { new string[2] { "tripo_part_7", "tripo_part_3" }, new string[2] { "tripo_part_1", "tripo_part_9" }, new string[2] { "tripo_part_8", "tripo_part_13" } }; private static readonly string[] LegacyCageParts = new string[4] { "tripo_part_2", "tripo_part_7", "tripo_part_33", "tripo_part_12" }; private static FieldInfo s_ghostField; private static bool s_ghostWarned; public Character CarriedAnimal => m_carryAnimal; public string DisplayName => Kind switch { HerdKind.Knarr => "Herd Knarr", HerdKind.Drakkar => "Herd Drakkar", _ => "Herd Wagon", }; public bool IsLive { get { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid() || (Object)(object)ZNetScene.instance == (Object)null) { return false; } GameObject prefab = ZNetScene.instance.GetPrefab(Utils.GetPrefabName(((Component)this).gameObject)); if ((Object)(object)prefab != (Object)null) { return (Object)(object)prefab != (Object)(object)((Component)this).gameObject; } return false; } } public float TravelSpeed => m_speed; public float LeadYaw => m_leadYaw; public float Fuel { get { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return 0f; } return m_nview.GetZDO().GetFloat("skyherd_fuel", 0f); } private set { if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { m_nview.GetZDO().Set("skyherd_fuel", Mathf.Clamp(value, 0f, SkyherdPlugin.MaxFuel.Value)); } } } public Vector3 CarryOffset { get { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_carryAnimal == (Object)null) { return Vector3.zero; } HerdCarry component = ((Component)m_carryAnimal).GetComponent<HerdCarry>(); if (!((Object)(object)component != (Object)null)) { return Vector3.zero; } return component.WorldOffset; } } public Vector3 CarryHangOffset { get { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_carryAnimal == (Object)null) { return Vector3.down * 2.2f; } HerdCarry component = ((Component)m_carryAnimal).GetComponent<HerdCarry>(); if (!((Object)(object)component != (Object)null)) { return Vector3.down * 2.2f; } return component.HangOffset; } } private void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); if (CageCount <= 0) { CageCount = ((Kind == HerdKind.Drakkar) ? 24 : ((Kind == HerdKind.Knarr) ? 12 : 4)); } } private void OnEnable() { if (!All.Contains(this)) { All.Add(this); } } private void OnDisable() { All.Remove(this); } private void Update() { if (IsLive && !Player.IsPlacementGhost(((Component)this).gameObject) && !IsHammerGhost()) { if (!m_built) { BuildVisuals(); } if (!m_reaped) { ReapStoredOrigins(); m_reaped = true; } TryLaunch(); RightHull(); } } private void FixedUpdate() { //IL_0048: 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_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_00c6: 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_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_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0178: 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_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) if (Kind != HerdKind.Wagon || !IsLive || !IsFollowing()) { m_speed = Mathf.MoveTowards(m_speed, 0f, Time.fixedDeltaTime * 8f); if (Kind == HerdKind.Wagon) { m_leadYaw = ((Component)this).transform.eulerAngles.y; } } else if ((Object)(object)m_heli != (Object)null && !m_heli.IsDocked) { m_speed = Mathf.MoveTowards(m_speed, 0f, Time.fixedDeltaTime * 8f); } else { if (!EnsureOwner()) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } Vector3 position = ((Component)localPlayer).transform.position; Vector3 position2 = ((Component)this).transform.position; Vector3 val = position - position2; val.y = 0f; float magnitude = ((Vector3)(ref val)).magnitude; float fixedDeltaTime = Time.fixedDeltaTime; if (SkyherdPlugin.AllowTeleportCatchup.Value && magnitude > SkyherdPlugin.TeleportDistance.Value) { Vector3 val2 = position - ((Component)localPlayer).transform.forward * (SkyherdPlugin.StopDistance.Value + 1f); float num = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val2, ref num)) { val2.y = num + 0.2f; } PlaceWagon(val2, ((Component)localPlayer).transform.rotation); m_leadYaw = ((Component)localPlayer).transform.eulerAngles.y; m_speed = 0f; return; } float num2 = Mathf.Max(3f, SkyherdPlugin.StopDistance.Value); float num3 = 0f; if (magnitude > num2) { num3 = (((Character)localPlayer).IsRunning() ? SkyherdPlugin.SprintSpeed.Value : SkyherdPlugin.FollowSpeed.Value); } m_speed = Mathf.MoveTowards(m_speed, num3, 6f * fixedDeltaTime); float y = ((Component)this).transform.eulerAngles.y; if (((Vector3)(ref val)).sqrMagnitude < 0.05f || m_speed <= 0.05f) { m_leadYaw = Mathf.MoveTowardsAngle(m_leadYaw, y, 90f * fixedDeltaTime); return; } Quaternion val3 = Quaternion.LookRotation(val); float y2 = ((Quaternion)(ref val3)).eulerAngles.y; m_leadYaw = Mathf.MoveTowardsAngle(m_leadYaw, y2, 240f * fixedDeltaTime); float num4 = ((SkyherdPlugin.HitchAngle != null) ? SkyherdPlugin.HitchAngle.Value : 40f); float num5; float num6; if (num4 <= 1f) { num5 = y2; num6 = SkyherdPlugin.TurnSpeed.Value; } else { num5 = y + Mathf.Clamp(Mathf.DeltaAngle(y, m_leadYaw), 0f - num4, num4); num6 = SkyherdPlugin.TurnSpeed.Value * 0.45f; } float num7 = Mathf.MoveTowardsAngle(y, num5, num6 * fixedDeltaTime); Vector3 val4 = position2 + Quaternion.Euler(0f, num7, 0f) * Vector3.forward * (m_speed * fixedDeltaTime); float num8 = default(float); if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val4, ref num8)) { val4.y = num8 + 0.15f; } PlaceWagon(val4, Quaternion.Euler(0f, num7, 0f)); } } private void PlaceWagon(Vector3 position, Quaternion rotation) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)m_body != (Object)null && m_body.isKinematic) { m_body.MovePosition(position); m_body.MoveRotation(rotation); } else { ((Component)this).transform.SetPositionAndRotation(position, rotation); } } public string HoverText(bool cage, int slot = -1) { //IL_0005: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_0182: 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) string text = ((object)SkyherdPlugin.MarkKey.Value/*cast due to .constrained prefix*/).ToString(); string text2 = DisplayName + "\nCages " + OccupiedCount() + "/" + CageCount + " Fuel " + Mathf.RoundToInt(Fuel) + "/" + Mathf.RoundToInt(SkyherdPlugin.MaxFuel.Value) + " " + (((Object)(object)m_heli != (Object)null) ? m_heli.Status : "no helicopter"); if (m_queue.Count > 0) { text2 = text2 + "\n" + m_queue.Count + " animal(s) marked"; } if (cage) { text2 = ((!TryRead(slot, out var record)) ? (text2 + "\nEmpty cage") : (text2 + "\n" + NiceName(record) + " [E] Release")); } else if (Kind == HerdKind.Wagon) { text2 += (IsFollowing() ? ("\n[" + ((object)SkyherdPlugin.FollowToggleKey.Value/*cast due to .constrained prefix*/).ToString() + "] or [Shift+F] Stay") : ("\n[" + ((object)SkyherdPlugin.FollowToggleKey.Value/*cast due to .constrained prefix*/).ToString() + "] or [Shift+F] Follow")); } else { text2 = text2 + "\n[" + ((object)SkyherdPlugin.PickupKey.Value/*cast due to .constrained prefix*/).ToString() + "] Pick me up, when you are in range"; text2 = text2 + "\n[" + ((object)SkyherdPlugin.FetchWagonKey.Value/*cast due to .constrained prefix*/).ToString() + "] Send the helicopter for the wagon cages"; } return text2 + "\n[Shift+E] Stoke with coal or wood\n[" + text + "] Mark the tame you are looking at\n[Alt+" + text + "] Sweep nearby tames\n[Shift+" + text + "] Move cages to the nearest pen"; } public void AnnounceStatus(Player player) { Say(DisplayName + ": " + OccupiedCount() + "/" + CageCount + " cages, fuel " + Mathf.RoundToInt(Fuel) + ", " + (((Object)(object)m_heli != (Object)null) ? m_heli.Status : "no helicopter") + "."); } public void ToggleFollow(Player player) { if (Kind == HerdKind.Wagon && EnsureOwner()) { bool flag = !IsFollowing(); m_nview.GetZDO().Set("skyherd_follow", flag); Say(flag ? "The mule takes the harness." : "The herd wagon stays."); } } public void RequestPickup(Player player) { //IL_003f: 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) if ((Object)(object)player == (Object)null || Kind == HerdKind.Wagon) { return; } if ((Object)(object)m_heli == (Object)null || !m_heli.IsDocked) { Say("The helicopter is already out."); return; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)player).transform.position); if (num < 8f) { Say("You are already at the ship."); return; } if (num > SkyherdPlugin.PickupRange.Value) { Say("You are out of the helicopter's range."); return; } m_liftFrom = null; m_liftSlot = -1; m_heli.LaunchPassenger(player); Say("The helicopter is coming to pick you up."); } public bool IsFollowing() { if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { return m_nview.GetZDO().GetBool("skyherd_follow", false); } return false; } public void ConsumeFuel(float dt) { if (EnsureOwner()) { float num = Mathf.Max(0f, SkyherdPlugin.FuelPerSecond.Value); Fuel -= num * dt; } } public void TryStoke(Player player) { if ((Object)(object)player == (Object)null || !EnsureOwner()) { return; } if (Fuel >= SkyherdPlugin.MaxFuel.Value - 0.1f) { Say("The boiler is full."); return; } ItemData val = FindFuel(player, coal: true); float value = SkyherdPlugin.CoalFuel.Value; if (val == null) { val = FindFuel(player, coal: false); value = SkyherdPlugin.WoodFuel.Value; } if (val == null) { Say("Need coal or wood for the helicopter."); return; } ((Humanoid)player).GetInventory().RemoveOneItem(val); Fuel += value; Say("Boiler stoked. " + Mathf.RoundToInt(Fuel) + "/" + Mathf.RoundToInt(SkyherdPlugin.MaxFuel.Value) + "."); } public bool Enqueue(Character animal) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_00fd: Unknown result type (might be due to invalid IL or missing references) if (!IsTransportable(animal)) { Say("Skyherd only lifts tamed animals."); return false; } ZNetView component = ((Component)animal).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null) { return false; } ZDOID uid = component.GetZDO().m_uid; if (m_queue.Contains(uid)) { Say(animal.m_name + " is already marked."); return false; } if (FreeCages() <= m_queue.Count) { Say("Every cage is spoken for."); return false; } if (Vector3.Distance(((Component)this).transform.position, ((Component)animal).transform.position) > SkyherdPlugin.PickupRange.Value) { Say("That one is too far for the helicopter."); return false; } if (Fuel < SkyherdPlugin.MinFuelToLaunch.Value && ((Object)(object)m_heli == (Object)null || m_heli.IsDocked)) { Say("Not enough fuel to lift off."); return false; } m_queue.Add(uid); Say("Marked " + animal.m_name + ". " + m_queue.Count + " waiting, " + FreeCages() + " cages free."); return true; } public void EnqueueNearby() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (Fuel < SkyherdPlugin.MinFuelToLaunch.Value) { Say("Not enough fuel to lift off."); return; } List<Character> list = new List<Character>(); Character.GetCharactersInRange(((Component)this).transform.position, SkyherdPlugin.SweepRadius.Value, list); int num = 0; for (int i = 0; i < list.Count; i++) { if (FreeCages() <= m_queue.Count) { break; } if (EnqueueQuiet(list[i])) { num++; } } Say((num > 0) ? ("Marked " + num + " tame" + ((num == 1) ? "" : "s") + ".") : "No unmarked tames in range."); } public void TryTransfer() { //IL_0085: 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) if ((Object)(object)m_heli != (Object)null && !m_heli.IsDocked) { Say("Wait until the helicopter is back on the pad."); return; } HerdTransport herdTransport = null; float num = SkyherdPlugin.TransferRange.Value; for (int i = 0; i < All.Count; i++) { HerdTransport herdTransport2 = All[i]; if (!((Object)(object)herdTransport2 == (Object)null) && !((Object)(object)herdTransport2 == (Object)(object)this) && herdTransport2.IsLive && (!((Object)(object)herdTransport2.m_heli != (Object)null) || herdTransport2.m_heli.IsDocked)) { float num2 = Vector3.Distance(((Component)this).transform.position, ((Component)herdTransport2).transform.position); if (num2 < num) { num = num2; herdTransport = herdTransport2; } } } if ((Object)(object)herdTransport == (Object)null) { Say("No other pen close enough."); return; } int num3 = 0; for (int j = 0; j < CageCount; j++) { if (TryRead(j, out var record)) { int num4 = herdTransport.FirstFree(); if (num4 < 0 || !EnsureOwner() || !herdTransport.EnsureOwner()) { break; } herdTransport.Write(num4, record); GiveCaptive(j, herdTransport, num4); ClearSlot(j); PaintCage(j); herdTransport.PaintCage(num4); num3++; } } Say((num3 > 0) ? ("Moved " + num3 + " cage" + ((num3 == 1) ? "" : "s") + " to the " + herdTransport.DisplayName + ".") : "Nothing moved. The other pen is full, or this one is empty."); } public CarryResult BeginCarry(Character animal) { //IL_00ac: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: 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_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)animal == (Object)null || m_carrySlot >= 0) { return CarryResult.Failed; } int num = FirstFree(); if (num < 0 || m_anchors == null || num >= m_anchors.Length) { return CarryResult.Failed; } bool flag = (Object)(object)((Component)animal).GetComponent<HerdMark>() != (Object)null || (Object)(object)((Component)animal).GetComponentInParent<HerdMark>() != (Object)null; ZNetView component = ((Component)animal).GetComponent<ZNetView>(); bool flag2 = (Object)(object)component != (Object)null && component.IsValid() && component.GetZDO() != null; if (!flag2 && !flag) { return CarryResult.Failed; } if (flag2 && !component.IsOwner()) { component.ClaimOwnership(); return CarryResult.NotReady; } if (!EnsureOwner()) { return CarryResult.NotReady; } ZDOID item = (flag2 ? component.GetZDO().m_uid : ZDOID.None); float num2 = animal.GetHealth(); float maxHealth = animal.GetMaxHealth(); if (num2 <= 0f) { num2 = ((maxHealth > 0f) ? maxHealth : 1f); } HerdRecord record = new HerdRecord { Prefab = Utils.GetPrefabName(((Component)animal).gameObject), Health = num2, MaxHealth = ((maxHealth > 0f) ? maxHealth : num2), Level = animal.GetLevel(), UserId = ((ZDOID)(ref item)).UserID, ZdoId = ((ZDOID)(ref item)).ID, Name = AnimalName(animal) }; Write(num, record); HerdPersist.Quiet(((Component)animal).gameObject); HerdCarry herdCarry = ((Component)animal).gameObject.GetComponent<HerdCarry>(); if ((Object)(object)herdCarry == (Object)null) { herdCarry = ((Component)animal).gameObject.AddComponent<HerdCarry>(); } Transform val = (herdCarry.Target = (((Object)(object)m_heli != (Object)null) ? ((Component)m_heli).transform : ((Component)this).transform)); herdCarry.WorldOffset = ((Component)animal).transform.position - val.position; herdCarry.HangOffset = Vector3.down * HangDistance(((Component)animal).gameObject); m_carryAnimal = animal; m_carrySlot = num; m_queue.Remove(item); PaintCage(num); return CarryResult.Done; } public void MoveCarry(Vector3 worldOffset) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_carryAnimal == (Object)null)) { HerdCarry component = ((Component)m_carryAnimal).GetComponent<HerdCarry>(); if ((Object)(object)component != (Object)null) { component.WorldOffset = worldOffset; } } } public bool CarryCagePoint(out Vector3 point) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) point = ((Component)this).transform.position; if (m_carrySlot < 0 || m_anchors == null || m_carrySlot >= m_anchors.Length || (Object)(object)m_anchors[m_carrySlot] == (Object)null) { return false; } point = m_anchors[m_carrySlot].position; return true; } public void StowCarry() { if (m_carrySlot < 0) { return; } int carrySlot = m_carrySlot; Character carryAnimal = m_carryAnimal; m_carrySlot = -1; m_carryAnimal = null; if ((Object)(object)carryAnimal != (Object)null) { HerdCarry component = ((Component)carryAnimal).GetComponent<HerdCarry>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } PlaceCaptive(((Component)carryAnimal).gameObject, carrySlot); } else { SpawnVisual(carrySlot); } PaintCage(carrySlot); } public void ReleaseSlot(int slot, Player player) { //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_0081: 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) if (!EnsureOwner()) { return; } HerdRecord record; if (slot == m_carrySlot) { Say("That one is still in the sling."); } else if (!TryRead(slot, out record)) { Say("That cage is empty."); } else if (!((Object)(object)ZNetScene.instance == (Object)null)) { GameObject prefab = ZNetScene.instance.GetPrefab(record.Prefab); if ((Object)(object)prefab == (Object)null) { Say("Cannot find a " + record.Prefab + " to release."); return; } Vector3 val = ReleasePoint(); GameObject spawned = Object.Instantiate<GameObject>(prefab, val, Quaternion.identity); TameReleased(spawned, record); DestroyCaptive(slot); ClearSlot(slot); PaintCage(slot); Say("Released " + NiceName(record) + "."); } } public void Say(string message) { //IL_0020: 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) if (!((Object)(object)Player.m_localPlayer == (Object)null) && !string.IsNullOrEmpty(message) && !(Vector3.Distance(((Component)Player.m_localPlayer).transform.position, ((Component)this).transform.position) > 80f)) { ((Character)Player.m_localPlayer).Message((MessageType)2, message, 0, (Sprite)null, false); } } public static HerdTransport FindNearest(Vector3 position, float range) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) HerdTransport result = null; float num = range; for (int num2 = All.Count - 1; num2 >= 0; num2--) { HerdTransport herdTransport = All[num2]; if ((Object)(object)herdTransport == (Object)null) { All.RemoveAt(num2); } else if (herdTransport.IsLive) { float num3 = Vector3.Distance(position, ((Component)herdTransport).transform.position); if (num3 < num) { num = num3; result = herdTransport; } } } return result; } public static HerdTransport FindNearestWagon(Vector3 position, float range) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) HerdTransport result = null; float num = range; for (int num2 = All.Count - 1; num2 >= 0; num2--) { HerdTransport herdTransport = All[num2]; if (!((Object)(object)herdTransport == (Object)null) && herdTransport.IsLive && herdTransport.Kind == HerdKind.Wagon) { float num3 = Vector3.Distance(position, ((Component)herdTransport).transform.position); if (num3 < num) { num = num3; result = herdTransport; } } } return result; } public static HerdTransport FindNearestShip(Vector3 position, float range) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) HerdTransport result = null; float num = range; for (int num2 = All.Count - 1; num2 >= 0; num2--) { HerdTransport herdTransport = All[num2]; if (!((Object)(object)herdTransport == (Object)null) && herdTransport.IsLive && herdTransport.Kind != HerdKind.Wagon) { float num3 = Vector3.Distance(position, ((Component)herdTransport).transform.position); if (num3 < num) { num = num3; result = herdTransport; } } } return result; } public static bool IsTransportable(Character animal) { if ((Object)(object)animal == (Object)null || animal.IsDead() || animal is Player) { return false; } if ((Object)(object)((Component)animal).GetComponent<HerdMark>() != (Object)null) { return false; } Tameable component = ((Component)animal).GetComponent<Tameable>(); if ((Object)(object)component != (Object)null) { return component.IsTamed(); } return false; } private void TryLaunch() { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_heli == (Object)null || !m_heli.IsDocked || m_carrySlot >= 0) { return; } if (m_queue.Count == 0) { if (Kind != HerdKind.Wagon) { TryFetchWagon(); } } else { if (Fuel < SkyherdPlugin.MinFuelToLaunch.Value) { return; } if (FreeCages() <= 0) { m_queue.Clear(); Say("The cages are full."); return; } while (m_queue.Count > 0) { ZDOID val = m_queue[0]; m_queue.RemoveAt(0); if ((Object)(object)ZNetScene.instance == (Object)null) { return; } GameObject val2 = ZNetScene.instance.FindInstance(val); Character val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Character>() : null); if (IsTransportable(val3)) { if (!(Vector3.Distance(((Component)this).transform.position, ((Component)val3).transform.position) > SkyherdPlugin.PickupRange.Value)) { m_liftFrom = null; m_liftSlot = -1; m_heli.Launch(val3); return; } Say(val3.m_name + " wandered out of range."); } } if (Kind != HerdKind.Wagon) { TryFetchWagon(); } } } public void RequestWagonFetch() { if (!SendForWagon(speak: true, out var reason) && !string.IsNullOrEmpty(reason)) { Say(reason); } } private void TryFetchWagon() { if (SkyherdPlugin.FetchWagonCages.Value && !SendForWagon(speak: false, out var reason) && !string.IsNullOrEmpty(reason)) { Say(reason); } } private bool SendForWagon(bool speak, out string reason) { //IL_009b: 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) reason = null; if ((Object)(object)m_heli == (Object)null) { if (speak) { reason = "This ship has no helicopter."; } return false; } if (!m_heli.IsDocked) { if (speak) { reason = "The helicopter is already out."; } return false; } if (FreeCages() <= 0) { if (speak) { reason = "The ship's cages are full."; } return false; } float num = SkyherdPlugin.PickupRange.Value; HerdTransport herdTransport = null; int num2 = -1; Character val = null; for (int i = 0; i < All.Count; i++) { HerdTransport herdTransport2 = All[i]; if ((Object)(object)herdTransport2 == (Object)null || (Object)(object)herdTransport2 == (Object)(object)this || !herdTransport2.IsLive || herdTransport2.Kind != HerdKind.Wagon) { continue; } float num3 = Vector3.Distance(((Component)this).transform.position, ((Component)herdTransport2).transform.position); if (!(num3 > num)) { int slot; Character val2 = herdTransport2.NextCageAnimal(out slot); if (!((Object)(object)val2 == (Object)null)) { num = num3; herdTransport = herdTransport2; num2 = slot; val = val2; } } } if ((Object)(object)herdTransport == (Object)null || (Object)(object)val == (Object)null) { if (speak) { reason = "No animal in a wagon cage within the helicopter's range."; } return false; } if (Fuel < SkyherdPlugin.MinFuelToLaunch.Value) { reason = "Stoke the ship first. Fuel " + Mathf.RoundToInt(Fuel) + "/" + Mathf.RoundToInt(SkyherdPlugin.MaxFuel.Value) + "."; if (!speak && Time.time < m_fuelNag) { reason = null; } else { m_fuelNag = Time.time + 8f; } return false; } m_liftFrom = ((num2 >= 0) ? herdTransport : null); m_liftSlot = num2; m_heli.Launch(val); SkyherdPlugin.Log.LogInfo((object)("Skyherd: fetching " + val.m_name + " from the herd wagon.")); if (speak) { Say("The helicopter is going for the wagon."); } return true; } public Character NextCageAnimal(out int slot) { slot = -1; if (Kind != HerdKind.Wagon) { return null; } int num = CageCount; if (m_anchors != null) { num = Mathf.Min(num, m_anchors.Length); } for (int i = 0; i < num; i++) { if ((Object)(object)CaptiveChild(i) == (Object)null && TryRead(i, out var _)) { SpawnVisual(i); } Character val = CharacterOf(CaptiveChild(i)); if ((Object)(object)val == (Object)null) { val = CharacterInAnchor(i); } if ((Object)(object)val != (Object)null) { slot = i; return val; } } return AnimalStandingInCage(out slot); } private Character AnimalStandingInCage(out int slot) { //IL_0019: 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_0072: Unknown result type (might be due to invalid IL or missing references) slot = -1; if (m_anchors == null) { return null; } List<Character> list = new List<Character>(); Character.GetCharactersInRange(((Component)this).transform.position, 24f, list); Character result = null; float num = 3.5f; for (int i = 0; i < list.Count; i++) { Character val = list[i]; if (!IsTransportable(val)) { continue; } for (int j = 0; j < m_anchors.Length && j < CageCount; j++) { if (!((Object)(object)m_anchors[j] == (Object)null)) { float num2 = Vector3.Distance(m_anchors[j].position, ((Component)val).transform.position); if (num2 < num) { num = num2; result = val; } } } } slot = -1; return result; } private static Character CharacterOf(Transform child) { if ((Object)(object)child == (Object)null) { return null; } Character val = ((Component)child).GetComponent<Character>(); if ((Object)(object)val == (Object)null) { val = ((Component)child).GetComponentInChildren<Character>(true); } return val; } private Character CharacterInAnchor(int slot) { if (m_anchors == null || slot < 0 || slot >= m_anchors.Length || (Object)(object)m_anchors[slot] == (Object)null) { return null; } Character[] componentsInChildren = ((Component)m_anchors[slot]).GetComponentsInChildren<Character>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { return componentsInChildren[i]; } } return null; } public void CancelWagonLift() { m_liftFrom = null; m_liftSlot = -1; } public void ClaimWagonLift() { if (!((Object)(object)m_liftFrom == (Object)null)) { m_liftFrom.ReleaseVisualToSling(m_liftSlot); m_liftFrom = null; m_liftSlot = -1; } } public Character CaptiveAnimal(int slot) { Transform val = CaptiveChild(slot); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponentInChildren<Character>(); } public void ReleaseVisualToSling(int slot) { Transform val = CaptiveChild(slot); if ((Object)(object)val != (Object)null) { HerdPin component = ((Component)val).GetComponent<HerdPin>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } val.SetParent((Transform)null, true); } ClearSlot(slot); PaintCage(slot); } public Vector3 BoardingPoint() { //IL_0081: 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_0090: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0075: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)this).transform.Find("SkyherdBody"); if ((Object)(object)val != (Object)null && IsOpenHull()) { Vector3 val2 = ((m_bodyFile == "falt_ship.glb") ? new Vector3(0f, 0.116f, 0f) : new Vector3(-0.18f, 0.16f, 0f)); return val.TransformPoint(val2) + Vector3.up * 0.35f; } return ((Component)this).transform.position + Vector3.up * 2.5f; } private int FirstOccupied() { for (int i = 0; i < CageCount; i++) { if (TryRead(i, out var _) && (Object)(object)CaptiveChild(i) != (Object)null) { return i; } } return -1; } private bool EnqueueQuiet(Character animal) { //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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0077: Unknown result type (might be due to invalid IL or missing references) if (!IsTransportable(animal)) { return false; } ZNetView component = ((Component)animal).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null) { return false; } ZDOID uid = component.GetZDO().m_uid; if (m_queue.Contains(uid)) { return false; } if (Vector3.Distance(((Component)this).transform.position, ((Component)animal).transform.position) > SkyherdPlugin.PickupRange.Value) { return false; } m_queue.Add(uid); return true; } private void FoldExtraCages(int keep) { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return; } for (int i = keep; i < keep + 4; i++) { if (!TryRead(i, out var record)) { continue; } int num = -1; for (int j = 0; j < keep; j++) { if (!TryRead(j, out var _)) { num = j; break; } } if (num >= 0) { Write(num, record); ClearSlot(i); } else { ReleaseSlot(i, null); } } } private void FoldSpareCages(int keep, int oldMax) { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return; } for (int i = keep; i < oldMax; i++) { if (!TryRead(i, out var record)) { continue; } int num = -1; for (int j = 0; j < keep; j++) { if (!TryRead(j, out var _)) { num = j; break; } } if (num >= 0) { Write(num, record); ClearSlot(i); } else { ReleaseSlot(i, null); } } } private void BuildVisuals() { //IL_00a5: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: 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_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: 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_014c: Unknown result type (might be due to invalid IL or missing references) EnsureBody(); Transform val = TryBodyModel(); if ((Object)(object)val != (Object)null && IsArmWagon()) { FoldExtraCages(4); CageCount = 4; } else if ((Object)(object)val != (Object)null && m_bodyFile == "wagon_2.glb") { CageCount = WagonCageGroups.Length; } else if ((Object)(object)val != (Object)null && IsOpenHull()) { FoldSpareCages(8, 24); CageCount = 8; CreateDeckWalk(val); RaiseHelm(val); } if (!Measure(((Object)(object)val != (Object)null) ? val : ((Component)this).transform, out var local)) { ((Bounds)(ref local))..ctor(Vector3.zero, new Vector3(2.2f, 1.6f, 4.5f)); } if ((Object)(object)val != (Object)null) { HideVanillaMeshes(val); } if (Kind == HerdKind.Wagon) { NudgeWagonCages(val); } float deckY = DeckHeight(((Object)(object)val != (Object)null) ? val : ((Component)this).transform, local); CreateAnchors(val, local, deckY); if (!TrySternPad(val) && !TryNamedPad(val) && !TryRoofPad(val)) { CreatePad(local, deckY); } CreateHelicopter(); if (Kind == HerdKind.Wagon && !TryCreateMule(val, local) && SkyherdPlugin.UseLox.Value) { CreateLox(local); } if (Kind != HerdKind.Wagon) { CreatePost(deckY); } RebuildCaptives(); DeckFloor.SeparateFromHull(((Component)this).gameObject); m_built = true; SkyherdPlugin.Log.LogInfo((object)(DisplayName + " ready. Cages " + CageCount + ", bed " + ((Bounds)(ref local)).size.x.ToString("0.0") + " x " + ((Bounds)(ref local)).size.z.ToString("0.0") + " m.")); } private void EnsureBody() { if (Kind == HerdKind.Wagon) { m_body = ((Component)this).GetComponent<Rigidbody>(); if ((Object)(object)m_body == (Object)null) { m_body = ((Component)this).gameObject.AddComponent<Rigidbody>(); } m_body.isKinematic = true; m_body.useGravity = false; m_body.interpolation = (RigidbodyInterpolation)1; }