Updated KD and ModulLoader
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
using SFML.Window;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Firebird2D.EventPipelines.EventArguments
|
||||
{
|
||||
public class FirebirdJoystickButtonEventArgs : JoystickButtonEventArgs
|
||||
{
|
||||
public InputEventType InputEventType { get; private set; }
|
||||
|
||||
public FirebirdJoystickButtonEventArgs(JoystickButtonEvent e, InputEventType t) : base(e)
|
||||
{
|
||||
InputEventType = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using SFML.Window;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Firebird2D.EventPipelines.EventArguments
|
||||
{
|
||||
public class FirebirdKeyEventArgs : KeyEventArgs
|
||||
{
|
||||
public InputEventType InputEventType { get; private set; }
|
||||
|
||||
public FirebirdKeyEventArgs(KeyEvent e, InputEventType t) : base(e)
|
||||
{
|
||||
InputEventType = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
using SFML.Window;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Firebird2D.EventPipelines.EventArguments
|
||||
{
|
||||
public class FirebirdMouseButtonEventArgs : MouseButtonEventArgs
|
||||
{
|
||||
public InputEventType InputEventType { get; private set; }
|
||||
|
||||
public FirebirdMouseButtonEventArgs(MouseButtonEvent e,InputEventType t) : base(e)
|
||||
{
|
||||
InputEventType = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Firebird2D.EventPipelines.EventArguments
|
||||
{
|
||||
public enum InputEventType
|
||||
{
|
||||
Pressed = 0,
|
||||
Released = 1
|
||||
}
|
||||
}
|
||||
@@ -15,11 +15,11 @@ namespace Firebird2D.EventPipelines
|
||||
{
|
||||
// Dictionary that stores various pipelines for specific FirebirdEvents.
|
||||
// The key is the event, and the value is the corresponding pipeline.
|
||||
private Dictionary<FirebirdEvent, IPipeline> pipelines = new();
|
||||
private Dictionary<FirebirdEvent, IPipelineBase> pipelines = new();
|
||||
|
||||
// Dictionary that stores a list of callbacks for each FirebirdEvent.
|
||||
// These callbacks will be invoked when the event's pipeline is build.
|
||||
private Dictionary<FirebirdEvent, List<Action<IPipeline>>> pendingHooks = new();
|
||||
private Dictionary<FirebirdEvent, List<Action<IPipelineBase>>> pendingHooks = new();
|
||||
|
||||
/// <summary>
|
||||
/// Registers a callback (hook) for a specific event. The callback will be invoked when the pipeline for this event is built.
|
||||
@@ -27,7 +27,7 @@ namespace Firebird2D.EventPipelines
|
||||
/// <param name="callback">The function to be called when the pipeline for the event is built.</param>
|
||||
/// <param name="type">The event for which the callback should be registered.</param>
|
||||
/// <exception cref="ArgumentNullException">Thrown when the callback is null.</exception>
|
||||
public void OnPipelineIsBuild(Action<IPipeline> callback, FirebirdEvent type)
|
||||
public void OnPipelineIsBuild(Action<IPipelineBase> callback, FirebirdEvent type)
|
||||
{
|
||||
if (callback == null) throw new ArgumentNullException(nameof(callback));
|
||||
|
||||
@@ -46,16 +46,23 @@ namespace Firebird2D.EventPipelines
|
||||
/// Otherwise, a new pipeline is created and stored.
|
||||
/// </summary>
|
||||
/// <param name="type">The event for which the pipeline should be created or retrieved.</param>
|
||||
/// <param name="argsType">The type of the arguments to be passed to the pipeline.</param>
|
||||
/// <param name="master">The master object used when creating the pipeline.</param>
|
||||
/// <returns>The pipeline for the given event.</returns>
|
||||
public IPipeline GetOrBuildPipeline(FirebirdEvent type, Type argsType, object master)
|
||||
public IPipeline<T> GetOrBuildPipeline<T>(FirebirdEvent type, object master) where T : EventArgs
|
||||
{
|
||||
if (pipelines.TryGetValue(type, out var pipeline)) return pipeline;
|
||||
if (pipelines.TryGetValue(type, out var pipeline)) return (IPipeline<T>)pipeline;
|
||||
|
||||
var genericPipelineType = typeof(Pipeline<>).MakeGenericType(argsType);
|
||||
var pipelineInstance = (IPipeline)Activator.CreateInstance(genericPipelineType, master)!;
|
||||
var pipelineInstance = new Pipeline<T>(master);
|
||||
pipelines[type] = pipelineInstance;
|
||||
if (pendingHooks.TryGetValue(type, out var hookList)) return pipelineInstance;
|
||||
|
||||
if (hookList == null) return pipelineInstance;
|
||||
|
||||
foreach (Action<IPipelineBase> hook in hookList)
|
||||
{
|
||||
hook.Invoke(pipelineInstance);
|
||||
}
|
||||
|
||||
return pipelineInstance;
|
||||
}
|
||||
|
||||
@@ -63,9 +70,8 @@ namespace Firebird2D.EventPipelines
|
||||
/// Retrieves the pipeline for an event if it exists; otherwise, returns null.
|
||||
/// </summary>
|
||||
/// <param name="type">The event for which the pipeline should be retrieved.</param>
|
||||
/// <param name="argsType">The type of the arguments for the pipeline.</param>
|
||||
/// <returns>The pipeline for the event, or null if it does not exist.</returns>
|
||||
public IPipeline? GetPipeline(FirebirdEvent type, Type argsType)
|
||||
public IPipelineBase? GetPipeline(FirebirdEvent type)
|
||||
{
|
||||
if (!pipelines.TryGetValue(type, out var pipeline)) return null;
|
||||
return pipeline;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Firebird2D.EventPipelines
|
||||
/// Eventpypeline which transports an event to every Subscyber
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Event Arguments for the Pipeline event</typeparam>
|
||||
public class Pipeline <T> : IPipeline where T : EventArgs
|
||||
public class Pipeline <T> : IPipeline<T> where T : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Class witch owns the Pipeline and has the right to send events or delete the pipeline
|
||||
|
||||
Reference in New Issue
Block a user