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.CastleBuilding;
using ProjectM.Network;
using ProjectM.Tiles;
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 UnityEngine;
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.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+ed7bdf2f63b30c161c11d969a6326dba57ffd599")]
[assembly: AssemblyProduct("ScarletCarrier")]
[assembly: AssemblyTitle("ScarletCarrier")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[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.0.0")]
[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.0.0");
((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);
if (GameSystems.Initialized)
{
OnInitialize(null, null);
}
else
{
EventManager.OnInitialize += OnInitialize;
}
EventManager.OnUserDisconnected += delegate(object? _, UserDisconnectedEventArgs userEvent)
{
PlayerData player = userEvent.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(object _, object __)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
LogInstance.LogInfo((object)"Removing carrier entities...");
CarrierService.Initialize();
CleanupService.ClearEntitiesInRadius(new float2(0f, 0f), 15f);
LogInstance.LogInfo((object)"Carrier entities removed.");
}
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.0.0";
}
}
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_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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
//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_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_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_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00f1: 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)
ClearAllLegacy();
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;
if (!ECSExtensions.IsNull(current) && ECSExtensions.Exists(current) && ECSExtensions.Has<ServantCoffinstation>(current) && ECSExtensions.Has<NameableInteractable>(current) && ECSExtensions.Has<EntityOwner>(current))
{
Entity owner = ECSExtensions.Read<EntityOwner>(current).Owner;
PlayerData playerData = PlayerDataExtensions.GetPlayerData(owner);
if (playerData != null)
{
Entity entity = ECSExtensions.Read<ServantCoffinstation>(current).ConnectedServant._Entity;
Carrier carrier = new Carrier(current, entity, playerData);
Carriers[playerData.PlatformId] = carrier;
carrier.Hide();
}
}
}
}
public static void Spawn(ulong platformId)
{
//IL_00a8: 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)
PlayerData playerData = PlayerDataExtensions.GetPlayerData(platformId);
Carrier carrier;
if (!Carriers.ContainsKey(playerData.PlatformId))
{
carrier = new Carrier(playerData);
carrier.Create();
}
else
{
carrier = Carriers[playerData.PlatformId];
}
if (carrier == null)
{
Log.Error((object)$"Failed to create carrier for player {playerData.Name} ({playerData.PlatformId}).");
}
else if (!ECSExtensions.Exists(carrier.ServantEntity) || !ECSExtensions.Exists(carrier.CoffinEntity))
{
Carriers.Remove(playerData.PlatformId);
carrier = new Carrier(playerData);
carrier.Create();
}
else
{
carrier.Call();
Carriers[playerData.PlatformId] = carrier;
}
}
public static void Dismiss(ulong platformId)
{
//IL_0025: 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)
PlayerData playerData = PlayerDataExtensions.GetPlayerData(platformId);
if (Carriers.TryGetValue(playerData.PlatformId, out var value))
{
if (!ECSExtensions.Exists(value.ServantEntity) || !ECSExtensions.Exists(value.CoffinEntity))
{
Carriers.Remove(playerData.PlatformId);
value = new Carrier(playerData);
value.Create();
}
else
{
value.Dismiss();
}
}
}
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_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: 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((object)$"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_0023: 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)
//IL_0037: 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_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_004d: 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_0050: 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)
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);
}
ECSExtensions.Destroy(servant, false);
}
}
}
internal static class CleanupService
{
public static GenerateCastleSystem GenerateCastleSystem => GameSystems.Server.GetOrCreateSystemManaged<GenerateCastleSystem>();
public static void ClearEntitiesInRadius(float2 center, float radius)
{
//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_0019: 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_002a: Unknown result type (might be due to invalid IL or missing references)
IEnumerable<Entity> allEntitiesInRadius = GetAllEntitiesInRadius<PrefabGUID>(center, radius);
foreach (Entity item in allEntitiesInRadius)
{
if (ECSExtensions.Has<PrefabGUID>(item))
{
ECSExtensions.Destroy(item, false);
}
}
}
public static IEnumerable<Entity> GetAllEntitiesInRadius<T>(float2 center, float radius)
{
//IL_0008: 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)
TileModelSpatialLookupSystemData spatialData = GenerateCastleSystem._TileModelLookupSystemData;
TileModelSpatialLookupRO tileModelSpatialLookupRO = ((TileModelSpatialLookupSystemData)(ref spatialData)).GetSpatialLookupReadOnlyAndComplete((SystemBase)(object)GenerateCastleSystem);
float2 gridPosMin = ConvertPosToTileGrid(center - radius);
float2 gridPosMax = ConvertPosToTileGrid(center + radius);
BoundsMinMax bounds = new BoundsMinMax(Mathf.FloorToInt(gridPosMin.x), Mathf.FloorToInt(gridPosMin.y), Mathf.CeilToInt(gridPosMax.x), Mathf.CeilToInt(gridPosMax.y));
NativeList<Entity> entities = ((TileModelSpatialLookupRO)(ref tileModelSpatialLookupRO)).GetEntities(ref bounds, (TileType)255, 16, 16);
Enumerator<Entity> enumerator = entities.GetEnumerator();
while (enumerator.MoveNext())
{
Entity entity = enumerator.Current;
if (ECSExtensions.Has<PrefabGUID>(entity) && ECSExtensions.Has<Translation>(entity))
{
float3 pos = ECSExtensions.Read<Translation>(entity).Value;
if (math.distance(center, ((float3)(ref pos)).xz) <= radius)
{
yield return entity;
}
pos = default(float3);
}
}
entities.Dispose();
}
public static float2 ConvertPosToTileGrid(float2 pos)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0039: Unknown result type (might be due to invalid IL or missing references)
return new float2((float)(Mathf.FloorToInt(pos.x * 2f) + 6400), (float)(Mathf.FloorToInt(pos.y * 2f) + 6400));
}
public static float3 ConvertPosToTileGrid(float3 pos)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: 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)
return new float3((float)(Mathf.FloorToInt(pos.x * 2f) + 6400), pos.y, (float)(Mathf.FloorToInt(pos.z * 2f) + 6400));
}
}
}
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_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_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_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_0061: 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_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
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_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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: 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_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_0055: 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_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: 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_0082: 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)
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.IsNull(current) || !ECSExtensions.Exists(current))
{
continue;
}
UseEmoteEvent val2 = ECSExtensions.Read<UseEmoteEvent>(current);
FromCharacter val3 = ECSExtensions.Read<FromCharacter>(current);
PrefabGUID action = val2.Action;
User val4 = ECSExtensions.Read<User>(val3.User);
ulong platformId = val4.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((object)("Error in EmoteSystemPatch: " + ex.Message));
}
finally
{
val.Dispose();
}
}
}
}
namespace ScarletCarrier.Models
{
internal class Carrier
{
private const float MaxSpawnDistance = 3f;
private const float MaxTeleportDistance = 15f;
public const float Height = 221f;
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 Call()
{
//IL_0029: 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_0047: 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_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_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
if (!Busy)
{
SetAsBusy();
ActionScheduler.Delayed((Action)delegate
{
Busy = false;
}, BusyDuration);
SetName(Owner.Name);
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, 221f, 0f);
Entity characterEntity = Owner.CharacterEntity;
CoffinEntity = UnitSpawnerService.ImmediateSpawn(coffinPrefab, val, 1f, 1f, (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);
}
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 = UnitSpawnerService.ImmediateSpawn(servantAppearance, position, 1f, 1f, (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_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_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0063: 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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
if (ECSExtensions.IsNull(ServantEntity) || !ECSExtensions.Exists(ServantEntity))
{
Log.Error((object)"Current servant entity is invalid.");
return;
}
StopFollow();
PrefabGUID servantAppearance = GetServantAppearance();
float3 oldServantPosition = ECSExtensions.Position(ServantEntity);
float3 val = oldServantPosition;
Entity characterEntity = Owner.CharacterEntity;
Entity newServant = UnitSpawnerService.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, 221f, 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_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_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_005e: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
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)
//IL_0061: 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_006f: 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_0084: 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 val = ((num <= 3f) ? aimPosition : (position + MathUtility.GetDirection(position, aimPosition) * 3f));
val.y = position.y;
TeleportService.TeleportToPosition(ServantEntity, val, true);
TeleportService.TeleportToPosition(CoffinEntity, val + new float3(0f, 221f, 0f), true);
}
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)
Entity @null = Entity.Null;
if (!((Entity)(ref @null)).Equals(ServantEntity) && ECSExtensions.Exists(ServantEntity))
{
TeleportService.TeleportToPosition(ServantEntity, position, 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_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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_0114: 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)
{
TeleportService.TeleportToPosition(ServantEntity, lastValidPosition, true);
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);
});
}
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_0025: Unknown result type (might be due to invalid IL or missing references)
if (_selectedActions.ContainsKey(playerData))
{
ActionScheduler.CancelAction(_selectedActions[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("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."));
}
}
}