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 CastleLink.Services;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Network;
using ProjectM.Scripting;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Geckuss")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Share resources across all the castles a player owns: right-click a station recipe to pull its materials from your other castles, and use chat commands to gather/deposit resources between castles.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bb24d1a1a1f9d070450dee60ed4966e7857c57e5")]
[assembly: AssemblyProduct("CastleLink")]
[assembly: AssemblyTitle("CastleLink")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CastleLink
{
internal static class Core
{
public static ManualLogSource Log { get; set; }
public static World Server { get; private set; }
public static EntityManager EntityManager { get; private set; }
public static ServerGameManager ServerGameManager => Server.GetExistingSystemManaged<ServerScriptMapper>().GetServerGameManager();
public static PrefabCollectionSystem PrefabCollectionSystem { get; private set; }
public static GameDataSystem GameDataSystem { get; private set; }
public static bool Initialized { get; private set; }
public static void Initialize()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (!Initialized)
{
Server = GetServerWorld() ?? throw new Exception("CastleLink: server World not found");
EntityManager = Server.EntityManager;
PrefabCollectionSystem = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
GameDataSystem = Server.GetExistingSystemManaged<GameDataSystem>();
Initialized = true;
ManualLogSource log = Log;
if (log != null)
{
log.LogInfo((object)"CastleLink Core initialized (server world resolved).");
}
}
}
private static World GetServerWorld()
{
Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
while (enumerator.MoveNext())
{
World current = enumerator.Current;
if (current.Name == "Server")
{
return current;
}
}
return null;
}
}
[BepInPlugin("CastleLink", "CastleLink", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private Harmony _harmony;
public override void Load()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Expected O, but got Unknown
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>("CastleLink");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
Core.Log = ((BasePlugin)this).Log;
_harmony = new Harmony("CastleLink");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
CommandRegistry.RegisterAll();
}
public override bool Unload()
{
CommandRegistry.UnregisterAssembly();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "CastleLink";
public const string PLUGIN_NAME = "CastleLink";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace CastleLink.Services
{
internal static class OwnerCastleService
{
private const double CacheTtlSeconds = 5.0;
private static double _lastBuild = double.NegativeInfinity;
private static readonly Dictionary<ulong, List<Entity>> _heartsByOwner = new Dictionary<ulong, List<Entity>>();
private static EntityManager EM => Core.EntityManager;
public static List<Entity> GetOtherHeartsOwnedBy(ulong platformId, Entity excludeHeart)
{
//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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_003f: 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_0050: Unknown result type (might be due to invalid IL or missing references)
EnsureFresh();
List<Entity> list = new List<Entity>();
if (!_heartsByOwner.TryGetValue(platformId, out var value))
{
return list;
}
foreach (Entity item in value)
{
if (!(item == excludeHeart))
{
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(item) && !IsRaided(item))
{
list.Add(item);
}
}
}
return list;
}
public static ulong GetOwnerPlatformId(Entity heart)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_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_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)
//IL_002b: 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_0037: 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_0044: 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_004c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(heart))
{
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<CastleHeart>(heart))
{
eM = EM;
Entity castleTerritoryEntity = ((EntityManager)(ref eM)).GetComponentData<CastleHeart>(heart).CastleTerritoryEntity;
if (!(castleTerritoryEntity == Entity.Null))
{
eM = EM;
if (((EntityManager)(ref eM)).Exists(castleTerritoryEntity))
{
EntityManager eM2 = EM;
return GetTerritoryOwnerRequestSystem.GetPlatformId(ref eM2, castleTerritoryEntity);
}
}
return 0uL;
}
}
return 0uL;
}
public static Entity GetHeartOf(Entity target)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0020: 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_0018: 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_002e: 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_0034: 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_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_004a: 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_0052: Unknown result type (might be due to invalid IL or missing references)
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(target))
{
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<CastleHeartConnection>(target))
{
eM = EM;
CastleHeartConnection componentData = ((EntityManager)(ref eM)).GetComponentData<CastleHeartConnection>(target);
Entity entityOnServer = ((NetworkedEntity)(ref componentData.CastleHeartEntity)).GetEntityOnServer();
eM = EM;
if (!((EntityManager)(ref eM)).Exists(entityOnServer))
{
return Entity.Null;
}
return entityOnServer;
}
}
return Entity.Null;
}
public static ulong GetOwnerPlatformIdFromTarget(Entity target)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_001b: 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_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_0072: 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_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_002b: 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_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_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_005f: 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)
EntityManager eM = EM;
if (!((EntityManager)(ref eM)).Exists(target))
{
return 0uL;
}
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<PlayerCharacter>(target))
{
eM = EM;
Entity userEntity = ((EntityManager)(ref eM)).GetComponentData<PlayerCharacter>(target).UserEntity;
eM = EM;
if (((EntityManager)(ref eM)).Exists(userEntity))
{
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<User>(userEntity))
{
eM = EM;
return ((EntityManager)(ref eM)).GetComponentData<User>(userEntity).PlatformId;
}
}
}
Entity heartOf = GetHeartOf(target);
if (!(heartOf != Entity.Null))
{
return 0uL;
}
return GetOwnerPlatformId(heartOf);
}
public static Entity GetHeartAtTile(int2 tile)
{
//IL_0108: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0080: 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_0089: 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_009b: 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_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_00b4: 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_00bb: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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)
EnsureFresh();
foreach (KeyValuePair<ulong, List<Entity>> item in _heartsByOwner)
{
foreach (Entity item2 in item.Value)
{
EntityManager eM = EM;
if (!((EntityManager)(ref eM)).Exists(item2))
{
continue;
}
eM = EM;
if (!((EntityManager)(ref eM)).HasComponent<CastleHeart>(item2))
{
continue;
}
eM = EM;
Entity castleTerritoryEntity = ((EntityManager)(ref eM)).GetComponentData<CastleHeart>(item2).CastleTerritoryEntity;
if (castleTerritoryEntity == Entity.Null)
{
continue;
}
eM = EM;
if (!((EntityManager)(ref eM)).Exists(castleTerritoryEntity))
{
continue;
}
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<CastleTerritory>(castleTerritoryEntity))
{
eM = EM;
CastleTerritory componentData = ((EntityManager)(ref eM)).GetComponentData<CastleTerritory>(castleTerritoryEntity);
EntityManager eM2 = EM;
Entity val = castleTerritoryEntity;
if (CastleTerritoryExtensions.IsTileInTerritory(eM2, tile, ref val, ref componentData))
{
return item2;
}
}
}
}
return Entity.Null;
}
public static List<Entity> GetSiblingHeartsForTarget(Entity target)
{
//IL_0000: 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_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_001e: 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_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_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_003b: 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_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_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)
ulong ownerPlatformIdFromTarget = GetOwnerPlatformIdFromTarget(target);
if (ownerPlatformIdFromTarget == 0L)
{
return new List<Entity>();
}
Entity excludeHeart = Entity.Null;
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(target))
{
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<TilePosition>(target))
{
eM = EM;
excludeHeart = GetHeartAtTile(((EntityManager)(ref eM)).GetComponentData<TilePosition>(target).Tile);
}
}
return GetOtherHeartsOwnedBy(ownerPlatformIdFromTarget, excludeHeart);
}
public static Entity GetCurrentHeart(Entity character)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0020: 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_0018: 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_002e: 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_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)
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(character))
{
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<TilePosition>(character))
{
eM = EM;
return GetHeartAtTile(((EntityManager)(ref eM)).GetComponentData<TilePosition>(character).Tile);
}
}
return Entity.Null;
}
private static bool IsRaided(Entity heart)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_0026: Invalid comparison between Unknown and I4
EntityManager eM = EM;
if (!((EntityManager)(ref eM)).HasComponent<CastleHeart>(heart))
{
return true;
}
eM = EM;
return (int)((EntityManager)(ref eM)).GetComponentData<CastleHeart>(heart).ActiveEvent >= 2;
}
private static void EnsureFresh()
{
double realtimeSinceStartupAsDouble = Time.realtimeSinceStartupAsDouble;
if (!(realtimeSinceStartupAsDouble - _lastBuild < 5.0) || _heartsByOwner.Count <= 0)
{
Rebuild();
_lastBuild = realtimeSinceStartupAsDouble;
}
}
private static void Rebuild()
{
//IL_000a: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_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_003a: 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_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
_heartsByOwner.Clear();
EntityManager eM = EM;
EntityQuery val = ((EntityManager)(ref eM)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly<CastleHeart>() });
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
Enumerator<Entity> enumerator = val2.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
ulong ownerPlatformId = GetOwnerPlatformId(current);
if (ownerPlatformId != 0L)
{
if (!_heartsByOwner.TryGetValue(ownerPlatformId, out var value))
{
value = new List<Entity>();
_heartsByOwner[ownerPlatformId] = value;
}
value.Add(current);
}
}
}
finally
{
val2.Dispose();
}
}
}
internal static class StashService
{
private static EntityManager EM => Core.EntityManager;
private static ServerGameManager SGM => Core.ServerGameManager;
public static List<Entity> GetStashes(Entity heart)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
List<Entity> list = new List<Entity>();
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(heart))
{
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<SharedCastleInventoryConnection>(heart))
{
eM = EM;
SharedCastleInventoryConnection componentData = ((EntityManager)(ref eM)).GetComponentData<SharedCastleInventoryConnection>(heart);
Entity entityOnServer = ((NetworkedEntity)(ref componentData.SharedInventoryManager)).GetEntityOnServer();
eM = EM;
if (((EntityManager)(ref eM)).Exists(entityOnServer))
{
eM = EM;
if (((EntityManager)(ref eM)).HasBuffer<SharedCastleInventories>(entityOnServer))
{
eM = EM;
DynamicBuffer<SharedCastleInventories> buffer = ((EntityManager)(ref eM)).GetBuffer<SharedCastleInventories>(entityOnServer, false);
for (int i = 0; i < buffer.Length; i++)
{
Entity inventorySource = buffer[i].InventorySource;
eM = EM;
if (((EntityManager)(ref eM)).Exists(inventorySource))
{
list.Add(inventorySource);
}
}
return list;
}
}
return list;
}
}
return list;
}
public static bool TryGetInventory(Entity stash, out Entity inventory)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
inventory = stash;
EntityManager eM;
try
{
Entity val = default(Entity);
if (InventoryUtilities.TryGetInventoryEntity<EntityManager>(EM, stash, ref val, 0))
{
eM = EM;
if (((EntityManager)(ref eM)).Exists(val))
{
inventory = val;
return true;
}
}
}
catch
{
}
eM = EM;
return ((EntityManager)(ref eM)).Exists(stash);
}
public static int GetMaxStack(PrefabGUID item, int fallback = 1000)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: 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_002d: Unknown result type (might be due to invalid IL or missing references)
try
{
NativeParallelHashMap<PrefabGUID, ItemData> itemHashLookupMap = Core.GameDataSystem.ItemHashLookupMap;
if (!itemHashLookupMap.IsCreated)
{
return fallback;
}
ItemData val = default(ItemData);
if (itemHashLookupMap.TryGetValue(item, ref val) && val.MaxAmount > 0)
{
return val.MaxAmount;
}
}
catch
{
}
return fallback;
}
public static ItemCategory GetItemCategory(PrefabGUID item)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: 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_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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)
try
{
NativeParallelHashMap<PrefabGUID, ItemData> itemHashLookupMap = Core.GameDataSystem.ItemHashLookupMap;
if (!itemHashLookupMap.IsCreated)
{
return (ItemCategory)0;
}
ItemData val = default(ItemData);
if (itemHashLookupMap.TryGetValue(item, ref val))
{
return val.ItemCategory;
}
}
catch
{
}
return (ItemCategory)0;
}
public static bool IsRestrictedStash(Entity stash)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_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_001c: 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_0023: 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_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)
try
{
EntityManager eM = EM;
if (!((EntityManager)(ref eM)).HasBuffer<InventoryInstanceElement>(stash))
{
return false;
}
eM = EM;
DynamicBuffer<InventoryInstanceElement> buffer = ((EntityManager)(ref eM)).GetBuffer<InventoryInstanceElement>(stash, false);
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i].RestrictedCategory != 0L)
{
return true;
}
InventoryInstanceElement val = buffer[i];
if (((PrefabGUID)(ref val.RestrictedType)).GuidHash != 0)
{
return true;
}
}
}
catch
{
}
return false;
}
public static List<Entity> GetRestrictedStashes(Entity heart)
{
//IL_0006: 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_001c: 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)
List<Entity> list = new List<Entity>();
foreach (Entity stash in GetStashes(heart))
{
if (IsRestrictedStash(stash))
{
list.Add(stash);
}
}
return list;
}
public static int DepositIntoRestrictedBox(Entity heart, PrefabGUID item, int amount)
{
//IL_0002: 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_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_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_002b: 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_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_003e: 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_009a: 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)
int num = 0;
List<Entity> restrictedStashes = GetRestrictedStashes(heart);
ServerGameManager sGM;
foreach (Entity item2 in restrictedStashes)
{
if (num >= amount)
{
break;
}
int inventoryItemCount;
try
{
sGM = SGM;
inventoryItemCount = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(item2, item);
}
catch
{
continue;
}
if (inventoryItemCount > 0)
{
num += TryDeposit(item2, item, amount - num);
}
}
foreach (Entity item3 in restrictedStashes)
{
if (num >= amount)
{
break;
}
int inventoryItemCount2;
try
{
sGM = SGM;
inventoryItemCount2 = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(item3, item);
}
catch
{
continue;
}
if (inventoryItemCount2 <= 0)
{
num += TryDeposit(item3, item, amount - num);
}
}
return num;
}
public static Dictionary<int, PrefabGUID> GetStoredItemTypes(Entity heart)
{
//IL_0006: 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_0024: 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_002d: 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_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_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_0059: 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)
Dictionary<int, PrefabGUID> dictionary = new Dictionary<int, PrefabGUID>();
foreach (Entity stash in GetStashes(heart))
{
if (!TryGetInventory(stash, out var inventory))
{
continue;
}
EntityManager eM = EM;
if (!((EntityManager)(ref eM)).HasBuffer<InventoryBuffer>(inventory))
{
continue;
}
eM = EM;
DynamicBuffer<InventoryBuffer> buffer = ((EntityManager)(ref eM)).GetBuffer<InventoryBuffer>(inventory, false);
for (int i = 0; i < buffer.Length; i++)
{
PrefabGUID itemType = buffer[i].ItemType;
if (((PrefabGUID)(ref itemType)).GuidHash != 0)
{
dictionary[((PrefabGUID)(ref itemType)).GuidHash] = itemType;
}
}
}
return dictionary;
}
public static int CountItemInCastle(Entity heart, PrefabGUID item)
{
//IL_0002: 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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: 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)
int num = 0;
foreach (Entity stash in GetStashes(heart))
{
int num2 = num;
ServerGameManager sGM = SGM;
num = num2 + ((ServerGameManager)(ref sGM)).GetInventoryItemCount(stash, item);
}
return num;
}
public static int RemoveItemFromCastle(Entity heart, PrefabGUID item, int amount)
{
//IL_0002: 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_0017: 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_002b: 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_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_004f: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
foreach (Entity stash in GetStashes(heart))
{
if (num >= amount)
{
break;
}
int num2 = amount - num;
ServerGameManager sGM = SGM;
int inventoryItemCount = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(stash, item);
if (inventoryItemCount > 0)
{
int num3 = ((inventoryItemCount < num2) ? inventoryItemCount : num2);
sGM = SGM;
if (((ServerGameManager)(ref sGM)).TryRemoveInventoryItem(stash, item, num3))
{
num += num3;
}
}
}
return num;
}
public static void ReturnItemToCastle(Entity heart, PrefabGUID item, int amount)
{
//IL_0000: 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_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_0024: 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_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_003b: Unknown result type (might be due to invalid IL or missing references)
foreach (Entity stash in GetStashes(heart))
{
if (amount <= 0)
{
break;
}
ServerGameManager sGM = SGM;
AddItemResponse val = ((ServerGameManager)(ref sGM)).TryAddInventoryItem(stash, item, amount);
if (((AddItemResponse)(ref val)).Success)
{
amount = 0;
break;
}
amount = val.RemainingAmount;
}
}
public static int DepositIntoMatchingChest(Entity heart, PrefabGUID item, int amount)
{
//IL_0002: 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_000e: 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_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0080: 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_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_0095: 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)
int num = 0;
List<Entity> stashes = GetStashes(heart);
ServerGameManager sGM = SGM;
foreach (Entity item2 in stashes)
{
if (num >= amount)
{
break;
}
int inventoryItemCount;
try
{
inventoryItemCount = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(item2, item);
}
catch
{
continue;
}
if (inventoryItemCount > 0)
{
num += TryDeposit(item2, item, amount - num);
}
}
foreach (Entity item3 in stashes)
{
if (num >= amount)
{
break;
}
int inventoryItemCount2;
try
{
inventoryItemCount2 = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(item3, item);
}
catch
{
continue;
}
if (inventoryItemCount2 <= 0)
{
num += TryDeposit(item3, item, amount - num);
}
}
return num;
}
private static int TryDeposit(Entity stash, PrefabGUID item, int want)
{
//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_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
if (want <= 0)
{
return 0;
}
try
{
ServerGameManager sGM = SGM;
AddItemResponse val = ((ServerGameManager)(ref sGM)).TryAddInventoryItem(stash, item, want);
if (((AddItemResponse)(ref val)).Success)
{
return want;
}
return want - val.RemainingAmount;
}
catch
{
return 0;
}
}
}
}
namespace CastleLink.Patches
{
[HarmonyPatch(typeof(StopCraftingSystem), "OnUpdate")]
internal static class CraftPullPatch
{
private static EntityManager EM => Core.EntityManager;
private static ServerGameManager SGM => Core.ServerGameManager;
private static void Prefix(StopCraftingSystem __instance)
{
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Expected O, but got Unknown
//IL_000a: 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_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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//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_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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_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_006d: 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_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_007e: 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)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: 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_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00b4: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: 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)
if (!Core.Initialized)
{
return;
}
NativeArray<Entity> val;
try
{
EntityQuery eventQuery = __instance._EventQuery;
val = ((EntityQuery)(ref eventQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
}
catch
{
return;
}
try
{
Enumerator<Entity> enumerator = val.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
EntityManager eM = EM;
if (!((EntityManager)(ref eM)).HasComponent<StopCraftItemEvent>(current))
{
continue;
}
eM = EM;
if (!((EntityManager)(ref eM)).HasComponent<FromCharacter>(current))
{
continue;
}
eM = EM;
StopCraftItemEvent componentData = ((EntityManager)(ref eM)).GetComponentData<StopCraftItemEvent>(current);
eM = EM;
Entity character = ((EntityManager)(ref eM)).GetComponentData<FromCharacter>(current).Character;
eM = EM;
if (!((EntityManager)(ref eM)).Exists(character))
{
continue;
}
eM = EM;
if (((EntityManager)(ref eM)).HasComponent<Interactor>(character))
{
eM = EM;
Entity target = ((EntityManager)(ref eM)).GetComponentData<Interactor>(character).Target;
eM = EM;
if (((EntityManager)(ref eM)).Exists(target))
{
TryPullForRecipe(character, target, componentData.RecipeGuid);
}
}
}
}
catch (Exception ex)
{
ManualLogSource log = Core.Log;
if (log != null)
{
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(28, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("CastleLink CraftPull error: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
log.LogError(val2);
}
}
finally
{
val.Dispose();
}
}
private static void TryPullForRecipe(Entity character, Entity station, PrefabGUID recipeGuid)
{
//IL_0000: 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_001d: 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_0031: 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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: 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_005c: 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_006a: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00d1: 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_00f6: 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_0104: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: 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_0120: 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_0129: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: 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)
List<Entity> siblingHeartsForTarget = OwnerCastleService.GetSiblingHeartsForTarget(character);
Entity val = default(Entity);
if (siblingHeartsForTarget.Count == 0 || !Core.PrefabCollectionSystem._PrefabGuidToEntityMap.TryGetValue(recipeGuid, ref val))
{
return;
}
EntityManager eM = EM;
Entity val2 = default(Entity);
if (!((EntityManager)(ref eM)).HasBuffer<RecipeRequirementBuffer>(val) || !InventoryUtilities.TryGetInventoryEntity<EntityManager>(EM, character, ref val2, 0))
{
return;
}
eM = EM;
if (!((EntityManager)(ref eM)).Exists(val2))
{
return;
}
TryGetStationInventory(station, out var inventory);
eM = EM;
DynamicBuffer<RecipeRequirementBuffer> buffer = ((EntityManager)(ref eM)).GetBuffer<RecipeRequirementBuffer>(val, false);
for (int i = 0; i < buffer.Length; i++)
{
RecipeRequirementBuffer val3 = buffer[i];
PrefabGUID guid = val3.Guid;
int amount = val3.Amount;
if (amount <= 0)
{
continue;
}
eM = EM;
int num;
ServerGameManager sGM;
if (!((EntityManager)(ref eM)).Exists(inventory))
{
num = 0;
}
else
{
sGM = SGM;
num = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(inventory, guid);
}
int num2 = num;
sGM = SGM;
int inventoryItemCount = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(val2, guid);
int num3 = amount - (num2 + inventoryItemCount);
if (num3 <= 0)
{
continue;
}
foreach (Entity item in siblingHeartsForTarget)
{
if (num3 <= 0)
{
break;
}
int num4 = StashService.RemoveItemFromCastle(item, guid, num3);
if (num4 > 0)
{
sGM = SGM;
AddItemResponse val4 = ((ServerGameManager)(ref sGM)).TryAddInventoryItem(val2, guid, num4);
if (((AddItemResponse)(ref val4)).Success)
{
num3 -= num4;
}
else
{
StashService.ReturnItemToCastle(item, guid, num4);
}
}
}
}
}
private static bool TryGetStationInventory(Entity station, out Entity inventory)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: 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_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_0032: 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_000f: 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_0018: Unknown result type (might be due to invalid IL or missing references)
EntityManager eM;
if (InventoryUtilities.TryGetInventoryEntity<EntityManager>(EM, station, ref inventory, 0))
{
eM = EM;
if (((EntityManager)(ref eM)).Exists(inventory))
{
return true;
}
}
inventory = station;
eM = EM;
return ((EntityManager)(ref eM)).Exists(station);
}
}
[HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), "OnUpdate")]
internal static class InitializationPatch
{
[HarmonyPostfix]
private static void Postfix()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
if (Core.Initialized)
{
return;
}
try
{
Core.Initialize();
}
catch (Exception ex)
{
ManualLogSource log = Core.Log;
if (log != null)
{
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(35, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("CastleLink Core.Initialize failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
log.LogError(val);
}
}
}
}
}
namespace CastleLink.Commands
{
internal static class CastleLinkCommands
{
private static readonly Dictionary<string, ItemCategory> CategoryGroups = new Dictionary<string, ItemCategory>(StringComparer.OrdinalIgnoreCase)
{
["armor"] = (ItemCategory)2,
["weapons"] = (ItemCategory)1,
["weapon"] = (ItemCategory)1,
["gear"] = (ItemCategory)8650755,
["herbs"] = (ItemCategory)131088,
["materials"] = (ItemCategory)251658336,
["jewels"] = (ItemCategory)8388612,
["consumables"] = (ItemCategory)536936448,
["fish"] = (ItemCategory)1048576,
["coins"] = (ItemCategory)33792,
["gems"] = (ItemCategory)4,
["blood"] = (ItemCategory)536879232,
["soulshards"] = (ItemCategory)1073741824,
["relics"] = (ItemCategory)16384,
["bags"] = (ItemCategory)262144,
["saddles"] = (ItemCategory)524288,
["stables"] = (ItemCategory)3145728,
["magic"] = (ItemCategory)268435456,
["lumber"] = (ItemCategory)134217760,
["stone"] = (ItemCategory)64,
["minerals"] = (ItemCategory)67108864,
["alchemy"] = (ItemCategory)16777216,
["tailoring"] = (ItemCategory)33554432,
["flowers"] = (ItemCategory)16,
["everything"] = (ItemCategory)(-1)
};
private static EntityManager EM => Core.EntityManager;
private static ServerGameManager SGM => Core.ServerGameManager;
[Command("clhelp", "clh", null, "List all CastleLink commands.", null, false)]
public static void Help(ChatCommandContext ctx)
{
ctx.Reply("CastleLink — share resources across your castles:");
ctx.Reply(".wolt (.all) — top up THIS castle's storage boxes to one stack of each storable item, from your other castles.");
ctx.Reply(".pull — top up items you already carry to one full stack (storable items only).");
ctx.Reply(".pull <guid> <amount> — pull a specific item by PrefabGUID hash.");
ctx.Reply(".pullcat (.pc) <category> — pull all items of a category (other castles first, then current).");
ctx.Reply(".deposit (.dep) — deposit inventory into this castle's dedicated boxes (leaves armor/weapons).");
ctx.Reply("Categories: " + string.Join(", ", CategoryGroups.Keys));
ctx.Reply("Crafting: right-click a recipe at a station to pull its materials from your other castles.");
}
[Command("pull", null, null, "Pull resources from your other castles into your inventory (fills until inventory is full).", null, false)]
public static void Pull(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_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_0040: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: 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_00aa: 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_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity;
List<Entity> siblingHeartsForTarget = OwnerCastleService.GetSiblingHeartsForTarget(senderCharacterEntity);
if (siblingHeartsForTarget.Count == 0)
{
ctx.Reply("No other castles found to pull from.");
return;
}
Entity val = default(Entity);
if (InventoryUtilities.TryGetInventoryEntity<EntityManager>(EM, senderCharacterEntity, ref val, 0))
{
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(val))
{
Dictionary<int, PrefabGUID> dictionary = new Dictionary<int, PrefabGUID>();
foreach (Entity item in siblingHeartsForTarget)
{
foreach (Entity restrictedStash in StashService.GetRestrictedStashes(item))
{
if (!StashService.TryGetInventory(restrictedStash, out var inventory))
{
continue;
}
eM = EM;
if (!((EntityManager)(ref eM)).HasBuffer<InventoryBuffer>(inventory))
{
continue;
}
eM = EM;
DynamicBuffer<InventoryBuffer> buffer = ((EntityManager)(ref eM)).GetBuffer<InventoryBuffer>(inventory, false);
for (int i = 0; i < buffer.Length; i++)
{
PrefabGUID itemType = buffer[i].ItemType;
if (((PrefabGUID)(ref itemType)).GuidHash != 0)
{
dictionary[((PrefabGUID)(ref itemType)).GuidHash] = itemType;
}
}
}
}
int num = 0;
foreach (KeyValuePair<int, PrefabGUID> item2 in dictionary)
{
PrefabGUID value = item2.Value;
ServerGameManager sGM = SGM;
int inventoryItemCount = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(val, value);
if (inventoryItemCount > 0)
{
int num2 = StashService.GetMaxStack(value) - inventoryItemCount;
if (num2 > 0)
{
num += PullItem(siblingHeartsForTarget, val, value, num2);
}
}
}
ctx.Reply((num > 0) ? $"Topped up {num} items into your inventory (one stack each)." : "Nothing to top up (you already have full stacks, or other castles are empty).");
return;
}
}
ctx.Reply("Could not access your inventory.");
}
[Command("pullcat", "pc", null, "Pull all items of a category from your other castles into your inventory. Categories: armor, weapons, gear, herbs, materials, jewels, consumables, fish, silver.", null, false)]
public static void PullCategory(ChatCommandContext ctx, string category)
{
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: 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_00c5: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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_0119: 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_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
if (!CategoryGroups.TryGetValue(category, out var value))
{
ctx.Reply($"Unknown category '{category}'. Options: {string.Join(", ", CategoryGroups.Keys)}.");
return;
}
Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity;
List<Entity> siblingHeartsForTarget = OwnerCastleService.GetSiblingHeartsForTarget(senderCharacterEntity);
Entity currentHeart = OwnerCastleService.GetCurrentHeart(senderCharacterEntity);
List<Entity> list = new List<Entity>(siblingHeartsForTarget);
if (currentHeart != Entity.Null)
{
list.Add(currentHeart);
}
if (list.Count == 0)
{
ctx.Reply("No castles found to pull from.");
return;
}
Entity val = default(Entity);
if (InventoryUtilities.TryGetInventoryEntity<EntityManager>(EM, senderCharacterEntity, ref val, 0))
{
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(val))
{
Dictionary<int, PrefabGUID> dictionary = new Dictionary<int, PrefabGUID>();
foreach (Entity item in list)
{
foreach (KeyValuePair<int, PrefabGUID> storedItemType in StashService.GetStoredItemTypes(item))
{
if ((StashService.GetItemCategory(storedItemType.Value) & value) != 0)
{
dictionary[storedItemType.Key] = storedItemType.Value;
}
}
}
int num = 0;
foreach (KeyValuePair<int, PrefabGUID> item2 in dictionary)
{
num += PullItem(list, val, item2.Value, int.MaxValue);
}
ctx.Reply((num > 0) ? $"Pulled {num} {category} items into your inventory." : ("Nothing to pull for '" + category + "' (none found, or inventory full)."));
return;
}
}
ctx.Reply("Could not access your inventory.");
}
[Command("pull", null, null, "Pull a specific amount of an item (by PrefabGUID hash) into your inventory.", null, false)]
public static void PullSpecific(ChatCommandContext ctx, int prefabGuid, int amount)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_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_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)
Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity;
List<Entity> siblingHeartsForTarget = OwnerCastleService.GetSiblingHeartsForTarget(senderCharacterEntity);
if (siblingHeartsForTarget.Count == 0)
{
ctx.Reply("No other castles found to pull from.");
return;
}
Entity val = default(Entity);
if (InventoryUtilities.TryGetInventoryEntity<EntityManager>(EM, senderCharacterEntity, ref val, 0))
{
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(val))
{
int num = PullItem(siblingHeartsForTarget, val, new PrefabGUID(prefabGuid), amount);
ctx.Reply((num > 0) ? $"Pulled {num}x item {prefabGuid}." : "Nothing pulled (not found in other castles, or inventory full).");
return;
}
}
ctx.Reply("Could not access your inventory.");
}
[Command("deposit", "dep", null, "Deposit inventory items into this castle's dedicated storage boxes (materials/herbs/etc.; leaves armor/weapons).", null, false)]
public static void Deposit(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_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_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_0045: 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_0068: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: 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_0101: 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_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity;
Entity currentHeart = OwnerCastleService.GetCurrentHeart(senderCharacterEntity);
if (currentHeart == Entity.Null)
{
ctx.Reply("You must be standing in one of your castles.");
return;
}
Entity val = default(Entity);
if (InventoryUtilities.TryGetInventoryEntity<EntityManager>(EM, senderCharacterEntity, ref val, 0))
{
EntityManager eM = EM;
if (((EntityManager)(ref eM)).Exists(val))
{
Dictionary<int, PrefabGUID> dictionary = new Dictionary<int, PrefabGUID>();
eM = EM;
DynamicBuffer<InventoryBuffer> buffer = ((EntityManager)(ref eM)).GetBuffer<InventoryBuffer>(val, false);
for (int i = 0; i < buffer.Length; i++)
{
InventoryBuffer val2 = buffer[i];
if (((PrefabGUID)(ref val2.ItemType)).GuidHash != 0)
{
dictionary[((PrefabGUID)(ref val2.ItemType)).GuidHash] = val2.ItemType;
}
}
int num = 0;
foreach (KeyValuePair<int, PrefabGUID> item in dictionary)
{
PrefabGUID value = item.Value;
ServerGameManager sGM = SGM;
int inventoryItemCount = ((ServerGameManager)(ref sGM)).GetInventoryItemCount(val, value);
if (inventoryItemCount > 0)
{
int num2 = StashService.DepositIntoRestrictedBox(currentHeart, value, inventoryItemCount);
if (num2 > 0)
{
sGM = SGM;
((ServerGameManager)(ref sGM)).TryRemoveInventoryItem(val, value, num2);
num += num2;
}
}
}
ctx.Reply((num > 0) ? $"Deposited {num} items into this castle's chests." : "Nothing deposited (no matching chests for your items).");
return;
}
}
ctx.Reply("Could not access your inventory.");
}
[Command("wolt", "all", null, "Pull storable resources from your other castles straight into this castle's storage boxes (one stack each).", null, false)]
public static void Wolt(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: 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_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00e9: 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_0109: 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_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: 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_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity;
Entity currentHeart = OwnerCastleService.GetCurrentHeart(senderCharacterEntity);
if (currentHeart == Entity.Null)
{
ctx.Reply("You must be standing in one of your castles.");
return;
}
List<Entity> siblingHeartsForTarget = OwnerCastleService.GetSiblingHeartsForTarget(senderCharacterEntity);
if (siblingHeartsForTarget.Count == 0)
{
ctx.Reply("No other castles found to pull from.");
return;
}
Dictionary<int, PrefabGUID> dictionary = new Dictionary<int, PrefabGUID>();
foreach (Entity item in siblingHeartsForTarget)
{
foreach (KeyValuePair<int, PrefabGUID> storedItemType in StashService.GetStoredItemTypes(item))
{
dictionary[storedItemType.Key] = storedItemType.Value;
}
}
int num = 0;
foreach (KeyValuePair<int, PrefabGUID> item2 in dictionary)
{
PrefabGUID value = item2.Value;
int maxStack = StashService.GetMaxStack(value);
int num2 = StashService.CountItemInCastle(currentHeart, value);
int num3 = maxStack - num2;
if (num3 <= 0)
{
continue;
}
foreach (Entity item3 in siblingHeartsForTarget)
{
if (num3 <= 0)
{
break;
}
int num4 = StashService.RemoveItemFromCastle(item3, value, num3);
if (num4 > 0)
{
int num5 = StashService.DepositIntoRestrictedBox(currentHeart, value, num4);
num += num5;
num3 -= num5;
int num6 = num4 - num5;
if (num6 > 0)
{
StashService.ReturnItemToCastle(item3, value, num6);
}
}
}
}
ctx.Reply((num > 0) ? $"Topped up {num} items into this castle's storage boxes (one stack each)." : "Nothing to top up (storage already full, or no storable resources in other castles).");
}
private static int PullItem(List<Entity> siblings, Entity inventory, PrefabGUID item, int amount)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_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_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_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_0052: 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_006b: 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_006d: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
foreach (Entity sibling in siblings)
{
if (num >= amount)
{
break;
}
int amount2 = amount - num;
int num2 = StashService.RemoveItemFromCastle(sibling, item, amount2);
if (num2 <= 0)
{
continue;
}
ServerGameManager sGM = SGM;
AddItemResponse val = ((ServerGameManager)(ref sGM)).TryAddInventoryItem(inventory, item, num2);
if (((AddItemResponse)(ref val)).Success)
{
num += num2;
continue;
}
int num3 = num2 - val.RemainingAmount;
num += num3;
if (val.RemainingAmount > 0)
{
StashService.ReturnItemToCastle(sibling, item, val.RemainingAmount);
}
break;
}
return num;
}
}
}