using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.Json;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using HarmonyLib;
using HookDOTS.API;
using HookDOTS.API.Attributes;
using Il2CppInterop.Runtime;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using KindredLogistics;
using KindredLogistics.Commands.Converters;
using KindredLogistics.Services;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.CastleBuilding.Rebuilding;
using ProjectM.Gameplay.Systems;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using ProjectM.Shared;
using ProjectM.Shared.Systems;
using ProjectM.Terrain;
using Stunlock.Core;
using Stunlock.Localization;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Scenes;
using Unity.Transforms;
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("KindredLogistics")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Inventory management mod. Stashing, craftpulling, finding chests, etc")]
[assembly: AssemblyFileVersion("1.6.1.0")]
[assembly: AssemblyInformationalVersion("1.6.0+0.Branch.main.Sha.62bb8fcf39ee2ebe62410e48ec8f8fdc72e85b10.c8efc0a685b45c3cfa2d1a91f83175a6371fd90b")]
[assembly: AssemblyProduct("KindredLogistics")]
[assembly: AssemblyTitle("KindredLogistics")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.1.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;
}
}
}
internal class TrashService
{
private bool CanEmptyTrash(Entity charEntity, out int territoryIndex)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//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_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_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_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_0086: 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_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_00ac: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_00da: 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_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_00f5: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Invalid comparison between Unknown and I4
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
User user = charEntity.Read<PlayerCharacter>().UserEntity.Read<User>();
territoryIndex = Core.TerritoryService.GetTerritoryId(charEntity);
if (Core.PlayerSettings.IsTrashEnabled())
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Trash is globally disabled.");
return false;
}
if (territoryIndex == -1)
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Unable to empty trash outside territories!");
return false;
}
PrefabGUID val = default(PrefabGUID);
((PrefabGUID)(ref val))..ctor(-1992158531);
Entity val2 = default(Entity);
if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, charEntity, PrefabIdentifier.op_Implicit(val), ref val2))
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Unable to empty trash while downed!");
return false;
}
if (charEntity.Read<Health>().IsDead)
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Unable to empty trash when dead!");
return false;
}
Entity castleHeart = Core.TerritoryService.GetCastleHeart(territoryIndex);
if (castleHeart == Entity.Null)
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "There is no heart on this territory!");
return false;
}
ServerGameManager serverGameManager = Core.ServerGameManager;
if (!((ServerGameManager)(ref serverGameManager)).IsAllies(castleHeart, charEntity))
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "You aren't allies with the heart on this territory!");
return false;
}
CastleHeart val3 = castleHeart.Read<CastleHeart>();
if ((int)val3.ActiveEvent >= 2)
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Unable to empty trash while castle is " + ((object)(CastleHeartEvent)(ref val3.ActiveEvent)).ToString());
return false;
}
Entity val4 = default(Entity);
if (BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, charEntity, PrefabIdentifier.op_Implicit(Const.Buff_InCombat_PvPVampire), ref val4))
{
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Unable to empty trash while in PvP combat.");
return false;
}
return true;
}
public void EmptyTrash(Entity charEntity)
{
//IL_0001: 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_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_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_0043: 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_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_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_0056: 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)
if (!CanEmptyTrash(charEntity, out var territoryIndex))
{
return;
}
int num = 0;
Entity val = default(Entity);
foreach (Entity allTrashStash in Core.Stash.GetAllTrashStashes(territoryIndex))
{
if (!InventoryUtilities.TryGetInventoryEntity<EntityManager>(Core.EntityManager, allTrashStash, ref val, 0))
{
continue;
}
EntityManager entityManager = Core.EntityManager;
DynamicBuffer<InventoryBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<InventoryBuffer>(val, false);
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i].Amount != 0)
{
InventoryUtilitiesServer.ClearSlot(Core.EntityManager, val, i);
}
}
num++;
}
User user = charEntity.Read<PlayerCharacter>().UserEntity.Read<User>();
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Trash emptied from " + Format.Color(num.ToString(), Color.White) + "x trash containers.");
}
public void EmptyTrash(Entity charEntity, Entity trashContainer)
{
//IL_0001: 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_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_0026: 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_0037: 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_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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
Entity val = default(Entity);
if (!CanEmptyTrash(charEntity, out var _) || !InventoryUtilities.TryGetInventoryEntity<EntityManager>(Core.EntityManager, trashContainer, ref val, 0))
{
return;
}
EntityManager entityManager = Core.EntityManager;
DynamicBuffer<InventoryBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<InventoryBuffer>(val, false);
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i].Amount != 0)
{
InventoryUtilitiesServer.ClearSlot(Core.EntityManager, val, i);
}
}
User user = charEntity.Read<PlayerCharacter>().UserEntity.Read<User>();
Utilities.SendSystemMessageToClient(Core.EntityManager, user, "Sunlight, at this hour, in this castle, localized entirely within this trash bin? This trash is ashed.");
}
}
namespace Logistics.Commands
{
[CommandGroup("logistics", "l")]
public static class LogisticsCommands
{
[Command("sortstash", "ss", ".l ss", "Toggles autostashing on double clicking sort button for player.", null, false)]
public static void TogglePlayerAutoStash(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleSortStash(platformId);
ctx.Reply("SortStash is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("craftpull", "cr", ".l cr", "Toggles right-clicking on recipes for missing ingredients.", null, false)]
public static void TogglePlayerAutoPull(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleCraftPull(platformId);
ctx.Reply("CraftPull is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("dontpulllast", "dpl", ".l dpl", "Toggles the ability to not pull the last item from a container for Logistics commands.", null, false)]
public static void ToggleDontPullLast(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleDontPullLast(platformId);
ctx.Reply("DontPullLast is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("autostashmissions", "asm", ".l asm", "Toggles autostashing for servant missions.", null, false)]
public static void ToggleServantAutoStash(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleAutoStashMissions(platformId);
ctx.Reply("AutoStash for missions is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("conveyor", "co", ".l co", "Toggles the ability of sender/receiver's to move items around.", null, false)]
public static void ToggleConveyor(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleConveyor(platformId);
ctx.Reply("Conveyor is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("salvage", "sal", ".l sal", "Toggles the ability to salvage items from a chest named 'salvage'.", null, false)]
public static void ToggleSalvage(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleSalvage(platformId);
ctx.Reply("Salvage is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("unitspawner", "us", ".l sp", "Toggles the ability to fill unit stations from a chest named 'spawner'.", null, false)]
public static void ToggleUnitSpawner(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleUnitSpawner(platformId);
ctx.Reply("Spawner is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("brazier", "bz", ".l bz", "Toggles the ability to fill braziers from a chest named 'brazier'.", null, false)]
public static void ToggleBrazier(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleBrazier(platformId);
ctx.Reply("Brazier is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("silentpull", "sp", null, "Toggles the ability to not send messages when pulling about where they came from.", null, false)]
public static void ToggleSilentCraftPull(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleSilentPull(platformId);
ctx.Reply("SilentPull is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("silentstash", "ssh", null, "Toggles the ability to not send messages when stashing items about where they go.", null, false)]
public static void ToggleSilentStash(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
bool flag = Core.PlayerSettings.ToggleSilentStash(platformId);
ctx.Reply("SilentStash is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("settings", "s", ".l s", "Displays current settings.", null, false)]
public static void DisplaySettings(ChatCommandContext ctx)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
ulong platformId = ctx.Event.User.PlatformId;
PlayerSettingsService.PlayerSettings settings = Core.PlayerSettings.GetSettings(platformId);
PlayerSettingsService.PlayerSettings globalSettings = Core.PlayerSettings.GetGlobalSettings();
ctx.Reply("KindredLogistics Settings:\nSortStash: " + ((!globalSettings.SortStash) ? "<color=red>Server Off</color>" : (settings.SortStash ? "<color=green>On</color>" : "<color=red>Off</color>")) + "\nPull (Global) : " + (globalSettings.Pull ? "<color=green>Server On</color>" : "<color=red>Server Off</color>") + "\nCraftPull: " + ((!globalSettings.CraftPull) ? "<color=red>Server Off</color>" : (settings.CraftPull ? "<color=green>On</color>" : "<color=red>Off</color>")) + "\nDontPullLast: " + (settings.DontPullLast ? "<color=green>On</color>" : "<color=red>Off</color>") + "\nAutoStashMissions: " + ((!globalSettings.AutoStashMissions) ? "<color=red>Server Off</color>" : (settings.AutoStashMissions ? "<color=green>On</color>" : "<color=red>Off</color>")) + "\nConveyor: " + ((!globalSettings.Conveyor) ? "<color=red>Server Off</color>" : (settings.Conveyor ? "<color=green>On</color>" : "<color=red>Off</color>")) + "\nSalvage: " + ((!globalSettings.Salvage) ? "<color=red>Server Off</color>" : (settings.Salvage ? "<color=green>On</color>" : "<color=red>Off</color>")) + "\nUnitSpawner: " + ((!globalSettings.UnitSpawner) ? "<color=red>Server Off</color>" : (settings.UnitSpawner ? "<color=green>On</color>" : "<color=red>Off</color>")) + "\nBrazier: " + ((!globalSettings.Brazier) ? "<color=red>Server Off</color>" : (settings.Brazier ? "<color=green>On</color>" : "<color=red>Off</color>")) + " | Named: " + (globalSettings.Named ? "<color=green>Server On</color>" : "<color=red>Server Off</color>") + "\nSilent (Pull: " + (settings.SilentPull ? "<color=green>On</color>" : "<color=red>Off</color>") + " | Stash: " + (settings.SilentStash ? "<color=green>On</color>" : "<color=red>Off</color>") + ")");
}
}
[CommandGroup("logisticsglobal", "lg")]
public static class LogisticsGlobal
{
[Command("sortstash", "ss", ".lg ss", "Toggles autostashing on double clicking sort button for player.", null, true)]
public static void TogglePlayerAutoStash(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleSortStash(0uL);
ctx.Reply("Global SortStash is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("pull", "p", ".lg p", "Toggles the ability to pull items from containers.", null, true)]
public static void TogglePlayerPull(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.TogglePull();
ctx.Reply("Global Pull is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("craftpull", "cr", ".lg cr", "Toggles right-clicking on recipes for missing ingredients.", null, true)]
public static void TogglePlayerAutoPull(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleCraftPull(0uL);
ctx.Reply("CraftPull is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("autostashmissions", "asm", ".lg asm", "Toggles autostashing for servant missions.", null, true)]
public static void ToggleServantAutoStash(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleAutoStashMissions(0uL);
ctx.Reply("Global AutoStash for missions is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("conveyor", "co", ".lg co", "Toggles the ability of sender/receiver's to move items around.", null, true)]
public static void ToggleConveyor(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleConveyor(0uL);
ctx.Reply("Global Conveyor is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("salvage", "sal", ".lg sal", "Toggles the ability to salvage items from a chest named 'salvage'.", null, true)]
public static void ToggleSalvage(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleSalvage(0uL);
ctx.Reply("Global Salvage is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("unitspawner", "us", ".lg sp", "Toggles the ability to fill unit stations from a chest named 'spawner'.", null, true)]
public static void ToggleUnitSpawner(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleUnitSpawner(0uL);
ctx.Reply("Global Spawner is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("brazier", "bz", ".lg bz", "Toggles the ability to fill braziers from a chest named 'brazier'.", null, true)]
public static void ToggleBrazier(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleBrazier(0uL);
ctx.Reply("Global Brazier is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("named", "nam", ".lg nam", "Toggles the ability allow night/proximity controlled braziers.", null, true)]
public static void ToggleSolar(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleSolar(0uL);
ctx.Reply("Global Named is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("trash", null, ".lg trash", "Toggles the ability to allowed trashes to delete contents.", null, true)]
public static void ToggleTrash(ChatCommandContext ctx)
{
bool flag = Core.PlayerSettings.ToggleTrash();
ctx.Reply("Global Trash is " + (flag ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + ".");
}
[Command("settings", "s", ".lg s", "Displays current settings.", null, true)]
public static void DisplaySettings(ChatCommandContext ctx)
{
PlayerSettingsService.PlayerSettings globalSettings = Core.PlayerSettings.GetGlobalSettings();
ctx.Reply("KindredLogistics Global settings:\nSortStash: " + (globalSettings.SortStash ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nPull: " + (globalSettings.Pull ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nCraftPull: " + (globalSettings.CraftPull ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nAutoStashMissions: " + (globalSettings.AutoStashMissions ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nConveyor: " + (globalSettings.Conveyor ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nSalvage: " + (globalSettings.Salvage ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nUnitSpawner: " + (globalSettings.UnitSpawner ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nBrazier: " + (globalSettings.Brazier ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nNamed: " + (globalSettings.Named ? "<color=green>enabled</color>" : "<color=red>disabled</color>") + "\nTrash: " + (globalSettings.Trash ? "<color=green>enabled</color>" : "<color=red>disabled</color>"));
}
}
public static class AdditionalCommands
{
[Command("stash", null, null, "Stashes all items in your inventory.", null, false)]
public static void StashInventory(ChatCommandContext ctx)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Core.Stash.StashCharacterInventory(ctx.Event.SenderCharacterEntity);
}
[Command("pull", null, null, "Pulls specified item from containers.", null, false)]
public static void PullItem(ChatCommandContext ctx, FoundItem item, int quantity = 1)
{
//IL_0006: 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)
PullService.PullItem(ctx.Event.SenderCharacterEntity, item.prefab, quantity);
}
[Command("finditem", "fi", null, "Finds the specified item in containers", null, false)]
public static void FindItem(ChatCommandContext ctx, FoundItem item)
{
//IL_000b: 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)
Core.Stash.ReportWhereItemIsLocated(ctx.Event.SenderCharacterEntity, item.prefab);
}
[Command("findchest", "fc", null, "Finds the specified chest by name", null, false)]
public static void FindChest(ChatCommandContext ctx, string name)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Core.Stash.ReportWhereChestIsLocated(ctx.Event.SenderCharacterEntity, name);
}
[Command("emptytrash", null, null, "Empties all items in your trash containers.", null, true)]
public static void EmptyTrash(ChatCommandContext ctx)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Core.Trash.EmptyTrash(ctx.Event.SenderCharacterEntity);
}
[Command("adminstash", null, null, "Spawns in items to stash to the current territory.", null, true)]
public static void AdminStash(ChatCommandContext ctx, FoundItem item, int quantity = 1)
{
//IL_000b: 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)
Core.Stash.AdminStash(ctx.Event.SenderCharacterEntity, item.prefab, quantity);
}
}
}
namespace KindredLogistics
{
internal class Buffs
{
public delegate void BuffCreated(Entity buffEntity);
[CompilerGenerated]
private sealed class <RemoveAndAddBuffCoroutine>d__4 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public Entity targetEntity;
public PrefabGUID buffPrefab;
public Entity userEntity;
public float duration;
public BuffCreated callback;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RemoveAndAddBuffCoroutine>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0018: 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_0041: 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_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_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
RemoveBuff(targetEntity, buffPrefab);
break;
case 1:
<>1__state = -1;
break;
}
if (BuffUtility.HasBuff<EntityManager>(Core.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab)))
{
<>2__current = null;
<>1__state = 1;
return true;
}
AddBuff(userEntity, targetEntity, buffPrefab, duration);
Entity buffEntity = default(Entity);
if (callback != null && BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab), ref buffEntity))
{
callback(buffEntity);
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static bool AddBuff(Entity User, Entity Character, PrefabGUID buffPrefab, float duration = 0f, bool immortal = true)
{
//IL_000d: 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_001d: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0036: 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_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_0057: 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_0063: 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_0069: 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_007b: 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_0083: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_0115: 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_00b7: 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_011d: 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_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: 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_00d5: 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_00de: 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_00ec: 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_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
DebugEventsSystem existingSystemManaged = Core.Server.GetExistingSystemManaged<DebugEventsSystem>();
ApplyBuffDebugEvent val = default(ApplyBuffDebugEvent);
val.BuffPrefabGUID = buffPrefab;
ApplyBuffDebugEvent val2 = val;
FromCharacter val3 = default(FromCharacter);
val3.User = User;
val3.Character = Character;
FromCharacter val4 = val3;
Entity entity = default(Entity);
if (!BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity))
{
existingSystemManaged.ApplyBuff(val4, val2);
if (BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref entity))
{
if (entity.Has<CreateGameplayEventsOnSpawn>())
{
entity.Remove<CreateGameplayEventsOnSpawn>();
}
if (entity.Has<GameplayEventListeners>())
{
entity.Remove<GameplayEventListeners>();
}
if (immortal)
{
entity.Add<Buff_Persists_Through_Death>();
if (entity.Has<RemoveBuffOnGameplayEvent>())
{
entity.Remove<RemoveBuffOnGameplayEvent>();
}
if (entity.Has<RemoveBuffOnGameplayEventEntry>())
{
entity.Remove<RemoveBuffOnGameplayEventEntry>();
}
}
if (duration > -1f && duration != 0f)
{
if (!entity.Has<LifeTime>())
{
entity.Add<LifeTime>();
entity.Write<LifeTime>(new LifeTime
{
EndAction = (LifeTimeEndAction)2
});
}
LifeTime componentData = entity.Read<LifeTime>();
componentData.Duration = duration;
entity.Write<LifeTime>(componentData);
}
else if (duration == -1f)
{
if (entity.Has<LifeTime>())
{
LifeTime componentData2 = entity.Read<LifeTime>();
componentData2.Duration = -1f;
componentData2.EndAction = (LifeTimeEndAction)0;
entity.Write<LifeTime>(componentData2);
}
if (entity.Has<RemoveBuffOnGameplayEvent>())
{
entity.Remove<RemoveBuffOnGameplayEvent>();
}
if (entity.Has<RemoveBuffOnGameplayEventEntry>())
{
entity.Remove<RemoveBuffOnGameplayEventEntry>();
}
}
return true;
}
return false;
}
return false;
}
public static void RemoveBuff(Entity Character, PrefabGUID buffPrefab)
{
//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_0006: 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_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)
Entity val = default(Entity);
if (BuffUtility.TryGetBuff<EntityManager>(Core.EntityManager, Character, PrefabIdentifier.op_Implicit(buffPrefab), ref val))
{
DestroyUtility.Destroy(Core.EntityManager, val, (DestroyDebugReason)13, (string)null, 0);
}
}
public static void RemoveAndAddBuff(Entity userEntity, Entity targetEntity, PrefabGUID buffPrefab, float duration = -1f, BuffCreated callback = null)
{
//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_0006: 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_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_0047: 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_0015: 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_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_003e: Unknown result type (might be due to invalid IL or missing references)
if (!BuffUtility.HasBuff<EntityManager>(Core.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab)))
{
AddBuff(userEntity, targetEntity, buffPrefab, duration);
Entity buffEntity = default(Entity);
if (callback != null && BuffUtility.TryGetBuff<EntityManager>(Core.Server.EntityManager, targetEntity, PrefabIdentifier.op_Implicit(buffPrefab), ref buffEntity))
{
callback(buffEntity);
}
}
else
{
Core.StartCoroutine(RemoveAndAddBuffCoroutine(userEntity, targetEntity, buffPrefab, duration, callback));
}
}
[IteratorStateMachine(typeof(<RemoveAndAddBuffCoroutine>d__4))]
private static IEnumerator RemoveAndAddBuffCoroutine(Entity userEntity, Entity targetEntity, PrefabGUID buffPrefab, float duration, BuffCreated callback)
{
//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_000e: 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_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)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RemoveAndAddBuffCoroutine>d__4(0)
{
userEntity = userEntity,
targetEntity = targetEntity,
buffPrefab = buffPrefab,
duration = duration,
callback = callback
};
}
}
internal static class Const
{
public const string RECEIVER_REGEX = "r(\\d+)";
public const string SENDER_REGEX = "s(\\d+)";
public static readonly PrefabGUID Buff_InCombat_PvPVampire = new PrefabGUID(697095869);
}
internal static class Core
{
public const int MAX_REPLY_LENGTH = 509;
private static bool hasInitialized;
private static MonoBehaviour monoBehaviour;
public static World Server { get; } = GetWorld("Server") ?? throw new Exception("There is no Server world (yet). Did you install a server mod on the client?");
public static EntityManager EntityManager { get; } = Server.EntityManager;
public static GameDataSystem GameDataSystem { get; } = Server.GetExistingSystemManaged<GameDataSystem>();
public static PrefabCollectionSystem PrefabCollectionSystem { get; internal set; }
public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; }
public static ServerScriptMapper ServerScriptMapper { get; internal set; }
public static DebugEventsSystem DebugEventsSystem { get; internal set; }
public static double ServerTime => ServerGameManager.ServerTime;
public static ServerGameManager ServerGameManager => ServerScriptMapper.GetServerGameManager();
public static ManualLogSource Log => Plugin.LogInstance;
public static ConveyorService ConveyorService { get; internal set; }
public static LocalizationService Localization { get; } = new LocalizationService();
public static PlayerSettingsService PlayerSettings { get; } = new PlayerSettingsService();
public static RefinementStationsService RefinementStations { get; internal set; }
public static RegionService RegionService { get; internal set; }
public static SalvageService SalvageService { get; internal set; }
public static StashService Stash { get; } = new StashService();
public static TrashService Trash { get; } = new TrashService();
public static TerritoryService TerritoryService { get; internal set; }
public static UnitSpawnerstationService UnitSpawnerstationService { get; internal set; }
public static BrazierService BrazierService { get; internal set; }
internal static bool HasInitialized => hasInitialized;
public static void LogException(Exception e, [CallerMemberName] string caller = null)
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
ManualLogSource log = Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(51, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failure in ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(caller);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nMessage: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.Message);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Inner:");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.Message);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n\nStack: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.StackTrace);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\nInner Stack: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(e.InnerException?.StackTrace);
}
log.LogError(val);
}
public static void Initialize()
{
if (!hasInitialized)
{
PrefabCollectionSystem = Server.GetExistingSystemManaged<PrefabCollectionSystem>();
ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
DebugEventsSystem = Server.GetExistingSystemManaged<DebugEventsSystem>();
ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
RefinementStations = new RefinementStationsService();
RegionService = new RegionService();
SalvageService = new SalvageService();
TerritoryService = new TerritoryService();
UnitSpawnerstationService = new UnitSpawnerstationService();
BrazierService = new BrazierService();
ConveyorService = new ConveyorService();
FoundItemConverter.LoadItemNames();
FixAdvanceFurnaces();
Log.LogInfo((object)"KindredLogistics initialized");
hasInitialized = true;
}
}
private static World GetWorld(string name)
{
Enumerator<World> enumerator = World.s_AllWorlds.GetEnumerator();
while (enumerator.MoveNext())
{
World current = enumerator.Current;
if (current.Name == name)
{
return current;
}
}
return null;
}
public static void StartCoroutine(IEnumerator routine)
{
//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_0027: Expected O, but got Unknown
if ((Object)(object)monoBehaviour == (Object)null)
{
GameObject val = new GameObject("KindredLogistics");
monoBehaviour = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
Object.DontDestroyOnLoad((Object)val);
}
monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
}
private static void FixAdvanceFurnaces()
{
//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_000b: 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_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_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: 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_00be: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Expected O, but got Unknown
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: 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_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
EntityQueryBuilder val = new EntityQueryBuilder(AllocatorHandle.op_Implicit((Allocator)2));
val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<Refinementstation>(), (AccessMode)1));
val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<PrefabGUID>(), (AccessMode)1));
val = ((EntityQueryBuilder)(ref val)).AddAll(new ComponentType(Il2CppType.Of<RefinementstationRecipesBuffer>(), (AccessMode)0));
EntityQueryBuilder val2 = ((EntityQueryBuilder)(ref val)).WithOptions((EntityQueryOptions)3);
EntityManager entityManager = EntityManager;
EntityQuery val3 = ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val2);
((EntityQueryBuilder)(ref val2)).Dispose();
NativeArray<Entity> val4 = ((EntityQuery)(ref val3)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
PrefabGUID val5 = default(PrefabGUID);
((PrefabGUID)(ref val5))..ctor(461575192);
Enumerator<Entity> enumerator = val4.GetEnumerator();
bool flag = default(bool);
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
PrefabGUID val6 = current.Read<PrefabGUID>();
if (((PrefabGUID)(ref val6)).GuidHash != -222851985)
{
continue;
}
entityManager = EntityManager;
DynamicBuffer<RefinementstationRecipesBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<RefinementstationRecipesBuffer>(current, false);
for (int i = 0; i < buffer.Length; i++)
{
RefinementstationRecipesBuffer val7 = buffer[i];
if (((PrefabGUID)(ref val7.RecipeGuid)).GuidHash == 394757670)
{
ManualLogSource log = Log;
BepInExInfoLogInterpolatedStringHandler val8 = new BepInExInfoLogInterpolatedStringHandler(29, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("Replacing recipe ");
((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<string>(val7.RecipeGuid.LookupName());
((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" on ");
((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<string>(current.EntityName());
((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<int>(current.Index);
((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(":");
((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<int>(current.Version);
((BepInExLogInterpolatedStringHandler)val8).AppendLiteral(" with ");
((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<string>(val5.LookupName());
}
log.LogInfo(val8);
val7.RecipeGuid = val5;
buffer[i] = val7;
}
}
}
val4.Dispose();
((EntityQuery)(ref val3)).Dispose();
}
}
public static class ECSExtensions
{
private static EntityManager EntityManager { get; } = Core.Server.EntityManager;
public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: 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_003b: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
byte[] array = StructureToByteArray(componentData);
int num = Marshal.SizeOf<T>();
fixed (byte* ptr = array)
{
EntityManager entityManager = EntityManager;
((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num);
}
}
private static byte[] StructureToByteArray<T>(T structure) where T : struct
{
int num = Marshal.SizeOf(structure);
byte[] array = new byte[num];
IntPtr intPtr = Marshal.AllocHGlobal(num);
Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true);
Marshal.Copy(intPtr, array, 0, num);
Marshal.FreeHGlobal(intPtr);
return array;
}
public unsafe static T Read<T>(this Entity entity) where T : struct
{
//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_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_0017: Unknown result type (might be due to invalid IL or missing references)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = EntityManager;
return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex)));
}
public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct
{
//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_000d: 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)
EntityManager entityManager = Core.Server.EntityManager;
return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false);
}
public static bool Has<T>(this Entity entity)
{
//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_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)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = EntityManager;
return ((EntityManager)(ref entityManager)).HasComponent(entity, val);
}
public static string LookupName(this PrefabGUID prefabGuid)
{
//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_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_002a: Unknown result type (might be due to invalid IL or missing references)
PrefabLookupMap prefabLookupMap = Core.Server.GetExistingSystemManaged<PrefabCollectionSystem>()._PrefabLookupMap;
string text = default(string);
object obj;
if (!((PrefabLookupMap)(ref prefabLookupMap)).TryGetName(prefabGuid, ref text))
{
obj = "GUID Not Found";
}
else
{
string text2 = text;
PrefabGUID val = prefabGuid;
obj = text2 + " " + ((object)(PrefabGUID)(ref val)).ToString();
}
return obj.ToString();
}
public static string PrefabName(this PrefabGUID prefabGuid)
{
//IL_0005: 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)
string prefabName = Core.Localization.GetPrefabName(prefabGuid);
if (!string.IsNullOrEmpty(prefabName))
{
return prefabName;
}
return prefabGuid.LookupName();
}
public static string EntityName(this Entity entity)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//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_0022: 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)
NameableInteractable val = entity.Read<NameableInteractable>();
string text = ((object)(FixedString64Bytes)(ref val.Name)).ToString();
if (string.IsNullOrEmpty(text) && entity.Has<PrefabGUID>())
{
text = entity.Read<PrefabGUID>().PrefabName();
}
if (string.IsNullOrEmpty(text))
{
text = ((object)(Entity)(ref entity)).ToString();
}
return text;
}
public static void Add<T>(this Entity entity)
{
//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_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)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = EntityManager;
((EntityManager)(ref entityManager)).AddComponent(entity, val);
}
public static void Remove<T>(this Entity entity)
{
//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_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)
ComponentType val = default(ComponentType);
((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0);
EntityManager entityManager = EntityManager;
((EntityManager)(ref entityManager)).RemoveComponent(entity, val);
}
}
[BepInPlugin("KindredLogistics", "KindredLogistics", "1.6.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private static Plugin plugin;
private Harmony _harmony;
public HookDOTS hookDOTS;
public static Harmony Harmony => plugin._harmony;
public static ManualLogSource LogInstance => ((BasePlugin)plugin).Log;
public override void Load()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
plugin = this;
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>("KindredLogistics");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.6.1");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
_harmony = new Harmony("KindredLogistics");
_harmony.PatchAll(Assembly.GetExecutingAssembly());
CommandRegistry.RegisterAll();
hookDOTS = new HookDOTS("KindredLogistics", ((BasePlugin)this).Log);
hookDOTS.RegisterAnnotatedHooks();
}
public override bool Unload()
{
CommandRegistry.UnregisterAssembly();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public class Utilities
{
public static readonly ComponentType[] StashQuery = (ComponentType[])(object)new ComponentType[4]
{
ComponentType.ReadOnly(Il2CppType.Of<InventoryOwner>()),
ComponentType.ReadOnly(Il2CppType.Of<CastleHeartConnection>()),
ComponentType.ReadOnly(Il2CppType.Of<AttachedBuffer>()),
ComponentType.ReadOnly(Il2CppType.Of<NameableInteractable>())
};
public static readonly ComponentType[] RefinementStationQuery = (ComponentType[])(object)new ComponentType[4]
{
ComponentType.ReadOnly(Il2CppType.Of<Team>()),
ComponentType.ReadOnly(Il2CppType.Of<CastleHeartConnection>()),
ComponentType.ReadOnly(Il2CppType.Of<Refinementstation>()),
ComponentType.ReadOnly(Il2CppType.Of<NameableInteractable>())
};
public static readonly ComponentType[] UserEntityQuery = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly(Il2CppType.Of<User>()) };
public static void StashServantInventory(Entity servant)
{
//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_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)
Entity inventory = default(Entity);
if (InventoryUtilities.TryGetInventoryEntity<EntityManager>(Core.EntityManager, servant, ref inventory, 0))
{
StashInventoryEntity(servant, inventory, "spoils");
}
}
public static Dictionary<PrefabGUID, List<Entity>> GetItemStashesOnTerritory(int territoryId)
{
//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_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_0036: 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_004b: 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_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_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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: 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_00dd: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
ServerGameManager serverGameManager = Core.ServerGameManager;
Dictionary<PrefabGUID, List<Entity>> dictionary = new Dictionary<PrefabGUID, List<Entity>>(100);
HashSet<PrefabGUID> hashSet = new HashSet<PrefabGUID>(32);
DynamicBuffer<AttachedBuffer> val = default(DynamicBuffer<AttachedBuffer>);
foreach (Entity item in Core.Stash.GetStashesOnTerritory(territoryId))
{
if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<AttachedBuffer>(item, ref val))
{
continue;
}
Enumerator<AttachedBuffer> enumerator2 = val.GetEnumerator();
while (enumerator2.MoveNext())
{
AttachedBuffer current2 = enumerator2.Current;
hashSet.Clear();
Entity entity = current2.Entity;
if (!entity.Has<PrefabGUID>())
{
continue;
}
PrefabGUID val2 = entity.Read<PrefabGUID>();
if (!((PrefabGUID)(ref val2)).Equals(StashService.ExternalInventoryPrefab))
{
continue;
}
Enumerator<InventoryBuffer> enumerator3 = entity.ReadBuffer<InventoryBuffer>().GetEnumerator();
while (enumerator3.MoveNext())
{
PrefabGUID itemType = enumerator3.Current.ItemType;
if (((PrefabGUID)(ref itemType)).GuidHash != 0 && !hashSet.Contains(itemType))
{
if (!dictionary.TryGetValue(itemType, out var value))
{
value = (dictionary[itemType] = new List<Entity>());
}
value.Add(entity);
hashSet.Add(itemType);
}
}
}
}
return dictionary;
}
public static void StashInventoryEntity(Entity inventory, Dictionary<PrefabGUID, List<Entity>> itemInventories, List<Entity> overflows)
{
//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_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0039: 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_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: 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_008b: 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_0092: 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_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: 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_00c1: 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_00c4: 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_00af: 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_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
ServerGameManager serverGameManager = Core.ServerGameManager;
DynamicBuffer<InventoryBuffer> val = default(DynamicBuffer<InventoryBuffer>);
if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<InventoryBuffer>(inventory, ref val))
{
return;
}
Entity entity = default(Entity);
DynamicBuffer<InventoryInstanceElement> val5 = default(DynamicBuffer<InventoryInstanceElement>);
for (int i = 0; i < val.Length; i++)
{
PrefabGUID itemType = val[i].ItemType;
InventoryBuffer val2 = val[i];
bool flag = !((object)(NetworkedEntity)(ref val2.ItemEntity)).Equals((object?)NetworkedEntity.Empty);
if (((PrefabGUID)(ref itemType)).IsEmpty())
{
continue;
}
int num = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, itemType);
EntityManager entityManager;
if (itemInventories.TryGetValue(itemType, out var value))
{
for (int num2 = value.Count - 1; num2 >= 0; num2--)
{
Entity val3 = value[num2];
entityManager = Core.EntityManager;
if (!((EntityManager)(ref entityManager)).Exists(val3))
{
value.RemoveAt(num2);
}
else
{
int amountTransferred;
if (flag)
{
TransferItemEntities(inventory, val3, itemType, num, ref i, out amountTransferred);
}
else
{
amountTransferred = TransferItems(serverGameManager, inventory, val3, itemType, num);
}
num -= amountTransferred;
if (num <= 0)
{
break;
}
value.RemoveAt(num2);
}
}
}
if (num <= 0)
{
continue;
}
ItemData val4 = default(ItemData);
if (overflows.Any())
{
PrefabLookupMap prefabLookupMap = Core.PrefabCollectionSystem._PrefabLookupMap;
if (((PrefabLookupMap)(ref prefabLookupMap)).TryGetValue(itemType, ref entity))
{
val4 = entity.Read<ItemData>();
}
}
foreach (Entity overflow in overflows)
{
entityManager = Core.EntityManager;
if (!((EntityManager)(ref entityManager)).Exists(overflow) || !((ServerGameManager)(ref serverGameManager)).TryGetBuffer<InventoryInstanceElement>(overflow, ref val5))
{
continue;
}
Enumerator<InventoryInstanceElement> enumerator2 = val5.GetEnumerator();
while (enumerator2.MoveNext())
{
InventoryInstanceElement current2 = enumerator2.Current;
if ((!(current2.RestrictedType != PrefabGUID.Empty) || !(current2.RestrictedType != itemType)) && (current2.RestrictedCategory == 0L || (int)(current2.RestrictedCategory & val4.ItemCategory) != 0))
{
int amountTransferred2 = 0;
NetworkedEntity externalInventoryEntity;
if (flag)
{
externalInventoryEntity = current2.ExternalInventoryEntity;
TransferItemEntities(inventory, ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(), itemType, num, ref i, out amountTransferred2);
}
else
{
ServerGameManager serverGameManager2 = serverGameManager;
externalInventoryEntity = current2.ExternalInventoryEntity;
amountTransferred2 = TransferItems(serverGameManager2, inventory, ((NetworkedEntity)(ref externalInventoryEntity)).GetEntityOnServer(), itemType, num);
}
num -= amountTransferred2;
}
}
if (num <= 0)
{
break;
}
}
}
}
public static void StashInventoryEntity(Entity entityWithTerritory, Entity inventory, string overflowStashName)
{
//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_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_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Expected O, but got Unknown
//IL_0023: 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_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: 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_00a5: 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_00ec: 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)
//IL_00b0: 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_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0119: 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_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_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0281: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0232: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
ServerGameManager serverGameManager = Core.ServerGameManager;
Dictionary<PrefabGUID, List<(Entity, Entity)>> dictionary = new Dictionary<PrefabGUID, List<(Entity, Entity)>>(100);
(Entity, Entity) tuple = (Entity.Null, Entity.Null);
try
{
Entity val2 = default(Entity);
DynamicBuffer<AttachedBuffer> val3 = default(DynamicBuffer<AttachedBuffer>);
foreach (Entity stash in Core.Stash.GetAllAlliedStashesOnTerritory(entityWithTerritory))
{
NameableInteractable val = stash.Read<NameableInteractable>();
if (((object)(FixedString64Bytes)(ref val.Name)).ToString().ToLower().Contains(overflowStashName) && ((Entity)(ref tuple.Item1)).Equals(Entity.Null))
{
if (!InventoryUtilities.TryGetInventoryEntity<EntityManager>(Core.EntityManager, stash, ref val2, 0))
{
continue;
}
if (!((ServerGameManager)(ref serverGameManager)).HasFullInventory(val2))
{
tuple = (stash, val2);
continue;
}
}
if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<AttachedBuffer>(stash, ref val3))
{
continue;
}
Enumerator<AttachedBuffer> enumerator2 = val3.GetEnumerator();
while (enumerator2.MoveNext())
{
Entity entity = enumerator2.Current.Entity;
if (!entity.Has<PrefabGUID>())
{
continue;
}
PrefabGUID val4 = entity.Read<PrefabGUID>();
if (!((PrefabGUID)(ref val4)).Equals(StashService.ExternalInventoryPrefab))
{
continue;
}
Enumerator<InventoryBuffer> enumerator3 = entity.ReadBuffer<InventoryBuffer>().GetEnumerator();
while (enumerator3.MoveNext())
{
PrefabGUID itemType = enumerator3.Current.ItemType;
if (((PrefabGUID)(ref itemType)).GuidHash != 0)
{
if (!dictionary.TryGetValue(itemType, out var value))
{
value = (dictionary[itemType] = new List<(Entity, Entity)>());
}
else if (value.Any<(Entity, Entity)>(((Entity stash, Entity inventory) x) => x.stash == stash))
{
continue;
}
value.Add((stash, entity));
}
}
}
}
DynamicBuffer<InventoryBuffer> val5 = default(DynamicBuffer<InventoryBuffer>);
if (!((ServerGameManager)(ref serverGameManager)).TryGetBuffer<InventoryBuffer>(inventory, ref val5))
{
return;
}
for (int i = 0; i < val5.Length; i++)
{
PrefabGUID itemType2 = val5[i].ItemType;
int num = ((ServerGameManager)(ref serverGameManager)).GetInventoryItemCount(inventory, itemType2);
if (dictionary.TryGetValue(itemType2, out var value2))
{
foreach (var item in value2)
{
num -= TransferItems(serverGameManager, inventory, item.Item2, itemType2, num);
if (num <= 0)
{
break;
}
}
}
if (num > 0 && !((Entity)(ref tuple.Item1)).Equals(Entity.Null))
{
TransferItems(serverGameManager, inventory, tuple.Item2, itemType2, num);
}
}
}
catch (Exception ex)
{
ManualLogSource log = Core.Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(36, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("Exited StashServantInventory early: ");
((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
}
log.LogError(val6);
}
}
public static bool TerritoryCheck(Entity character, Entity target)
{
//IL_0000: 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_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_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_0017: 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_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_0035: Unknown result type (might be due to invalid IL or missing references)
if (!target.Has<CastleHeartConnection>())
{
return false;
}
TilePosition val = character.Read<TilePosition>();
CastleHeartConnection val2 = target.Read<CastleHeartConnection>();
Entity castleTerritoryEntity = ((NetworkedEntity)(ref val2.CastleHeartEntity)).GetEntityOnServer().Read<CastleHeart>().CastleTerritoryEntity;
CastleTerritory val3 = default(CastleTerritory);
return CastleTerritoryExtensions.IsTileInTerritory(Core.EntityManager, val.Tile, ref castleTerritoryEntity, ref val3);
}
public static bool SharedHeartConnection(Entity input, Entity ouput)
{
//IL_0000: 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_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_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)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
if (input.Has<CastleHeartConnection>() && ouput.Has<CastleHeartConnection>())
{
Entity entity = input.Read<CastleHeartConnection>().CastleHeartEntity._Entity;
Entity entity2 = ouput.Read<CastleHeartConnection>().CastleHeartEntity._Entity;
return ((Entity)(ref entity)).Equals(entity2);
}
return false;
}
private static void CheckIfInventoryEmpty(Entity inventory)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//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_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: 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_0039: 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_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_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_0059: Unknown result type (might be due to invalid IL or missing references)
DynamicBuffer<InventoryBuffer> val = inventory.ReadBuffer<InventoryBuffer>();
for (int i = 0; i < val.Length; i++)
{
if (val[i].Amount != 0)
{
return;
}
}
InventoryOwner componentData = inventory.Read<InventoryOwner>();
componentData.HasItems = false;
inventory.Write<InventoryOwner>(componentData);
Entity inventoryOwner = inventory.Read<InventoryConnection>().InventoryOwner;
InventoryOwner componentData2 = inventoryOwner.Read<InventoryOwner>();
componentData2.HasItems = false;
inventoryOwner.Write<InventoryOwner>(componentData2);
}
public static bool TransferItemEntities(Entity outputInventory, Entity inputInventory, PrefabGUID itemPrefab, int transferAmount, ref int startInputSlot, out int amountTransferred)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//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_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_000d: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_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_004c: 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_0070: 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_0083: 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_00cf: 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_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_0099: 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_00a1: 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)
DynamicBuffer<InventoryBuffer> val = outputInventory.ReadBuffer<InventoryBuffer>();
DynamicBuffer<InventoryBuffer> val2 = inputInventory.ReadBuffer<InventoryBuffer>();
amountTransferred = 0;
for (int i = 0; i < val.Length; i++)
{
InventoryBuffer val3 = val[i];
if (!((PrefabGUID)(ref val3.ItemType)).Equals(itemPrefab))
{
continue;
}
while (startInputSlot < val2.Length)
{
InventoryBuffer val4 = val2[startInputSlot];
if (!((PrefabGUID)(ref val4.ItemType)).Equals(PrefabGUID.Empty))
{
startInputSlot++;
continue;
}
val2[startInputSlot] = val3;
val[i] = val4;
Entity entityOnServer = ((NetworkedEntity)(ref val3.ItemEntity)).GetEntityOnServer();
if (entityOnServer.Has<InventoryItem>())
{
InventoryItem componentData = entityOnServer.Read<InventoryItem>();
componentData.ContainerEntity = inputInventory;
entityOnServer.Write<InventoryItem>(componentData);
}
startInputSlot++;
amountTransferred++;
break;
}
if (amountTransferred >= transferAmount)
{
CheckIfInventoryEmpty(outputInventory);
return false;
}
if (val2.Length <= startInputSlot)
{
CheckIfInventoryEmpty(outputInventory);
return true;
}
}
CheckIfInventoryEmpty(outputInventory);
return false;
}
public static int TransferItems(ServerGameManager serverGameManager, Entity outputInventory, Entity inputInventory, PrefabGUID itemGuid, int transferAmount)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: 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_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_0019: 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_0026: 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_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
if (((ServerGameManager)(ref serverGameManager)).TryRemoveInventoryItem(outputInventory, itemGuid, transferAmount))
{
AddItemResponse val = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(inputInventory, itemGuid, transferAmount);
if ((int)val.Result == 0)
{
return transferAmount;
}
_ = ((ServerGameManager)(ref serverGameManager)).TryAddInventoryItem(outputInventory, itemGuid, val.RemainingAmount).Result;
return transferAmount - val.RemainingAmount;
}
return 0;
}
public static AddItemSettings GetAddItemSettings()
{
//IL_0002: 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_000f: 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_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)
AddItemSettings result = default(AddItemSettings);
result.EntityManager = Core.EntityManager;
ServerGameManager serverGameManager = Core.ServerGameManager;
result.ItemDataMap = ((ServerGameManager)(ref serverGameManager)).ItemLookupMap;
return result;
}
public static void SendSystemMessageToClient(EntityManager entityManager, User user, string message)
{
//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)
FixedString512Bytes val = default(FixedString512Bytes);
((FixedString512Bytes)(ref val))..ctor(message);
ServerChatUtils.SendSystemMessageToClient(entityManager, user, ref val);
}
public static bool IsRoomOfType(Entity roomEntity, CastleFloorTypes floorType)
{
//IL_0000: 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_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_001c: 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_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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_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_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_0059: 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_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0087: 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_0090: Invalid comparison between Unknown and I4
if (!roomEntity.Has<CastleRoom>())
{
return false;
}
CastleRoom val = roomEntity.Read<CastleRoom>();
if (!((CastleRoom)(ref val)).IsEnclosedRo