Added ModulLoader
This commit is contained in:
@@ -3,6 +3,8 @@ using Firebird2D.EventPipelines;
|
||||
using SFML.Window;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text.Json;
|
||||
using Firebird2D.Interfaces;
|
||||
using Firebird2D.Datatypes;
|
||||
|
||||
namespace Firebird2D.KeyMapping
|
||||
{
|
||||
@@ -11,7 +13,7 @@ namespace Firebird2D.KeyMapping
|
||||
/// </summary>
|
||||
public class KeyMapper
|
||||
{
|
||||
private EventBus eventBus;
|
||||
private readonly IEventBus eventBus;
|
||||
|
||||
// Stores registered input events by name.
|
||||
private Dictionary<string, Delegate> inputEvents = [];
|
||||
@@ -23,9 +25,9 @@ namespace Firebird2D.KeyMapping
|
||||
private Dictionary<string, FirebirdEvent> inputMapping = [];
|
||||
|
||||
// Caches active pipelines for performance.
|
||||
private Dictionary<FirebirdEvent, I_Pipeline> cachedPipelines = [];
|
||||
private Dictionary<FirebirdEvent, IPipeline> cachedPipelines = [];
|
||||
|
||||
public KeyMapper(EventBus eventBus)
|
||||
public KeyMapper(IEventBus eventBus)
|
||||
{
|
||||
if (eventBus == null) throw new NullReferenceException(nameof(eventBus));
|
||||
this.eventBus = eventBus;
|
||||
@@ -70,7 +72,7 @@ namespace Firebird2D.KeyMapping
|
||||
if (!inputMapping.TryGetValue(EventName, out var firebirdEvent)) return;
|
||||
if (!eventTypes.TryGetValue(EventName, out var type)) return;
|
||||
|
||||
I_Pipeline? pipeline = eventBus.GetPipeline(firebirdEvent, type);
|
||||
IPipeline? pipeline = eventBus.GetPipeline(firebirdEvent, type);
|
||||
|
||||
if (pipeline != null)
|
||||
{
|
||||
@@ -92,7 +94,7 @@ namespace Firebird2D.KeyMapping
|
||||
{
|
||||
if (!eventTypes.TryGetValue(EventName, out var type)) return;
|
||||
|
||||
I_Pipeline pipeline = eventBus.GetOrBuildPipeline(eventNumber, type, this);
|
||||
IPipeline pipeline = eventBus.GetOrBuildPipeline(eventNumber, type, this);
|
||||
pipeline.Subscribe(inputEvents[EventName]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user