mirror of
https://github.com/Jacobwasbeast/LegacyWeaveLoader.git
synced 2026-05-22 05:34:36 +00:00
Introduce a managed custom item API with mine-block callbacks and cancellation semantics, plus native runtime support for registering pickaxe items. Key changes: - add WeaveLoader.API Item base/PickaxeItem and dispatcher plumbing - register managed item instances in ItemRegistry - add native export for pickaxe registration and wire through GameObjectFactory - resolve/hook item mineBlock paths (ItemInstance/Item/DiggerItem) and dispatch to managed host - expose managed OnItemMineBlock entry in WeaveLoader.Core and DotNetHost - add Ruby Pickaxe example item + placeholder texture - keep logger usable even before managed handler setup via native fallback
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
namespace WeaveLoader.API;
|
|
|
|
public enum LogLevel
|
|
{
|
|
Debug = 0,
|
|
Info = 1,
|
|
Warning = 2,
|
|
Error = 3
|
|
}
|
|
|
|
/// <summary>
|
|
/// Logging facade that routes messages through the native runtime to the game's debug output.
|
|
/// </summary>
|
|
public static class Logger
|
|
{
|
|
private static Action<string, LogLevel>? LogHandler;
|
|
|
|
/// <summary>
|
|
/// Set the log handler that routes messages to the native runtime.
|
|
/// Called by WeaveLoader.Core during initialization.
|
|
/// </summary>
|
|
public static void SetLogHandler(Action<string, LogLevel> handler) => LogHandler = handler;
|
|
|
|
public static void Debug(string message) => Log(message, LogLevel.Debug);
|
|
public static void Info(string message) => Log(message, LogLevel.Info);
|
|
public static void Warning(string message) => Log(message, LogLevel.Warning);
|
|
public static void Error(string message) => Log(message, LogLevel.Error);
|
|
|
|
public static void Log(string message, LogLevel level = LogLevel.Info)
|
|
{
|
|
if (LogHandler != null)
|
|
{
|
|
LogHandler(message, level);
|
|
return;
|
|
}
|
|
|
|
string formatted = $"[WeaveLoader/{level}] {message}";
|
|
try
|
|
{
|
|
// Fallback path: write directly to native runtime logging so mod logs
|
|
// still appear even if the managed log handler was not initialized.
|
|
NativeInterop.native_log(formatted, (int)level);
|
|
}
|
|
catch
|
|
{
|
|
Console.WriteLine(formatted);
|
|
}
|
|
}
|
|
}
|