Files

4.9 KiB

classDiagram

namespace EventPipelines{
    class Pipeline~T~ {
        + PiplineMaster : object{readonly}
        + IsEventEmpty : bool{readonly}
        + Subscribe(handler : Delegate)
        + Unsubscribe(handler : Delegate)
        + SendEvent(sender : object, args : T)
    }

    class EventBus {
        - pipelines : Dictionary~FirebirdEvent, Pipeline~T~>
        - pendingHooks : Dictionary~FirebirdEvent, List~Action~object~~
        + OnPipelineIsBuild(callback : Action~IPipelineBase~, firebirdEvent : FirebirdEvent )
        + GetOrBuildPipeline(type : FirebirdEvent, master : object) : IPipeline~T~
        + GetPipeline(type : FirebirdEvent) : IPipelineBase? 
        + DestroyPipeline(type : FirebirdEvent, master : object)
    }
}

namespace keymapping{
 class KeyMapper{
        - eventBus : IEventBus;
        - inputEvents : Dictionary~string, Delegate~ ;
        - eventTypes : Dictionary~string, Type~;
        - inputMapping : Dictionary~string, FirebirdEvent~ ;
        - cachedPipelines : Dictionary~FirebirdEvent, IPipeline~ ;

        + KeyMapper(eventBus : IEventBus)

        + RegisterEvent~T~(EventName : string , handler : EventHandler~T~ , eventNumber : FirebirdEvent )
        + Map(EventName : string , eventNumbe : FirebirdEvent)
        - RemoveMapping(EventName : string)
        - AjustPipeline(EventName : string, eventNumber : FirebirdEvent )
        + SaveMapping(Path : string)
        + LoadMapping(Path : string)
        + InvalidatePipelineCache(fbEvent : FirebirdEvent)
        + GetOrCachePipeline~T~(fbEvent : FirebirdEvent ) : Pipeline~T~?
        + HandleKeyboardInput(key : KeyEvent , type : KeyEvent)
        + HandleMouseInput(button : MouseButtonEvent, type : InputEventType)
        + HandleJoystickButtonInput(joystickButton : JoystickButtonEvent , type : InputEventType)
        + HandleMouseMovement(mouseMove : MouseMoveEvent)
        + HandleJoytickMove(joystickMove : JoystickMoveEvent)
    }
}

namespace DatatypesAndInterfaces{
    %% === Enum ===
    class FirebirdEvent {
        <<enum>>
        Tick
        ModulesLoading
        Startup
        KeyboardInputs
        MouseInputs
    }

    class ModuleType{
        <<enum>>
        Extension
        EventSystem
        KeyMapper
    }

    class IEventBus{
        <<Interface>>
        + OnPipelineIsBuild(callback : Action~IPipelineBase~, firebirdEvent : FirebirdEvent )
        + GetOrBuildPipeline(type : FirebirdEvent, master : object) : IPipeline~T~
        + GetPipeline(type : FirebirdEvent) : IPipelineBase? 
        + DestroyPipeline(type : FirebirdEvent, master : object)
    }

    class IPipelineBase {
        <<Interface>>
        + PiplineMaster : object&lbrace;readonly&rbrace;
        + IsEventEmpty : bool&lbrace;readonly&rbrace;
        + Subscribe(handler : Delegate)
        + Unsubscribe(handler : Delegate)
    }

    class IPipeline~T~{
        <<Interface>>
        + SendEvent(sender : object, args : T)
    }

    class IKeyMapper{
        <<Interface>>
        + Map(EventName : string , eventNumbe : FirebirdEvent)
        + SaveMapping(Path : string)
        + LoadMapping(Path : string)
        + InvalidatePipelineCache(fbEvent : FirebirdEvent)
        + GetOrCachePipeline~T~(fbEvent : FirebirdEvent ) : Pipeline~T~?
        + HandleKeyboardInput(key : KeyEvent , type : KeyEvent)
        + HandleMouseInput(button : MouseButtonEvent, type : InputEventType)
        + HandleJoystickButtonInput(joystickButton : JoystickButtonEvent , type : InputEventType)
        + HandleMouseMovement(mouseMove : MouseMoveEvent)
        + HandleJoytickMove(joystickMove : JoystickMoveEvent)
    }

    class IExtensionBase{
        <<Interface>>
        + Startup()
    }

    class IGame{
        <<Interface>>
        + EventBus : IEventBus
        + KeyMapper : IKeyMapper
    }
}

namespace ModulLoading{
    class Modul {
        +ModuleType ModuleType
        +string Name
        +string RelativePath
    }

    class ModulList {
        +List~Modul~ mods
    }

    class ModulLoader {
        -ModulList? modulList
        -static Dictionary~ExtensionDependencyInjection, (Type, Func<IGame, object>)~ providers
        +ModulLoader(IGame)
        +T? LoadSystemComponent<T>(ModuleType, IGame)
        +void LoadExtensions(IGame)
        -T? LoadModule<T>(ModuleType, IGame, string)
        +void DeserialiseModulList()
    }

}

%% === Beziehungen ===
EventBus --> Pipeline~T~
EventBus --> IPipeline~T~
EventBus --> IPipelineBase
EventBus ..|> IEventBus

Pipeline~T~ ..|> IPipeline~T~
Pipeline~T~ ..|> IPipelineBase

KeyMapper --> IEventBus
KeyMapper --> FirebirdEvent
KeyMapper --> IPipeline~T~
KeyMapper ..|> IKeyMapper

IKeyMapper --> FirebirdEvent
IKeyMapper --> IPipeline~T~

ModulList --> Modul 
ModulLoader --> ModulList
ModulLoader --> Modul 
ModulLoader --> ModuleType 
ModulLoader --> IGame 
ModulLoader --> IExtensionBase
ModulLoader --> IEventBus 
ModulLoader --> IKeyMapper