using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalSteps.Patches;
using TerminalApi;
using TerminalApi.Classes;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LethalSteps")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LethalSteps")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("598987e7-a475-4060-8821-381c28688d25")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LethalSteps
{
[BepInPlugin("Rhkellz.LethalSteps", "LethalSteps", "1.0.0")]
public class LSBase : BaseUnityPlugin
{
private const string modGUID = "Rhkellz.LethalSteps";
private const string modName = "LethalSteps";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Rhkellz.LethalSteps");
private static LSBase Instance;
internal ManualLogSource mls;
private void Awake()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Rhkellz.LethalSteps");
mls.LogInfo((object)"LethalSteps loaded");
TerminalApi.AddCommand("steps", new CommandInfo
{
DisplayTextSupplier = () => PlayerControllerBPatch.getSteps()
}, (string)null, true);
harmony.PatchAll(typeof(LSBase));
harmony.PatchAll(typeof(PlayerControllerBPatch));
}
}
public class PlayerData
{
public ulong id { get; set; }
public int steps { get; set; }
public string username { get; set; }
public PlayerData(ulong ID, int Steps, string ign)
{
id = ID;
steps = Steps;
username = ign;
}
public ulong getID()
{
return id;
}
public int getSteps()
{
return steps;
}
public string getUsername()
{
return username;
}
public void updateSteps()
{
steps++;
}
}
}
namespace LethalSteps.Patches
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
internal static ManualLogSource stepLog;
public static List<PlayerData> Players = new List<PlayerData>();
[HarmonyPatch("PlayFootstepServer")]
[HarmonyPostfix]
private static void stepCount(ref ulong ___playerClientId, ref string ___playerUsername)
{
bool flag = true;
stepLog = Logger.CreateLogSource("steps");
foreach (PlayerData player in Players)
{
if (player.getID() == ___playerClientId)
{
flag = false;
}
}
if (flag)
{
Players.Add(new PlayerData(___playerClientId, 0, ___playerUsername));
}
foreach (PlayerData player2 in Players)
{
if (player2.getID() == ___playerClientId)
{
player2.updateSteps();
}
}
}
public static string getSteps()
{
string text = null;
foreach (PlayerData player in Players)
{
text = text + player.getUsername() + ": " + player.getSteps() + "\n";
}
return text;
}
}
}