using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using DropTeleportBound.Data;
using DropTeleportBound.Services;
using HarmonyLib;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using Network.Systems;
using ProjectM;
using ProjectM.Network;
using ProjectM.Physics;
using ProjectM.Scripting;
using ProjectM.Shared;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Scenes;
using UnityEngine;
using VampireCommandFramework;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DropTeleportBound")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Server-side V Rising mod that helps players handle teleport-bound items before using Vampire Waygates")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("DropTeleportBound")]
[assembly: AssemblyTitle("DropTeleportBound")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DropTeleportBound
{
internal static class Core
{
private static World _server;
private static bool _hasInitialized;
private static MonoBehaviour monoBehaviour;
public static World Server
{
get
{
if (_server == null)
{
_server = GetWorld("Server");
}
return _server;
}
}
public static EntityManager EntityManager => Server.EntityManager;
public static bool IsServer => Application.productName == "VRisingServer";
public static GameDataSystem GameDataSystem => Server.GetExistingSystemManaged<GameDataSystem>();
public static ServerScriptMapper ServerScriptMapper { get; internal set; }
public static ServerGameSettingsSystem ServerGameSettingsSystem { get; internal set; }
public static ManualLogSource Log => Plugin.PluginLog;
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 LogException(Exception e, [CallerMemberName] string caller = null)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
ManualLogSource log = Log;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(52, 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);
}
internal static void InitializeAfterLoaded()
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
if (!_hasInitialized)
{
ServerScriptMapper = Server.GetExistingSystemManaged<ServerScriptMapper>();
ServerGameSettingsSystem = Server.GetExistingSystemManaged<ServerGameSettingsSystem>();
_hasInitialized = true;
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("InitializeAfterLoaded");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" completed.");
}
log.LogInfo(val);
}
}
public static Coroutine StartCoroutine(IEnumerator routine)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
if ((Object)(object)monoBehaviour == (Object)null)
{
GameObject val = new GameObject("DropTeleportBound");
monoBehaviour = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>();
Object.DontDestroyOnLoad((Object)(object)val);
}
return monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine));
}
public static void StopCoroutine(Coroutine coroutine)
{
if (!((Object)(object)monoBehaviour == (Object)null))
{
monoBehaviour.StopCoroutine(coroutine);
}
}
}
internal static class Helper
{
private static readonly PrefabGUID AB_Interact_UseWaypoint_Blocked_AbilityGroup = new PrefabGUID(-1696712851);
private static readonly PrefabGUID Buff_InCombat_PvPVampire = new PrefabGUID(697095869);
public static bool TryGetBlockedWaypointUser(EntityManager entityManager, Entity character, out Entity userEntity)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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_0034: 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_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_006a: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
userEntity = Entity.Null;
if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character))
{
return false;
}
if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(character))
{
return false;
}
if (!((EntityManager)(ref entityManager)).HasComponent<Interactor>(character))
{
return false;
}
Interactor componentData = ((EntityManager)(ref entityManager)).GetComponentData<Interactor>(character);
if (!((PrefabGUID)(ref componentData.InteractAbilityGuid)).Equals(AB_Interact_UseWaypoint_Blocked_AbilityGroup))
{
return false;
}
if (!IsWaypointTarget(entityManager, componentData.Target))
{
return false;
}
if (!IsTargetBeingInteracted(entityManager, componentData.Target))
{
return false;
}
PlayerCharacter componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<PlayerCharacter>(character);
userEntity = componentData2.UserEntity;
if (userEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity))
{
return false;
}
return ((EntityManager)(ref entityManager)).HasComponent<User>(userEntity);
}
public static bool HasPvPCombatBuff(EntityManager entityManager, Entity character)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character))
{
return false;
}
return BuffUtility.HasBuff<EntityManager>(entityManager, character, PrefabIdentifier.op_Implicit(Buff_InCombat_PvPVampire));
}
private static bool IsWaypointTarget(EntityManager entityManager, Entity target)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0030: Unknown result type (might be due to invalid IL or missing references)
if (target == Entity.Null || !((EntityManager)(ref entityManager)).Exists(target))
{
return false;
}
return ((EntityManager)(ref entityManager)).HasComponent<ChunkWaypoint>(target) || ((EntityManager)(ref entityManager)).HasComponent<CastleWaypoint>(target);
}
private static bool IsTargetBeingInteracted(EntityManager entityManager, Entity target)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_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_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)
if (target == Entity.Null || !((EntityManager)(ref entityManager)).Exists(target))
{
return false;
}
if (!((EntityManager)(ref entityManager)).HasComponent<InteractedUpon>(target))
{
return false;
}
InteractedUpon componentData = ((EntityManager)(ref entityManager)).GetComponentData<InteractedUpon>(target);
return componentData.Interacting;
}
public static string GetSteamId(EntityManager entityManager, Entity userEntity)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if (userEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity))
{
return string.Empty;
}
if (!((EntityManager)(ref entityManager)).HasComponent<User>(userEntity))
{
return string.Empty;
}
return ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity).PlatformId.ToString();
}
public static bool TryGetInventoryEntities(EntityManager entityManager, Entity character, out NativeList<Entity> inventoryEntities)
{
//IL_0002: 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_0009: 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_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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)
inventoryEntities = default(NativeList<Entity>);
if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character))
{
return false;
}
inventoryEntities = new NativeList<Entity>(AllocatorHandle.op_Implicit((Allocator)2));
InventoryUtilities.TryGetInventoryEntities<EntityManager>(entityManager, character, ref inventoryEntities);
return inventoryEntities.IsCreated;
}
public static void ForEachInventoryItem(EntityManager entityManager, Entity character, Func<InventoryItemContext, bool> visitor)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_004d: 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_0081: 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)
if (!TryGetInventoryEntities(entityManager, character, out var inventoryEntities))
{
return;
}
try
{
NativeArray<InventoryBuffer> val2 = default(NativeArray<InventoryBuffer>);
InventoryBuffer item = default(InventoryBuffer);
for (int i = 0; i < inventoryEntities.Length; i++)
{
Entity val = inventoryEntities[i];
if (val == Entity.Null || !((EntityManager)(ref entityManager)).Exists(val) || !InventoryUtilities._TryGetInventoryFromInventoryEntity<EntityManager>(entityManager, val, ref val2))
{
continue;
}
try
{
for (int j = 0; j < val2.Length; j++)
{
if (InventoryUtilities.TryGetItemAtSlot(val2, j, ref item) && !visitor(new InventoryItemContext(val, j, item)))
{
return;
}
}
}
finally
{
val2.Dispose();
}
}
}
finally
{
inventoryEntities.Dispose();
}
}
public static void NotifyUser(EntityManager entityManager, Entity userEntity, string message)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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)
if (!(userEntity == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(userEntity) && ((EntityManager)(ref entityManager)).HasComponent<User>(userEntity))
{
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(userEntity);
FixedString512Bytes val = default(FixedString512Bytes);
((FixedString512Bytes)(ref val))..ctor(message);
ServerChatUtils.SendSystemMessageToClient(entityManager, componentData, ref val);
}
}
}
[BepInPlugin("DropTeleportBound", "DropTeleportBound", "1.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
internal static Harmony Harmony;
internal static ManualLogSource PluginLog;
internal static ConfigFile PluginConfig;
internal static ConfigEntry<bool> AutoDropOnTeleportBoundItems;
internal static ConfigEntry<bool> PreventAutoDropInPvPCombat;
internal static ConfigEntry<bool> NotifyWhenAutoDropEnabled;
internal static ConfigEntry<bool> NotifyWhenAutoDropDisabled;
public override void Load()
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Expected O, but got Unknown
if (!(Application.productName != "VRisingServer"))
{
PluginLog = ((BasePlugin)this).Log;
PluginConfig = ((BasePlugin)this).Config;
AutoDropOnTeleportBoundItems = ((BasePlugin)this).Config.Bind<bool>("AutoDrop", "AutoDropOnTeleportBoundItems", true, "Enable the waypoint auto-drop feature for teleport-bound items.");
PreventAutoDropInPvPCombat = ((BasePlugin)this).Config.Bind<bool>("AutoDrop", "PreventAutoDropInPvPCombat", true, "Prevent auto-drop while the player has the PvP combat buff.");
NotifyWhenAutoDropEnabled = ((BasePlugin)this).Config.Bind<bool>("Notify", "NotifyWhenAutoDropEnabled", true, "Send a message when teleport-bound items are automatically dropped.");
NotifyWhenAutoDropDisabled = ((BasePlugin)this).Config.Bind<bool>("Notify", "NotifyWhenAutoDropDisabled", true, "Send a notification when waypoint teleport is blocked and auto-drop is disabled for the player.");
PlayerSettingService.Load();
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>("DropTeleportBound");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" version ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.1");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
Harmony = new Harmony("DropTeleportBound");
Harmony.PatchAll(Assembly.GetExecutingAssembly());
CommandRegistry.RegisterAll();
}
}
public override bool Unload()
{
PlayerSettingService.Save();
CommandRegistry.UnregisterAssembly();
Harmony harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "DropTeleportBound";
public const string PLUGIN_NAME = "DropTeleportBound";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace DropTeleportBound.Services
{
internal static class DropTeleportBoundService
{
private static readonly Dictionary<Entity, DateTime> _commandCooldowns = new Dictionary<Entity, DateTime>();
private static readonly TimeSpan CommandCooldown = TimeSpan.FromSeconds(3.0);
public static DropTeleportBoundResult TryDropTeleportBoundItems(Entity userEntity, Entity character)
{
//IL_0025: 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)
try
{
if (!ServerSettingsService.IsTeleportBoundItemsEnabled())
{
return DropTeleportBoundResult.Ok(ServerSettingsService.TeleportBoundItemsDisabledMessage, default(DropTeleportBoundStats));
}
return DropTeleportBoundItems(Core.EntityManager, Core.GameDataSystem.ItemHashLookupMap, userEntity, character);
}
catch (Exception e)
{
Core.LogException(e, "TryDropTeleportBoundItems");
return DropTeleportBoundResult.Fail("<color=red>An error occurred while dropping teleport-bound items.</color>");
}
}
public static DropTeleportBoundStats TryAutoDropTeleportBoundItems(Entity userEntity, Entity character)
{
//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_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_003f: 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)
try
{
if (!ServerSettingsService.IsTeleportBoundItemsEnabled())
{
return default(DropTeleportBoundStats);
}
EntityManager entityManager = Core.EntityManager;
if (!ValidateEntities(entityManager, userEntity, character, out var _))
{
return default(DropTeleportBoundStats);
}
return DropItems(entityManager, Core.GameDataSystem.ItemHashLookupMap, userEntity, character);
}
catch (Exception e)
{
Core.LogException(e, "TryAutoDropTeleportBoundItems");
return default(DropTeleportBoundStats);
}
}
public static bool HasTeleportBoundItems(Entity character)
{
//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_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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
try
{
if (!ServerSettingsService.IsTeleportBoundItemsEnabled())
{
return false;
}
EntityManager entityManager = Core.EntityManager;
if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character))
{
return false;
}
return HasTeleportBoundItems(entityManager, Core.GameDataSystem.ItemHashLookupMap, character);
}
catch (Exception e)
{
Core.LogException(e, "HasTeleportBoundItems");
return false;
}
}
private static DropTeleportBoundResult DropTeleportBoundItems(EntityManager entityManager, NativeParallelHashMap<PrefabGUID, ItemData> itemDataMap, Entity userEntity, Entity character)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: 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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
if (!ValidateEntities(entityManager, userEntity, character, out var errorMessage))
{
return DropTeleportBoundResult.Fail(errorMessage);
}
if (IsCommandOnCooldown(userEntity, out var secondsLeft))
{
return DropTeleportBoundResult.Fail($"<color=yellow>Please wait {secondsLeft}s before using this command again.</color>");
}
_commandCooldowns[userEntity] = DateTime.UtcNow;
DropTeleportBoundStats stats = DropItems(entityManager, itemDataMap, userEntity, character);
if (stats.DroppedStacks <= 0)
{
return DropTeleportBoundResult.Ok("<color=yellow>No teleport-bound items found.</color>", stats);
}
return DropTeleportBoundResult.Ok("<color=green>Dropped teleport-bound items.</color>", stats);
}
private static DropTeleportBoundStats DropItems(EntityManager entityManager, NativeParallelHashMap<PrefabGUID, ItemData> itemDataMap, Entity userEntity, Entity character)
{
//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)
//IL_001c: 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_0040: 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)
int scannedSlots = 0;
int matchedStacks = 0;
int droppedStacks = 0;
int droppedAmount = 0;
Helper.ForEachInventoryItem(entityManager, character, delegate(InventoryItemContext context)
{
//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_001f: 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_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_0062: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
scannedSlots++;
InventoryBuffer item = context.Item;
ItemData val = default(ItemData);
if (!itemDataMap.TryGetValue(item.ItemType, ref val))
{
return true;
}
if (!ShouldDrop(val.ItemCategory))
{
return true;
}
matchedStacks++;
if (CreateDropInventoryItemEvent(entityManager, userEntity, character, context.InventoryEntity, context.Slot))
{
droppedStacks++;
droppedAmount += item.Amount;
}
return true;
});
return new DropTeleportBoundStats(scannedSlots, matchedStacks, droppedStacks, droppedAmount);
}
private static bool HasTeleportBoundItems(EntityManager entityManager, NativeParallelHashMap<PrefabGUID, ItemData> itemDataMap, Entity character)
{
//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_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)
bool found = false;
Helper.ForEachInventoryItem(entityManager, character, delegate(InventoryItemContext context)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_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_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)
InventoryBuffer item = context.Item;
ItemData val = default(ItemData);
if (!itemDataMap.TryGetValue(item.ItemType, ref val))
{
return true;
}
if (!ShouldDrop(val.ItemCategory))
{
return true;
}
found = true;
return false;
});
return found;
}
private static bool CreateDropInventoryItemEvent(EntityManager entityManager, Entity userEntity, Entity character, Entity inventoryEntity, int slot)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_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_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_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_007c: 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_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
if (inventoryEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(inventoryEntity))
{
return false;
}
if (!((EntityManager)(ref entityManager)).HasComponent<NetworkId>(inventoryEntity))
{
return false;
}
NetworkId componentData = ((EntityManager)(ref entityManager)).GetComponentData<NetworkId>(inventoryEntity);
Entity val = ((EntityManager)(ref entityManager)).CreateEntity((ComponentType[])(object)new ComponentType[3]
{
ComponentType.ReadWrite<FromCharacter>(),
ComponentType.ReadWrite<DropInventoryItemEvent>(),
ComponentType.ReadWrite<SendNetworkEventTag>()
});
((EntityManager)(ref entityManager)).SetComponentData<FromCharacter>(val, new FromCharacter
{
User = userEntity,
Character = character
});
((EntityManager)(ref entityManager)).SetComponentData<DropInventoryItemEvent>(val, new DropInventoryItemEvent
{
Inventory = componentData,
SlotIndex = slot
});
return true;
}
private static bool ValidateEntities(EntityManager entityManager, Entity userEntity, Entity character, out string errorMessage)
{
//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)
//IL_0017: 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_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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)
errorMessage = string.Empty;
if (userEntity == Entity.Null || !((EntityManager)(ref entityManager)).Exists(userEntity))
{
errorMessage = "<color=red>User entity is not available.</color>";
return false;
}
if (!((EntityManager)(ref entityManager)).HasComponent<User>(userEntity))
{
errorMessage = "<color=red>User component is not available.</color>";
return false;
}
if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character))
{
errorMessage = "<color=red>Character entity is not available.</color>";
return false;
}
if (!((EntityManager)(ref entityManager)).HasComponent<PlayerCharacter>(character))
{
errorMessage = "<color=red>PlayerCharacter component is not available.</color>";
return false;
}
return true;
}
private static bool IsCommandOnCooldown(Entity userEntity, out int secondsLeft)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
secondsLeft = 0;
if (!_commandCooldowns.TryGetValue(userEntity, out var value))
{
return false;
}
TimeSpan timeSpan = CommandCooldown - (DateTime.UtcNow - value);
if (timeSpan <= TimeSpan.Zero)
{
return false;
}
secondsLeft = Math.Max(1, (int)Math.Ceiling(timeSpan.TotalSeconds));
return true;
}
private static bool ShouldDrop(ItemCategory category)
{
//IL_0001: 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)
if (HasCategory(category, (ItemCategory)2048))
{
return false;
}
return HasCategory(category, (ItemCategory)512);
}
private static bool HasCategory(ItemCategory category, ItemCategory flag)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
return (ItemCategory)(category & flag) == flag;
}
}
internal static class PlayerSettingService
{
private static readonly string CONFIG_DIR = Path.Combine(Paths.ConfigPath, "DropTeleportBound");
private static readonly string CONFIG_FILE = Path.Combine(CONFIG_DIR, "players_setting.json");
private static AutoDropBoundPreferenceData _data = new AutoDropBoundPreferenceData();
public static bool IsEnabled(string steamId)
{
return !string.IsNullOrWhiteSpace(steamId) && _data.EnabledPlayers.Contains(steamId);
}
public static bool SetEnabled(string steamId, bool enabled)
{
if (string.IsNullOrWhiteSpace(steamId))
{
return false;
}
bool flag = (enabled ? _data.EnabledPlayers.Add(steamId) : _data.EnabledPlayers.Remove(steamId));
if (flag)
{
Save();
}
return flag;
}
public static void Load()
{
try
{
Directory.CreateDirectory(CONFIG_DIR);
if (!File.Exists(CONFIG_FILE))
{
Save();
return;
}
string json = File.ReadAllText(CONFIG_FILE);
_data = JsonSerializer.Deserialize<AutoDropBoundPreferenceData>(json) ?? new AutoDropBoundPreferenceData();
AutoDropBoundPreferenceData data = _data;
if (data.EnabledPlayers == null)
{
HashSet<string> hashSet = (data.EnabledPlayers = new HashSet<string>());
}
}
catch (Exception e)
{
Core.LogException(e, "Load");
_data = new AutoDropBoundPreferenceData();
}
}
public static void Save()
{
try
{
Directory.CreateDirectory(CONFIG_DIR);
string contents = JsonSerializer.Serialize(_data, new JsonSerializerOptions
{
WriteIndented = true
});
File.WriteAllText(CONFIG_FILE, contents);
}
catch (Exception e)
{
Core.LogException(e, "Save");
}
}
}
internal static class ServerSettingsService
{
public static string TeleportBoundItemsDisabledMessage => "<color=yellow>This server allows teleporting with teleport-bound items. You can use waygates normally.</color>";
public static bool IsTeleportBoundItemsEnabled()
{
try
{
if (Core.ServerGameSettingsSystem == null)
{
Core.InitializeAfterLoaded();
}
return Core.ServerGameSettingsSystem._Settings.TeleportBoundItems;
}
catch (Exception e)
{
Core.LogException(e, "IsTeleportBoundItemsEnabled");
return true;
}
}
}
internal static class WaypointAutoDropService
{
private static readonly Dictionary<Entity, DateTime> _autoDropCooldowns = new Dictionary<Entity, DateTime>();
private static readonly Dictionary<Entity, DateTime> _notifyCooldowns = new Dictionary<Entity, DateTime>();
private static readonly Dictionary<Entity, CastSnapshot> _lastCastSnapshots = new Dictionary<Entity, CastSnapshot>();
private static readonly Dictionary<Entity, PendingDrop> _pendingDrops = new Dictionary<Entity, PendingDrop>();
private static DateTime _nextScanTime = DateTime.MinValue;
private static readonly TimeSpan ScanInterval = TimeSpan.FromSeconds(0.1);
private const double AutoDropDelaySeconds = 0.1;
private const int AutoDropCooldownSeconds = 2;
private const int NotifyCooldownSeconds = 3;
private static bool _scannerStopped;
public static void Update(TeleportIncorrectPositionSystem system)
{
//IL_006a: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (!Plugin.AutoDropOnTeleportBoundItems.Value)
{
StopScanner();
return;
}
if (!ServerSettingsService.IsTeleportBoundItemsEnabled())
{
StopScanner();
return;
}
_scannerStopped = false;
DateTime utcNow = DateTime.UtcNow;
if (utcNow < _nextScanTime)
{
return;
}
_nextScanTime = utcNow + ScanInterval;
NativeArray<Entity> val = default(NativeArray<Entity>);
try
{
EntityManager entityManager = ((ComponentSystemBase)system).EntityManager;
EntityQuery _query_524969957_ = system.__query_524969957_0;
val = ((EntityQuery)(ref _query_524969957_)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
for (int i = 0; i < val.Length; i++)
{
HandlePlayer(entityManager, val[i], utcNow);
}
ProcessPendingDrops(entityManager, utcNow);
CleanupCachedState(entityManager, utcNow);
}
catch (Exception e)
{
Core.LogException(e, "Update");
}
finally
{
if (val.IsCreated)
{
val.Dispose();
}
}
}
private static void HandlePlayer(EntityManager entityManager, Entity character, DateTime now)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: 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_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_0046: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: 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_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
if (character == Entity.Null || !((EntityManager)(ref entityManager)).Exists(character) || !((EntityManager)(ref entityManager)).HasComponent<AbilityBar_Shared>(character))
{
return;
}
AbilityBar_Shared componentData = ((EntityManager)(ref entityManager)).GetComponentData<AbilityBar_Shared>(character);
CastSnapshot value = CastSnapshot.From(componentData);
CastSnapshot value2;
bool flag = _lastCastSnapshots.TryGetValue(character, out value2);
Entity userEntity = Entity.Null;
bool flag2 = flag && value.HasChangedFrom(value2) && Helper.TryGetBlockedWaypointUser(entityManager, character, out userEntity);
_lastCastSnapshots[character] = value;
if (!flag2)
{
return;
}
string steamId = Helper.GetSteamId(entityManager, userEntity);
if (string.IsNullOrWhiteSpace(steamId))
{
return;
}
if (PlayerSettingService.IsEnabled(steamId))
{
if (IsAutoDropOnCooldown(userEntity, now))
{
return;
}
if (ShouldPreventAutoDropInPvPCombat(entityManager, character))
{
if (Plugin.NotifyWhenAutoDropDisabled.Value && !IsNotifyOnCooldown(userEntity, now) && DropTeleportBoundService.HasTeleportBoundItems(character))
{
SendCombatBlockedNotification(entityManager, userEntity, now);
}
}
else
{
QueueAutoDrop(character, userEntity, steamId, now);
}
}
else if (Plugin.NotifyWhenAutoDropDisabled.Value && !IsNotifyOnCooldown(userEntity, now) && DropTeleportBoundService.HasTeleportBoundItems(character))
{
SendDisabledAutoDropNotification(entityManager, userEntity, now);
}
}
private static void QueueAutoDrop(Entity character, Entity userEntity, string steamId, DateTime now)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
DateTime executeAt = now + TimeSpan.FromSeconds(0.1);
_pendingDrops[character] = new PendingDrop(userEntity, steamId, executeAt);
}
private static void ProcessPendingDrops(EntityManager entityManager, DateTime now)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: 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_0098: Unknown result type (might be due to invalid IL or missing references)
if (_pendingDrops.Count == 0)
{
return;
}
List<Entity> list = new List<Entity>();
foreach (KeyValuePair<Entity, PendingDrop> pendingDrop in _pendingDrops)
{
Entity key = pendingDrop.Key;
PendingDrop value = pendingDrop.Value;
if (!(now < value.ExecuteAt))
{
list.Add(key);
ExecutePendingDrop(entityManager, key, value, now);
}
}
for (int i = 0; i < list.Count; i++)
{
_pendingDrops.Remove(list[i]);
}
}
private static void ExecutePendingDrop(EntityManager entityManager, Entity character, PendingDrop pendingDrop, DateTime now)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
Entity userEntity = pendingDrop.UserEntity;
if (ServerSettingsService.IsTeleportBoundItemsEnabled() && !(character == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(character) && !(userEntity == Entity.Null) && ((EntityManager)(ref entityManager)).Exists(userEntity) && ((EntityManager)(ref entityManager)).HasComponent<User>(userEntity) && PlayerSettingService.IsEnabled(pendingDrop.SteamId) && !IsAutoDropOnCooldown(userEntity, now) && !ShouldPreventAutoDropInPvPCombat(entityManager, character) && Helper.TryGetBlockedWaypointUser(entityManager, character, out var userEntity2) && !(userEntity2 != userEntity) && DropTeleportBoundService.TryAutoDropTeleportBoundItems(userEntity, character).DroppedStacks > 0)
{
_autoDropCooldowns[userEntity] = now;
if (Plugin.NotifyWhenAutoDropEnabled.Value)
{
Helper.NotifyUser(entityManager, userEntity, "<color=yellow>Auto-dropped teleport-bound items.</color>\nUse <color=green>.tpb off</color> to disable auto-drop.");
}
}
}
private static void SendDisabledAutoDropNotification(EntityManager entityManager, Entity userEntity, DateTime now)
{
//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_000f: Unknown result type (might be due to invalid IL or missing references)
_notifyCooldowns[userEntity] = now;
Helper.NotifyUser(entityManager, userEntity, "<color=yellow>You are carrying teleport-bound items.</color>\nUse <color=green>.throw</color> to drop them, or use <color=green>.tpb on</color> to enable auto-drop.");
}
private static void SendCombatBlockedNotification(EntityManager entityManager, Entity userEntity, DateTime now)
{
//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_000f: Unknown result type (might be due to invalid IL or missing references)
_notifyCooldowns[userEntity] = now;
Helper.NotifyUser(entityManager, userEntity, "<color=yellow>Auto-drop is blocked while in combat.</color>\nUse <color=green>.throw</color> to drop teleport-bound items manually.");
}
private static bool IsAutoDropOnCooldown(Entity userEntity, DateTime now)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (!_autoDropCooldowns.TryGetValue(userEntity, out var value))
{
return false;
}
return now - value < TimeSpan.FromSeconds(2.0);
}
private static bool IsNotifyOnCooldown(Entity userEntity, DateTime now)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (!_notifyCooldowns.TryGetValue(userEntity, out var value))
{
return false;
}
return now - value < TimeSpan.FromSeconds(3.0);
}
private static bool ShouldPreventAutoDropInPvPCombat(EntityManager entityManager, Entity character)
{
//IL_000d: 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)
return Plugin.PreventAutoDropInPvPCombat.Value && Helper.HasPvPCombatBuff(entityManager, character);
}
private static void CleanupCachedState(EntityManager entityManager, DateTime now)
{
//IL_0001: 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_0041: 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)
CleanupDateTimeDictionary(entityManager, _autoDropCooldowns, now, TimeSpan.FromMinutes(5.0), 256);
CleanupDateTimeDictionary(entityManager, _notifyCooldowns, now, TimeSpan.FromMinutes(5.0), 256);
CleanupCastSnapshots(entityManager);
CleanupPendingDrops(entityManager, now);
}
private static void CleanupCastSnapshots(EntityManager entityManager)
{
//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_004f: 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_009b: Unknown result type (might be due to invalid IL or missing references)
if (_lastCastSnapshots.Count < 512)
{
return;
}
List<Entity> list = new List<Entity>();
foreach (KeyValuePair<Entity, CastSnapshot> lastCastSnapshot in _lastCastSnapshots)
{
if (lastCastSnapshot.Key == Entity.Null || !((EntityManager)(ref entityManager)).Exists(lastCastSnapshot.Key))
{
list.Add(lastCastSnapshot.Key);
}
}
for (int i = 0; i < list.Count; i++)
{
_lastCastSnapshots.Remove(list[i]);
}
}
private static void CleanupPendingDrops(EntityManager entityManager, DateTime now)
{
//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_004f: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
if (_pendingDrops.Count < 256)
{
return;
}
List<Entity> list = new List<Entity>();
foreach (KeyValuePair<Entity, PendingDrop> pendingDrop in _pendingDrops)
{
if (pendingDrop.Key == Entity.Null || !((EntityManager)(ref entityManager)).Exists(pendingDrop.Key) || now - pendingDrop.Value.ExecuteAt > TimeSpan.FromSeconds(10.0))
{
list.Add(pendingDrop.Key);
}
}
for (int i = 0; i < list.Count; i++)
{
_pendingDrops.Remove(list[i]);
}
}
private static void CleanupDateTimeDictionary(EntityManager entityManager, Dictionary<Entity, DateTime> dictionary, DateTime now, TimeSpan maxAge, int threshold)
{
//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_0044: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
if (dictionary.Count < threshold)
{
return;
}
List<Entity> list = new List<Entity>();
foreach (KeyValuePair<Entity, DateTime> item in dictionary)
{
if (item.Key == Entity.Null || !((EntityManager)(ref entityManager)).Exists(item.Key) || now - item.Value > maxAge)
{
list.Add(item.Key);
}
}
for (int i = 0; i < list.Count; i++)
{
dictionary.Remove(list[i]);
}
}
private static void StopScanner()
{
if (!_scannerStopped)
{
ClearCachedState();
_scannerStopped = true;
}
}
private static void ClearCachedState()
{
_autoDropCooldowns.Clear();
_notifyCooldowns.Clear();
_lastCastSnapshots.Clear();
_pendingDrops.Clear();
_nextScanTime = DateTime.MinValue;
}
}
}
namespace DropTeleportBound.Patches
{
[HarmonyPatch(typeof(SceneSectionStreamingSystem), "ShutdownAsynchrnonousStreamingSupport")]
public static class InitializationPatch
{
[HarmonyPostfix]
public static void OneShot_AfterLoad_InitializationPatch()
{
if (Core.IsServer)
{
Core.InitializeAfterLoaded();
Harmony harmony = Plugin.Harmony;
if (harmony != null)
{
harmony.Unpatch((MethodBase)typeof(SceneSectionStreamingSystem).GetMethod("ShutdownAsynchrnonousStreamingSupport"), typeof(InitializationPatch).GetMethod("OneShot_AfterLoad_InitializationPatch"));
}
}
}
}
[HarmonyPatch(typeof(TeleportIncorrectPositionSystem), "OnUpdate")]
internal static class WaypointAutoDropScannerPatch
{
[HarmonyPostfix]
private static void Postfix(TeleportIncorrectPositionSystem __instance)
{
WaypointAutoDropService.Update(__instance);
}
}
}
namespace DropTeleportBound.Data
{
internal sealed class AutoDropBoundPreferenceData
{
public HashSet<string> EnabledPlayers { get; set; } = new HashSet<string>();
}
internal readonly struct DropTeleportBoundResult
{
public bool Success { get; }
public string Message { get; }
public DropTeleportBoundStats Stats { get; }
private DropTeleportBoundResult(bool success, string message, DropTeleportBoundStats stats)
{
Success = success;
Message = message;
Stats = stats;
}
public static DropTeleportBoundResult Ok(string message, DropTeleportBoundStats stats)
{
return new DropTeleportBoundResult(success: true, message, stats);
}
public static DropTeleportBoundResult Fail(string message)
{
return new DropTeleportBoundResult(success: false, message, default(DropTeleportBoundStats));
}
}
internal readonly struct DropTeleportBoundStats
{
public int ScannedSlots { get; }
public int MatchedStacks { get; }
public int DroppedStacks { get; }
public int DroppedAmount { get; }
public DropTeleportBoundStats(int scannedSlots, int matchedStacks, int droppedStacks, int droppedAmount)
{
ScannedSlots = scannedSlots;
MatchedStacks = matchedStacks;
DroppedStacks = droppedStacks;
DroppedAmount = droppedAmount;
}
}
internal readonly struct PendingDrop
{
public Entity UserEntity { get; }
public string SteamId { get; }
public DateTime ExecuteAt { get; }
public PendingDrop(Entity userEntity, string steamId, DateTime executeAt)
{
//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)
UserEntity = userEntity;
SteamId = steamId;
ExecuteAt = executeAt;
}
}
internal readonly struct CastSnapshot
{
private readonly int _castStartedCounter;
private readonly int _castCompletedCounter;
private readonly int _serverCastCounter;
private readonly int _serverInterruptCounter;
private CastSnapshot(int castStartedCounter, int castCompletedCounter, int serverCastCounter, int serverInterruptCounter)
{
_castStartedCounter = castStartedCounter;
_castCompletedCounter = castCompletedCounter;
_serverCastCounter = serverCastCounter;
_serverInterruptCounter = serverInterruptCounter;
}
public static CastSnapshot From(AbilityBar_Shared abilityBar)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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)
return new CastSnapshot(abilityBar.CastStartedCounter, abilityBar.CastCompletedCounter, abilityBar.ServerCastCounter, abilityBar.ServerInterruptCounter);
}
public bool HasChangedFrom(CastSnapshot other)
{
return _castStartedCounter != other._castStartedCounter || _castCompletedCounter != other._castCompletedCounter || _serverCastCounter != other._serverCastCounter || _serverInterruptCounter != other._serverInterruptCounter;
}
}
internal readonly struct InventoryItemContext
{
public Entity InventoryEntity { get; }
public int Slot { get; }
public InventoryBuffer Item { get; }
public InventoryItemContext(Entity inventoryEntity, int slot, InventoryBuffer item)
{
//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_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)
InventoryEntity = inventoryEntity;
Slot = slot;
Item = item;
}
}
}
namespace DropTeleportBound.Commands
{
[CommandGroup("tpbound", "tpb")]
internal static class AutoDropTeleportBoundCommands
{
[Command("on", null, null, "Enable automatic dropping of teleport-bound items when using waygates.", null, false)]
public static void AutoDropBoundOnCommand(ChatCommandContext ctx)
{
string steamId;
if (!Plugin.AutoDropOnTeleportBoundItems.Value)
{
ctx.Reply("<color=yellow>Auto-drop is currently disabled by the server.</color>\nUse <color=green>.throw</color> to drop teleport-bound items manually.");
}
else if (!ServerSettingsService.IsTeleportBoundItemsEnabled())
{
ctx.Reply(ServerSettingsService.TeleportBoundItemsDisabledMessage);
}
else if (TryGetSteamId(ctx, out steamId))
{
PlayerSettingService.SetEnabled(steamId, enabled: true);
ctx.Reply("<color=green>Auto-drop for teleport-bound items is now enabled.</color>");
}
}
[Command("off", null, null, "Disable automatic dropping of teleport-bound items when using waygates.", null, false)]
public static void AutoDropBoundOffCommand(ChatCommandContext ctx)
{
string steamId;
if (!Plugin.AutoDropOnTeleportBoundItems.Value)
{
ctx.Reply("<color=yellow>Auto-drop is currently disabled by the server.</color>\nUse <color=green>.throw</color> to drop teleport-bound items manually.");
}
else if (!ServerSettingsService.IsTeleportBoundItemsEnabled())
{
ctx.Reply(ServerSettingsService.TeleportBoundItemsDisabledMessage);
}
else if (TryGetSteamId(ctx, out steamId))
{
PlayerSettingService.SetEnabled(steamId, enabled: false);
ctx.Reply("<color=yellow>Auto-drop for teleport-bound items is now disabled.</color>");
}
}
[Command("status", null, null, "Check whether automatic dropping of teleport-bound items is enabled.", null, false)]
public static void AutoDropBoundStatusCommand(ChatCommandContext ctx)
{
if (TryGetSteamId(ctx, out var steamId))
{
bool flag = PlayerSettingService.IsEnabled(steamId);
bool value = Plugin.AutoDropOnTeleportBoundItems.Value;
bool flag2 = ServerSettingsService.IsTeleportBoundItemsEnabled();
string text = (flag ? "<color=green>Enabled</color>" : "<color=red>Disabled</color>");
string text2 = (value ? "<color=green>Enabled</color>" : "<color=red>Disabled</color>");
string text3 = (flag2 ? "<color=yellow>Does not allow teleporting with teleport-bound items.</color>" : "<color=green>Allows teleporting with teleport-bound items.</color>");
ctx.Reply("<color=yellow>Teleport-bound item drop status</color>\nYour auto-drop setting: " + text + "\nGlobal auto-drop setting: " + text2 + "\nServer teleport-bound rule: " + text3);
}
}
private static bool TryGetSteamId(ChatCommandContext ctx, out string steamId)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
steamId = Helper.GetSteamId(Core.EntityManager, ctx.Event.SenderUserEntity);
if (!string.IsNullOrWhiteSpace(steamId))
{
return true;
}
ctx.Reply("<color=red>Unable to read your SteamID.</color>");
return false;
}
}
internal static class DropTeleportBoundCommands
{
[Command("throw", "dropbound", null, "Drop all items that cannot be teleported through waygates.", null, false)]
public static void DropBoundCommand(ChatCommandContext ctx)
{
//IL_0007: 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)
ctx.Reply(DropTeleportBoundService.TryDropTeleportBoundItems(ctx.Event.SenderUserEntity, ctx.Event.SenderCharacterEntity).Message);
}
}
}