GithubHelp home page GithubHelp logo

neuro-machina / fservice Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 6 KB

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

C# 100.00%
flax-engine plugin service service-pattern

fservice's Introduction

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.

fservice's People

Contributors

neuro-machina avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.