TilePlus Version 5
Unity3D Tilemap Extension
Loading...
Searching...
No Matches
TilePlus.TpMessaging Class Referencesealed

Library of tile messaging methods. Note that it's a Service. More...

Inheritance diagram for TilePlus.TpMessaging:
Collaboration diagram for TilePlus.TpMessaging:

Public Member Functions

override void OnEnable ()
 OnEnable event override.
override 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.
override bool CanPollForDetails ()
 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
override string Details (int length=-1)
 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
MessagingContextPeekContextStack (bool unpooled=true)
 Peek the top of the context stack and return an unpooled instance or optionally, the actual top of stack (pooled): pooled useful if you're forwarding packets.
void SendMessage< T > (TilePlusBase tile, T packet)
 Send a message to a single tile.
void SendMessage< T > (Tilemap map, Vector3Int position, T packet)
 Send a message to a single tile on a given map.
bool SendMessage< T > (string guid, T packet)
 Send a message to a single tile with a GUID in string form, on a given map. –Convenience wrapper method.
bool SendMessage< T > (Guid guid, T packet)
 Send a message to a single tile with a GUID on a given map.
void SendMessage< T > (Tilemap map, IEnumerable< Vector3Int > positions, T packet, Func< TilePlusBase, bool >? tileFilter=null)
 Send a message to tiles on a given map with an IEnumerable of positions.
int[] SendMessage< T > (Tilemap map, string tag, T packet, Func< TilePlusBase, bool >? tileFilter=null, Func< T, TilePlusBase, bool >? packetFilter=null, RectInt? region=null)
 send a message to one or more tagged tiles. Optional prefilter
int[] SendMessage< T > (Tilemap? map, Type typeSpec, T packet, Func< TilePlusBase, bool >? tileFilter=null, Func< T, TilePlusBase, bool >? packetFilter=null, RectInt? region=null)
 send a message to one or more tiles of a particular type. Optional prefilter.
int[] SendMessage< T, TI > (T packet, Func< TI, TilePlusBase, bool >? interfaceAndTileFilter=null, Func< T, TilePlusBase, bool >? packetFilter=null, Func< TilePlusBase, bool >? tileFilter=null, RectInt? region=null)
 send a message to one or more tiles with a particular interface
Public Member Functions inherited from TilePlus.ScriptableRuntimeService< T >
override string ToString ()
 Customize ToString in overrides.
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 Public Member Functions

static bool RejectSameInstancePacketFilter< T > (T packet, TilePlusBase tile)
 Basic packet filter rejects packets with same source instance. ALWAYS returns true if the packet's source instance is null. NOTE THAT IF YOU USE THIS PACKET FILTER then the tileFilter is ignored even if specified in the method call. Can't have tileFilter and PacketFilter in the same call to SendMessage.

Properties

ulong LastMessageID [get]
 ID of the last or current message.
int MaxMessagedCount [get]
 Max # of messages sent in one method call. Note can be confusing since messages can be re-sent from message handlers.
int LastMessagedCount [get]
ObjectPool< ObjectPacketObjectPacketPool [get]
 Pool for ObjectPackets.
ObjectPool< ActionToTilePacketActionToTilePacketPool [get]
 Pool for ActionToTilePackets.
ObjectPool< PositionPacketPositionPacketPool [get]
 Pool for position packets.
ObjectPool< StringPacketStringPacketPool [get]
 Pool for String packets.
Properties inherited from TilePlus.ScriptableRuntimeService< T >
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.

Additional Inherited Members

Static Protected Member Functions inherited from TilePlus.ScriptableRuntimeService< T >
static void Create ()
 Create and initialize method.

Detailed Description

Library of tile messaging methods. Note that it's a Service.

Null-checks are not used in certain loops to enhance speed. However, since user code is generally single-threaded, TpLib shouldn't be returning null tiles within any of these methods.

Member Function Documentation

◆ CanPollForDetails()

override bool TilePlus.TpMessaging.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 from TilePlus.ScriptableRuntimeService< T >.

◆ Details()

override string TilePlus.TpMessaging.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 from TilePlus.ScriptableRuntimeService< T >.

◆ OnEnable()

override void TilePlus.TpMessaging.OnEnable ( )
virtual

OnEnable event override.

Reimplemented from TilePlus.ScriptableRuntimeService< T >.

◆ PeekContextStack()

MessagingContext? TilePlus.TpMessaging.PeekContextStack ( bool unpooled = true)

Peek the top of the context stack and return an unpooled instance or optionally, the actual top of stack (pooled): pooled useful if you're forwarding packets.

Parameters
unpooledif true (default) returns UNPOOLED copy of top of stack.
Returns
(optional Copy of) top of context stack or null if the stack is empty.

You CANNOT forward an UNPOOLED copy of the stack via another messaging method. That would eventually release an unpooled copy back to the pool: error. Please set the unpooled param FALSE if you're forwarding this packet via the messaging system.

◆ RejectSameInstancePacketFilter< T >()

bool TilePlus.TpMessaging.RejectSameInstancePacketFilter< T > ( T packet,
TilePlusBase tile )
static

Basic packet filter rejects packets with same source instance. ALWAYS returns true if the packet's source instance is null. NOTE THAT IF YOU USE THIS PACKET FILTER then the tileFilter is ignored even if specified in the method call. Can't have tileFilter and PacketFilter in the same call to SendMessage.

Parameters
packetThe Data packet of Type T
tile
Template Parameters
TMessagePacket or subclass
Returns
true if the SourceInstance is null or not a TilePlusBase or the packet SourceInstance isn't the same as the target tile.
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T >() [1/7]

bool TilePlus.TpMessaging.SendMessage< T > ( Guid guid,
T packet )

Send a message to a single tile with a GUID on a given map.

Parameters
guidGuid of tile
packetpacket to send. Get from pool if possible
Template Parameters
TMessagePacket concrete class
Returns
False if tile with specified GUID isn't found
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T >() [2/7]

bool TilePlus.TpMessaging.SendMessage< T > ( string guid,
T packet )

Send a message to a single tile with a GUID in string form, on a given map. –Convenience wrapper method.

Parameters
guidstring form of tile GUID
packetpacket to send. Get from pool if possible
Template Parameters
TMessagePacket concrete class
Returns
False if string GUID can't be parsed, or if tile with specified GUID isn't found
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T >() [3/7]

void TilePlus.TpMessaging.SendMessage< T > ( Tilemap map,
IEnumerable< Vector3Int > positions,
T packet,
Func< TilePlusBase, bool >? tileFilter = null )

Send a message to tiles on a given map with an IEnumerable of positions.

Parameters
maptarget map. Must not be null
positionsIenumerable of positions
packetpacket to send. Get from pool if possible
tileFilterOptional prefilter delegate, filter on tile Types or instance values.
Template Parameters
TMessagePacket concrete class
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T >() [4/7]

int[] TilePlus.TpMessaging.SendMessage< T > ( Tilemap map,
string tag,
T packet,
Func< TilePlusBase, bool >? tileFilter = null,
Func< T, TilePlusBase, bool >? packetFilter = null,
RectInt? region = null )

send a message to one or more tagged tiles. Optional prefilter

Template Parameters
TMessagePacket concrete class
Parameters
maptilemap to use. If null, uses all maps.
tagtag to look for
packetData to send of type MessagePacket or subclass
tileFilterOptional prefilter delegate, filter on tile Types or instance values.
packetFilterOptional filtering on packets.
regionOptional prefilter, if !null position must be contained in the RectInt.
Returns
An array of the instance IDs of all tiles messaged by this method.
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T >() [5/7]

void TilePlus.TpMessaging.SendMessage< T > ( Tilemap map,
Vector3Int position,
T packet )

Send a message to a single tile on a given map.

Parameters
maptarget map. Must not be null
positionposition
packetpacket to send. Get from pool if possible
Template Parameters
TMessagePacket concrete class
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T >() [6/7]

int[] TilePlus.TpMessaging.SendMessage< T > ( Tilemap? map,
Type typeSpec,
T packet,
Func< TilePlusBase, bool >? tileFilter = null,
Func< T, TilePlusBase, bool >? packetFilter = null,
RectInt? region = null )

send a message to one or more tiles of a particular type. Optional prefilter.

Template Parameters
TMessagePacket concrete class
Parameters
maptilemap to use. If null uses all maps. See GetAllTilesOfType
typeSpecWhat Type of tile to send the message to
packetData to send of type MessagePacket or subclass
tileFilterOptional tileFilter delegate. Filter on tile Types or instance values.
packetFilterOptional filtering on packets.
regionOptional pre-tileFilter for position. If region supplied, only tiles within the region are messaged
Returns
An array of the instance IDs of all tiles messaged by this method.
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T >() [7/7]

void TilePlus.TpMessaging.SendMessage< T > ( TilePlusBase tile,
T packet )

Send a message to a single tile.

Parameters
tiletarget TPT tile. Must not be null.
packetpacket to send. Get from pool if possible
Template Parameters
TMessagePacket concrete class
Type Constraints
T :MessagePacket<T> 

◆ SendMessage< T, TI >()

int[] TilePlus.TpMessaging.SendMessage< T, TI > ( T packet,
Func< TI, TilePlusBase, bool >? interfaceAndTileFilter = null,
Func< T, TilePlusBase, bool >? packetFilter = null,
Func< TilePlusBase, bool >? tileFilter = null,
RectInt? region = null )

send a message to one or more tiles with a particular interface

Template Parameters
TMessagePacket concrete class
TIInterface. Note that it's implicit that the Tiles implementing this interface also must implement ITpMessaging<T>
Parameters
packetData to send of type MessagePacket or subclass
interfaceAndTileFilterOptional delegate for test prior to sending message: the most complex test
packetFilterOptional filtering on packets. Second most complex test
tileFilterOptional filtering on tiles. Simplest test.
regionOptional pre-filter for position. If region supplied, only tiles within the region are messaged
Returns
An array of the instance IDs of all tiles messaged by this method.

If possible use the tileFilter as it's simplest. In general, only use one type of filter. However, if you use more than one: 'filter' is used first, then the packetFilter OR the Tile filter. Meaning: 'filter' and 'region' are always used. However, if packetFilter is used then tileFilter is NOT used.

Type Constraints
T :MessagePacket<T> 

◆ Status()

override string TilePlus.TpMessaging.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 from TilePlus.ScriptableRuntimeService< T >.

Property Documentation

◆ ActionToTilePacketPool

ObjectPool<ActionToTilePacket> TilePlus.TpMessaging.ActionToTilePacketPool
get

Pool for ActionToTilePackets.

◆ LastMessagedCount

int TilePlus.TpMessaging.LastMessagedCount
get

of messages in last method call. Note can be confusing since

messages can be re-sent from message handlers.

◆ LastMessageID

ulong TilePlus.TpMessaging.LastMessageID
get

ID of the last or current message.

◆ MaxMessagedCount

int TilePlus.TpMessaging.MaxMessagedCount
get

Max # of messages sent in one method call. Note can be confusing since messages can be re-sent from message handlers.

◆ ObjectPacketPool

ObjectPool<ObjectPacket> TilePlus.TpMessaging.ObjectPacketPool
get

Pool for ObjectPackets.

◆ PositionPacketPool

ObjectPool<PositionPacket> TilePlus.TpMessaging.PositionPacketPool
get

Pool for position packets.

◆ StringPacketPool

ObjectPool<StringPacket> TilePlus.TpMessaging.StringPacketPool
get

Pool for String packets.


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