using System;
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.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ProjectM;
using Stunlock.Core;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Transforms;
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("SteedForge")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Created a Steed with high stats that can be purchased.")]
[assembly: AssemblyFileVersion("0.1.10.0")]
[assembly: AssemblyInformationalVersion("0.1.10+1.Branch.main.Sha.c33d0879382e1a0da34861ec55914ba7e637a80e")]
[assembly: AssemblyProduct("SteedForge")]
[assembly: AssemblyTitle("SteedForge")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.10.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public static class MainConfig
{
public static ConfigEntry<bool> ModEnabled { get; private set; }
public static ConfigEntry<float> DefaultSpeed { get; private set; }
public static ConfigEntry<float> DefaultAcceleration { get; private set; }
public static ConfigEntry<float> DefaultRotation { get; private set; }
public static ConfigEntry<string> CurrencyName { get; private set; }
public static ConfigEntry<int> RequiredCurrencyGUID { get; private set; }
public static ConfigEntry<int> CurrencyCost { get; private set; }
public static void Init(ConfigFile config)
{
ModEnabled = config.Bind<bool>("General", "EnableMod", true, "Enable or disable the SteedForge mod functionality.");
DefaultSpeed = config.Bind<float>("Horse", "DefaultSpeed", 10f, "Default maximum speed for the upgraded horse.");
DefaultAcceleration = config.Bind<float>("Horse", "DefaultAcceleration", 7f, "Default acceleration for the upgraded horse.");
DefaultRotation = config.Bind<float>("Horse", "DefaultRotation", 14f, "Default rotation speed for the upgraded horse.");
CurrencyName = config.Bind<string>("Currency", "CurrencyName", "Silver Coin", "The name of the currency required for upgrades.");
RequiredCurrencyGUID = config.Bind<int>("Currency", "RequiredCurrencyGUID", -949672483, "The GUID of the required currency.");
CurrencyCost = config.Bind<int>("Currency", "CurrencyCost", 500, "The cost in currency for the upgrade.");
}
public static void ReloadConfig(ConfigFile config)
{
config.Reload();
}
}
namespace SteedForge
{
public static class Commands
{
private const int VampireHorseGUID = -1502865710;
[Command("upgradehorse", "uh", null, "Upgrade the stats of a tamed vampire horse you are aiming at", null, false)]
public static void UpgradeHorse(ChatCommandContext ctx)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: 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_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
//IL_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
if (!MainConfig.ModEnabled.Value)
{
ctx.Reply("<color=orange>This mod is currently disabled.</color>");
return;
}
EntityManager entityManager = VWorldUtils.Server.EntityManager;
float value = MainConfig.DefaultSpeed.Value;
float value2 = MainConfig.DefaultAcceleration.Value;
float value3 = MainConfig.DefaultRotation.Value;
int value4 = MainConfig.CurrencyCost.Value;
string value5 = MainConfig.CurrencyName.Value;
PrefabGUID itemGuid = default(PrefabGUID);
((PrefabGUID)(ref itemGuid))..ctor(MainConfig.RequiredCurrencyGUID.Value);
EntityAimData val = default(EntityAimData);
if (!((EntityManager)(ref entityManager)).TryGetComponentData<EntityAimData>(ctx.Event.SenderCharacterEntity, ref val))
{
ctx.Reply("<color=red> Error: Could not read your aim/cursor data.</color>");
return;
}
float3 aimPosition = val.AimPosition;
Entity val2 = FindClosestHorseNearCursor(entityManager, aimPosition, 2.5f);
Mountable val3 = default(Mountable);
if (val2 == Entity.Null)
{
ctx.Reply("<color=yellow> No Vampiric Steed found near your cursor.</color>");
}
else if (((EntityManager)(ref entityManager)).TryGetComponentData<Mountable>(val2, ref val3))
{
if (AreFloatsEqual(val3.MaxSpeed, value) && AreFloatsEqual(val3.Acceleration, value2) && AreFloatsEqual(val3.RotationSpeed, value3 * 10f))
{
ctx.Reply("<color=yellow> The Vampiric Steed already has max stats. No upgrade applied.</color>");
return;
}
Entity senderCharacterEntity = ctx.Event.SenderCharacterEntity;
if (!SteedForgeInventorySystem.HasEnoughOfItem(senderCharacterEntity, itemGuid, value4))
{
ctx.Reply($"<color=red> You need {value4} {value5} to upgrade your Vampiric Steed.</color>");
}
else if (!SteedForgeInventorySystem.TryRemoveItem(senderCharacterEntity, itemGuid, value4))
{
ctx.Reply("<color=red> Failed to remove the required items from your inventory.</color>");
}
else
{
val3.MaxSpeed = value;
val3.Acceleration = value2;
val3.RotationSpeed = value3 * 10f;
((EntityManager)(ref entityManager)).SetComponentData<Mountable>(val2, val3);
ctx.Reply($"<color=green> The Vampiric Steed has been upgraded for {value4} {value5}!</color>");
}
}
else
{
ctx.Reply("<color=red> Internal error: Target entity unexpectedly missing Mountable component.</color>");
}
}
[Command("reloadsteedforge", "rsf", null, "Reloads the SteedForge configuration file.", null, true)]
public static void ReloadSteedForgeConfig(ChatCommandContext ctx)
{
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
if (Plugin.Instance == null || Plugin.Configuration == null)
{
ctx.Reply("<color=red>Error: Plugin instance or configuration not found. Cannot reload config.</color>");
ManualLogSource logInstance = Plugin.LogInstance;
if (logInstance != null)
{
logInstance.LogError((object)"Attempted to reload config, but Plugin.Instance or Plugin.Configuration was null.");
}
return;
}
bool flag = default(bool);
try
{
MainConfig.ReloadConfig(Plugin.Configuration);
ManualLogSource logInstance2 = Plugin.LogInstance;
if (logInstance2 != null)
{
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(58, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("SteedForge configuration reloaded by admin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<FixedString64Bytes>(ctx.User.CharacterName);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(". Mod Enabled: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(MainConfig.ModEnabled.Value);
}
logInstance2.LogInfo(val);
}
ctx.Reply("<color=green>SteedForge configuration reloaded successfully.</color>");
}
catch (Exception ex)
{
ManualLogSource logInstance3 = Plugin.LogInstance;
if (logInstance3 != null)
{
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(35, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Error reloading SteedForge config: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
logInstance3.LogError(val2);
}
ctx.Reply("<color=red>Error reloading SteedForge config: " + ex.Message + "</color>");
}
}
private static Entity FindClosestHorseNearCursor(EntityManager entityManager, float3 cursorPosition, float maxDistance)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_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_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
ComponentType[] array = (ComponentType[])(object)new ComponentType[3]
{
ComponentType.ReadOnly<Mountable>(),
ComponentType.ReadOnly<PrefabGUID>(),
ComponentType.ReadOnly<LocalToWorld>()
};
EntityQuery val = ((EntityManager)(ref entityManager)).CreateEntityQuery(Il2CppStructArray<ComponentType>.op_Implicit(array));
NativeArray<Entity> val2 = ((EntityQuery)(ref val)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2));
Entity result = Entity.Null;
float num = maxDistance * maxDistance;
try
{
Enumerator<Entity> enumerator = val2.GetEnumerator();
while (enumerator.MoveNext())
{
Entity current = enumerator.Current;
if (((EntityManager)(ref entityManager)).HasComponent<Dead>(current) || ((EntityManager)(ref entityManager)).HasComponent<DestroyTag>(current))
{
continue;
}
PrefabGUID componentData = ((EntityManager)(ref entityManager)).GetComponentData<PrefabGUID>(current);
if (((PrefabGUID)(ref componentData)).GuidHash == -1502865710)
{
LocalToWorld componentData2 = ((EntityManager)(ref entityManager)).GetComponentData<LocalToWorld>(current);
float3 position = ((LocalToWorld)(ref componentData2)).Position;
float num2 = math.distancesq(cursorPosition, position);
if (num2 < num)
{
num = num2;
result = current;
}
}
}
}
finally
{
val2.Dispose();
}
return result;
}
private static bool AreFloatsEqual(float value1, float value2, float epsilon = 0.0001f)
{
return math.abs(value1 - value2) < epsilon;
}
}
public static class HorseDb
{
public static readonly PrefabGUID CHAR_Mount_Horse = new PrefabGUID(1149585723);
}
[BepInPlugin("SteedForge", "SteedForge", "0.1.10")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
private Harmony _harmony;
internal static ManualLogSource LogInstance { get; private set; }
internal static Plugin? Instance { get; private set; }
internal static ConfigFile? Configuration { get; private set; }
public override void Load()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Expected O, but got Unknown
Instance = this;
LogInstance = ((BasePlugin)this).Log;
Configuration = ((BasePlugin)this).Config;
MainConfig.Init(((BasePlugin)this).Config);
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SteedForge] ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SteedForge");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" v");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("0.1.10");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded!");
}
log.LogInfo(val);
((BasePlugin)this).Log.LogInfo((object)"[SteedForge] Configuration initialized.");
_harmony = new Harmony("SteedForge");
_harmony.PatchAll();
((BasePlugin)this).Log.LogInfo((object)"[SteedForge] Harmony Patches applied (if any).");
CommandRegistry.RegisterAll();
((BasePlugin)this).Log.LogInfo((object)"[SteedForge] Commands registered.");
}
public override bool Unload()
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
CommandRegistry.UnregisterAssembly();
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(23, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[SteedForge] ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("SteedForge");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" unloaded.");
}
log.LogInfo(val);
Instance = null;
Configuration = null;
return true;
}
}
public static class SteedForgeInventorySystem
{
public static bool HasEnoughOfItem(Entity playerEntity, PrefabGUID itemGuid, int neededAmount)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
EntityManager entityManager = VWorldUtils.Server.EntityManager;
Entity val = default(Entity);
if (!InventoryUtilities.TryGetInventoryEntity<EntityManager>(entityManager, playerEntity, ref val, 0))
{
return false;
}
if (!((EntityManager)(ref entityManager)).HasBuffer<InventoryBuffer>(val))
{
return false;
}
DynamicBuffer<InventoryBuffer> buffer = ((EntityManager)(ref entityManager)).GetBuffer<InventoryBuffer>(val, false);
int num = 0;
Enumerator<InventoryBuffer> enumerator = buffer.GetEnumerator();
while (enumerator.MoveNext())
{
InventoryBuffer current = enumerator.Current;
if (current.ItemType == itemGuid)
{
num += current.Amount;
}
}
return num >= neededAmount;
}
public static bool TryRemoveItem(Entity playerEntity, PrefabGUID itemGuid, int removeAmount)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
if (removeAmount <= 0)
{
return true;
}
EntityManager entityManager = VWorldUtils.Server.EntityManager;
return InventoryUtilitiesServer.TryRemoveItem(entityManager, playerEntity, itemGuid, removeAmount);
}
}
internal static class VWorldUtils
{
private static World? _serverWorld;
public static World Server
{
get
{
if (_serverWorld != null && _serverWorld.IsCreated)
{
return _serverWorld;
}
_serverWorld = GetWorld("Server");
if (_serverWorld == null)
{
throw new Exception("Could not find Server world. Ensure this mod is running on the server.");
}
return _serverWorld;
}
}
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 class MyPluginInfo
{
public const string PLUGIN_GUID = "SteedForge";
public const string PLUGIN_NAME = "SteedForge";
public const string PLUGIN_VERSION = "0.1.10";
}
}