added code from unity

This commit is contained in:
Sebastian Bularca
2026-04-06 20:45:22 +02:00
parent a66b4471fa
commit 2872300873
34 changed files with 2164 additions and 2 deletions

36
Runtime/InGameLogger.cs Normal file
View File

@@ -0,0 +1,36 @@
using System.Runtime.CompilerServices;
namespace Jovian.InGameLogging {
public readonly struct InGameLogger {
private readonly IGameLogStore store;
private readonly LogChannel channel;
public InGameLogger(IGameLogStore store, LogChannel channel) {
this.store = store;
this.channel = channel;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Log(string message) {
store.Add(channel, message);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Log(string message, string hexColor) {
var prefix = hexColor.Length > 0 && hexColor[0] == '#' ? "" : "#";
store.Add(channel, $"<color={prefix}{hexColor}>{message}</color>");
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Enable() {
store.EnableChannel(channel);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void Disable() {
store.DisableChannel(channel);
}
public bool IsEnabled => store.IsChannelEnabled(channel);
}
}