Decompiled source of ScarletCarrier v1.1.2
ScarletCarrier.dll
Decompiled 4 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Shared; using ScarletCarrier.Models; using ScarletCarrier.Services; using ScarletCore; using ScarletCore.Data; using ScarletCore.Events; using ScarletCore.Services; using ScarletCore.Systems; using ScarletCore.Utils; using Stunlock.Core; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Transforms; using VampireCommandFramework; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("ScarletCarrier")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Scarlet Carrier")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2+9999b675d8ade01e47f44cb97ef7631263e33932")] [assembly: AssemblyProduct("ScarletCarrier")] [assembly: AssemblyTitle("ScarletCarrier")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ScarletCarrier { [BepInPlugin("ScarletCarrier", "ScarletCarrier", "1.1.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { private static Harmony _harmony; public static Harmony Harmony => _harmony; public static Plugin Instance { get; private set; } public static ManualLogSource LogInstance { get; private set; } public static Settings Settings { get; private set; } public static Database Database { get; private set; } public override void Load() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown Instance = this; LogInstance = ((BasePlugin)this).Log; ManualLogSource log = ((BasePlugin)this).Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ScarletCarrier"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.2"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!"); } log.LogInfo(val); _harmony = new Harmony("ScarletCarrier"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); Database = new Database("ScarletCarrier"); Settings = new Settings("ScarletCarrier", (BasePlugin)(object)Instance); GameSystems.OnInitialize((Action)OnInitialize); EventManager.On((PlayerEvents)1, (Action<PlayerData>)delegate(PlayerData player) { if (CarrierService.HasServant(player.PlatformId)) { CarrierService.Dismiss(player.PlatformId); } }); LoadSettings(); CommandRegistry.RegisterAll(); } public override bool Unload() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } EventManager.UnregisterAssembly(Assembly.GetExecutingAssembly()); ActionScheduler.UnregisterAssembly(Assembly.GetExecutingAssembly()); CommandRegistry.UnregisterAssembly(); return true; } public static void OnInitialize() { CarrierService.Initialize(); } public static void LoadSettings() { Settings.Section("General").Add<int>("ExpireDays", 15, "Carrier lifetime in days before automatic cleanup (server uptime only).\nTimer resets each time a player interacts with their carrier.\nWarning: All items stored in expired carriers will be permanently lost."); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "ScarletCarrier"; public const string PLUGIN_NAME = "ScarletCarrier"; public const string PLUGIN_VERSION = "1.1.2"; } } namespace ScarletCarrier.Services { internal static class CarrierService { private static readonly Dictionary<ulong, Carrier> Carriers = new Dictionary<ulong, Carrier>(); public static readonly PrefabGUID[] AppearancePrefabs = (PrefabGUID[])(object)new PrefabGUID[22] { new PrefabGUID(-450600397), new PrefabGUID(2142021685), new PrefabGUID(40217214), new PrefabGUID(-1099047820), new PrefabGUID(-1108748448), new PrefabGUID(-274383877), new PrefabGUID(-383158562), new PrefabGUID(1649578802), new PrefabGUID(-1213645419), new PrefabGUID(565869317), new PrefabGUID(-1773935659), new PrefabGUID(1502148822), new PrefabGUID(-924080115), new PrefabGUID(-1788957652), new PrefabGUID(-444945115), new PrefabGUID(1218339832), new PrefabGUID(-823557242), new PrefabGUID(-442412464), new PrefabGUID(-1416355128), new PrefabGUID(-1192403515), new PrefabGUID(-2085282780), new PrefabGUID(-1897484769) }; public static readonly string[] AppearanceNames = new string[22] { "Bomber", "Alchemist", "Lurker", "Night Maiden", "Viper", "Striker", "Lightweaver", "Paladin", "Sentry Officer", "Tractor Beamer", "Militia Veteran", "Exsanguinator", "Tazer", "Nun", "Sister", "Cleric", "Devoted", "Slave Master", "Ruffian", "Villager (Female)", "Villager (Male)", RichTextFormatter.Format("~*~~Ace Incinerator~", new List<string>(2) { "green", RichTextFormatter.HighlightColor }) }; public const string CustomAppearances = "CustomAppearances"; public static void Initialize() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00d5: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0124: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = GameSystems.EntityManager; EntityQueryDesc[] array = new EntityQueryDesc[1]; EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<ServantData>() }); val.Options = (EntityQueryOptions)2; array[0] = val; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array); Enumerator<Entity> enumerator = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!ECSExtensions.Exists(current) || !ECSExtensions.Has<ServantData>(current) || !ECSExtensions.Has<NameableInteractable>(current) || !ECSExtensions.Has<EntityOwner>(current)) { continue; } NameableInteractable val3 = ECSExtensions.Read<NameableInteractable>(current); if (((FixedString64Bytes)(ref val3.Name)).Value != "__ScarletCarrier1.0__") { continue; } Entity owner = ECSExtensions.Read<EntityOwner>(current).Owner; if (!ECSExtensions.Exists(owner)) { continue; } PlayerData playerData = PlayerDataExtensions.GetPlayerData(owner); if (playerData != null) { Entity entity = ECSExtensions.Read<ServantConnectedCoffin>(current).CoffinEntity._Entity; if (!ECSExtensions.Exists(entity)) { Log.Info(new object[1] { $"Found orphaned servant for player {playerData.Name} ({playerData.PlatformId}), recreating coffin..." }); Carrier carrier = new Carrier(Entity.Null, current, playerData); carrier.RecreateCoffin(); Carriers[playerData.PlatformId] = carrier; carrier.Hide(); } else { Carrier carrier2 = new Carrier(entity, current, playerData); Carriers[playerData.PlatformId] = carrier2; carrier2.Hide(); } } } } public static void Spawn(ulong platformId) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) PlayerData playerData = PlayerDataExtensions.GetPlayerData(platformId); Carrier carrier; if (!Carriers.TryGetValue(playerData.PlatformId, out var value)) { carrier = new Carrier(playerData); carrier.Create(); } else { carrier = value; } if (carrier == null) { Log.Error(new object[1] { $"Failed to create carrier for player {playerData.Name} ({playerData.PlatformId})." }); return; } if (!ECSExtensions.Exists(carrier.ServantEntity) && !ECSExtensions.Exists(carrier.CoffinEntity)) { Log.Info(new object[1] { "Both servant and coffin missing for player " + playerData.Name + ", creating new carrier." }); Carriers.Remove(playerData.PlatformId); carrier = new Carrier(playerData); carrier.Create(); return; } if (!ECSExtensions.Exists(carrier.CoffinEntity) && ECSExtensions.Exists(carrier.ServantEntity)) { Log.Info(new object[1] { "Coffin missing for player " + playerData.Name + ", recreating coffin..." }); carrier.RecreateCoffin(); } else if (!ECSExtensions.Exists(carrier.ServantEntity) && ECSExtensions.Exists(carrier.CoffinEntity)) { Log.Warning(new object[1] { "Servant missing but coffin exists for player " + playerData.Name + ", recreating both..." }); Carriers.Remove(playerData.PlatformId); carrier = new Carrier(playerData); carrier.Create(); return; } InventoryService.ModifyInventorySize(carrier.ServantEntity, 27); carrier.EnsureEntitiesEnabled(); carrier.Call(); Carriers[playerData.PlatformId] = carrier; } public static void Dismiss(ulong platformId) { //IL_0028: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) PlayerData playerData = PlayerDataExtensions.GetPlayerData(platformId); if (Carriers.TryGetValue(playerData.PlatformId, out var value)) { if (!ECSExtensions.Exists(value.ServantEntity) && !ECSExtensions.Exists(value.CoffinEntity)) { Log.Info(new object[1] { "Both servant and coffin missing for player " + playerData.Name + ", creating new carrier for dismiss." }); Carriers.Remove(playerData.PlatformId); value = new Carrier(playerData); value.Create(); } else if (!ECSExtensions.Exists(value.CoffinEntity) && ECSExtensions.Exists(value.ServantEntity)) { Log.Info(new object[1] { "Coffin missing for player " + playerData.Name + ", recreating coffin for dismiss..." }); value.RecreateCoffin(); } else if (!ECSExtensions.Exists(value.ServantEntity) && ECSExtensions.Exists(value.CoffinEntity)) { Log.Warning(new object[1] { "Servant missing but coffin exists for player " + playerData.Name + ", recreating both for dismiss..." }); Carriers.Remove(playerData.PlatformId); value = new Carrier(playerData); value.Create(); } value.Dismiss(); } } public static void RemoveCarrier(ulong platformId) { if (HasServant(platformId)) { Carriers.Remove(platformId); } } public static Carrier GetCarrier(ulong platformId) { if (Carriers.TryGetValue(platformId, out var value) && value.IsValid()) { return value; } return null; } public static bool HasServant(ulong platformId) { Carrier value; return Carriers.TryGetValue(platformId, out value) && value.IsValid(); } public static bool IsFollowing(ulong platformId) { Carrier value; return Carriers.TryGetValue(platformId, out value) && value.IsFollowing; } public static void ToggleFollow(ulong platformId) { if (Carriers.TryGetValue(platformId, out var value)) { value.ToggleFollow(); } } public static void StartFollow(ulong platformId) { if (Carriers.TryGetValue(platformId, out var value)) { value.StartFollow(); } } public static void StopFollow(ulong platformId) { if (Carriers.TryGetValue(platformId, out var value)) { value.StopFollow(); } } public static void ClearAllLegacy() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = GameSystems.EntityManager; EntityQueryDesc[] array = new EntityQueryDesc[1]; EntityQueryDesc val = new EntityQueryDesc(); val.All = Il2CppStructArray<ComponentType>.op_Implicit((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<ServantCoffinstation>() }); val.Options = (EntityQueryOptions)2; array[0] = val; EntityQuery val2 = ((EntityManager)(ref entityManager)).CreateEntityQuery((EntityQueryDesc[])(object)array); Enumerator<Entity> enumerator = ((EntityQuery)(ref val2)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; ClearLegacyCoffinFromWorld(current); } } private static void ClearLegacyCoffinFromWorld(Entity coffin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00c1: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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) Entity @null = Entity.Null; if (((Entity)(ref @null)).Equals(coffin) || !ECSExtensions.Has<ServantCoffinstation>(coffin) || !ECSExtensions.Has<NameableInteractable>(coffin) || !ECSExtensions.Has<LocalTransform>(coffin)) { return; } float3 position = ECSExtensions.Read<LocalTransform>(coffin).Position; NameableInteractable val = ECSExtensions.Read<NameableInteractable>(coffin); string value = ((FixedString64Bytes)(ref val.Name)).Value; if (position.y == 221f && !(value != "__ScarletCarrier__")) { Entity entity = ECSExtensions.Read<ServantCoffinstation>(coffin).ConnectedServant._Entity; @null = Entity.Null; if (!((Entity)(ref @null)).Equals(entity) && ECSExtensions.Has<Follower>(entity)) { ClearLegacyServantFromWorld(entity); } Enumerator<BuffBuffer> enumerator = ECSExtensions.ReadBuffer<BuffBuffer>(coffin).GetEnumerator(); while (enumerator.MoveNext()) { BuffBuffer current = enumerator.Current; BuffService.TryRemoveBuff(coffin, current.PrefabGuid); } Log.Info(new object[1] { $"Clearing legacy coffin {coffin} from world." }); ECSExtensions.Destroy(coffin, false); } } private static void ClearLegacyServantFromWorld(Entity servant) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0053: 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_00ab: Unknown result type (might be due to invalid IL or missing references) Entity @null = Entity.Null; if (!((Entity)(ref @null)).Equals(servant) && ECSExtensions.Has<Follower>(servant)) { ECSExtensions.Remove<Follower>(servant); InventoryService.ClearInventory(servant); Enumerator<BuffBuffer> enumerator = ECSExtensions.ReadBuffer<BuffBuffer>(servant).GetEnumerator(); while (enumerator.MoveNext()) { BuffBuffer current = enumerator.Current; BuffService.TryRemoveBuff(servant, current.PrefabGuid); } Log.Info(new object[1] { $"Clearing legacy servant {servant} from world." }); ECSExtensions.Destroy(servant, false); } } } } namespace ScarletCarrier.Patches { [HarmonyPatch(typeof(AbilityCastStarted_SetupAbilityTargetSystem_Shared), "OnUpdate")] public static class AbilityPatch { private static readonly PrefabGUID FlightAbilityGuid = new PrefabGUID(-104327922); [HarmonyPrefix] private static void OnUpdatePrefix(AbilityCastStarted_SetupAbilityTargetSystem_Shared __instance) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_009c: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery val = ((Il2CppArrayBase<EntityQuery>)(object)((ComponentSystemBase)__instance).EntityQueries)[0]; NativeArray<AbilityCastStartedEvent> val2 = ((EntityQuery)(ref val)).ToComponentDataArray<AbilityCastStartedEvent>(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<AbilityCastStartedEvent> enumerator = val2.GetEnumerator(); while (enumerator.MoveNext()) { AbilityCastStartedEvent current = enumerator.Current; PrefabGUID val3 = ECSExtensions.Read<PrefabGUID>(current.AbilityGroup); int guidHash = ((PrefabGUID)(ref val3)).GuidHash; PrefabGUID flightAbilityGuid = FlightAbilityGuid; if (guidHash == ((PrefabGUID)(ref flightAbilityGuid)).GuidHash) { Entity character = current.Character; if (ECSExtensions.Has<PlayerCharacter>(character) || ECSExtensions.Has<User>(character)) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(character); CarrierService.Dismiss(playerData.PlatformId); } } } } finally { val2.Dispose(); } } } [HarmonyPatch(typeof(EmoteSystem), "OnUpdate")] public static class EmoteSystemPatch { private static readonly Dictionary<PrefabGUID, Action<ulong>> EmoteActions = new Dictionary<PrefabGUID, Action<ulong>> { { new PrefabGUID(-1525577000), CarrierService.Spawn }, { new PrefabGUID(-53273186), CarrierService.Dismiss }, { new PrefabGUID(-452406649), CarrierService.ToggleFollow } }; [HarmonyPrefix] private static void OnUpdatePrefix(EmoteSystem __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0079: 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_00b1: 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) if (!GameSystems.Initialized) { return; } EntityQuery query = __instance._Query; NativeArray<Entity> val = ((EntityQuery)(ref query)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)); try { Enumerator<Entity> enumerator = val.GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (!ECSExtensions.Exists(current)) { continue; } UseEmoteEvent val2 = ECSExtensions.Read<UseEmoteEvent>(current); FromCharacter val3 = ECSExtensions.Read<FromCharacter>(current); PrefabGUID action = val2.Action; Entity user = val3.User; if (!ECSExtensions.Exists(user)) { continue; } PlayerData playerData = PlayerDataExtensions.GetPlayerData(user); if (playerData == null) { continue; } ulong platformId = playerData.PlatformId; if (EmoteActions.TryGetValue(action, out var value)) { List<ulong> list = Plugin.Database.Get<List<ulong>>("DisabledEmotes"); if (list == null || !list.Contains(platformId)) { ECSExtensions.Destroy(current, true); value(platformId); } } } } catch (Exception ex) { Log.Error(new object[1] { "Error in EmoteSystemPatch: " + ex.Message }); } finally { val.Dispose(); } } } [HarmonyPatch(typeof(InteractValidateAndStopSystemServer), "OnUpdate")] public static class InteractPatch { private static readonly PrefabGUID CarrierInteractAbility = new PrefabGUID(-127008514); [HarmonyPrefix] public static void Prefix(InteractValidateAndStopSystemServer __instance) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_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_003f: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (!GameSystems.Initialized) { return; } EntityQuery _query_195794971_ = __instance.__query_195794971_3; Enumerator<Entity> enumerator = ((EntityQuery)(ref _query_195794971_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2)).GetEnumerator(); while (enumerator.MoveNext()) { Entity current = enumerator.Current; if (ECSExtensions.GetPrefabGuid(current) != CarrierInteractAbility) { continue; } Entity owner = ECSExtensions.Read<EntityOwner>(current).Owner; if (owner == Entity.Null || !ECSExtensions.Has<PlayerCharacter>(owner)) { continue; } Entity target = ECSExtensions.Read<Interactor>(owner).Target; if (!ECSExtensions.Has<NameableInteractable>(target)) { continue; } NameableInteractable val = ECSExtensions.Read<NameableInteractable>(target); string value = ((FixedString64Bytes)(ref val.Name)).Value; if (!(value != "__ScarletCarrier1.0__") && ECSExtensions.Has<Follower>(target)) { PlayerData playerData = PlayerDataExtensions.GetPlayerData(owner); Entity value2 = ECSExtensions.Read<Follower>(target).Followed._Value; if (!playerData.IsAdmin && value2 != playerData.UserEntity && value2 != playerData.CharacterEntity) { BuffService.TryRemoveBuff(owner, CarrierInteractAbility); } } } } } } namespace ScarletCarrier.Models { internal class Carrier { private const float MaxSpawnDistance = 3f; private const float MaxTeleportDistance = 15f; public const float LegacyHeight = 221f; public const float Height = 215f; private const int MaxPositionHistory = 8; private const float ServantSpeedMultiplier = 0.95f; public const string Id = "__ScarletCarrier1.0__"; public const string LegacyId = "__ScarletCarrier__"; private static readonly PrefabGUID CoffinPrefab = new PrefabGUID(723455393); private static readonly PrefabGUID DefaultServantPrefab = new PrefabGUID(2142021685); private static readonly PrefabGUID NeutralFaction = new PrefabGUID(-1430861195); private static readonly PrefabGUID PlayerMountedBuff = new PrefabGUID(-978792376); private static readonly PrefabGUID SpawnPlayerBuff = new PrefabGUID(-1879665573); private static readonly PrefabGUID[] ServantPermaBuffs = (PrefabGUID[])(object)new PrefabGUID[3] { new PrefabGUID(-480024072), new PrefabGUID(1934061152), new PrefabGUID(1360141727) }; private const string NameFormat = "{playerName}'s Carrier"; public float3 DismissPosition = new float3(-359f, 15f, -280f); private List<float3> _positionHistory = new List<float3>(); private ActionId _followAction; private float3 _currentTargetPosition; private bool _isFollowing; public float BusyDuration = 1.5f; public Entity CoffinEntity { get; private set; } public Entity ServantEntity { get; private set; } public PlayerData Owner { get; private set; } public ulong PlatformId => Owner.PlatformId; public bool IsFollowing => _isFollowing; public bool Busy { get; private set; } = false; public static int MaxDays => Plugin.Settings.Get<int>("ExpireDays") * 24 * 60 * 60; public Carrier(PlayerData ownerData) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Owner = ownerData; } public Carrier(Entity coffin, Entity servant, PlayerData ownerData) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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) CoffinEntity = coffin; ServantEntity = servant; Owner = ownerData; BindCoffinServant(); } public void EnsureEntitiesEnabled() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (ECSExtensions.Exists(ServantEntity) && ECSExtensions.Has<Disabled>(ServantEntity)) { ECSExtensions.Remove<Disabled>(ServantEntity); Log.Info(new object[1] { "Enabled disabled servant entity for player " + Owner.Name }); } if (ECSExtensions.Exists(CoffinEntity) && ECSExtensions.Has<Disabled>(CoffinEntity)) { ECSExtensions.Remove<Disabled>(CoffinEntity); Log.Info(new object[1] { "Enabled disabled coffin entity for player " + Owner.Name }); } } public void Call() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_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_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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) if (!Busy) { SetAsBusy(); ActionScheduler.Delayed((Action)delegate { Busy = false; }, BusyDuration); SetName(Owner.Name); EnsureEntitiesEnabled(); if (BuffService.HasBuff(ServantEntity, CarrierState.Hidden)) { BuffService.TryRemoveBuff(ServantEntity, CarrierState.Hidden); } if (!BuffService.HasBuff(Owner.CharacterEntity, SpawnPlayerBuff)) { BuffService.TryApplyBuff(Owner.CharacterEntity, SpawnPlayerBuff, 0f); } if (!BuffService.HasBuff(ServantEntity, CarrierState.Spawning)) { BuffService.TryApplyBuff(ServantEntity, CarrierState.Spawning, BusyDuration); } ResetLifeTime(); PositionServantOnPlayerAim(); LookAtPlayer(); LoadServantInventoryFromLegacy(); } } public void ResetLifeTime() { //IL_0002: 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_0058: 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) ECSExtensions.AddWith<LifeTime>(ServantEntity, (WithRefHandler<LifeTime>)delegate(ref LifeTime lifetime) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) lifetime.Duration = MaxDays; lifetime.EndAction = (LifeTimeEndAction)2; }); ECSExtensions.AddWith<LifeTime>(CoffinEntity, (WithRefHandler<LifeTime>)delegate(ref LifeTime lifetime) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) lifetime.Duration = MaxDays; lifetime.EndAction = (LifeTimeEndAction)2; }); ECSExtensions.With<Age>(ServantEntity, (WithRefHandler<Age>)delegate(ref Age age) { age.Value = 0f; }); ECSExtensions.With<Age>(CoffinEntity, (WithRefHandler<Age>)delegate(ref Age age) { age.Value = 0f; }); } public void Dismiss() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if (!Busy) { SetAsBusy(); StopFollow(); if (!BuffService.HasBuff(ServantEntity, CarrierState.Leaving)) { BuffService.TryApplyBuff(ServantEntity, CarrierState.Leaving, BusyDuration); } if (!BuffService.HasBuff(ServantEntity, CarrierState.Hidden)) { BuffService.TryApplyBuff(ServantEntity, CarrierState.Hidden, -1f); } ActionScheduler.DelayedFrames((Action)Hide, 3); } } private void SetAsBusy() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) Busy = true; ActionScheduler.Delayed((Action)delegate { Busy = false; }, BusyDuration); } public bool IsValid() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_001b: 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_002c: 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) Entity @null = Entity.Null; int result; if (!((Entity)(ref @null)).Equals(CoffinEntity)) { @null = Entity.Null; if (!((Entity)(ref @null)).Equals(ServantEntity) && ECSExtensions.Exists(CoffinEntity)) { result = (ECSExtensions.Exists(ServantEntity) ? 1 : 0); goto IL_0046; } } result = 0; goto IL_0046; IL_0046: return (byte)result != 0; } private void SetName(string playerName) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) ECSExtensions.With<ServantCoffinstation>(CoffinEntity, (WithRefHandler<ServantCoffinstation>)delegate(ref ServantCoffinstation coffinStation) { //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) coffinStation.ServantName = new FixedString64Bytes("{playerName}'s Carrier".Replace("{playerName}", playerName)); }); } public void Create() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) CreateCoffin(); CreateServant(); BindCoffinServant(); RemoveDisableComponents(CoffinEntity); RemoveDisableComponents(ServantEntity); } private void CreateCoffin() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_0054: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) PrefabGUID coffinPrefab = CoffinPrefab; float3 val = Owner.Position + new float3(0f, 215f, 0f); Entity characterEntity = Owner.CharacterEntity; CoffinEntity = SpawnerService.ImmediateSpawn(coffinPrefab, val, 0f, 0f, (float)MaxDays, characterEntity); ECSExtensions.AddWith<NameableInteractable>(CoffinEntity, (WithRefHandler<NameableInteractable>)delegate(ref NameableInteractable nameable) { //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) nameable.Name = new FixedString64Bytes("__ScarletCarrier1.0__"); }); ECSExtensions.AddWith<EntityOwner>(CoffinEntity, (WithRefHandler<EntityOwner>)delegate(ref EntityOwner owner) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) owner.Owner = Owner.CharacterEntity; }); ECSExtensions.SetTeam(CoffinEntity, Owner.CharacterEntity); } public void RecreateCoffin() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) if (ECSExtensions.Exists(CoffinEntity)) { Log.Warning(new object[1] { "Attempted to recreate coffin that still exists for player " + Owner.Name }); return; } Log.Info(new object[1] { $"Recreating missing coffin for player {Owner.Name} ({Owner.PlatformId})" }); float3 val = ECSExtensions.Position(ServantEntity); PrefabGUID coffinPrefab = CoffinPrefab; float3 val2 = val + new float3(0f, 215f, 0f); Entity characterEntity = Owner.CharacterEntity; CoffinEntity = SpawnerService.ImmediateSpawn(coffinPrefab, val2, 0f, 0f, (float)MaxDays, characterEntity); ECSExtensions.AddWith<NameableInteractable>(CoffinEntity, (WithRefHandler<NameableInteractable>)delegate(ref NameableInteractable nameable) { //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) nameable.Name = new FixedString64Bytes("__ScarletCarrier1.0__"); }); ECSExtensions.AddWith<EntityOwner>(CoffinEntity, (WithRefHandler<EntityOwner>)delegate(ref EntityOwner owner) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) owner.Owner = Owner.CharacterEntity; }); ECSExtensions.SetTeam(CoffinEntity, Owner.CharacterEntity); BindCoffinServant(); RemoveDisableComponents(CoffinEntity); EnsureEntitiesEnabled(); ResetLifeTime(); } private void CreateServant() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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) PrefabGUID servantAppearance = GetServantAppearance(); float3 position = Owner.Position; Entity characterEntity = Owner.CharacterEntity; ServantEntity = SpawnerService.ImmediateSpawn(servantAppearance, position, 0f, 0f, (float)MaxDays, characterEntity); ConfigureServant(); } private PrefabGUID GetServantAppearance() { //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_0045: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) Dictionary<ulong, string> dictionary = Plugin.Database.Get<Dictionary<ulong, string>>("CustomAppearances") ?? new Dictionary<ulong, string>(); PrefabGUID result = DefaultServantPrefab; PrefabGUID val = default(PrefabGUID); if (dictionary.TryGetValue(PlatformId, out var value) && PrefabGUID.TryParse(value, ref val)) { result = val; } return result; } public void SwapServantAppearance() { //IL_000f: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_0096: 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_00ad: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: 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_0110: Unknown result type (might be due to invalid IL or missing references) if (ECSExtensions.IsNull(ServantEntity) || !ECSExtensions.Exists(ServantEntity)) { Log.Error(new object[1] { "Current servant entity is invalid." }); return; } StopFollow(); PrefabGUID servantAppearance = GetServantAppearance(); float3 oldServantPosition = ECSExtensions.Position(ServantEntity); TeleportService.TeleportToPosition(CoffinEntity, oldServantPosition + new float3(0f, 215f, 0f), true); float3 val = oldServantPosition; Entity characterEntity = Owner.CharacterEntity; Entity newServant = SpawnerService.ImmediateSpawn(servantAppearance, val, 0f, 0f, (float)MaxDays, characterEntity); DynamicBuffer<InventoryBuffer> inventoryItems = InventoryService.GetInventoryItems(ServantEntity); ServantEquipment oldServantEquipment = ECSExtensions.Read<ServantEquipment>(ServantEntity); ServantEquipment val2 = ECSExtensions.Read<ServantEquipment>(newServant); ActionScheduler.CreateSequence().ThenWaitFrames(5).Then((Action)delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_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) for (int i = 0; i < inventoryItems.Length; i++) { InventoryService.TransferItem(ServantEntity, newServant, i, 0); } ECSExtensions.Write<ServantEquipment>(newServant, oldServantEquipment); ECSExtensions.Write<ServantEquipment>(ServantEntity, default(ServantEquipment)); ECSExtensions.Destroy(ServantEntity, false); ServantEntity = newServant; TeleportService.TeleportToPosition(CoffinEntity, oldServantPosition + new float3(0f, 215f, 0f), true); if (!BuffService.HasBuff(ServantEntity, CarrierState.Spawning)) { BuffService.TryApplyBuff(ServantEntity, CarrierState.Spawning, 2f); } LookAtPlayer(); ConfigureServant(); BindCoffinServant(); }) .Execute(); } private void ConfigureServant() { //IL_0002: 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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006c: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) ECSExtensions.AddWith<Immortal>(ServantEntity, (WithRefHandler<Immortal>)delegate(ref Immortal immortal) { immortal.IsImmortal = true; }); ECSExtensions.AddWith<NameableInteractable>(ServantEntity, (WithRefHandler<NameableInteractable>)delegate(ref NameableInteractable nameable) { //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) nameable.Name = new FixedString64Bytes("__ScarletCarrier1.0__"); }); PrefabGUID[] servantPermaBuffs = ServantPermaBuffs; foreach (PrefabGUID val in servantPermaBuffs) { BuffService.TryApplyBuff(ServantEntity, val, -1f); } ECSExtensions.With<AggroConsumer>(ServantEntity, (WithRefHandler<AggroConsumer>)delegate(ref AggroConsumer aggroConsumer) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) aggroConsumer.Active = new ModifiableBool(false); }); ECSExtensions.With<Aggroable>(ServantEntity, (WithRefHandler<Aggroable>)delegate(ref Aggroable aggroable) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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) aggroable.Value = new ModifiableBool(false); aggroable.DistanceFactor = new ModifiableFloat(0f); aggroable.AggroFactor = new ModifiableFloat(0f); }); ECSExtensions.With<FactionReference>(ServantEntity, (WithRefHandler<FactionReference>)delegate(ref FactionReference factionReference) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) factionReference.FactionGuid = new ModifiablePrefabGUID(NeutralFaction); }); ECSExtensions.With<Follower>(ServantEntity, (WithRefHandler<Follower>)delegate(ref Follower follower) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) follower.Followed = new ModifiableEntity(Owner.UserEntity); }); ECSExtensions.SetTeam(ServantEntity, Owner.CharacterEntity); } private void BindCoffinServant() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) ECSExtensions.AddWith<ServantConnectedCoffin>(ServantEntity, (WithRefHandler<ServantConnectedCoffin>)delegate(ref ServantConnectedCoffin servantConnectedCoffin) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) servantConnectedCoffin.CoffinEntity = NetworkedEntity.ServerEntity(CoffinEntity); }); ECSExtensions.AddWith<ServantCoffinstation>(CoffinEntity, (WithRefHandler<ServantCoffinstation>)delegate(ref ServantCoffinstation coffinStation) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) coffinStation.ConnectedServant = NetworkedEntity.ServerEntity(ServantEntity); coffinStation.State = (ServantCoffinState)7; }); SetName(Owner.Name); } private void RemoveDisableComponents(Entity entity) { //IL_0001: 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_000c: 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) if (ECSExtensions.Has<DisableWhenNoPlayersInRange>(entity)) { ECSExtensions.Remove<DisableWhenNoPlayersInRange>(entity); } if (ECSExtensions.Has<DisableWhenNoPlayersInRangeOfChunk>(entity)) { ECSExtensions.Remove<DisableWhenNoPlayersInRangeOfChunk>(entity); } } private void PositionServantOnPlayerAim() { //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_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_0034: 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_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_0050: 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) float3 position = Owner.Position; float3 aimPosition = ECSExtensions.Read<EntityAimData>(Owner.CharacterEntity).AimPosition; float num = math.distance(position, aimPosition); float3 position2 = ((num <= 3f) ? aimPosition : (position + MathUtility.GetDirection(position, aimPosition) * 3f)); position2.y = position.y; TeleportToPosition(position2); } private void LoadServantInventoryFromLegacy() { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Database.Has(PlatformId.ToString())) { return; } Dictionary<int, int> dictionary = Plugin.Database.Get<Dictionary<int, int>>(PlatformId.ToString()) ?? new Dictionary<int, int>(); foreach (KeyValuePair<int, int> item in dictionary) { InventoryService.AddItem(ServantEntity, new PrefabGUID(item.Key), item.Value); } Plugin.Database.Delete(PlatformId.ToString()); } public void StartFollow() { //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 (_isFollowing) { return; } _positionHistory.Clear(); _isFollowing = true; _followAction = ActionScheduler.OncePerFrame((Action<Action>)delegate(Action end) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (ECSExtensions.IsNull(ServantEntity) || !ECSExtensions.Exists(ServantEntity) || BuffService.HasBuff(ServantEntity, CarrierState.Hidden)) { end(); _isFollowing = false; } else { UpdatePlayerPositionHistory(); FollowPlayer(); } }, -1); } public void StopFollow() { //IL_0018: 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_0025: 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_0042: Unknown result type (might be due to invalid IL or missing references) if (_isFollowing) { _isFollowing = false; if (_followAction != default(ActionId)) { ActionScheduler.CancelAction(_followAction); _followAction = default(ActionId); } StopSeekingPosition(); _positionHistory.Clear(); } } public void TeleportToPosition(float3 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_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) Entity @null = Entity.Null; if (!((Entity)(ref @null)).Equals(ServantEntity) && ECSExtensions.Exists(ServantEntity)) { TeleportService.TeleportToPosition(ServantEntity, position, true); TeleportService.TeleportToPosition(CoffinEntity, position + new float3(0f, 215f, 0f), true); } } public void Hide() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) SetName(Owner.Name); TeleportToPosition(DismissPosition); } private void LookAtPlayer() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ECSExtensions.With<EntityInput>(ServantEntity, (WithRefHandler<EntityInput>)delegate(ref EntityInput lookAtTarget) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) ((EntityInput)(ref lookAtTarget)).SetAllAimPositions(Owner.Position); }); } public void ToggleFollow() { if (_isFollowing) { StopFollow(); } else { StartFollow(); } } private void FollowPlayer() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_004c: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) float playerSpeed = ECSExtensions.Read<MoveVelocity>(Owner.CharacterEntity).MoveVelocityMagnitude; float3 val = ECSExtensions.Position(ServantEntity); float3 lastValidPosition = ECSExtensions.Read<PlayerLastValidPosition>(Owner.CharacterEntity).LastValidPosition; float num = math.distance(val, lastValidPosition); float num2 = math.abs(val.y - lastValidPosition.y); if (num > 15f || num2 > 4f) { TeleportToPosition(lastValidPosition); return; } float3 targetPositionFromHistory = GetTargetPositionFromHistory(val); if (math.distance(_currentTargetPosition, targetPositionFromHistory) > 0.1f) { _currentTargetPosition = targetPositionFromHistory; SetSeekingPosition(targetPositionFromHistory); } if (playerSpeed < 2f) { playerSpeed = 2f; } if (BuffService.HasBuff(Owner.CharacterEntity, PlayerMountedBuff)) { playerSpeed *= 5f; } ECSExtensions.With<Movement>(ServantEntity, (WithRefHandler<Movement>)delegate(ref Movement movement) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) movement.Speed = new ModifiableFloat(playerSpeed * 0.95f); }); TeleportService.TeleportToPosition(CoffinEntity, ECSExtensions.Position(ServantEntity) + new float3(0f, 215f, 0f), true); } private void SetSeekingPosition(float3 targetPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) ECSExtensions.With<AiMove_Server>(ServantEntity, (WithRefHandler<AiMove_Server>)delegate(ref AiMove_Server move) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_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_0040: Unknown result type (might be due to invalid IL or missing references) move.ForceLookAtTarget = (AiForceLookAtTarget)1; move.IsSeekingGoalPosition = true; move.SeekOutwards = false; move.TargettingMode = (AiTargettingMode)1; move.TargetPosition = new float2(targetPos.x, targetPos.z); move.MovePattern = (AiMovePattern)0; move.FreezeRotationWhenStationary = true; }); } private void StopSeekingPosition() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ECSExtensions.With<AiMove_Server>(ServantEntity, (WithRefHandler<AiMove_Server>)delegate(ref AiMove_Server move) { //IL_000a: 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) move.IsSeekingGoalPosition = false; move.TargettingMode = (AiTargettingMode)0; move.ForceLookAtTarget = (AiForceLookAtTarget)0; }); } private float3 GetTargetPositionFromHistory(float3 servantPosition) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) if (_positionHistory.Count == 0) { return servantPosition; } float3 lastValidPosition = ECSExtensions.Read<PlayerLastValidPosition>(Owner.CharacterEntity).LastValidPosition; if (math.distance(servantPosition, lastValidPosition) <= 3f) { _positionHistory.Clear(); return servantPosition; } while (_positionHistory.Count > 0 && math.distance(servantPosition, _positionHistory[0]) <= 0.2f) { _positionHistory.RemoveAt(0); } if (_positionHistory.Count == 0) { return servantPosition; } return _positionHistory[0]; } private void UpdatePlayerPositionHistory() { //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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) float3 lastValidPosition = ECSExtensions.Read<PlayerLastValidPosition>(Owner.CharacterEntity).LastValidPosition; if (_positionHistory.Count != 0) { List<float3> positionHistory = _positionHistory; if (!(math.distance(positionHistory[positionHistory.Count - 1], lastValidPosition) > 0.5f)) { return; } } _positionHistory.Add(lastValidPosition); if (_positionHistory.Count > 8) { _positionHistory.RemoveAt(0); } } } internal class CarrierState { public static PrefabGUID Leaving = new PrefabGUID(826269213); public static PrefabGUID Hidden = new PrefabGUID(-1144825660); public static PrefabGUID Spawning = new PrefabGUID(1497959076); } } namespace ScarletCarrier.Commands { [CommandGroup("carrier", "car")] public static class CarrierCommands { public static Dictionary<PlayerData, ActionId> _selectedActions = new Dictionary<PlayerData, ActionId>(); [Command("call", "c", null, null, null, false)] public static void SummonCommand(ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.User.PlatformId; CarrierService.Spawn(platformId); ctx.Reply(RichTextFormatter.Format("Your ~carrier~ has been summoned!", (List<string>)null)); } [Command("dismiss", "d", null, null, null, false)] public static void DismissCommand(ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.User.PlatformId; CarrierService.Dismiss(platformId); ctx.Reply(RichTextFormatter.Format("Your ~carrier~ has been dismissed.", (List<string>)null)); } [Command("follow", "f", null, null, null, false)] public static void FollowCommand(ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) CarrierService.StartFollow(ctx.User.PlatformId); ctx.Reply(RichTextFormatter.Format("Your ~carrier~ will now follow you.", (List<string>)null)); } [Command("stop", "s", null, null, null, false)] public static void StopCommand(ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ulong platformId = ctx.User.PlatformId; if (!CarrierService.HasServant(platformId)) { ctx.Reply(RichTextFormatter.FormatError("You do not have a ~carrier~ summoned.")); return; } if (!CarrierService.IsFollowing(platformId)) { ctx.Reply(RichTextFormatter.FormatError("Your ~carrier~ is not following you.")); return; } CarrierService.StopFollow(platformId); ctx.Reply(RichTextFormatter.Format("Your ~carrier~ will no longer follow you.", (List<string>)null)); } [Command("toggle emotes", "te", null, null, null, false)] public static void ToggleEmotesCommand(ChatCommandContext ctx) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) List<ulong> list = Plugin.Database.Get<List<ulong>>("DisabledEmotes") ?? new List<ulong>(); ulong platformId = ctx.User.PlatformId; if (list.Contains(platformId)) { list.Remove(platformId); ctx.Reply(RichTextFormatter.Format("~Carrier emotes enabled~ for you.", (List<string>)null)); } else { list.Add(platformId); ctx.Reply(RichTextFormatter.FormatError("~Carrier emotes disabled~ for you.")); } Plugin.Database.Save<List<ulong>>("DisabledEmotes", list); } [Command("list", "l", null, null, null, false)] public static void AppearanceListCommand(ChatCommandContext ctx) { string[] appearanceNames = CarrierService.AppearanceNames; if (appearanceNames.Length == 0) { ctx.Reply(RichTextFormatter.FormatError("No appearances found.")); return; } string text = RichTextFormatter.Format("~Available appearances:~", (List<string>)null); for (int i = 0; i < appearanceNames.Length; i++) { text += RichTextFormatter.Format($"\n{i + 1} - ~{appearanceNames[i]}~", (List<string>)null); if ((i + 1) % 5 == 0 && i != appearanceNames.Length - 1) { ctx.Reply(text); text = string.Empty; } } ctx.Reply(text); ctx.Reply(RichTextFormatter.Format("Use ~.carrier <number>~ to change your carrier's appearance.", (List<string>)null)); } [Command("appearance", "a", null, null, null, false)] public static void AppearanceCommand(ChatCommandContext ctx, int number) { //IL_0002: 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) PlayerData val = default(PlayerData); if (!PlayerService.TryGetById(ctx.User.PlatformId, ref val)) { ctx.Reply(RichTextFormatter.Format($"Error: Player ~{ctx.User.CharacterName}~ not found.", (List<string>)null)); return; } PrefabGUID[] appearancePrefabs = CarrierService.AppearancePrefabs; string[] appearanceNames = CarrierService.AppearanceNames; if (number < 1 || number > appearancePrefabs.Length) { ctx.Reply(RichTextFormatter.FormatError("Invalid appearance number. Use ~.carrier appearance list~ to see available appearances.")); return; } number--; Dictionary<ulong, string> dictionary = Plugin.Database.Get<Dictionary<ulong, string>>("CustomAppearances") ?? new Dictionary<ulong, string>(); if (dictionary.TryGetValue(val.PlatformId, out var value) && value == ((PrefabGUID)(ref appearancePrefabs[number])).GuidHash.ToString()) { ctx.Reply(RichTextFormatter.FormatError("Your carrier is already using the ~" + appearanceNames[number] + "~ appearance.")); return; } dictionary[val.PlatformId] = ((PrefabGUID)(ref appearancePrefabs[number])).GuidHash.ToString(); Plugin.Database.Save<Dictionary<ulong, string>>("CustomAppearances", dictionary); Carrier carrier = CarrierService.GetCarrier(val.PlatformId); carrier.SwapServantAppearance(); ctx.Reply(RichTextFormatter.Format("Your carrier's appearance has been changed to ~" + appearanceNames[number] + "~.", (List<string>)null)); } [Command("move", "m", null, null, null, true)] public static void MoveCommand(ChatCommandContext ctx) { //IL_0014: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0114: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_017d: 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) PlayerData playerData = default(PlayerData); if (!PlayerService.TryGetById(ctx.User.PlatformId, ref playerData)) { ctx.Reply(RichTextFormatter.Format($"Error: Player ~{ctx.User.CharacterName}~ not found.", (List<string>)null)); return; } if (_selectedActions.ContainsKey(playerData)) { ctx.Reply(RichTextFormatter.FormatError("You are already moving a carrier.")); return; } Entity hoveredEntity = ECSExtensions.Read<EntityInput>(playerData.CharacterEntity).HoveredEntity; if (!ECSExtensions.Exists(hoveredEntity)) { ctx.Reply(RichTextFormatter.FormatError("Please aim at the carrier you want to move.")); return; } if (ECSExtensions.Has<ServantData>(hoveredEntity) && ECSExtensions.Has<NameableInteractable>(hoveredEntity)) { NameableInteractable val = ECSExtensions.Read<NameableInteractable>(hoveredEntity); if (!(((FixedString64Bytes)(ref val.Name)).Value != "__ScarletCarrier1.0__")) { _selectedActions[playerData] = ActionScheduler.OncePerFrame((Action<Action>)delegate(Action end) { //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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //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) //IL_005c: Unknown result type (might be due to invalid IL or missing references) EntityInput val2 = ECSExtensions.Read<EntityInput>(playerData.CharacterEntity); if ((int)val2.State.InputsDown == 2) { end(); _selectedActions.Remove(playerData); ctx.Reply(RichTextFormatter.FormatSuccess("Carrier moved.")); } else { ECSExtensions.SetPosition(hoveredEntity, val2.AimPosition); } }, -1); ActionScheduler.Delayed((Action)delegate { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (_selectedActions.TryGetValue(playerData, out var value)) { ActionScheduler.CancelAction(value); _selectedActions.Remove(playerData); } }, 180f); ctx.Reply(RichTextFormatter.Format("You are now moving the carrier. ~Click to place it~.", (List<string>)null)); return; } } ctx.Reply(RichTextFormatter.FormatError("The hovered entity is not a carrier.")); } [Command("forcedismiss", "fd", null, null, null, true)] public static void ForceDismissCommand(ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetById(ctx.User.PlatformId, ref val)) { ctx.Reply(RichTextFormatter.Format($"Error: Player ~{ctx.User.CharacterName}~ not found.", (List<string>)null)); return; } Entity hoveredEntity = ECSExtensions.Read<EntityInput>(val.CharacterEntity).HoveredEntity; if (!ECSExtensions.Exists(hoveredEntity)) { ctx.Reply(RichTextFormatter.FormatError("Please aim at the carrier you want to move.")); return; } if (ECSExtensions.Has<ServantData>(hoveredEntity) && ECSExtensions.Has<NameableInteractable>(hoveredEntity)) { NameableInteractable val2 = ECSExtensions.Read<NameableInteractable>(hoveredEntity); if (!(((FixedString64Bytes)(ref val2.Name)).Value != "__ScarletCarrier1.0__") && ECSExtensions.Has<EntityOwner>(hoveredEntity)) { Entity owner = ECSExtensions.Read<EntityOwner>(hoveredEntity).Owner; PlayerData playerData = PlayerDataExtensions.GetPlayerData(owner); Carrier carrier = CarrierService.GetCarrier(playerData.PlatformId); if (carrier == null) { ctx.Reply(RichTextFormatter.FormatError("Something went wrong, the carrier for player " + playerData.Name + " was not found.")); return; } carrier.Dismiss(); ctx.Reply(RichTextFormatter.FormatSuccess("Carrier for player ~" + playerData.Name + "~ has been dismissed.")); return; } } ctx.Reply(RichTextFormatter.FormatError("The hovered entity is not a carrier.")); } [Command("forceremove", "fr", null, null, null, true)] public static void ForceRemoveCommand(ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetById(ctx.User.PlatformId, ref val)) { ctx.Reply(RichTextFormatter.Format($"Error: Player ~{ctx.User.CharacterName}~ not found.", (List<string>)null)); return; } Entity hoveredEntity = ECSExtensions.Read<EntityInput>(val.CharacterEntity).HoveredEntity; if (!ECSExtensions.Exists(hoveredEntity)) { ctx.Reply(RichTextFormatter.FormatError("Please aim at the carrier you want to move.")); return; } if (ECSExtensions.Has<ServantData>(hoveredEntity) && ECSExtensions.Has<NameableInteractable>(hoveredEntity)) { NameableInteractable val2 = ECSExtensions.Read<NameableInteractable>(hoveredEntity); if (!(((FixedString64Bytes)(ref val2.Name)).Value != "__ScarletCarrier1.0__") && ECSExtensions.Has<EntityOwner>(hoveredEntity)) { Entity entity = ECSExtensions.Read<ServantConnectedCoffin>(hoveredEntity).CoffinEntity._Entity; if (ECSExtensions.Exists(entity)) { ECSExtensions.Destroy(entity, false); } ECSExtensions.Destroy(hoveredEntity, false); ctx.Reply(RichTextFormatter.FormatSuccess("Carrier removed for player.")); return; } } ctx.Reply(RichTextFormatter.FormatError("The hovered entity is not a carrier.")); } [Command("forcedismiss", "fd", null, null, null, true)] public static void ForceDismissCommand(ChatCommandContext ctx, string playerName) { PlayerData val = default(PlayerData); if (!PlayerService.TryGetByName(playerName, ref val)) { ctx.Reply(RichTextFormatter.Format("Error: Player ~" + playerName + "~ not found.", (List<string>)null)); return; } Carrier carrier = CarrierService.GetCarrier(val.PlatformId); if (carrier == null) { ctx.Reply(RichTextFormatter.FormatError("Carrier for player ~" + val.Name + "~ not found.")); return; } carrier.Dismiss(); ctx.Reply(RichTextFormatter.FormatSuccess("Carrier for player ~" + val.Name + "~ has been dismissed.")); } [Command("forceenableinteract", "fei", null, null, null, true)] public static void ForceEnableInteractCommand(ChatCommandContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) PlayerData val = default(PlayerData); if (!PlayerService.TryGetById(ctx.User.PlatformId, ref val)) { ctx.Reply(RichTextFormatter.Format($"Error: Player ~{ctx.User.CharacterName}~ not found.", (List<string>)null)); return; } Entity hoveredEntity = ECSExtensions.Read<EntityInput>(val.CharacterEntity).HoveredEntity; if (!ECSExtensions.Exists(hoveredEntity)) { ctx.Reply(RichTextFormatter.FormatError("Please aim at the carrier you want to enable interaction for.")); return; } if (ECSExtensions.Has<ServantData>(hoveredEntity) && ECSExtensions.Has<NameableInteractable>(hoveredEntity)) { NameableInteractable val2 = ECSExtensions.Read<NameableInteractable>(hoveredEntity); if (!(((FixedString64Bytes)(ref val2.Name)).Value != "__ScarletCarrier1.0__") && E