using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Microsoft.CodeAnalysis;
using ProjectM;
using ProjectM.CastleBuilding;
using ProjectM.Gameplay.Scripting;
using ProjectM.Network;
using ProjectM.Shared;
using ProjectM.Tiles;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FasterCastleMovement")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Faster movement on foot on castle plots you or a clanmate own, as fast as Wolf Form")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d34736b1cdb69266e80b1ce65c407014f8936054")]
[assembly: AssemblyProduct("FasterCastleMovement")]
[assembly: AssemblyTitle("FasterCastleMovement")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace FasterCastleMovement
{
internal enum PlotClass
{
Outside,
Unclaimed,
Own,
Clan,
Other
}
internal readonly record struct Plot(PlotClass Class, int TerritoryIndex, string Owner, int2 Tile)
{
public override string ToString()
{
//IL_008b: 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)
if (Class == PlotClass.Outside)
{
return $"Outside tile={Tile}";
}
return $"{Class} territory={TerritoryIndex} owner={Owner} tile={Tile}";
}
}
internal static class Plots
{
private static Entity[] _territories;
internal static int Count(EntityManager em)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return Territories(em).Length;
}
private static Entity[] Territories(EntityManager em)
{
//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_002c: 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_003a: 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_005a: Unknown result type (might be due to invalid IL or missing references)
if (_territories != null)
{
return _territories;
}
EntityQuery val = ((EntityManager)(ref em)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1]
{
new ComponentType(Il2CppType.Of<CastleTerritory>(), (AccessMode)1)
});
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
List<Entity> list = new List<Entity>();
for (int i = 0; i < val2.Length; i++)
{
if (((EntityManager)(ref em)).HasBuffer<CastleTerritoryTiles>(val2[i]))
{
list.Add(val2[i]);
}
}
_territories = list.ToArray();
}
finally
{
val2.Dispose();
((EntityQuery)(ref val)).Dispose();
}
return _territories;
}
internal static Plot Classify(EntityManager em, Entity userEntity, Entity character)
{
//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_0008: 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_0017: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_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_005b: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_007f: 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)
LocalToWorld componentData = ((EntityManager)(ref em)).GetComponentData<LocalToWorld>(character);
float3 position = ((LocalToWorld)(ref componentData)).Position;
int2 val = SpaceConversion.WorldToTile(new float2(position.x, position.z));
Entity[] array = Territories(em);
foreach (Entity val2 in array)
{
if (!((EntityManager)(ref em)).Exists(val2))
{
continue;
}
CastleTerritory componentData2 = ((EntityManager)(ref em)).GetComponentData<CastleTerritory>(val2);
if (((BoundsMinMax)(ref componentData2.WorldBounds)).Contains(val))
{
DynamicBuffer<CastleTerritoryTiles> buffer = ((EntityManager)(ref em)).GetBuffer<CastleTerritoryTiles>(val2, false);
string ownerName;
if (CastleTerritoryExtensions.IsTileInTerritory(val, ref componentData2, ref buffer))
{
return new Plot(Owner(em, userEntity, componentData2.CastleHeart, out ownerName), componentData2.CastleTerritoryIndex, ownerName, val);
}
}
}
return new Plot(PlotClass.Outside, -1, "-", val);
}
private unsafe static PlotClass Owner(EntityManager em, Entity userEntity, Entity heart, out string ownerName)
{
//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_0016: 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_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_0032: 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)
//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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: 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_00a3: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
ownerName = "-";
if (heart == Entity.Null || !((EntityManager)(ref em)).Exists(heart) || !((EntityManager)(ref em)).HasComponent<UserOwner>(heart))
{
return PlotClass.Unclaimed;
}
UserOwner componentData = ((EntityManager)(ref em)).GetComponentData<UserOwner>(heart);
Entity entityOnServer = ((NetworkedEntity)(ref componentData.Owner)).GetEntityOnServer();
if (entityOnServer == Entity.Null || !((EntityManager)(ref em)).Exists(entityOnServer) || !((EntityManager)(ref em)).HasComponent<User>(entityOnServer))
{
return PlotClass.Unclaimed;
}
User componentData2 = ((EntityManager)(ref em)).GetComponentData<User>(entityOnServer);
ownerName = ((object)(*(FixedString64Bytes*)(&componentData2.CharacterName))/*cast due to .constrained prefix*/).ToString();
if (entityOnServer == userEntity)
{
return PlotClass.Own;
}
User componentData3 = ((EntityManager)(ref em)).GetComponentData<User>(userEntity);
Entity entityOnServer2 = ((NetworkedEntity)(ref componentData3.ClanEntity)).GetEntityOnServer();
if (!(entityOnServer2 != Entity.Null) || !(entityOnServer2 == ((NetworkedEntity)(ref componentData2.ClanEntity)).GetEntityOnServer()))
{
return PlotClass.Other;
}
return PlotClass.Clan;
}
}
[BepInPlugin("FasterCastleMovement", "FasterCastleMovement", "1.0.0")]
public class Plugin : BasePlugin
{
internal static ManualLogSource Logger;
internal static ConfigEntry<bool> Enabled;
internal static ConfigEntry<float> OwnSpeedPercent;
internal static ConfigEntry<float> ClanSpeedPercent;
internal static ConfigEntry<int> CheckIntervalSeconds;
internal static ConfigEntry<bool> LogChanges;
internal static World ServerWorld;
internal static Plugin Instance;
private Harmony _harmony;
public override void Load()
{
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Expected O, but got Unknown
Logger = ((BasePlugin)this).Log;
Instance = this;
Enabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "Set to false to turn the mod off (everything stays as in the base game).");
OwnSpeedPercent = ((BasePlugin)this).Config.Bind<float>("General", "OwnSpeedPercent", 62.5f, "Movement speed bonus (%) on foot on castle plots you own (62.5 = Wolf Form). 0 = off.");
ClanSpeedPercent = ((BasePlugin)this).Config.Bind<float>("General", "ClanSpeedPercent", 62.5f, "Movement speed bonus (%) on foot on castle plots a clanmate owns (62.5 = Wolf Form). 0 = off.");
CheckIntervalSeconds = ((BasePlugin)this).Config.Bind<int>("General", "CheckIntervalSeconds", 1, "How often (seconds) online players are checked.");
LogChanges = ((BasePlugin)this).Config.Bind<bool>("General", "LogChanges", true, "Log a line each time the bonus is applied or removed.");
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val;
if (!Paths.ProcessName.Equals("VRisingServer", StringComparison.OrdinalIgnoreCase))
{
ManualLogSource log = ((BasePlugin)this).Log;
val = new BepInExInfoLogInterpolatedStringHandler(47, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("FasterCastleMovement");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is a server mod; nothing to do on the client.");
}
log.LogInfo(val);
return;
}
_harmony = Harmony.CreateAndPatchAll(typeof(ServerReadyPatch), "FasterCastleMovement");
ManualLogSource log2 = ((BasePlugin)this).Log;
val = new BepInExInfoLogInterpolatedStringHandler(44, 5, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("FasterCastleMovement");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded on server ");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(Enabled=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(Enabled.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Own=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(OwnSpeedPercent.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("%, Clan=");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(ClanSpeedPercent.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("%)");
}
log2.LogInfo(val);
}
public override bool Unload()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
return true;
}
internal static void OnServerReady(World world)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
bool flag = default(bool);
try
{
ServerWorld = world;
ManualLogSource logger = Logger;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(42, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Server ready (world ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(world.Name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Plots.Count(world.EntityManager));
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" castle territories)");
}
logger.LogInfo(val);
if (SpeedKeeper.CheckPrefabs(world))
{
((BasePlugin)Instance).AddComponent<SpeedKeeper>();
}
}
catch (Exception ex)
{
ManualLogSource logger2 = Logger;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Server-ready handler failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
logger2.LogError(val2);
}
}
}
[HarmonyPatch(typeof(SpawnTeamSystem_OnPersistenceLoad), "OnUpdate")]
internal static class ServerReadyPatch
{
private static bool _done;
private static void Postfix(SpawnTeamSystem_OnPersistenceLoad __instance)
{
if (_done)
{
return;
}
World world = ((ComponentSystemBase)__instance).World;
if (world != null && !(world.Name != "Server"))
{
PrefabCollectionSystem existingSystemManaged = world.GetExistingSystemManaged<PrefabCollectionSystem>();
if (existingSystemManaged != null && existingSystemManaged.GameDataInitialized)
{
_done = true;
Plugin.OnServerReady(world);
}
}
}
}
public class SpeedKeeper : MonoBehaviour
{
internal static readonly PrefabGUID Carrier = new PrefabGUID(-1850436869);
internal static readonly PrefabGUID WolfForm = new PrefabGUID(900707394);
private float _next;
private readonly Dictionary<Entity, float> _applied = new Dictionary<Entity, float>();
private readonly HashSet<Entity> _pending = new HashSet<Entity>();
private readonly Dictionary<ulong, bool> _wolf = new Dictionary<ulong, bool>();
public SpeedKeeper(IntPtr ptr)
: base(ptr)
{
}
private static bool WolfFormUnlocked(EntityManager em, Entity userEntity)
{
//IL_0002: 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_0014: 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_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: 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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if (!((EntityManager)(ref em)).HasComponent<ProgressionMapper>(userEntity))
{
return false;
}
ProgressionMapper componentData = ((EntityManager)(ref em)).GetComponentData<ProgressionMapper>(userEntity);
Entity entityOnServer = ((NetworkedEntity)(ref componentData.ProgressionEntity)).GetEntityOnServer();
if (entityOnServer == Entity.Null || !((EntityManager)(ref em)).HasBuffer<UnlockedShapeshiftElement>(entityOnServer))
{
return false;
}
DynamicBuffer<UnlockedShapeshiftElement> buffer = ((EntityManager)(ref em)).GetBuffer<UnlockedShapeshiftElement>(entityOnServer, false);
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i].UnlockedShapeshift == WolfForm)
{
return true;
}
}
return false;
}
private void Update()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Expected O, but got Unknown
if (Time.unscaledTime < _next)
{
return;
}
_next = Time.unscaledTime + (float)Math.Max(1, Plugin.CheckIntervalSeconds.Value);
World serverWorld = Plugin.ServerWorld;
if (serverWorld == null || !serverWorld.IsCreated)
{
return;
}
try
{
CheckPlayers(serverWorld);
}
catch (Exception ex)
{
ManualLogSource logger = Plugin.Logger;
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Player check failed: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
}
logger.LogError(val);
}
}
private unsafe void CheckPlayers(World world)
{
//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_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_01ac: 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_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: 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_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Expected O, but got Unknown
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: 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_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_034e: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_0360: Unknown result type (might be due to invalid IL or missing references)
//IL_0368: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_037a: Unknown result type (might be due to invalid IL or missing references)
//IL_037c: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Unknown result type (might be due to invalid IL or missing references)
//IL_0386: Unknown result type (might be due to invalid IL or missing references)
//IL_0388: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_02da: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Expected O, but got Unknown
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03cf: Expected O, but got Unknown
EntityManager entityManager = world.EntityManager;
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery((ComponentType[])(object)new ComponentType[1]
{
new ComponentType(Il2CppType.Of<User>(), (AccessMode)1)
});
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
try
{
bool flag3 = default(bool);
for (int i = 0; i < val2.Length; i++)
{
Entity val3 = val2[i];
User componentData = ((EntityManager)(ref entityManager)).GetComponentData<User>(val3);
if (!componentData.IsConnected)
{
continue;
}
Entity entityOnServer = ((NetworkedEntity)(ref componentData.LocalCharacter)).GetEntityOnServer();
if (entityOnServer == Entity.Null || !((EntityManager)(ref entityManager)).Exists(entityOnServer))
{
continue;
}
string text = ((object)(*(FixedString64Bytes*)(&componentData.CharacterName))/*cast due to .constrained prefix*/).ToString();
Plot plot = Plots.Classify(entityManager, val3, entityOnServer);
float num = plot.Class switch
{
PlotClass.Own => Plugin.OwnSpeedPercent.Value,
PlotClass.Clan => Plugin.ClanSpeedPercent.Value,
_ => 0f,
};
bool flag = NotOnFootBuff(entityManager, entityOnServer) == Entity.Null;
bool flag2 = WolfFormUnlocked(entityManager, val3);
if (Plugin.LogChanges.Value && (!_wolf.TryGetValue(componentData.PlatformId, out var value) || value != flag2))
{
ManualLogSource logger = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(12, 2, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": Wolf Form ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(flag2 ? "unlocked" : "not unlocked yet, no speed bonus");
}
logger.LogInfo(val4);
}
_wolf[componentData.PlatformId] = flag2;
if (!Plugin.Enabled.Value || !flag || !flag2 || num <= 0f)
{
num = 0f;
}
Entity val5 = FindBuff(entityManager, entityOnServer, Carrier);
float value2;
float? num2 = (_applied.TryGetValue(val5, out value2) ? new float?(value2) : ((float?)null));
if (val5 != Entity.Null && !num2.HasValue && _pending.Remove(val3))
{
num2 = Configure(entityManager, val5, num);
ManualLogSource logger2 = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(59, 1, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": speed buff found one tick after applying; configured late");
}
logger2.LogInfo(val4);
}
float? num3 = ((num > 0f) ? new float?(num) : ((float?)null));
if (num3 == num2)
{
continue;
}
if (val5 != Entity.Null)
{
_applied.Remove(val5);
DestroyUtility.Destroy(entityManager, val5, (DestroyDebugReason)13, (string)null, 0);
if (Plugin.LogChanges.Value)
{
ManualLogSource logger3 = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(33, 3, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": speed bonus removed (");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Plot>(plot);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(", onFoot=");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<bool>(flag);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")");
}
logger3.LogInfo(val4);
}
}
else
{
if (!num3.HasValue)
{
continue;
}
world.GetExistingSystemManaged<DebugEventsSystem>().ApplyBuff(new FromCharacter
{
User = val3,
Character = entityOnServer
}, new ApplyBuffDebugEvent
{
BuffPrefabGUID = Carrier
});
val5 = FindBuff(entityManager, entityOnServer, Carrier);
if (val5 == Entity.Null)
{
_pending.Add(val3);
continue;
}
Configure(entityManager, val5, num);
if (Plugin.LogChanges.Value)
{
ManualLogSource logger4 = Plugin.Logger;
BepInExInfoLogInterpolatedStringHandler val4 = new BepInExInfoLogInterpolatedStringHandler(26, 3, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": speed bonus ");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<float>(num);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("% applied (");
((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Plot>(plot);
((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(")");
}
logger4.LogInfo(val4);
}
}
}
}
finally
{
val2.Dispose();
((EntityQuery)(ref val)).Dispose();
}
}
private float Configure(EntityManager em, Entity buff, float percent)
{
//IL_0002: 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_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: 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_0045: 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_0059: 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_004f: 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_0060: 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_0075: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: 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)
if (((EntityManager)(ref em)).HasComponent<LifeTime>(buff))
{
LifeTime componentData = ((EntityManager)(ref em)).GetComponentData<LifeTime>(buff);
componentData.Duration = 0f;
componentData.EndAction = (LifeTimeEndAction)0;
((EntityManager)(ref em)).SetComponentData<LifeTime>(buff, componentData);
}
if (((EntityManager)(ref em)).HasComponent<ModifyMovementSpeedBuff>(buff))
{
((EntityManager)(ref em)).RemoveComponent<ModifyMovementSpeedBuff>(buff);
}
DynamicBuffer<ModifyUnitStatBuff_DOTS> val = (((EntityManager)(ref em)).HasBuffer<ModifyUnitStatBuff_DOTS>(buff) ? ((EntityManager)(ref em)).GetBuffer<ModifyUnitStatBuff_DOTS>(buff, false) : ((EntityManager)(ref em)).AddBuffer<ModifyUnitStatBuff_DOTS>(buff));
val.Clear();
val.Add(new ModifyUnitStatBuff_DOTS
{
StatType = (UnitStatType)5,
ModificationType = (ModificationType)4,
Value = 1f + percent / 100f,
Modifier = 1f,
AttributeCapType = (AttributeCapType)(-1),
Id = ModificationId.NewId(0)
});
_applied[buff] = percent;
return percent;
}
internal static Entity NotOnFootBuff(EntityManager em, Entity character)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_0042: Unknown result type (might be due to invalid IL or missing references)
if (!((EntityManager)(ref em)).HasBuffer<BuffBuffer>(character))
{
return Entity.Null;
}
DynamicBuffer<BuffBuffer> buffer = ((EntityManager)(ref em)).GetBuffer<BuffBuffer>(character, false);
for (int i = 0; i < buffer.Length; i++)
{
Entity entity = buffer[i].Entity;
if (((EntityManager)(ref em)).Exists(entity) && (((EntityManager)(ref em)).HasComponent<Script_Buff_Shapeshift_DataShared>(entity) || ((EntityManager)(ref em)).HasComponent<MountBuff>(entity)))
{
return entity;
}
}
return Entity.Null;
}
private static Entity FindBuff(EntityManager em, Entity character, PrefabGUID guid)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: 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_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)
if (!((EntityManager)(ref em)).HasBuffer<BuffBuffer>(character))
{
return Entity.Null;
}
DynamicBuffer<BuffBuffer> buffer = ((EntityManager)(ref em)).GetBuffer<BuffBuffer>(character, false);
for (int i = 0; i < buffer.Length; i++)
{
if (buffer[i].PrefabGuid == guid && ((EntityManager)(ref em)).Exists(buffer[i].Entity))
{
return buffer[i].Entity;
}
}
return Entity.Null;
}
internal static bool CheckPrefabs(World world)
{
//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_0016: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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_0085: Expected O, but got Unknown
PrefabLookupMap prefabLookupMap = world.GetExistingSystemManaged<PrefabCollectionSystem>()._PrefabLookupMap;
bool result = true;
(PrefabGUID, string)[] array = new(PrefabGUID, string)[2]
{
(Carrier, "AB_Militia_EyeOfGod_Haste_Hard"),
(WolfForm, "AB_Shapeshift_Wolf_Group")
};
bool flag = default(bool);
for (int i = 0; i < array.Length; i++)
{
(PrefabGUID, string) tuple = array[i];
PrefabGUID item = tuple.Item1;
string item2 = tuple.Item2;
string name = ((PrefabLookupMap)(ref prefabLookupMap)).GetName(item);
if (!(name == item2))
{
ManualLogSource logger = Plugin.Logger;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(83, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Prefab ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(((PrefabGUID)(ref item)).GuidHash);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" should be ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(item2);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" but is '");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name ?? "missing");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'; the mod stays off. A game update may have changed it.");
}
logger.LogWarning(val);
result = false;
}
}
return result;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "FasterCastleMovement";
public const string PLUGIN_NAME = "FasterCastleMovement";
public const string PLUGIN_VERSION = "1.0.0";
}
}