Pustalorc.RocketModServices 1.1.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package Pustalorc.RocketModServices --version 1.1.1                
NuGet\Install-Package Pustalorc.RocketModServices -Version 1.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Pustalorc.RocketModServices" Version="1.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Pustalorc.RocketModServices --version 1.1.1                
#r "nuget: Pustalorc.RocketModServices, 1.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Pustalorc.RocketModServices as a Cake Addin
#addin nuget:?package=Pustalorc.RocketModServices&version=1.1.1

// Install Pustalorc.RocketModServices as a Cake Tool
#tool nuget:?package=Pustalorc.RocketModServices&version=1.1.1                

RocketMod Service Manager NuGet

Library that adds a BackgroundWorker and TaskQueue with Async support.

Installation & Usage

Before you begin, please make sure that your current solution has installed the nuget package of this library.
You can find this package here.


Service Usage

The service system is the primary utility included in this library.
It allows static access to plugin defined services.

Example usage of registering and retrieving a service named BuildableAbstractionsService:

// Registering the service
RocketModService<IBuildableAbstractionsService>.RegisterService(new BuildableAbstractionsServiceImplementation());

// Retrieving the service (but will throw an exception if its not registered, useful if the service is a hard requirement)
var buildableAbstractionService = RocketModService<IBuildableAbstractionService>.GetService();

// Retrieveing the service (but will return null if its not registered, useful if the service is a soft requirement)
var buildableAbstractionService = RocketModService<IBuildableAbstractionService>.TryGetService();

Do note that it is best to target an interface with services, rather than a specific class.
The clas that stores the services are per-type, so registering the service to the class rather than the interface will make it impossible to find through the interface unless the other developers target the class when searching for the service.
With the example above, if the service is registered to RocketModService<BuildableAbstractionsServiceImplementation>, it will only be accessible through that exact type, and not through RocketModService<IBuildableAbstractionService>

Event Bus Usage

The event bus is the secondary and simple utility included in this library.
It helps services raise events whilst still allowing services to be replaced without event handlers needing to be resubscribed.
The usage is simple, if you want to hook to an event, for example BuildableDestroyedEvent, simply call Subscribe:

EventBus.Subscribe<BuildableDestroyedEvent>(MyHandlingMethod);

public void MyHandlingMethod(BuildableDestroyedEventArguments eventArguments)
{
}

If you wish to unsubscribe from a method, you simply run the same code but call Unsubscribe:

EventBus.Unsubscribe<BuildableDestroyedEvent>(MyHandlingMethod);

public void MyHandlingMethod(BuildableDestroyedEventArguments eventArguments)
{
}

If you own the event and you wish to raise a message to all handlers that subscribed to your event, simply call Publish:

EventBus.Publish<BuildableDestroyedEvent>(new BuildableDestroyedEventArguments(buildable));
Product Compatible and additional computed target framework versions.
.NET Framework net481 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.8.1

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Pustalorc.RocketModServices:

Package Downloads
Pustalorc.BuildableAbstractions.API

Unturned Library to provide abstractions for Barricades and Structures, as Buildables. Also includes some useful patches for events that don't exist by default.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.1.2 163 8/10/2024
1.1.1 106 8/10/2024
1.1.0 102 6/20/2024
1.0.0 186 7/15/2023

Updated JetBrains.Annotations package, and made it private assets so projects that use this project do no automatically import and use JetBrains.Annotations