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 SilentVanillaCart v1.3.3
SilentVanillaCart.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Photon.Pun; using Photon.Realtime; using SilentVanilla.Cart; using SilentVanilla.Chat; using SilentVanilla.Net; using TMPro; using Unity.AI.Navigation; using UnityEngine; using UnityEngine.AI; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Silent")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.3.0")] [assembly: AssemblyInformationalVersion("1.3.3")] [assembly: AssemblyProduct("SilentVanilla")] [assembly: AssemblyTitle("SilentVanillaCart")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.3.3.0")] [module: UnverifiableCode] namespace SilentVanilla { internal static class Cfg { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> ChatCommands; internal static ConfigEntry<string> ReplyChannel; internal static ConfigEntry<bool> CartEnabled; internal static ConfigEntry<bool> CartOverrideClaims; internal static ConfigEntry<string> CartSpeed; internal static ConfigEntry<string> PathBlocked; internal static ConfigEntry<string> StuckHandling; internal static ConfigEntry<string> ExtractionChoice; private static readonly float[] SpeedsSlow = new float[8] { 3f, 0.6f, 2f, 1.5f, 1.8f, 1.2f, 0.5f, 1f }; private static readonly float[] SpeedsNormal = new float[8] { 4.5f, 0.8f, 3f, 2f, 2.5f, 1.6f, 0.6f, 1.2f }; private static readonly float[] SpeedsFast = new float[8] { 5f, 1f, 3.5f, 2.5f, 3f, 2f, 0.7f, 1.4f }; internal const float ClearanceMargin = 0.15f; internal const float PreferredExtraClearance = 0.35f; internal static ConfigEntry<float> FollowWakeDistance; internal static ConfigEntry<float> FollowRetrySeconds; internal static ConfigEntry<float> TaxmanQuietSeconds; internal static ConfigEntry<bool> DebugLog; private static float[] SpeedsNow { get { string text = ((CartSpeed != null) ? CartSpeed.Value : null); if (text == "Slow") { return SpeedsSlow; } if (text == "Fast") { return SpeedsFast; } return SpeedsNormal; } } internal static float MaxSpeed => SpeedsNow[0]; internal static float MinSpeed => SpeedsNow[1]; internal static float CornerSpeed => SpeedsNow[2]; internal static float StairsSpeed => SpeedsNow[3]; internal static float DoorSpeed => SpeedsNow[4]; internal static float Lookahead => SpeedsNow[5]; internal static float StairsLookahead => SpeedsNow[6]; internal static float StairsUpAssist => SpeedsNow[7]; internal static float BlockedReplanTime { get { if (!(((PathBlocked != null) ? PathBlocked.Value : null) == "Patient")) { return 2f; } return 4f; } } internal static float ClearTimeBeforeResume { get { if (!(((PathBlocked != null) ? PathBlocked.Value : null) == "Patient")) { return 1f; } return 2f; } } internal static float StuckTimeout { get { if (!(((StuckHandling != null) ? StuckHandling.Value : null) == "Sensitive")) { return 2.5f; } return 1.5f; } } internal static float BlockedAreaLifetime { get { if (!(((StuckHandling != null) ? StuckHandling.Value : null) == "Sensitive")) { return 25f; } return 15f; } } internal static bool ExtractionFurthestFromTruck => ((ExtractionChoice != null) ? ExtractionChoice.Value : null) != "ClosestToCart"; internal static bool ExtractionClosestToCart => !ExtractionFurthestFromTruck; internal static void Bind(ConfigFile cfg) { //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Expected O, but got Unknown //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown Enabled = cfg.Bind<bool>("General", "Enabled", true, "Master switch. Off = the host changes nothing about the run, vanilla behaviour all round."); ChatCommands = cfg.Bind<bool>("Chat", "EnableCommands", true, "Parse incoming chat for commands. This is the only interface vanilla players get, so keep it on."); ReplyChannel = cfg.Bind<string>("Chat", "ReplyChannel", "Echo", new ConfigDescription("Where a command reply goes. Every one of these is a channel the game already replicates, so unmodded players receive it with nothing installed. Echo (default) = the reply is voiced by the PLAYER WHO ASKED. Voice = your own chat line, attributed to your character. Taxman = the truck's monitor, printed as the game's own computer. EchoAndTaxman = both. HostUI = only on your screen. Log = BepInEx log only.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[6] { "Echo", "Voice", "Taxman", "EchoAndTaxman", "HostUI", "Log" }), Array.Empty<object>())); CartEnabled = cfg.Bind<bool>("Cart", "Enabled", true, "Autopilot the supply cart for players who claim it."); CartOverrideClaims = cfg.Bind<bool>("Cart", "OverrideClaims", false, "What happens when a player claims a cart someone else already owns. True = the new player takes it over. False (default) = the claim is refused and they are told who owns it."); CartSpeed = cfg.Bind<string>("Cart", "CartSpeed", "Normal", new ConfigDescription("Cart speed preset. Slow = short careful trips. Normal = the tuned default. Fast = 5 m/s, the game's pull cap.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "Slow", "Normal", "Fast" }), Array.Empty<object>())); PathBlocked = cfg.Bind<string>("Obstacles", "PathBlocked", "Normal", new ConfigDescription("How long the cart puts up with a blocked path before replanning. Normal = the tuned default. Patient = waits twice as long before giving up on a route.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Normal", "Patient" }), Array.Empty<object>())); StuckHandling = cfg.Bind<string>("Obstacles", "StuckHandling", "Normal", new ConfigDescription("How fast the cart reacts to being stuck. Normal = the tuned default. Sensitive = backs up sooner and forgets blocked spots sooner.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "Normal", "Sensitive" }), Array.Empty<object>())); ExtractionChoice = cfg.Bind<string>("Extraction", "ExtractionChoice", "FurthestFromTruck", new ConfigDescription("Which unfinished extraction point the cart drives to. An already active extraction always takes priority.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[2] { "FurthestFromTruck", "ClosestToCart" }), Array.Empty<object>())); FollowWakeDistance = cfg.Bind<float>("Cart", "FollowWakeDistance", 12f, "Smart follow ('!cart follow'): the cart parks while its owner is within this many meters and chases once they stray beyond it."); FollowRetrySeconds = cfg.Bind<float>("Cart", "FollowRetrySeconds", 5f, "Smart follow: seconds between attempts after a failure. Follow mode never surrenders - it retries forever and says 'Cart stuck' when it can no longer make progress."); TaxmanQuietSeconds = cfg.Bind<float>("Taxman", "QuietSeconds", 15f, "Seconds the vanilla Taxman's scripted pages stay invisible at the start of every phase (level, store, truck). The pages still type and drive the game normally; only their text is muted so [SilentVanilla] messages show first. 0 disables muting."); DebugLog = cfg.Bind<bool>("Debug", "DebugLog", false, "Verbose logging: command registration and every chat line the host parses."); } } [BepInPlugin("silent.vanilla", "SilentVanilla AutoCart", "1.3.3")] public class Plugin : BaseUnityPlugin { public const string Guid = "silent.vanilla"; public const string Name = "SilentVanilla AutoCart"; public const string Version = "1.3.3"; internal static ManualLogSource Log; internal static Plugin Instance; private Harmony harmony; private void Awake() { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown try { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Cfg.Bind(((BaseUnityPlugin)this).Config); DiagLog.Init(); harmony = new Harmony("silent.vanilla"); harmony.PatchAll(); Log.LogInfo((object)"Harmony: single PatchAll() sweep applied, CartPilot boot shape."); CartCommands.Install(); SVPresentation.Install(); Log.LogInfo((object)string.Format("{0} {1} loaded. Host-only by design - vanilla clients need no mod.", "SilentVanilla AutoCart", "1.3.3")); Log.LogInfo((object)string.Format("Commands in chat: '{0}cart claim|release|follow|truck|exit|open|stop|status'.", "!")); } catch (Exception ex) { Log.LogError((object)("Awake failed\n" + ex)); } } private void OnDestroy() { try { if (harmony != null) { harmony.UnpatchSelf(); } } catch (Exception ex) { Log.LogWarning((object)("Unpatch failed\n" + ex)); } } internal static string DescribeRole() { if (!HostEnabled()) { return "disabled (config General.Enabled = false)"; } if (!HostAuthority.IsHost) { return "CLIENT - nothing runs; the host's changes reach you as ordinary game traffic"; } return "HOST - behaviour and chat commands run here"; } internal static bool HostEnabled() { if (Cfg.Enabled != null) { return Cfg.Enabled.Value; } return false; } } } namespace SilentVanilla.Patches { [HarmonyPatch(typeof(PlayerAvatar), "ChatMessageSendRPC")] internal static class IncomingChatPatch { private static void Postfix(string _message, PhotonMessageInfo _info) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (!HostAuthority.MustRun) { return; } try { ChatTriggers.Dispatch(_message, _info); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Incoming chat could not be parsed\n" + ex)); } } } [HarmonyPatch(typeof(ItemGun), "Misfire")] internal static class ItemGunMisfirePatch { private static bool Prefix(ItemGun __instance) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) return !CartPilotController.CarryingWhileDriving(((Component)__instance).transform.position); } } [HarmonyPatch(typeof(PhysGrabCart), "Start")] internal static class PhysGrabCartStartPatch { private static void Postfix(PhysGrabCart __instance) { if (!__instance.isSmallCart && !((Object)(object)((Component)__instance).GetComponent<CartPilotController>() != (Object)null)) { ((Component)__instance).gameObject.AddComponent<CartPilotController>(); } } } internal static class TaxmanQuietStart { internal static bool SuppressActive() { try { ConfigEntry<float> taxmanQuietSeconds = Cfg.TaxmanQuietSeconds; if (taxmanQuietSeconds == null || taxmanQuietSeconds.Value <= 0f) { return false; } return Time.timeSinceLevelLoad < taxmanQuietSeconds.Value; } catch (Exception) { return false; } } } [HarmonyPatch(typeof(TruckScreenText), "InitializeTextTyping")] internal static class Patch_TaxmanIntroSilencer { private static bool Prefix(TruckScreenText __instance) { if (!TaxmanQuietStart.SuppressActive()) { return true; } try { __instance.InitializeTextTypingLogic(); } catch (Exception) { } return false; } } [HarmonyPatch(typeof(TruckScreenText), "TypingUpdate")] internal static class Patch_TaxmanMuteTyping { private static TruckScreenText muteScreen; private static int muteLength = -1; private static void Prefix(TruckScreenText __instance) { muteScreen = null; muteLength = -1; if (!TaxmanQuietStart.SuppressActive()) { return; } muteScreen = __instance; try { muteLength = ((TMP_Text)__instance.textMesh).text.Length; } catch (Exception) { muteLength = -1; } } private static void Postfix(TruckScreenText __instance) { if ((Object)(object)muteScreen != (Object)(object)__instance || muteLength < 0) { return; } try { if (((TMP_Text)__instance.textMesh).text.Length > muteLength) { ((TMP_Text)__instance.textMesh).text = ((TMP_Text)__instance.textMesh).text.Substring(0, muteLength); } } catch (Exception) { } } } } namespace SilentVanilla.Net { internal static class HostAuthority { internal static bool IsHost { get { try { return SemiFunc.IsMasterClientOrSingleplayer(); } catch (Exception) { return !PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient; } } } internal static bool MustRun { get { if (!Plugin.HostEnabled()) { return false; } return IsHost; } } internal static bool InActiveRun { get { RunManager instance = RunManager.instance; if ((Object)(object)instance != (Object)null) { return (Object)(object)instance.levelCurrent != (Object)null; } return false; } } internal static void PublishRoomFlag(string name, object value) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown Room currentRoom = PhotonNetwork.CurrentRoom; if (currentRoom != null && IsHost) { Hashtable val = new Hashtable(); val[(object)FlagName(name)] = value; currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null); } } internal static bool ReadRoomFlag(string name) { Room currentRoom = PhotonNetwork.CurrentRoom; if (currentRoom == null || ((RoomInfo)currentRoom).CustomProperties == null) { return false; } if (!((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).TryGetValue((object)FlagName(name), out object value) || value == null) { return false; } if (value is bool) { return (bool)value; } bool result; return bool.TryParse(value.ToString(), out result) && result; } private static string FlagName(string name) { return "SV_" + name; } } } namespace SilentVanilla.Chat { internal static class CartVoice { internal static void Say(PlayerAvatar owner, string text) { if (string.IsNullOrEmpty(text)) { return; } try { ChatContext ctx = new ChatContext(null, owner, NameOf(owner), Array.Empty<string>(), null, (Object)(object)owner == (Object)null || (Object)(object)owner == (Object)(object)SemiFunc.PlayerAvatarLocal()); ChatAnnouncer.Announce(ChatReply.Speak(text), ctx); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Cart message could not be sent\n" + ex)); } } internal static string NameOf(PlayerAvatar avatar) { if ((Object)(object)avatar == (Object)null || (Object)(object)avatar.photonView == (Object)null) { return null; } try { return avatar.photonView.Owner.NickName; } catch (Exception) { return null; } } } internal static class ChatAnnouncer { internal static void Announce(ChatReply reply, ChatContext ctx) { if (reply == null) { return; } string text = reply.Logged ?? reply.Written ?? reply.Spoken; if (!string.IsNullOrEmpty(text)) { Plugin.Log.LogInfo((object)("[command] " + text)); } switch (Channel()) { case "hostui": ShowOnHost(reply); break; case "voice": SpeakOrHost(reply); break; case "taxman": if (!TaxmanScreen.TrySay(reply.Written)) { ShowOnHost(reply); } break; case "echoandtaxman": EchoOrVoice(reply, ctx); TaxmanScreen.TrySay(reply.Written); break; default: EchoOrVoice(reply, ctx); break; } } private static void EchoOrVoice(ChatReply reply, ChatContext ctx) { if (string.IsNullOrEmpty(reply.Spoken) || !ReplyEcho.TrySay(ctx, reply.Spoken)) { SpeakOrHost(reply); } } private static string Channel() { string text = ((Cfg.ReplyChannel != null) ? Cfg.ReplyChannel.Value : null); if (!string.IsNullOrEmpty(text)) { return text.Trim().ToLowerInvariant(); } return "auto"; } private static void SpeakOrHost(ChatReply reply) { if (string.IsNullOrEmpty(reply.Spoken) || !TrySpeak(reply.Spoken)) { ShowOnHost(reply); } } private static bool TrySpeak(string text) { PlayerAvatar val = SemiFunc.PlayerAvatarLocal(); if ((Object)(object)val == (Object)null) { return false; } try { val.ChatMessageSend(text, (string)null); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Reply could not be sent as chat\n" + ex)); return false; } } private static void ShowOnHost(ChatReply reply) { //IL_001c: 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) string forHostScreen = reply.ForHostScreen; if (string.IsNullOrEmpty(forHostScreen)) { return; } try { SemiFunc.UIBigMessage(forHostScreen, "{:O}", 20f, Color.white, new Color(1f, 0.55f, 0f)); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Reply could not be shown on the host\n" + ex)); } } } internal sealed class ChatContext { internal readonly Player PhotonPlayer; internal readonly PlayerAvatar Avatar; internal readonly string Name; internal readonly string[] Args; internal readonly string RawText; internal readonly bool FromHost; internal PlayerAvatar Actor { get { if (!((Object)(object)Avatar != (Object)null)) { return SemiFunc.PlayerAvatarLocal(); } return Avatar; } } internal string ActorName { get { if (!string.IsNullOrEmpty(Name)) { return Name; } return "you"; } } internal ChatContext(Player photonPlayer, PlayerAvatar avatar, string name, string[] args, string rawText, bool fromHost) { PhotonPlayer = photonPlayer; Avatar = avatar; Name = name; Args = ((args != null) ? args : Array.Empty<string>()); RawText = rawText; FromHost = fromHost; } } internal sealed class ChatReply { internal readonly string Spoken; internal readonly string Written; internal readonly string Logged; internal string ForHostScreen => Written ?? Spoken; private ChatReply(string spoken, string written, string logged) { Spoken = spoken; Written = written; Logged = logged; } internal static ChatReply Speak(string text) { return new ChatReply(text, text, text); } internal static ChatReply Of(string spoken, string logged) { return new ChatReply(spoken, spoken, logged); } internal static ChatReply Create(string spoken, string written, string logged) { return new ChatReply(spoken, written, logged); } internal static ChatReply LogOnly(string logged) { return new ChatReply(null, null, logged); } } internal sealed class ChatTrigger { internal readonly string Keyword; internal readonly string Description; internal readonly string[] Subcommands; internal readonly Func<ChatContext, ChatReply> Handler; internal ChatTrigger(string keyword, string description, Func<ChatContext, ChatReply> handler, string[] subcommands = null) { Keyword = (keyword ?? string.Empty).Trim().ToLowerInvariant(); Description = description; Handler = handler; Subcommands = subcommands; } internal bool MatchesSubcommand(string candidate) { if (Subcommands == null || string.IsNullOrEmpty(candidate)) { return false; } for (int i = 0; i < Subcommands.Length; i++) { if (string.Equals(Subcommands[i], candidate, StringComparison.OrdinalIgnoreCase)) { return true; } } return false; } } internal static class ChatTriggers { internal const string Prefix = "!"; private static readonly List<ChatTrigger> Triggers = new List<ChatTrigger>(); internal static void Register(ChatTrigger trigger) { if (trigger == null || string.IsNullOrEmpty(trigger.Keyword)) { Plugin.Log.LogWarning((object)"Ignored a chat trigger with no keyword"); return; } for (int i = 0; i < Triggers.Count; i++) { if (string.Equals(Triggers[i].Keyword, trigger.Keyword, StringComparison.OrdinalIgnoreCase)) { Plugin.Log.LogWarning((object)("Chat trigger '" + trigger.Keyword + "' is already registered")); return; } } Triggers.Add(trigger); } internal static bool Dispatch(string incomingChat, PhotonMessageInfo info) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(incomingChat) || Triggers.Count == 0) { return false; } if (!Plugin.HostEnabled() || Cfg.ChatCommands == null || !Cfg.ChatCommands.Value) { return false; } if (!TryParse(incomingChat, out var keyword, out var args)) { return false; } ChatTrigger chatTrigger = Find(keyword); if (Cfg.DebugLog.Value) { Plugin.Log.LogInfo((object)("Parsed incoming chat '" + incomingChat + "' -> " + ((chatTrigger == null) ? ("no trigger named '" + keyword + "'") : ("trigger '" + keyword + "'")))); } if (chatTrigger == null) { return false; } Run(chatTrigger, BuildContext(info, args, incomingChat)); return true; } private static void Run(ChatTrigger trigger, ChatContext context) { try { ChatAnnouncer.Announce(trigger.Handler(context), context); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Trigger '" + trigger.Keyword + "' failed\n" + ex)); } } private static ChatTrigger Find(string keyword) { for (int i = 0; i < Triggers.Count; i++) { if (string.Equals(Triggers[i].Keyword, keyword, StringComparison.OrdinalIgnoreCase)) { return Triggers[i]; } } return null; } private static bool TryParse(string text, out string keyword, out string[] args) { keyword = null; args = Array.Empty<string>(); string text2 = "!"; string text3 = text.Trim(); if (text3.Length <= text2.Length || !text3.StartsWith(text2, StringComparison.OrdinalIgnoreCase)) { return false; } string[] array = text3.Substring(text2.Length).Trim().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 0) { return false; } keyword = array[0].ToLowerInvariant(); if (array.Length > 1) { args = new string[array.Length - 1]; Array.Copy(array, 1, args, 0, args.Length); } return true; } private static ChatContext BuildContext(PhotonMessageInfo info, string[] args, string raw) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Player val = null; try { val = info.Sender; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not read the message sender\n" + ex)); } PlayerAvatar avatar = null; if (val != null) { try { avatar = SemiFunc.PlayerAvatarGetFromPhotonPlayer(val); } catch (Exception ex2) { Plugin.Log.LogWarning((object)("Could not resolve the sender's avatar\n" + ex2)); } } bool fromHost = val == null || val == PhotonNetwork.LocalPlayer; string name = ((val != null) ? SafeNickName(val) : null); return new ChatContext(val, avatar, name, args, raw, fromHost); } private static string SafeNickName(Player player) { try { return player.NickName; } catch (Exception) { return null; } } } internal static class ReplyEcho { private const float CooldownSeconds = 1.2f; private static readonly Dictionary<int, float> LastSpoken = new Dictionary<int, float>(); internal static bool TrySay(ChatContext ctx, string text) { if (ctx == null || string.IsNullOrEmpty(text)) { return false; } if (!SemiFunc.IsMultiplayer() || !InRun()) { return false; } PlayerAvatar actor = ctx.Actor; if ((Object)(object)actor == (Object)null || (Object)(object)actor.photonView == (Object)null) { return false; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { return false; } int instanceID = ((Object)actor).GetInstanceID(); if (!CoolEnough(instanceID)) { Plugin.Log.LogInfo((object)("Reply to " + ctx.ActorName + " skipped: still cooling down")); return false; } string text2 = Tagged(text); try { actor.ChatMessageSend(text2, (string)null); LastSpoken[instanceID] = Time.time; return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Could not relay a reply through the requester's avatar\n" + ex)); return false; } } internal static void Reset() { LastSpoken.Clear(); } private static bool CoolEnough(int key) { if (!LastSpoken.TryGetValue(key, out var value)) { return true; } return Time.time - value >= 1.2f; } private static bool InRun() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 try { return (Object)(object)GameDirector.instance != (Object)null && (int)GameDirector.instance.currentState == 2; } catch (Exception) { return false; } } private static string Tagged(string text) { return text; } } internal static class SVPresentation { internal const int UID = 1; private static readonly string[] SeriesGUIDs = new string[2] { "silent.vanilla", "silent.vanilla.maps" }; internal const string MarkerName = "SV_PresentationMarker"; private const float ScreenWaitMax = 20f; private const float SettleSeconds = 3f; private const float TypingWaitMax = 10f; private static bool ownsMarker; internal static bool WouldShow() { return HostAuthority.IsHost; } private static bool Installed(string guid) { try { PluginInfo value; return Chainloader.PluginInfos.TryGetValue(guid, out value) && value != null && (Object)(object)value.Instance != (Object)null; } catch (Exception) { return false; } } private static bool Outranked() { for (int i = 0; i < SeriesGUIDs.Length && i + 1 < 1; i++) { if (Installed(SeriesGUIDs[i])) { return true; } } return false; } internal static void Install() { SceneManager.sceneLoaded += OnSceneLoaded; } private static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if ((int)mode == 0 && !((Object)(object)Plugin.Instance == (Object)null)) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(Show()); } } private static IEnumerator Show() { bool flag = (Object)(object)GameObject.Find("SV_PresentationMarker") != (Object)null; if (flag && !ownsMarker) { yield break; } if (!flag) { if (!WouldShow() || Outranked()) { yield break; } Object.DontDestroyOnLoad((Object)new GameObject("SV_PresentationMarker")); ownsMarker = true; } float waited = 0f; while ((Object)(object)TruckScreenText.instance == (Object)null && waited < 20f) { waited += Time.deltaTime; yield return null; } if (!((Object)(object)TruckScreenText.instance == (Object)null)) { yield return (object)new WaitForSeconds(3f); waited = 0f; while (TruckScreenText.instance.isTyping && waited < 10f) { waited += Time.deltaTime; yield return null; } List<string> list = SeriesMods(); Say(Message(list)); Plugin.Log.LogInfo((object)("Taxman presentation shown after settle. Series mods installed: " + string.Join(", ", list))); } } private static string Message(List<string> mods) { List<string> list = new List<string>(); for (int i = 0; i < mods.Count; i++) { list.Add("<color=#00FF00>» " + mods[i] + "</color>"); } return "<b>========== SILENT VANILLA MODS ==========</b>\n" + string.Join("\n", list.ToArray()); } private static List<string> SeriesMods() { List<string> list = new List<string>(); try { foreach (PluginInfo value in Chainloader.PluginInfos.Values) { if (value != null && value.Metadata != null && !string.IsNullOrEmpty(value.Metadata.GUID) && value.Metadata.GUID.StartsWith("silent.vanilla", StringComparison.OrdinalIgnoreCase) && !((Object)(object)value.Instance == (Object)null)) { list.Add(value.Metadata.Name); } } } catch (Exception ex) { Plugin.Log.LogWarning((object)("Series discovery failed; showing this mod only\n" + ex)); } if (list.Count == 0) { list.Add("SilentVanilla AutoCart"); } list.Sort(StringComparer.OrdinalIgnoreCase); return list; } private static void Say(string text) { try { TaxmanScreen.TrySay(text); } catch (Exception ex) { Plugin.Log.LogWarning((object)("Presentation page failed\n" + ex)); } } } internal static class TaxmanScreen { internal static bool TrySay(string text) { if (string.IsNullOrEmpty(text)) { return false; } TruckScreenText instance = TruckScreenText.instance; if ((Object)(object)instance == (Object)null) { return false; } try { instance.MessageSendCustom(string.Empty, text, 0); Plugin.Log.LogInfo((object)("[SilentVanilla] Cart: truck screen page sent (" + text.Split('\n')[0] + ")")); return true; } catch (Exception ex) { Plugin.Log.LogWarning((object)("Truck screen message failed\n" + ex)); return false; } } } } namespace SilentVanilla.Cart { internal static class CartClaims { internal enum Result { Claimed, Overrode, AlreadyOwned, Taken, NoCart } private static readonly Dictionary<CartPilotController, PlayerAvatar> Owners = new Dictionary<CartPilotController, PlayerAvatar>(); internal static int Count => Owners.Count; internal static Result Claim(CartPilotController cart, PlayerAvatar requester) { Prune(); if ((Object)(object)cart == (Object)null || (Object)(object)requester == (Object)null) { return Result.NoCart; } Owners.TryGetValue(cart, out var value); if ((Object)(object)value == (Object)(object)requester) { return Result.AlreadyOwned; } if ((Object)(object)value != (Object)null) { if (Cfg.CartOverrideClaims == null || !Cfg.CartOverrideClaims.Value) { return Result.Taken; } cart.Halt(); } Owners[cart] = requester; if (!((Object)(object)value != (Object)null)) { return Result.Claimed; } return Result.Overrode; } internal static bool Release(PlayerAvatar requester) { CartPilotController cartPilotController = FindOf(requester); if ((Object)(object)cartPilotController == (Object)null) { return false; } Owners.Remove(cartPilotController); cartPilotController.Halt(); return true; } internal static CartPilotController FindOf(PlayerAvatar avatar) { if ((Object)(object)avatar == (Object)null) { return null; } foreach (KeyValuePair<CartPilotController, PlayerAvatar> owner in Owners) { if ((Object)(object)owner.Value == (Object)(object)avatar) { return owner.Key; } } return null; } internal static PlayerAvatar OwnerOf(CartPilotController cart) { if (!((Object)(object)cart != (Object)null) || !Owners.TryGetValue(cart, out var value)) { return null; } return value; } internal static CartPilotController Nearest(Vector3 pos) { //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_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) CartPilotController result = null; float num = float.MaxValue; foreach (CartPilotController item in CartPilotController.All) { if (!((Object)(object)item == (Object)null)) { Vector3 val = ((Component)item).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } internal static void Forget(PlayerAvatar avatar) { Prune(); } internal static void Clear() { Owners.Clear(); } private static void Prune() { List<CartPilotController> list = null; foreach (KeyValuePair<CartPilotController, PlayerAvatar> owner in Owners) { if ((Object)(object)owner.Key == (Object)null || (Object)(object)owner.Value == (Object)null) { if (list == null) { list = new List<CartPilotController>(); } list.Add(owner.Key); } } if (list != null) { for (int i = 0; i < list.Count; i++) { Owners.Remove(list[i]); } } } } internal static class CartCommands { private static readonly string[] Subcommands = new string[8] { "help", "claim", "unclaim", "follow", "stop", "truck", "extraction", "open" }; internal static void Install() { ChatTriggers.Register(new ChatTrigger("cart", "Claim and drive the supply cart", Handle, Subcommands)); } private static ChatReply Handle(ChatContext ctx) { if (ctx == null) { return null; } if (Cfg.CartEnabled == null || !Cfg.CartEnabled.Value) { return ChatReply.Speak("the cart pilot is switched off"); } string text = ((ctx.Args.Length != 0) ? ctx.Args[0].ToLowerInvariant() : "help"); if (text != null) { switch (text.Length) { case 4: { char c = text[0]; if (c != 'h') { if (c != 'o') { if (c != 's' || !(text == "stop")) { break; } goto IL_01bb; } if (!(text == "open")) { break; } goto IL_01dc; } if (!(text == "help")) { break; } goto IL_0199; } case 1: switch (text[0]) { case 'h': break; case 'c': goto IL_01a0; case 'r': case 'u': goto IL_01a7; case 'f': goto IL_01ae; case 's': goto IL_01bb; case 't': goto IL_01c2; case 'e': goto IL_01cf; case 'o': goto IL_01dc; default: goto end_IL_0051; } goto IL_0199; case 5: { char c = text[0]; if (c != 'c') { if (c != 't' || !(text == "truck")) { break; } goto IL_01c2; } if (!(text == "claim")) { break; } goto IL_01a0; } case 7: if (!(text == "unclaim")) { break; } goto IL_01a7; case 6: if (!(text == "follow")) { break; } goto IL_01ae; case 10: { if (!(text == "extraction")) { break; } goto IL_01cf; } IL_01bb: return Stop(ctx); IL_0199: return Help(ctx); IL_01dc: return Order(ctx, Destination.ExtractionOpen, "Cart opening the extraction"); IL_01cf: return Order(ctx, Destination.Extraction, "Cart to the extraction"); IL_01c2: return Order(ctx, Destination.Truck, "Cart to the truck"); IL_01ae: return Order(ctx, Destination.Player, "Cart following"); IL_01a7: return Unclaim(ctx); IL_01a0: return Claim(ctx); end_IL_0051: break; } } return ChatReply.Of("unknown cart command", "unknown cart command '" + text + "'; known: " + string.Join(", ", Subcommands)); } private static ChatReply Help(ChatContext ctx) { if (TaxmanScreen.TrySay(CommandList())) { return ChatReply.Of("On the truck screen", "command menu posted on the truck screen for " + ctx.ActorName); } return ChatReply.Speak("Help: claim, unclaim, follow, truck, extraction, open, stop"); } private static ChatReply Claim(ChatContext ctx) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar actor = ctx.Actor; if ((Object)(object)actor == (Object)null) { return ChatReply.Speak("no cart here"); } CartPilotController cartPilotController = CartClaims.Nearest(((Component)actor).transform.position); if ((Object)(object)cartPilotController == (Object)null) { return ChatReply.Speak("No cart here"); } string text = CartVoice.NameOf(CartClaims.OwnerOf(cartPilotController)); return CartClaims.Claim(cartPilotController, actor) switch { CartClaims.Result.Claimed => ChatReply.Of("Claimed", "cart '" + ((Object)cartPilotController).name + "' claimed by " + ctx.ActorName), CartClaims.Result.Overrode => ChatReply.Of("Cart taken from " + (text ?? "the other player"), "cart '" + ((Object)cartPilotController).name + "' taken from " + (text ?? "?") + " by " + ctx.ActorName), CartClaims.Result.AlreadyOwned => ChatReply.Speak("Already yours"), CartClaims.Result.Taken => ChatReply.Of("Cart in use by " + (text ?? "someone else"), "claim refused for " + ctx.ActorName + ": held by " + (text ?? "?") + " (Cart.OverrideClaims is off)"), _ => ChatReply.Speak("No cart here"), }; } private static ChatReply Unclaim(ChatContext ctx) { if (!CartClaims.Release(ctx.Actor)) { return ChatReply.Speak("Nothing claimed"); } return ChatReply.Of("Cart unclaimed", "cart unclaimed by " + ctx.ActorName); } private static ChatReply Order(ChatContext ctx, Destination dest, string spoken) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) CartPilotController cartPilotController = Owned(ctx); if ((Object)(object)cartPilotController == (Object)null) { return Unclaimed(ctx); } PlayerAvatar actor = ctx.Actor; if ((Object)(object)actor == (Object)null) { return ChatReply.Speak("you are not in the level yet"); } cartPilotController.Command(dest, ((Component)actor).transform.position, actor); return ChatReply.Of(spoken, "cart -> " + dest.ToString() + " for " + ctx.ActorName); } private static ChatReply Stop(ChatContext ctx) { CartPilotController cartPilotController = Owned(ctx); if ((Object)(object)cartPilotController == (Object)null) { return Unclaimed(ctx); } cartPilotController.Halt(); return ChatReply.Of("Cart stopped", "all actions stopped for " + ctx.ActorName + ", including follow mode"); } internal static string[] CommandLines() { return new string[4] { "!cart help (h) | !cart claim (c)", "!cart unclaim (u, r) | !cart follow (f)", "!cart stop (s) | !cart truck (t)", "!cart extraction (e) | !cart open (o)" }; } internal static string CommandList() { return string.Join("\n", CommandLines()); } private static CartPilotController Owned(ChatContext ctx) { return CartClaims.FindOf(ctx.Actor); } private static ChatReply Unclaimed(ChatContext ctx) { return ChatReply.Of("Claim a cart first", "refused for " + ctx.ActorName + ": no claimed cart (they must claim one first)"); } } internal static class CartNavMesh { private class Layer { public string Name; public int AgentTypeId = -1; public float Radius; public NavMeshData Data; public NavMeshDataInstance Instance; public AsyncOperation Op; } private struct BlockedArea { public Vector3 Pos; public float Radius; public float Expires; } private struct Gap { public Vector3 A; public Vector3 B; public Vector3 Out; } internal readonly struct Scope : IDisposable { private readonly bool active; internal Scope(bool _) { //IL_0037: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) active = Ready; if (!active || useDepth++ > 0) { return; } Layer[] layers = Layers; foreach (Layer obj in layers) { obj.Instance = NavMesh.AddNavMeshData(obj.Data); } if (!linksResolved) { ResolveLinks(); } foreach (NavMeshLinkData linkDatum in LinkData) { LinkInstances.Add(NavMesh.AddLink(linkDatum)); } } public void Dispose() { //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 (!active || --useDepth > 0) { return; } foreach (NavMeshLinkInstance linkInstance in LinkInstances) { NavMeshLinkInstance current = linkInstance; ((NavMeshLinkInstance)(ref current)).Remove(); } LinkInstances.Clear(); Layer[] layers = Layers; for (int i = 0; i < layers.Length; i++) { ((NavMeshDataInstance)(ref layers[i].Instance)).Remove(); } } } private static readonly Layer Comfortable = new Layer { Name = "comfortable" }; private static readonly Layer Tight = new Layer { Name = "tight" }; private static readonly Layer Squeeze = new Layer { Name = "squeeze" }; private static readonly Layer[] Layers = new Layer[3] { Comfortable, Tight, Squeeze }; private static readonly List<BlockedArea> Blocked = new List<BlockedArea>(); private static NavMeshData bakedFromGameData; private static float bakedRadius = -1f; private static float bakedExtra = -1f; private static int useDepth; private static readonly Func<NavMeshSurface, List<NavMeshBuildSource>> CollectSources = AccessTools.MethodDelegate<Func<NavMeshSurface, List<NavMeshBuildSource>>>(AccessTools.Method(typeof(NavMeshSurface), "CollectSources", (Type[])null, (Type[])null), (object)null, true); private static readonly Func<NavMeshSurface, List<NavMeshBuildSource>, Bounds> CalculateWorldBounds = AccessTools.MethodDelegate<Func<NavMeshSurface, List<NavMeshBuildSource>, Bounds>>(AccessTools.Method(typeof(NavMeshSurface), "CalculateWorldBounds", (Type[])null, (Type[])null), (object)null, true); private static readonly List<Gap> Gaps = new List<Gap>(); private static NavMeshData gapsFromGameData; private static float gapsMax = -1f; private static readonly List<NavMeshLinkData> LinkData = new List<NavMeshLinkData>(); private static readonly List<NavMeshLinkInstance> LinkInstances = new List<NavMeshLinkInstance>(); private static readonly NavMeshPath LinkCheck = new NavMeshPath(); private static bool linksResolved; private static bool pendingRebuild; private static List<NavMeshBuildSource> baseSources; private static Bounds baseBounds; internal static bool Busy => Array.Exists(Layers, (Layer l) => IsRunning(l.Op)); internal static bool Ready { get { if (!Busy) { return Array.TrueForAll(Layers, (Layer l) => (Object)(object)l.Data != (Object)null); } return false; } } internal static NavMeshQueryFilter ComfortableFilter => Filter(Comfortable); internal static NavMeshQueryFilter TightFilter => Filter(Tight); internal static NavMeshQueryFilter SqueezeFilter => Filter(Squeeze); internal static NavMeshQueryFilter GameFilter { get { //IL_0008: 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) NavMeshSurface val = GameSurface(); NavMeshQueryFilter result = default(NavMeshQueryFilter); ((NavMeshQueryFilter)(ref result)).agentTypeID = (((Object)(object)val != (Object)null) ? val.agentTypeID : 0); ((NavMeshQueryFilter)(ref result)).areaMask = -1; return result; } } internal static float TightRadius => Tight.Radius; private static NavMeshQueryFilter Filter(Layer l) { //IL_0002: 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) NavMeshQueryFilter result = default(NavMeshQueryFilter); ((NavMeshQueryFilter)(ref result)).agentTypeID = l.AgentTypeId; ((NavMeshQueryFilter)(ref result)).areaMask = -1; return result; } private static bool IsRunning(AsyncOperation op) { if (op != null) { return !op.isDone; } return false; } internal static bool EnsureBaked(float radius, float maxGap) { //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) NavMeshSurface val = GameSurface(); if ((Object)(object)val == (Object)null || (Object)(object)val.navMeshData == (Object)null) { return false; } float num = 0.35f; if (((Object)(object)val.navMeshData != (Object)(object)bakedFromGameData || !Mathf.Approximately(radius, bakedRadius) || !Mathf.Approximately(num, bakedExtra)) && !Busy) { if ((Object)(object)val.navMeshData != (Object)(object)bakedFromGameData) { Blocked.Clear(); } bakedFromGameData = val.navMeshData; bakedRadius = radius; bakedExtra = num; Comfortable.Radius = radius + num; Tight.Radius = radius; Squeeze.Radius = Mathf.Max(0.25f, radius * 0.5f); Layer[] layers = Layers; for (int i = 0; i < layers.Length; i++) { layers[i].Data = null; } baseSources = CollectSources(val); baseBounds = (Bounds)(((int)val.collectObjects == 0) ? new Bounds(val.center, new Vector3(Mathf.Abs(val.size.x), Mathf.Abs(val.size.y), Mathf.Abs(val.size.z))) : CalculateWorldBounds(val, baseSources)); Rebuild(val); Plugin.Log.LogInfo((object)$"Baking cart NavMesh (tight r={Tight.Radius:F2}, comfortable r={Comfortable.Radius:F2})..."); return false; } if (Ready && useDepth == 0 && ((Object)(object)gapsFromGameData != (Object)(object)bakedFromGameData || !Mathf.Approximately(maxGap, gapsMax))) { gapsFromGameData = bakedFromGameData; gapsMax = maxGap; FindGaps(maxGap); } return Ready; } private static Vector3Int Key(Vector3 p) { //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_000b: Unknown result type (might be due to invalid IL or missing references) return Vector3Int.RoundToInt(p * 50f); } private static bool FloorAt(Vector3 p, float y, out float hitY) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_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_003d: Unknown result type (might be due to invalid IL or missing references) hitY = 0f; RaycastHit val = default(RaycastHit); if (!Physics.Raycast(new Vector3(p.x, y + 0.5f, p.z), Vector3.down, ref val, 0.8f, PathPlanner.WorldMask, (QueryTriggerInteraction)1)) { return false; } hitY = ((RaycastHit)(ref val)).point.y; return true; } private static void FindGaps(float maxGap) { //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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: 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_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028f: 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_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) Gaps.Clear(); LinkData.Clear(); linksResolved = false; if (maxGap < 0.2f) { return; } NavMeshTriangulation val = NavMesh.CalculateTriangulation(); Vector3[] vertices = val.vertices; int[] indices = val.indices; Dictionary<(Vector3Int, Vector3Int), (int, int, int, int)> dictionary = new Dictionary<(Vector3Int, Vector3Int), (int, int, int, int)>(); for (int i = 0; i + 2 < indices.Length; i += 3) { for (int j = 0; j < 3; j++) { int num = indices[i + j]; int num2 = indices[i + (j + 1) % 3]; int item = indices[i + (j + 2) % 3]; Vector3Int val2 = Key(vertices[num]); Vector3Int val3 = Key(vertices[num2]); (Vector3Int, Vector3Int) key = ((((Vector3Int)(ref val2)).x > ((Vector3Int)(ref val3)).x || (((Vector3Int)(ref val2)).x == ((Vector3Int)(ref val3)).x && (((Vector3Int)(ref val2)).y > ((Vector3Int)(ref val3)).y || (((Vector3Int)(ref val2)).y == ((Vector3Int)(ref val3)).y && ((Vector3Int)(ref val2)).z > ((Vector3Int)(ref val3)).z)))) ? (val3, val2) : (val2, val3)); dictionary[key] = (dictionary.TryGetValue(key, out var value) ? (value.Item1, value.Item2, value.Item3, value.Item4 + 1) : (num, num2, item, 1)); } } foreach (var value2 in dictionary.Values) { var (num3, num4, num5, _) = value2; if (value2.Item4 != 1) { continue; } Vector3 val4 = vertices[num3]; Vector3 val5 = PathPlanner.Flat(vertices[num4] - val4); float magnitude = ((Vector3)(ref val5)).magnitude; if (!(magnitude >= 0.05f)) { continue; } val5 /= magnitude; Vector3 val6 = Vector3.Cross(Vector3.up, val5); if (Vector3.Dot(val6, PathPlanner.Flat(vertices[num5] - val4)) > 0f) { val6 = -val6; } for (float num6 = Mathf.Min(0.5f, magnitude * 0.5f); num6 < magnitude; num6 += 1f) { Vector3 val7 = val4 + val5 * num6; if (FloorAt(val7 + val6 * 0.7f, val7.y, out var _)) { continue; } float num7 = -1f; float num8 = -1f; for (float num9 = 0f; num9 <= 0.7f + maxGap + 0.2f; num9 += 0.1f) { float hitY2; bool flag = FloorAt(val7 + val6 * num9, val7.y, out hitY2) && Mathf.Abs(hitY2 - val7.y) < 0.2f; if (num7 < 0f) { if (!flag) { num7 = num9; } } else if (flag) { num8 = num9; break; } } if (!(num7 >= 0f) || !(num8 >= 0f) || !(num8 - num7 <= maxGap)) { continue; } Vector3 val8 = val7 + val6 * Mathf.Max(0f, num7 - 0.1f); Vector3 val9 = val7 + val6 * num8; if (!Physics.Linecast(val8 + Vector3.up * 0.4f, val9 + val6 * 0.3f + Vector3.up * 0.4f, PathPlanner.WorldMask, (QueryTriggerInteraction)1)) { Vector3 mid = (val8 + val9) * 0.5f; if (!Gaps.Exists(delegate(Gap g) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) Vector3 val11 = (g.A + g.B) * 0.5f - mid; return ((Vector3)(ref val11)).sqrMagnitude < 0.64000005f; })) { Gaps.Add(new Gap { A = val8, B = val9, Out = val6 }); } } } } Plugin.Log.LogInfo((object)$"Small floor gaps the cart can roll over: {Gaps.Count}"); foreach (Gap gap in Gaps) { object arg = gap.A; object arg2 = gap.B; Vector3 val10 = PathPlanner.Flat(gap.B - gap.A); PathPlanner.Verbose($"Gap {arg} -> {arg2} ({((Vector3)(ref val10)).magnitude:F2}m)"); } } private static void ResolveLinks() { //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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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_006d: 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_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) linksResolved = true; LinkData.Clear(); Layer[] layers = Layers; NavMeshHit val2 = default(NavMeshHit); NavMeshHit val3 = default(NavMeshHit); foreach (Layer layer in layers) { NavMeshQueryFilter val = Filter(layer); foreach (Gap gap in Gaps) { if (NavMesh.SamplePosition(gap.A - gap.Out * (layer.Radius + 0.2f), ref val2, 0.5f, val) && NavMesh.SamplePosition(gap.B + gap.Out * (layer.Radius + 0.2f), ref val3, 0.5f, val)) { if (NavMesh.CalculatePath(((NavMeshHit)(ref val2)).position, ((NavMeshHit)(ref val3)).position, val, LinkCheck)) { _ = LinkCheck.status; } List<NavMeshLinkData> linkData = LinkData; NavMeshLinkData item = default(NavMeshLinkData); ((NavMeshLinkData)(ref item)).startPosition = ((NavMeshHit)(ref val2)).position; ((NavMeshLinkData)(ref item)).endPosition = ((NavMeshHit)(ref val3)).position; ((NavMeshLinkData)(ref item)).width = 0f; ((NavMeshLinkData)(ref item)).bidirectional = true; ((NavMeshLinkData)(ref item)).costModifier = -1f; ((NavMeshLinkData)(ref item)).area = 0; ((NavMeshLinkData)(ref item)).agentTypeID = layer.AgentTypeId; linkData.Add(item); } } } Plugin.Log.LogInfo((object)$"Gap links on cart meshes: {LinkData.Count}"); } internal static void AddBlockedArea(Vector3 pos, float radius) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) Blocked.Add(new BlockedArea { Pos = pos, Radius = radius, Expires = Time.time + Cfg.BlockedAreaLifetime }); Plugin.Log.LogInfo((object)$"Blocked area at {pos} r={radius:F1} for {Cfg.BlockedAreaLifetime:F0}s"); pendingRebuild = true; Tick(); } internal static void Tick() { if (Blocked.RemoveAll((BlockedArea b) => b.Expires < Time.time) > 0) { pendingRebuild = true; } if (pendingRebuild && Ready) { NavMeshSurface val = GameSurface(); if (!((Object)(object)val == (Object)null)) { pendingRebuild = false; Rebuild(val); } } } internal static float RadiusOf(NavMeshQueryFilter f) { //IL_0056: 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) if (((NavMeshQueryFilter)(ref f)).agentTypeID == Comfortable.AgentTypeId) { return Comfortable.Radius; } if (((NavMeshQueryFilter)(ref f)).agentTypeID == Squeeze.AgentTypeId) { return Squeeze.Radius; } if (((NavMeshQueryFilter)(ref f)).agentTypeID != Tight.AgentTypeId) { NavMeshBuildSettings settingsByID = NavMesh.GetSettingsByID(((NavMeshQueryFilter)(ref f)).agentTypeID); return ((NavMeshBuildSettings)(ref settingsByID)).agentRadius; } return Tight.Radius; } private static void Rebuild(NavMeshSurface surface) { //IL_0023: 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_0062: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown List<NavMeshBuildSource> list = new List<NavMeshBuildSource>(baseSources); foreach (BlockedArea item2 in Blocked) { NavMeshBuildSource item = default(NavMeshBuildSource); ((NavMeshBuildSource)(ref item)).shape = (NavMeshBuildSourceShape)5; ((NavMeshBuildSource)(ref item)).transform = Matrix4x4.Translate(item2.Pos); ((NavMeshBuildSource)(ref item)).size = new Vector3(item2.Radius * 2f, 4f, item2.Radius * 2f); ((NavMeshBuildSource)(ref item)).area = 1; list.Add(item); } Bounds val = baseBounds; Layer[] layers = Layers; foreach (Layer layer in layers) { if (layer.AgentTypeId < 0) { NavMeshBuildSettings val2 = NavMesh.CreateSettings(); layer.AgentTypeId = ((NavMeshBuildSettings)(ref val2)).agentTypeID; } NavMeshBuildSettings buildSettings = surface.GetBuildSettings(); ((NavMeshBuildSettings)(ref buildSettings)).agentTypeID = layer.AgentTypeId; ((NavMeshBuildSettings)(ref buildSettings)).agentRadius = layer.Radius; if ((Object)(object)layer.Data == (Object)null) { layer.Data = new NavMeshData(layer.AgentTypeId) { position = ((Component)surface).transform.position, rotation = ((Component)surface).transform.rotation }; } layer.Op = NavMeshBuilder.UpdateNavMeshDataAsync(layer.Data, buildSettings, list, val); } } private static NavMeshSurface GameSurface() { LevelGenerator instance = LevelGenerator.Instance; if (!((Object)(object)instance != (Object)null) || !instance.Generated) { return null; } return ((Component)instance).GetComponent<NavMeshSurface>(); } internal static Scope Use() { return new Scope(_: true); } } internal class CartPilotController : MonoBehaviourPun { private enum State { Idle, WaitMesh, Driving, Yielding, Reversing, Recovering } internal enum HudState : byte { Hidden, Driving, Arrived, NoPath } internal static readonly List<CartPilotController> All = new List<CartPilotController>(); private PhysGrabCart cart; private Rigidbody rb; internal CartShape Shape; private float lastDrivingTime = -999f; private Player commander; private PlayerAvatar requester; private State state; private Vector3 goal; private Transform follow; private bool followForever; private float followRetryAt; private float followWakeTimer; private float followFailures; private float followStuckSay; private const float WakeInterval = 1f; private float arriveDistance; private int rejectedRoutes; private float failTime = -10f; private Vector3 failGoal; private Vector3 failPos; private ExtractionPoint extraction; private bool extractionInside; private bool extractionStayOutside; private List<Waypoint> path; private int seg; private float segT; private float offPath; private bool facingBack; private float lastPlanTime; private float followCheckTimer; private float yawCmd; private float hudTotal = -1f; private float hudRemaining; private float hudSendTime; private HudState hud; private static readonly int BlockerMask = LayerMask.GetMask(new string[4] { "Enemy", "Player", "PhysGrabObject", "PhysGrabObjectCart" }); private static readonly RaycastHit[] Hits = (RaycastHit[])(object)new RaycastHit[32]; private static readonly Collider[] Overlaps = (Collider[])(object)new Collider[32]; private const float ProbeLift = 0.3f; private Vector3 blockerPos; private float yieldTimer; private float clearTimer; private Vector3 reverseTarget; private float reverseTimer; private int committedChoke = -1; private float commandedSpeed; private Vector3 stuckRef; private float stuckTimer; private Vector3 lastStuckPos; private float lastStuckTime = -999f; private bool goalBlockNotified; private bool stuckRepeat; private Vector3 recoverDir; private float recoverTimer; private const float ScanInterval = 0.25f; private const float ScanRange = 15f; private float aheadScanTimer; private float aheadBlockedFor; private static readonly int FloorMask = LayerMask.GetMask(new string[3] { "Default", "NavmeshOnly", "PlayerOnlyCollision" }); private const float MaxDrop = 1f; private static readonly int DoorSearchMask = LayerMask.GetMask(new string[2] { "PhysGrabObjectHinge", "PhysGrabObject" }); private Destination lastDest; private float diagTickTimer; private static readonly int WallMask = LayerMask.GetMask(new string[1] { "Default" }); private int cargoCount; private float cargoValue; private float cargoLogCooldown; private float cargoSeen; private readonly List<PhysGrabObject> cargoBefore = new List<PhysGrabObject>(); private float hitLogCooldown; private float CartRadius => Shape.HalfWidth + 0.15f; private float WakeDistance { get { if (!(Cfg.FollowWakeDistance.Value > 0f)) { return 12f; } return Cfg.FollowWakeDistance.Value; } } private float MaxGap => Shape.HalfLength * 0.9f; private void Awake() { cart = ((Component)this).GetComponent<PhysGrabCart>(); rb = ((Component)this).GetComponent<Rigidbody>(); } private void Start() { Shape = CartShape.Measure(rb); Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}' measured: {Shape}"); Diag("spawn", ""); } private void OnEnable() { All.Add(this); } private void OnDisable() { All.Remove(this); } internal static bool CarryingWhileDriving(Vector3 pos) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_0062: 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_0081: Unknown result type (might be due to invalid IL or missing references) foreach (CartPilotController item in All) { if (Time.time - item.lastDrivingTime <= 2f && !((Object)(object)item.cart.inCart == (Object)null)) { Vector3 val = item.cart.inCart.InverseTransformPoint(pos); if (Mathf.Abs(val.x) < 0.6f && Mathf.Abs(val.z) < 0.6f && val.y > -0.6f && val.y < 1.5f) { return true; } } } return false; } internal static CartPilotController Nearest(Vector3 pos) { //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_0029: 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) CartPilotController result = null; float num = float.MaxValue; foreach (CartPilotController item in All) { Vector3 val = ((Component)item).transform.position - pos; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = item; } } return result; } internal void Command(Destination dest, Vector3 playerPos, PlayerAvatar requester) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMasterClientOrSingleplayer()) { this.requester = requester; commander = (((Object)(object)requester != (Object)null && (Object)(object)requester.photonView != (Object)null) ? requester.photonView.Owner : PhotonNetwork.LocalPlayer); followForever = dest == Destination.Player; GoTo(dest, playerPos); } } private void Notify(string message) { Plugin.Log.LogWarning((object)("Cart '" + ((Object)this).name + "': " + message)); Diag("FAIL", message); if (!followForever) { CartVoice.Say(requester, "cart " + message); } } private void GoTo(Destination dest, Vector3 playerPos) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) lastDest = dest; Diag("command", string.Format("{0} by {1}", dest, (commander == null) ? "host" : commander.NickName)); if (BeingHandled()) { Notify("someone is holding me"); return; } HudReset(); extraction = null; extractionInside = false; if (!ResolveDestination(dest, playerPos, out goal, out follow)) { Notify((dest == Destination.Extraction || dest == Destination.ExtractionOpen) ? "no extraction point available" : ("can't find the " + dest.ToString().ToLower())); HudSend(HudState.NoPath); return; } if (Time.time - failTime < 3f) { Vector3 val = goal - failGoal; if (((Vector3)(ref val)).magnitude < 1f) { val = ((Component)this).transform.position - failPos; if (((Vector3)(ref val)).magnitude < 0.5f) { Notify("still no way there"); HudSend(HudState.NoPath); return; } } } Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}' -> {dest} at {goal}"); arriveDistance = (((Object)(object)follow != (Object)null) ? (Shape.HalfLength + 1.2f) : 0.8f); rejectedRoutes = 0; SetState(State.WaitMesh); } private void SetState(State s) { if (s != state) { PathPlanner.Verbose($"Cart '{((Object)this).name}': {state} -> {s}"); Diag("state", $"{state}->{s}"); } if (s == State.Idle != (state == State.Idle)) { SetSlippery(s > State.Idle); } state = s; } private void SetSlippery(bool on) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!on) { _ = cart.currentState; return; } foreach (Collider capsuleCollider in cart.capsuleColliders) { capsuleCollider.material = (on ? cart.physMaterialSlippery : cart.physMaterialNormal); } foreach (Collider item in cart.cartInside) { item.material = (on ? SemiFunc.PhysicMaterialPhysGrabObject() : cart.physMaterialNormal); } } private void FixedUpdate() { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } CartNavMesh.Tick(); if (state == State.Idle) { if (followForever) { IdleFollowCheck(); } return; } lastDrivingTime = Time.time; DiagTick(); HudTick(); if (BeingHandled()) { Plugin.Log.LogInfo((object)"Player took the cart, stopping."); Stop(HudState.Hidden); return; } switch (state) { case State.WaitMesh: if (CartNavMesh.EnsureBaked(CartRadius, MaxGap)) { Replan(); } break; case State.Driving: Drive(); break; case State.Yielding: Yield(); break; case State.Reversing: Reverse(); break; case State.Recovering: Recover(); break; } } private bool BeingHandled() { return cart.physGrabObject.playerGrabbing.Count > 0; } internal void Halt() { followForever = false; Stop(HudState.Hidden); } internal string Describe() { if (state == State.Idle) { if (!followForever) { return "waiting"; } return "parked, follows when you go far"; } int num = ((path != null) ? Mathf.CeilToInt(RemainingLength()) : 0); if (followForever) { return "following you, " + num + " meters"; } return "driving to " + ((lastDest == Destination.Player) ? "you" : lastDest.ToString().ToLowerInvariant()) + ", " + num + " meters"; } internal void Stop(HudState result = HudState.NoPath) { //IL_001f: 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_003e: 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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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) SetState(State.Idle); path = null; rb.velocity = new Vector3(0f, rb.velocity.y, 0f); rb.angularVelocity = Vector3.zero; yawCmd = 0f; if (result == HudState.NoPath) { failTime = Time.time; failGoal = (((Object)(object)follow != (Object)null) ? follow.position : goal); failPos = ((Component)this).transform.position; } HudSend(result); if (followForever && result == HudState.NoPath) { followFailures += 1f; float num = ((Cfg.FollowRetrySeconds.Value > 0f) ? Cfg.FollowRetrySeconds.Value : 5f); followRetryAt = Time.time + num; if (followFailures >= 3f && Time.time - followStuckSay > 45f) { followStuckSay = Time.time; Plugin.Log.LogWarning((object)$"Cart '{((Object)this).name}': fully stuck after {followFailures:F0} attempts, retrying every {num:F0}s."); CartVoice.Say(requester, "Cart stuck"); } } } private void IdleFollowCheck() { //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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (BeingHandled() || (Object)(object)requester == (Object)null || requester.isDisabled || Time.time < followRetryAt || Time.time < followWakeTimer) { return; } followWakeTimer = Time.time + 1f; if ((Object)(object)follow == (Object)null) { GoTo(Destination.Player, ((Component)requester).transform.position); if (state != State.Idle) { CartVoice.Say(requester, "Cart following"); } return; } Vector3 val = PathPlanner.Flat(follow.position - ((Component)this).transform.position); if (!(((Vector3)(ref val)).magnitude <= WakeDistance)) { GoTo(Destination.Player, follow.position); if (state != State.Idle) { CartVoice.Say(requester, "Cart following"); } } } private void Replan(bool sticky = false) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) lastPlanTime = Time.time; Vector3 val = goal; if ((Object)(object)follow != (Object)null) { goal = follow.position; } Vector3 val2 = ((Component)this).transform.position + Vector3.up * Shape.BottomY; Stopwatch stopwatch = Stopwatch.StartNew(); PlanResult planResult = PathPlanner.Plan(val2, goal, Shape); if ((Object)(object)follow != (Object)null && Unreached(planResult, goal) && (planResult.Path == null || planResult.Path[planResult.Path.Count - 1].Pos.y < goal.y - 1f) && PathPlanner.FloorBelow(goal, out var floor)) { PlanResult planResult2 = PathPlanner.Plan(val2, floor, Shape); if (!Unreached(planResult2, floor)) { Plugin.Log.LogInfo((object)$"Cart '{((Object)this).name}': player is up out of reach, going to the floor below at {floor}."); planResult = planResult2; goal = floor; } } Diag("plantime", $"{stopwatch.Elapsed.TotalMilliseconds:F1}ms"); Vector3 val3; if (sticky && path != null) { float num = RemainingLength(); val3 = PathPlanner.Flat(goal - val); float num2 = num + ((Vector3)(ref val3)).magnitude + 4f; if (planResult.Path == null || planResult.Partial || PathLength(planResult.Path) > num2) { PathPlanner.Verbose("Player moved; new route is longer or worse, keeping the current one."); goal = val; return; } } if (planResult.Path == null) { Plugin.Log.LogWarning((object)("Cart '" + ((Object)this).name + "': route rejected (" + planResult.Error + ").")); if (!planResult.FailPoint.HasValue) { Notify("no way through for me, stopped"); Stop(); } else if (planResult.TooNarrow) { Notify("too narrow for the cart here, stopped"); Stop(); } else if (++rejectedRoutes > 2) { Notify("no way through for me, stopped"); Stop(); } else { CartNavMesh.AddBlockedArea(planResult.FailPoint.Value, CartRadius + 0.5f); SetState(State.WaitMesh); } return; } if (planResult.Partial) { Plugin.Log.LogInfo((object)"Goal not fully reachable for the cart; driving as close as possible."); } if (planResult.Partial && PathLength(planResult.Path) < 1f) { val3 = PathPlanner.Flat(goal - ((Component)this).transform.position); if (((Vector3)(ref val3)).magnitude > arriveDistance + 1f) { Notify("can't get any closer, stopped"); Stop(); return; } } path = planResult.Path; seg = 0; segT = 0f; ResetObstacleState(); if (followForever) { followFailures = 0f; } Diag("plan", $"ok waypoints={path.Count} partial={planResult.Partial}"); SetState(State.Driving); } private static bool Unreached(PlanResult r, Vector3 target) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (r.Path != null) { if (r.Partial) { Vector3 val = r.Path[r.Path.Count - 1].Pos - target; return ((Vector3)(ref val)).magnitude > 1.5f; } return false; } return !r.FailPoint.HasValue; } private void Drive() { //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) UpdateProgress(); if (offPath > 1.2f && Time.time - lastPlanTime > 0.5f) { PathPlanner.Verbose($"Off path by {offPath:F1}m, replanning."); Replan(); return; } Vector3 val; if ((Object)(object)follow != (Object)null && (followCheckTimer -= Time.fixedDeltaTime) < 0f) { followCheckTimer = 2f; val = PathPlanner.Flat(follow.position - goal); if (((Vector3)(ref val)).magnitude > 3f) { Replan(sticky: true); return; } } float num = RemainingLength(); if ((Object)(object)follow != (Object)null) { val = PathPlanner.Flat(follow.position - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude < arriveDistance + 0.3f && Mathf.Abs(follow.position.y - ((Component)this).transform.position.y) < 1.5f) { num = 0f; } } val = PathPlanner.Flat(path[path.Count - 1].Pos - goal); bool flag = ((Vector3)(ref val)).magnitude < 1f; if (num < (flag ? arriveDistance : 0.5f)) { if ((Object)(object)extraction != (Object)null) { val = PathPlanner.Flat(goal - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude > 3f) { Notify("can't reach the extraction, stopped"); Stop(); return; } } if ((Object)(object)extraction != (Object)null && !extractionInside) { extraction.OnClick(); if (extractionStayOutside) { Plugin.Log.LogInfo((object)("Cart '" + ((Object)this).name + "' at extraction: pressed button, staying outside.")); Stop(HudState.Arrived); return; } Plugin.Log.LogInfo((object)("Cart '" + ((Object)this).name + "' at extraction: pressed button, driving inside.")); extractionInside = true; goal = ((Component)extraction).transform.position; arriveDistance = 0.5f; Replan(); return; } if ((Object)(object)follow != (Object)null && flag && Time.time - lastPlanTime > 1f) { val = PathPlanner.Flat(follow.position - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude > arriveDistance + 2f && Mathf.Abs(follow.position.y - goal.y) < 1.5f) { Replan(); return; } } val = PathPlanner.Flat(goal - ((Component)this).transform.position); if (((Vector3)(ref val)).magnitude > arriveDistance + 1f) { ManualLogSource log = Plugin.Log; string name = ((Object)this).name; val = PathPlanner.Flat(goal - ((Component)this).transform.position); log.LogInfo((object)$"Cart '{name}' route ended {((Vector3)(ref val)).magnitude:F1}m from target."); Notify("can't get any closer, stopped"); Stop(); } else { Plugin.Log.LogInfo((object)("Cart '" + ((Object)this).name + "' arrived.")); Stop(HudState.Arrived); } return; } bool flag2 = StairsNear(1.5f); float num2 = TargetSpeed(num, flag2); float dist = (flag2 ? Cfg.StairsLookahead : Mathf.Lerp(0.8f, Cfg.Lookahead, num2 / Mathf.Max(0.1f, Cfg.MaxSpeed))); Vector3 val2 = PointAhead(dist); val = PathPlanner.Flat(val2 - ((Component)this).transform.position); Vector3 normalized = ((Vector3)(ref val)).normalized; if (!CheckObstacles(normalized)) { Steer(val2, num2); if (flag2) { StairsAssist(); } CheckStuck(normalized); } } private void Steer(Vector3 target, float speed) { //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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PathPlanner.Flat(target - ((Component)this).transform.position); if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f)) { ((Vector3)(ref val)).Normalize(); Vector3 val2 = PathPlanner.Flat(((Component)this).transform.forward); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Vector3.Angle(normalized, val); if (facingBack ? (num < 60f) : (num > 120f)) { facingBack = !facingBack; } float num2 = Vector3.SignedAngle(facingBack ? (-normalized) : normalized, val, Vector3.up); float yawRate = Mathf.Clamp(num2 * (MathF.PI / 180f) * 6f, -4f, 4f); SetYawRate(yawRate); float num3 = Mathf.Clamp01(1f - (Mathf.Abs(num2) - 25f) / 50f); commandedSpeed = speed * num3; ApplyVelocity(val * commandedSpeed); } } private void SetYawRate(float yawRate) { //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) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) Vector3 val = PathPlanner.Flat(rb.velocity); float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Min(1.5f / Mathf.Max(0.5f, Shape.HalfLength), 3f / Mathf.Max(0.1f, magnitude)); yawRate = Mathf.Clamp(yawRate, 0f - num, num); yawCmd = Mathf.MoveTowards(yawCmd, yawRate, 2.5f * Time.fixedDeltaTime); rb.angularVelocity = new Vector3(0f, yawCmd, 0f); } private void ApplyVelocity(Vector3 horizontal) { //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) //IL_002f: 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_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) Vector3 velocity = rb.velocity; float num = ((state == State.Driving && StairsNear(1.5f)) ? 30f : 10f); Vector3 val = Vector3.MoveTowards(new Vector3(velocity.x, 0f, velocity.z), horizontal, num * Time.fixedDeltaTime); rb.velocity = new Vector3(val.x, velocity.y, val.z); } private float TargetSpeed(float remaining, bool stairs) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0036: 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_003c: Unknown result type (might be due to invalid IL or missing references) float ma