TilePlus Version 5
Unity3D Tilemap Extension
Loading...
Searching...
No Matches
TilePlus.ScriptableRuntimeService< T > Class Template Referenceabstract

Simple and simplistic base class for Runtime Services. "Scriptable Runtime Service" or SRS. More...

Inheritance diagram for TilePlus.ScriptableRuntimeService< T >:
Collaboration diagram for TilePlus.ScriptableRuntimeService< T >:

Public Member Functions

virtual string Status ()
 The TilePlus SysInfo window will show all SRS 'Status' strings when playing in-editor (if the 'show' checkbox is checked). This is totally optional.
virtual bool CanPollForDetails ()
 Used by SRS inspector. If the contents of an SRS change frequently then this should be overridden to return true.
virtual string Details (int length=-1)
 The SRS inspector utility will show whatever this returns.
override string ToString ()
 Customize ToString in overrides.
virtual void OnEnable ()
 OnEnable.
virtual void OnDisable ()
 Unity event method.
Public Member Functions inherited from TilePlus.IScriptableService
void Update (float deltaTime)
 Update implementation: Must override with explicit implementation.
void MessageTarget (ObjectPacket packet)
 If Accepts messages is true, reimplement this to get messaged.

Static Protected Member Functions

static void Create ()
 Create and initialize method.

Properties

string ServiceName [get]
 A name for this service: used for profiling. Ordinarily just returns the 'name' property of the Service S.O. instance.
Properties inherited from TilePlus.IScriptableService
bool PeristThruReload [get]
 If true, this will not be deleted when the Unity scene changes.
bool WantsUpdate [get]
 Does this SRS want an update tick? MUST override if you're providing an Update method. MUST override with explicit implementation.
bool ReadyForUpdate [get]
 Is this SRS ready for an update? MUST Override if your SRS doesn't always need an update. MUST override with explicit implementation.
string[] AcceptableMessages [get]
 If true, can accept ObjectPacket messages from the Service Manager with command-strings matching those returned here.

Detailed Description

Simple and simplistic base class for Runtime Services. "Scriptable Runtime Service" or SRS.

Template Parameters
TType spec

Access a SRS with TpLib's Service manager methods such as RequestServiceOfType<T>

That returns an instance to the service.

TO USE THE SERVICE MANAGER: all concrete implementations MUST implement TpLib.PreRegisterSRS with the [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)] attribute. See TpMessaging for an example. If that's not done, then the SRS won't be available by the service manager. ---------------— WARNING -— Cannot use in EDIT mode!!! ------------------—

If you hold a ref to a SRS in-editor it'll be disabled but still present in memory. In a built app this does not matter.

There's no need to cache references, use the service manager to obtain the instance. The ServiceManager call is public static T? GetServiceOfType<T>(Action<UnityEngine.Object?*gt;? initializer=null, bool log=true) It's a very fast dictionary lookup, so unless it's a performance bottleneck (hard to imagine) there's no need to cache the handle returned from GetServiceOfType. The initializer is optional but may be required by specific services; e.g., TpTilePositionDb. ------------— Persistent through app lifetime --------------— Once instantiated, SRS should not be destroyed unless one knows that they don't have any

  1. events that the SRS has subscribed to, e.g., Tilemap callbacks, etc.
  2. subscriptions that something else has subscribed to, e.g. TpSpawner's callbacks. The intention is: once started, leave running. HOWEVER: You can use the Service Manager's Destroy to kill a service. If other code depends on a service it may be re-started automatically if GetServiceOfType is used again.
Type Constraints
T :ScriptableObject 
T :IScriptableService 

Member Function Documentation

◆ CanPollForDetails()

virtual bool TilePlus.ScriptableRuntimeService< T >.CanPollForDetails ( )
virtual

Used by SRS inspector. If the contents of an SRS change frequently then this should be overridden to return true.

Returns
T/F

accessed via reflection (editor only) don't change this to a prop or change the name

Reimplemented in TilePlus.TpMessaging, TilePlus.TpSpawner, and TilePlus.TpTweener.

◆ Create()

void TilePlus.ScriptableRuntimeService< T >.Create ( )
staticprotected

Create and initialize method.

DO NOT USE ScriptableObject.CreateInstance. IT WON'T WORK PROPERLY!!! This is a protected method intentionally: use the TpLib GetServiceOfType method for a service handle (reference).

◆ Details()

virtual string TilePlus.ScriptableRuntimeService< T >.Details ( int length = -1)
virtual

The SRS inspector utility will show whatever this returns.

Returns
a a string with details

accessed via reflection (editor only) don't change this to a prop or change the name

Reimplemented in TilePlus.TpMessaging, TilePlus.TpSpawner, and TilePlus.TpTweener.

◆ OnDisable()

virtual void TilePlus.ScriptableRuntimeService< T >.OnDisable ( )
virtual

Unity event method.

Reimplemented in TilePlus.TpSpawner, TilePlus.TpTilePositionDb, and TilePlus.TpTweener.

◆ OnEnable()

virtual void TilePlus.ScriptableRuntimeService< T >.OnEnable ( )
virtual

◆ Status()

virtual string TilePlus.ScriptableRuntimeService< T >.Status ( )
virtual

The TilePlus SysInfo window will show all SRS 'Status' strings when playing in-editor (if the 'show' checkbox is checked). This is totally optional.

Reimplemented in TilePlus.TpMessaging, TilePlus.TpSpawner, TilePlus.TpTilePositionDb, and TilePlus.TpTweener.

◆ ToString()

override string TilePlus.ScriptableRuntimeService< T >.ToString ( )

Customize ToString in overrides.

Returns
string

Property Documentation

◆ ServiceName

string TilePlus.ScriptableRuntimeService< T >.ServiceName
get

A name for this service: used for profiling. Ordinarily just returns the 'name' property of the Service S.O. instance.

Implements TilePlus.IScriptableService.


The documentation for this class was generated from the following file: