TilePlus Version 5
Unity3D Tilemap Extension
Loading...
Searching...
No Matches
TilePlus.TpServiceManager Class Reference

Manages Runtime Scriptable Services. Registration, queries, diagnostics. More...

Static Public Member Functions

static void RegisterSrs (ScriptableObject instance)
 Scriptable Runtime Services register themselves automatically when loaded.
static void UnregisterSrs (ScriptableObject instance)
 Scriptable Runtime Services de-register themselves when Destroyed.
static void KillAllRunningServices (bool evenPersistent=false)
 Use when changing scenes.
static void PreRegisterSrs (string rType, Action creator)
 Scriptable Runtime Services pre-register themselves in this simple 'service locator' before any monobehaviours run.
static bool HasServiceOfTypeAvailable (string rType)
 Is there a service of this type already preregistered? If not, it doesn't exist as it hasn't been preloaded.
static bool HasAllTheseRunningServices (IEnumerable< Type > types)
 Test for a set of active services.
static bool GetRunningService< T > (out T? service)
 Get a running service or null if not running.
static ? T GetServiceOfType< T > (bool log=true)
 Get an instance handle to a service using its type. Loads service if not running.
static bool TerminateServiceOfType< T > ()
 Shut down (Destroy) a service of a particular type.
static bool ServiceMessage (ObjectPacket packet)
 Send a message to a service.

Properties

static Type[] GetAllRunningServiceTypes [get]
 Get an array of all of the Scriptable Runtime Service TYPES in memory.
static string[] GetAllAvailableServiceNames [get]
 Get an array of all AVAILABLE (could be loaded...) Scriptable Runtime Service names.
static TpMessaging MessagingService [get]
 Convenience function: get handle to messaging service.
static TpSpawner SpawnerService [get]
 Convenience function: get handle to spawning service.
static TpTweener TweenerService [get]
 Convenience function: get handle to Tweener service.

Events

static ? Action< bool > OnLoadedSrsChange
 This fires when RegisterSrs or UnRegisterSrs is used. The boolean value is true for registration or false for unregister.

Detailed Description

Manages Runtime Scriptable Services. Registration, queries, diagnostics.

Member Function Documentation

◆ GetRunningService< T >()

bool TilePlus.TpServiceManager.GetRunningService< T > ( out T? service)
static

Get a running service or null if not running.

Parameters
serviceout parameter
Template Parameters
TService type
Returns
true if found. If false, out param is null.

Checks for a running service without starting it if it isn't running

Type Constraints
T :ScriptableRuntimeService<T> 

◆ GetServiceOfType< T >()

? T TilePlus.TpServiceManager.GetServiceOfType< T > ( bool log = true)
static

Get an instance handle to a service using its type. Loads service if not running.

Template Parameters
T
Parameters
logoptional logging control: implementation dependent
Returns
instance handle to a SRS service.

If you see the warning a few lines below, it probably means that you're using this method in an update loop and the loop execs one more time when exiting play mode. You might want to figure out why but it's not harmful.

Type Constraints
T :ScriptableRuntimeService<T> 

◆ HasAllTheseRunningServices()

bool TilePlus.TpServiceManager.HasAllTheseRunningServices ( IEnumerable< Type > types)
static

Test for a set of active services.

Parameters
typesan IEnumerable of the TYPES of services you need.
Returns

◆ HasServiceOfTypeAvailable()

bool TilePlus.TpServiceManager.HasServiceOfTypeAvailable ( string rType)
static

Is there a service of this type already preregistered? If not, it doesn't exist as it hasn't been preloaded.

Parameters
rTypeName (use nameof(Classname) of the service to check.

◆ KillAllRunningServices()

void TilePlus.TpServiceManager.KillAllRunningServices ( bool evenPersistent = false)
static

Use when changing scenes.

Parameters
evenPersistentIf true, kills ALL, even those marked as persistent with PeristThruReload => true

◆ PreRegisterSrs()

void TilePlus.TpServiceManager.PreRegisterSrs ( string rType,
Action creator )
static

Scriptable Runtime Services pre-register themselves in this simple 'service locator' before any monobehaviours run.

Parameters
rTypeNAME of the SRS (can use 'nameof' or make up a unique name)
creatorNormally CreateIfNeeded()

Action? initializer = null, bool log = true

◆ RegisterSrs()

void TilePlus.TpServiceManager.RegisterSrs ( ScriptableObject instance)
static

Scriptable Runtime Services register themselves automatically when loaded.

Parameters
instanceSRS instance.

◆ ServiceMessage()

bool TilePlus.TpServiceManager.ServiceMessage ( ObjectPacket packet)
static

Send a message to a service.

Parameters
packetObject packet. the 'Command' string value is used to select targets.
Returns
false for error: ie if the packet.Command isn't registered

The Service needs to implement the IScriptableService AcceptableMessages and MessageTarget interface items. Any implementations returning ALL for 'acceptable messages' get ANY message sent this way. These targets are messaged first.

◆ TerminateServiceOfType< T >()

bool TilePlus.TpServiceManager.TerminateServiceOfType< T > ( )
static

Shut down (Destroy) a service of a particular type.

Template Parameters
TThe service Type
Returns
false for error

Please be careful with this: ensure you really want to shut down.

Type Constraints
T :ScriptableRuntimeService<T> 

◆ UnregisterSrs()

void TilePlus.TpServiceManager.UnregisterSrs ( ScriptableObject instance)
static

Scriptable Runtime Services de-register themselves when Destroyed.

Parameters
instanceSRS instance

Property Documentation

◆ GetAllAvailableServiceNames

string [] TilePlus.TpServiceManager.GetAllAvailableServiceNames
staticget

Get an array of all AVAILABLE (could be loaded...) Scriptable Runtime Service names.

◆ GetAllRunningServiceTypes

Type [] TilePlus.TpServiceManager.GetAllRunningServiceTypes
staticget

Get an array of all of the Scriptable Runtime Service TYPES in memory.

◆ MessagingService

TpMessaging TilePlus.TpServiceManager.MessagingService
staticget

Convenience function: get handle to messaging service.

◆ SpawnerService

TpSpawner TilePlus.TpServiceManager.SpawnerService
staticget

Convenience function: get handle to spawning service.

◆ TweenerService

TpTweener TilePlus.TpServiceManager.TweenerService
staticget

Convenience function: get handle to Tweener service.

Alias for this can also be found as a static property in TilePlusBase

Event Documentation

◆ OnLoadedSrsChange

? Action<bool> TilePlus.TpServiceManager.OnLoadedSrsChange
static

This fires when RegisterSrs or UnRegisterSrs is used. The boolean value is true for registration or false for unregister.


The documentation for this class was generated from the following file:
  • /Users/jms/Documents/Tpt_55/TPT55/Assets/Plugins/TilePlus/Runtime/StaticLib/TpServiceManager.cs