Skip to content

Simple service pattern plugin for Flax Engine, inspired by MonoGame ServiceContainer.

Notifications You must be signed in to change notification settings

neuro-machina/FService

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

FService

Simple service pattern plugin for Flax Engine, inspired by MonoGame ServiceContainer.

To incorportate the plugin to your flax project, simply add the two cs files (IServicePlugin.cs and ServicePlugin.cs ) anywhere in your project, or simply copy paste the code directly in new created cs files in your source project.

How to use:

First you need to register a service, it can be done from anywhere you want as long you are registering a class, can also register an object by interface:

using FService;

ServicePlugin.Instance.AddService<MyServiceType>(MyServiceObject);

Then to retrieve a service simply call:

ServicePlugin.Instance.GetService<MyServiceType>();

You can also remove services (usefull for script type to be cleared on OnDestroy):

ServicePlugin.Instance.RemoveService(typeof(MyServiceType));

There are also two event Action callbacks you can subscribe to in the plugin for when a service is added and removed:

ServicePlugin.Instance.Add += MyVoidMethod;
ServicePlugin.Instance.Remove += MyVoidMethod;

Notes:

This is pretty much the ServiceContainer from MonoGame project, just wrapped up for Flax Engine use.

About

Simple service pattern plugin for Flax Engine, inspired by MonoGame ServiceContainer.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages