mirror of
https://github.com/ApeMV/AmongUsRevamped.git
synced 2026-10-19 15:51:59 +00:00
Project base
This commit is contained in:
1 parent
b8cda44e44
commit
1033fef95e
6 files changed
+314
No files matched your search
@@ -0,0 +1,35 @@
|
|||||||
|
using BepInEx;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using BepInEx.Unity.IL2CPP;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace HNSRevamped;
|
||||||
|
|
||||||
|
[BepInAutoPlugin]
|
||||||
|
[BepInProcess("Among Us.exe")]
|
||||||
|
public partial class Main : BasePlugin
|
||||||
|
{
|
||||||
|
public Harmony Harmony { get; } = new(Id);
|
||||||
|
public static BepInEx.Logging.ManualLogSource Logger;
|
||||||
|
public static BasePlugin Instance;
|
||||||
|
|
||||||
|
|
||||||
|
public override void Load()
|
||||||
|
{
|
||||||
|
var handler = HNSRevamped.Logger.Handler("GitVersion");
|
||||||
|
Logger = BepInEx.Logging.Logger.CreateLogSource("HNSRevamped");
|
||||||
|
HNSRevamped.Logger.Enable();
|
||||||
|
Instance = this;
|
||||||
|
|
||||||
|
Harmony.PatchAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(ModManager), nameof(ModManager.LateUpdate))]
|
||||||
|
class ModManagerLateUpdatePatch
|
||||||
|
{
|
||||||
|
public static void Prefix(ModManager __instance)
|
||||||
|
{
|
||||||
|
__instance.ShowModStamp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<LangVersion>latest</LangVersion>
|
||||||
|
<DebugType>embedded</DebugType>
|
||||||
|
|
||||||
|
<VersionPrefix>1.0.0</VersionPrefix>
|
||||||
|
<VersionSuffix>dev</VersionSuffix>
|
||||||
|
<Description>Mod generated using Reactor Template</Description>
|
||||||
|
<!-- <Authors>your name</Authors> -->
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Reactor" Version="2.0.0" />
|
||||||
|
<PackageReference Include="BepInEx.Unity.IL2CPP" Version="6.0.0-be.735" Private="false" ExcludeAssets="runtime;native" />
|
||||||
|
<PackageReference Include="AmongUs.GameLibs.Steam" Version="2025.10.14" PrivateAssets="all" />
|
||||||
|
|
||||||
|
<PackageReference Include="BepInEx.AutoPlugin" Version="1.1.0" PrivateAssets="all" />
|
||||||
|
<PackageReference Include="BepInEx.IL2CPP.MSBuild" Version="2.0.1" PrivateAssets="all" ExcludeAssets="runtime" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<Target Name="Copy" AfterTargets="Build" Condition="'$(AmongUs)' != ''">
|
||||||
|
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(AmongUs)/BepInEx/plugins/" UseSymboliclinksIfPossible="true" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
|
||||||
|
namespace HNSRevamped;
|
||||||
|
|
||||||
|
class LateTask
|
||||||
|
{
|
||||||
|
public string name;
|
||||||
|
public float timer;
|
||||||
|
public bool shouldLog;
|
||||||
|
public Action action;
|
||||||
|
public static List<LateTask> Tasks = [];
|
||||||
|
public bool Run(float deltaTime)
|
||||||
|
{
|
||||||
|
timer -= deltaTime;
|
||||||
|
if (timer <= 0)
|
||||||
|
{
|
||||||
|
action();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
public LateTask(Action action, float time, string name = "No Name Task", bool shoudLog = true, [CallerMemberName] string callerMethodName = "")
|
||||||
|
{
|
||||||
|
this.action = action;
|
||||||
|
this.timer = time;
|
||||||
|
if (name != "No Name Task")
|
||||||
|
this.name = name;
|
||||||
|
else
|
||||||
|
this.name = callerMethodName + " Task";
|
||||||
|
this.shouldLog = shoudLog;
|
||||||
|
|
||||||
|
Tasks.Add(this);
|
||||||
|
if (name != "")
|
||||||
|
if (shoudLog)
|
||||||
|
Logger.Info("\"" + name + "\" is created", "LateTask");
|
||||||
|
}
|
||||||
|
public static void Update(float deltaTime)
|
||||||
|
{
|
||||||
|
foreach (var task in Tasks.ToArray())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (task.Run(deltaTime))
|
||||||
|
{
|
||||||
|
if (task.name is not "" && task.shouldLog)
|
||||||
|
Logger.Info($"\"{task.name}\" is finished", "LateTask");
|
||||||
|
|
||||||
|
Tasks.Remove(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Error($"{ex.GetType()}: {ex.Message} in \"{task.name}\"\n{ex.StackTrace}", "LateTask.Error", false);
|
||||||
|
Tasks.Remove(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+158
@@ -0,0 +1,158 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using HarmonyLib;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using LogLevel = BepInEx.Logging.LogLevel;
|
||||||
|
|
||||||
|
namespace HNSRevamped;
|
||||||
|
|
||||||
|
public interface ILogHandler
|
||||||
|
{
|
||||||
|
public void Info(string text);
|
||||||
|
public void Warn(string text);
|
||||||
|
public void Error(string text);
|
||||||
|
public void Fatal(string text);
|
||||||
|
public void Msg(string text);
|
||||||
|
public void Exception(Exception ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
class LogHandler(string tag) : ILogHandler
|
||||||
|
{
|
||||||
|
public string Tag { get; } = tag;
|
||||||
|
|
||||||
|
public void Info(string text)
|
||||||
|
=> Logger.Info(text, Tag, true);
|
||||||
|
public void Warn(string text)
|
||||||
|
=> Logger.Warn(text, Tag, true);
|
||||||
|
public void Error(string text)
|
||||||
|
=> Logger.Error(text, Tag, true);
|
||||||
|
public void Fatal(string text)
|
||||||
|
=> Logger.Fatal(text, Tag, true);
|
||||||
|
public void Msg(string text)
|
||||||
|
=> Logger.Msg(text, Tag, true);
|
||||||
|
public void Exception(Exception ex)
|
||||||
|
=> Logger.Exception(ex, Tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
class Logger
|
||||||
|
{
|
||||||
|
public static bool IsEnable = true;
|
||||||
|
public static List<string> DisableList = [];
|
||||||
|
public static List<string> SendToGameList = [];
|
||||||
|
private static readonly HashSet<string> NowDetailedErrorLog = [];
|
||||||
|
|
||||||
|
public static bool isDetail = false;
|
||||||
|
public static bool isAlsoInGame = false;
|
||||||
|
public static void Enable() => IsEnable = true;
|
||||||
|
public static void Disable() => IsEnable = false;
|
||||||
|
public static void Enable(string tag, bool toGame = false)
|
||||||
|
{
|
||||||
|
DisableList.Remove(tag);
|
||||||
|
if (toGame && !SendToGameList.Contains(tag)) SendToGameList.Add(tag);
|
||||||
|
else SendToGameList.Remove(tag);
|
||||||
|
}
|
||||||
|
public static void Disable(string tag) { if (!DisableList.Contains(tag)) DisableList.Add(tag); }
|
||||||
|
public static void SendInGame(string text)
|
||||||
|
{
|
||||||
|
if (!IsEnable) return;
|
||||||
|
if (DestroyableSingleton<HudManager>._instance) DestroyableSingleton<HudManager>.Instance.Notifier.AddDisconnectMessage(text);
|
||||||
|
}
|
||||||
|
private static void SendToFile(string text, LogLevel level = LogLevel.Info, string tag = "", bool escapeCRLF = true, int lineNumber = 0, string fileName = "", bool multiLine = false)
|
||||||
|
{
|
||||||
|
if (!IsEnable || DisableList.Contains(tag)) return;
|
||||||
|
var logger = Main.Logger;
|
||||||
|
|
||||||
|
if (SendToGameList.Contains(tag) || isAlsoInGame)
|
||||||
|
{
|
||||||
|
SendInGame($"[{tag}]{text}");
|
||||||
|
}
|
||||||
|
|
||||||
|
string log_text;
|
||||||
|
if (level is LogLevel.Error or LogLevel.Fatal or LogLevel.Warning && !multiLine && !NowDetailedErrorLog.Contains(tag))
|
||||||
|
{
|
||||||
|
string t = DateTime.Now.ToString("HH:mm:ss");
|
||||||
|
StackFrame stack = new(2);
|
||||||
|
string className = stack.GetMethod()?.ReflectedType?.Name;
|
||||||
|
string memberName = stack.GetMethod()?.Name;
|
||||||
|
log_text = $"[{t}][{className}.{memberName}({Path.GetFileName(fileName)}:{lineNumber})][{tag}]{text}";
|
||||||
|
NowDetailedErrorLog.Add(tag);
|
||||||
|
_ = new LateTask(() => NowDetailedErrorLog.Remove(tag), 3f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (escapeCRLF) text = text.Replace("\r", "\\r").Replace("\n", "\\n");
|
||||||
|
string t = DateTime.Now.ToString("HH:mm:ss");
|
||||||
|
log_text = $"[{t}][{tag}]{text}";
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case LogLevel.Info when !multiLine:
|
||||||
|
logger.LogInfo(log_text);
|
||||||
|
break;
|
||||||
|
case LogLevel.Info:
|
||||||
|
log_text.Split("\\n").Do(logger.LogInfo);
|
||||||
|
break;
|
||||||
|
case LogLevel.Warning when !multiLine:
|
||||||
|
logger.LogWarning(log_text);
|
||||||
|
break;
|
||||||
|
case LogLevel.Warning:
|
||||||
|
log_text.Split("\\n").Do(logger.LogWarning);
|
||||||
|
break;
|
||||||
|
case LogLevel.Error when !multiLine:
|
||||||
|
logger.LogError(log_text);
|
||||||
|
break;
|
||||||
|
case LogLevel.Error:
|
||||||
|
log_text.Split("\\n").Do(logger.LogError);
|
||||||
|
break;
|
||||||
|
case LogLevel.Fatal when !multiLine:
|
||||||
|
logger.LogFatal(log_text);
|
||||||
|
break;
|
||||||
|
case LogLevel.Fatal:
|
||||||
|
log_text.Split("\\n").Do(logger.LogFatal);
|
||||||
|
break;
|
||||||
|
case LogLevel.Message when !multiLine:
|
||||||
|
logger.LogMessage(log_text);
|
||||||
|
break;
|
||||||
|
case LogLevel.Message:
|
||||||
|
log_text.Split("\\n").Do(logger.LogMessage);
|
||||||
|
break;
|
||||||
|
case LogLevel.Debug when !multiLine:
|
||||||
|
logger.LogFatal(log_text);
|
||||||
|
break;
|
||||||
|
case LogLevel.Debug:
|
||||||
|
log_text.Split("\\n").Do(logger.LogFatal);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.LogWarning("Error: Invalid LogLevel");
|
||||||
|
logger.LogInfo(log_text);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void Test(object content, string tag = "======= Test =======", bool escapeCRLF = true, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "", bool multiLine = false) =>
|
||||||
|
SendToFile(content.ToString(), LogLevel.Debug, tag, escapeCRLF, lineNumber, fileName, multiLine);
|
||||||
|
public static void Info(string text, string tag, bool escapeCRLF = true, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "", bool multiLine = false) =>
|
||||||
|
SendToFile(text, LogLevel.Info, tag, escapeCRLF, lineNumber, fileName, multiLine);
|
||||||
|
public static void Warn(string text, string tag, bool escapeCRLF = true, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "", bool multiLine = false) =>
|
||||||
|
SendToFile(text, LogLevel.Warning, tag, escapeCRLF, lineNumber, fileName, multiLine);
|
||||||
|
public static void Error(string text, string tag, bool escapeCRLF = true, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "", bool multiLine = false) =>
|
||||||
|
SendToFile(text, LogLevel.Error, tag, escapeCRLF, lineNumber, fileName, multiLine);
|
||||||
|
public static void Fatal(string text, string tag, bool escapeCRLF = true, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "", bool multiLine = false) =>
|
||||||
|
SendToFile(text, LogLevel.Fatal, tag, escapeCRLF, lineNumber, fileName, multiLine);
|
||||||
|
public static void Msg(string text, string tag, bool escapeCRLF = true, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "", bool multiLine = false) =>
|
||||||
|
SendToFile(text, LogLevel.Message, tag, escapeCRLF, lineNumber, fileName, multiLine);
|
||||||
|
public static void Exception(Exception ex, string tag, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "") =>
|
||||||
|
SendToFile(ex.ToString(), LogLevel.Error, tag, false, lineNumber, fileName);
|
||||||
|
public static void CurrentMethod([CallerLineNumber] int lineNumber = 0, [CallerFilePath] string fileName = "")
|
||||||
|
{
|
||||||
|
StackFrame stack = new(1);
|
||||||
|
Msg($"\"{stack.GetMethod().ReflectedType.Name}.{stack.GetMethod().Name}\" Called in \"{Path.GetFileName(fileName)}({lineNumber})\"", "Method");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LogHandler Handler(string tag)
|
||||||
|
=> new(tag);
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
var target = Argument("target", "Build");
|
||||||
|
|
||||||
|
var workflow = BuildSystem.GitHubActions.Environment.Workflow;
|
||||||
|
var buildId = workflow.RunNumber;
|
||||||
|
var tag = workflow.RefType == GitHubActionsRefType.Tag ? workflow.RefName : null;
|
||||||
|
|
||||||
|
Task("Build")
|
||||||
|
.Does(() =>
|
||||||
|
{
|
||||||
|
var settings = new DotNetBuildSettings
|
||||||
|
{
|
||||||
|
Configuration = "Release",
|
||||||
|
MSBuildSettings = new DotNetMSBuildSettings()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (tag != null)
|
||||||
|
{
|
||||||
|
settings.MSBuildSettings.Version = tag;
|
||||||
|
}
|
||||||
|
else if (buildId != 0)
|
||||||
|
{
|
||||||
|
settings.MSBuildSettings.VersionSuffix = "ci." + buildId;
|
||||||
|
}
|
||||||
|
|
||||||
|
DotNetBuild(".", settings);
|
||||||
|
});
|
||||||
|
|
||||||
|
RunTarget(target);
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<packageSources>
|
||||||
|
<add key="BepInEx" value="https://nuget.bepinex.dev/v3/index.json" />
|
||||||
|
</packageSources>
|
||||||
|
</configuration>
|
||||||
Reference in new issue
Block a user