Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
root = true

[*.cs]
dotnet_diagnostic.IDE0290.severity = none
34 changes: 18 additions & 16 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<ItemGroup>
<PackageVersion Include="Ahwoo.BRUTAL.Collections" Version="2026.10.1" />
<PackageVersion Include="Ahwoo.BRUTAL.Core" Version="2026.10.1" />
<PackageVersion Include="Ahwoo.BRUTAL.Glfw" Version="2026.10.4" />
<PackageVersion Include="Ahwoo.BRUTAL.ImGui" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Localization" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Logging" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Memory" Version="2026.10.1" />
<PackageVersion Include="Ahwoo.BRUTAL.Numerics" Version="2026.10.1" />
<PackageVersion Include="Ahwoo.BRUTAL.Strings" Version="2026.10.1" />
<PackageVersion Include="Ahwoo.BRUTAL.Vulkan" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Vulkan.Abstractions" Version="2026.10.2" />
<PackageVersion Include="Lib.Harmony" Version="2.4.2" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.13" />
<PackageVersion Include="Samboy063.Tomlet" Version="6.1.0" />
<PackageVersion Include="RocketWerkz.KSA" Version="2026.10.19.5638" />
<PackageVersion Include="RocketWerkz.KSA.Ref" Version="2026.10.19.5638" />
<PackageVersion Include="Ahwoo.BRUTAL.Collections" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Core" Version="2026.10.4" />
<PackageVersion Include="Ahwoo.BRUTAL.Glfw" Version="2026.10.5" />
<PackageVersion Include="Ahwoo.BRUTAL.ImGui" Version="2026.10.3" />
<PackageVersion Include="Ahwoo.BRUTAL.Localization" Version="2026.10.3" />
<PackageVersion Include="Ahwoo.BRUTAL.Logging" Version="2026.10.3" />
<PackageVersion Include="Ahwoo.BRUTAL.Memory" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Monitor.Common" Version="2026.10.3" />
<PackageVersion Include="Ahwoo.BRUTAL.Monitor.Host" Version="2026.10.3" />
<PackageVersion Include="Ahwoo.BRUTAL.Numerics" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Strings" Version="2026.10.2" />
<PackageVersion Include="Ahwoo.BRUTAL.Vulkan" Version="2026.10.3" />
<PackageVersion Include="Ahwoo.BRUTAL.Vulkan.Abstractions" Version="2026.10.3" />
<PackageVersion Include="Lib.Harmony" Version="2.4.3" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="10.0.14" />
<PackageVersion Include="Samboy063.Tomlet" Version="6.2.0" />
<PackageVersion Include="RocketWerkz.KSA" Version="2026.10.25.5707" />
<PackageVersion Include="RocketWerkz.KSA.Ref" Version="2026.10.25.5707" />
</ItemGroup>
</Project>
7 changes: 7 additions & 0 deletions StarMap.API/Events/IEventPublisher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace StarMap.API.Events
{
public interface IEventPublisher<T> : IDisposable
{
void Publish(T message);
}
}
6 changes: 6 additions & 0 deletions StarMap.API/Events/ISubscription.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace StarMap.API.Events
{
public interface ISubscription<T> : IDisposable
{
}
}
8 changes: 0 additions & 8 deletions StarMap.API/Mediation/IEventPublisher.cs

This file was deleted.

6 changes: 0 additions & 6 deletions StarMap.API/Mediation/IStarMapEvent.cs

This file was deleted.

6 changes: 0 additions & 6 deletions StarMap.API/Mediation/ISubscription.cs

This file was deleted.

13 changes: 13 additions & 0 deletions StarMap.API/Services/IEventBus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using StarMap.API.Events;

namespace StarMap.API.Services
{
public interface IEventBus
{
IEventPublisher<T> GetPublisher<T>();
IEventPublisher<T> GetPublisher<T>(string eventName);

ISubscription<T> Subscribe<T>(Action<T> handler);
ISubscription<T> Subscribe<T>(Action<T> handler, string eventName);
}
}
10 changes: 0 additions & 10 deletions StarMap.API/Services/IMediationService.cs

This file was deleted.

39 changes: 39 additions & 0 deletions StarMap.Core/API/EventBus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using StarMap.API.Events;
using StarMap.API.Services;
using StarMap.Core.ModRepository;
using StarMap.Core.Services;

namespace StarMap.Core.API
{
internal class EventBus : IEventBus
{
private readonly RuntimeMod _mod;
private readonly IMediator _mediator;

public EventBus(IModContext modContext, IMediator mediator)
{
_mod = modContext.Mod;
_mediator = mediator;
}

public IEventPublisher<T> GetPublisher<T>()
{
return _mediator.GetPublisher<T>();
}

public IEventPublisher<T> GetPublisher<T>(string eventName)
{
return _mediator.GetPublisher<T>(eventName);
}

public ISubscription<T> Subscribe<T>(Action<T> handler)
{
return _mediator.Subscribe(_mod, handler);
}

public ISubscription<T> Subscribe<T>(Action<T> handler, string eventName)
{
return _mediator.Subscribe(_mod, handler, eventName);
}
}
}
29 changes: 0 additions & 29 deletions StarMap.Core/API/MediationService.cs

This file was deleted.

24 changes: 13 additions & 11 deletions StarMap.Core/ModRepository/ModsLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ internal sealed class ModsLoader : IModsLoader
private readonly AssemblyLoadContext _coreAssemblyLoadContext;
private readonly IPatchManager _patchManager;
private readonly IServiceProviderService _serviceProviderService;
private readonly ILogger _logger;

public static Dictionary<string, StarMapMethodAttribute> RegisteredMethodAttributes = [];

Expand All @@ -31,13 +32,14 @@ internal sealed class ModsLoader : IModsLoader
return (attrType.Name, attrObject);
}

public ModsLoader([FromKeyedServices("Core")] AssemblyLoadContext coreAssemblyLoadContext, IPatchManager patchManager, IServiceProviderService serviceProviderService)
public ModsLoader([FromKeyedServices("Core")] AssemblyLoadContext coreAssemblyLoadContext, IPatchManager patchManager, IServiceProviderService serviceProviderService, ILogger logger)
{
_coreAssemblyLoadContext = coreAssemblyLoadContext;
_patchManager = patchManager;
_serviceProviderService = serviceProviderService;
_logger = logger;

Assembly coreAssembly = typeof(StarMapModAttribute).Assembly;
var coreAssembly = typeof(StarMapModAttribute).Assembly;

RegisteredMethodAttributes = coreAssembly
.GetTypes()
Expand Down Expand Up @@ -70,7 +72,7 @@ private void PrepareMods()
{
if (!mod.Enabled)
{
Console.WriteLine($"StarMap - Not loading mod: {mod.Id} because it is disabled in manifest");
_logger.Information($"StarMap - Not loading mod: {mod.Id} because it is disabled in manifest");
continue;
}

Expand All @@ -81,29 +83,29 @@ private void PrepareMods()

if (!runtimeMod.AllDependenciesLoaded(ModRegistry))
{
Console.WriteLine($"StarMap - Delaying load of mod: {runtimeMod.ModId} due to missing dependencies: {string.Join(", ", runtimeMod.NotLoadedModDependencies.Keys)}");
_logger.Information($"StarMap - Delaying load of mod: {runtimeMod.ModId} due to missing dependencies: {string.Join(", ", runtimeMod.NotLoadedModDependencies.Keys)}");
continue;
}

if (!runtimeMod.InitializeMod(ModRegistry, _patchManager, _serviceProviderService))
{
Console.WriteLine($"StarMap - Failed to initialize mod: {runtimeMod.ModId} from manifest");
_logger.Warning($"StarMap - Failed to initialize mod: {runtimeMod.ModId} from manifest");
continue;
}

Console.WriteLine($"StarMap - Loaded mod: {runtimeMod.ModId} from manifest");
_logger.Information($"StarMap - Loaded mod: {runtimeMod.ModId} from manifest");

var dependentMods = runtimeMod.CheckForDependentMods(ModRegistry);

foreach (var dependentMod in dependentMods)
{
if (dependentMod.InitializeMod(ModRegistry, _patchManager, _serviceProviderService))
{
Console.WriteLine($"StarMap - Loaded mod: {dependentMod.ModId} after loading {runtimeMod.ModId}");
_logger.Information($"StarMap - Loaded mod: {dependentMod.ModId} after loading {runtimeMod.ModId}");
}
else
{
Console.WriteLine($"StarMap - Failed to load mod: {dependentMod.ModId} after loading {runtimeMod.ModId}");
_logger.Warning($"StarMap - Failed to load mod: {dependentMod.ModId} after loading {runtimeMod.ModId}");
}
}
}
Expand All @@ -127,11 +129,11 @@ private void TryLoadWaitingMods()

if (waitingMod.InitializeMod(ModRegistry, _patchManager, _serviceProviderService))
{
Console.WriteLine($"StarMap - Loaded mod: {waitingMod.ModId} after all mods were loaded, not loaded optional mods: {string.Join(",", waitingMod.NotLoadedModDependencies.Values.Select(mod => mod.ModId))}");
_logger.Information($"StarMap - Loaded mod: {waitingMod.ModId} after all mods were loaded, not loaded optional mods: {string.Join(",", waitingMod.NotLoadedModDependencies.Values.Select(mod => mod.ModId))}");
}
else
{
Console.WriteLine($"StarMap - Failed to load mod:{waitingMod.ModId} after all mods were loaded, not loaded optional mods: {string.Join(",", waitingMod.NotLoadedModDependencies.Values.Select(mod => mod.ModId))}");
_logger.Warning($"StarMap - Failed to load mod:{waitingMod.ModId} after all mods were loaded, not loaded optional mods: {string.Join(",", waitingMod.NotLoadedModDependencies.Values.Select(mod => mod.ModId))}");
}
waitingMod.NotLoadedModDependencies.Clear();
}
Expand All @@ -142,7 +144,7 @@ private void TryLoadWaitingMods()
{
foreach (var waitingMod in ModRegistry.WaitingMods)
{
Console.WriteLine($"StarMap - Failed to load mod:{waitingMod.ModId} after all mods were loaded, missing mods (some may be optional): {string.Join(",", waitingMod.NotLoadedModDependencies.Values.Select(mod => mod.ModId))}");
_logger.Warning($"StarMap - Failed to load mod:{waitingMod.ModId} after all mods were loaded, missing mods (some may be optional): {string.Join(",", waitingMod.NotLoadedModDependencies.Values.Select(mod => mod.ModId))}");
}
ModRegistry.WaitingMods.Clear();
}
Expand Down
11 changes: 7 additions & 4 deletions StarMap.Core/Patches/StarMapPatches.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using HarmonyLib;
using KSA;
using StarMap.API.Services;
using StarMap.Core.Services;
using StarMap.Core.UI.ConfirmRestart;
using System.Diagnostics;

Expand All @@ -14,10 +15,12 @@ internal interface IStarMapPatches
internal class StarMapPatches : IStarMapPatches
{
private readonly IPatchManager _patchManager;
private readonly ILogger _logger;

public StarMapPatches(IPatchManager patchManager)
public StarMapPatches(IPatchManager patchManager, ILogger logger)
{
_patchManager = patchManager;
_logger = logger;
}

public void Init()
Expand Down Expand Up @@ -50,13 +53,13 @@ static bool wereNewModsEnabled()

if (confirmRestart.Restart)
{
Console.WriteLine("StarMap - RESTARTING");
Console.WriteLine("======================================");
_logger.Information("StarMap - RESTARTING");
_logger.Information("======================================");

var mainModule = Process.GetCurrentProcess().MainModule;
if (mainModule is null || Path.GetDirectoryName(mainModule.FileName) is not string starMapInstallLocation)
{
Console.WriteLine("Unable to get StarMap install location for restart.");
_logger.Warning("Unable to get StarMap install location for restart.");
}
else
{
Expand Down
37 changes: 37 additions & 0 deletions StarMap.Core/Services/Logger.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
namespace StarMap.Core.Services
{
internal interface ILogger
{
void Information(string message);
void Warning(string message);
void Error(string message);
}

internal class Logger : ILogger
{
//private readonly LogCategory _category;

public Logger()
{
//_category = LogCategory.Make("StarMap");
}

public void Error(string message)
{
Console.WriteLine($"StarMap error: '{message}'");
//_category.Error(message);
}

public void Information(string message)
{
Console.WriteLine($"StarMap info: '{message}'");
//_category.Info(message);
}

public void Warning(string message)
{
Console.WriteLine($"StarMap warning: '{message}'");
//_category.Warning(message);
}
}
}
Loading
Loading