Give GameShared an IDependencyCollection.

Death to IoCManager.
This commit is contained in:
Pieter-Jan Briers
2022-12-01 00:14:00 +01:00
parent ada056dcdf
commit 5fed38fecd
3 changed files with 5 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ END TEMPLATE-->
* New system for exposing links to e.g. a Discord in the launcher.
* The engine does not have a built-in method for configuring these, but it does now have a `StatusHostHelpers.AddLink` method to correctly format these from content. The idea is that content wires the types of links (with icon names) up itself via `IStatusHost.OnInfoRequest`.
* See also [the HTTP API documentation](https://docs.spacestation14.io/en/engine/http-api) for reference.
* `GameShared` now has a `Dependencies` property to allow access to the game's `IDependencyCollection`. This makes it possible to avoid using static `IoCManager` in `EntryPoint`-type content code.
### Bugfixes

View File

@@ -12,6 +12,7 @@ namespace Robust.Shared.ContentPack
public abstract class BaseModLoader
{
[Dependency] protected readonly IReflectionManager ReflectionManager = default!;
[Dependency] private readonly IDependencyCollection _dependencies = default!;
private readonly List<ModuleTestingCallbacks> _testingCallbacks = new();
@@ -38,6 +39,7 @@ namespace Robust.Shared.ContentPack
foreach (var entryPoint in entryPoints)
{
var entryPointInstance = (GameShared) Activator.CreateInstance(entryPoint)!;
entryPointInstance.Dependencies = _dependencies;
if (_testingCallbacks != null)
{
entryPointInstance.SetTestingCallbacks(_testingCallbacks);

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
namespace Robust.Shared.ContentPack
@@ -9,6 +10,7 @@ namespace Robust.Shared.ContentPack
/// </summary>
public abstract class GameShared : IDisposable
{
protected internal IDependencyCollection Dependencies { get; internal set; } = default!;
protected List<ModuleTestingCallbacks> TestingCallbacks { get; private set; } = new();
public void SetTestingCallbacks(List<ModuleTestingCallbacks> testingCallbacks)