Events library for TilePlus tiles.
More...
|
| static bool | AnyEvents [get] |
| | Are there any events to handle?
|
| static int | NumEvents [get] |
| | Count of pending events.
|
|
| static ? Action< Guid > | OnTileEvent |
| | Subscribe to get notified when your tile sends a event notice in immediate mode or for communication. Note that this includes the GUID of the tile in case you need to access the tile. To avoid memory leaks avoid making persistent copies of TPT tile references outside of the subscriber's event handler for this event. See: TpLib.GetTilePlusBaseFromGuid(Guid,bool)
|
Events library for TilePlus tiles.
◆ ClearOnTileEventSubscribers()
| void TilePlus.TpEvents.ClearOnTileEventSubscribers |
( |
| ) |
|
|
static |
Clears OnTileEvent events.
◆ ClearPendingEvents()
| bool TilePlus.TpEvents.ClearPendingEvents |
( |
| ) |
|
|
static |
Clear any pending events.
- Returns
- FALSE if there were any pending events remaining
◆ GetAllEvents()
| bool TilePlus.TpEvents.GetAllEvents |
( |
List< TilePlusBase > | output, |
|
|
bool | clear = true ) |
|
static |
Get all the pending events into a list which you provide. Useful if it's not desirable to process them using ProcessEvents.
- Parameters
-
| output | List to place the tile instances which have posted events. |
| clear | clear the internal events list when done. |
◆ PostTileEvent()
| void TilePlus.TpEvents.PostTileEvent |
( |
TilePlusBase | tpb, |
|
|
bool | alwaysUseOnTileEvent = false ) |
|
static |
Post an event.
- Parameters
-
| tpb | tile instance sending the event. usually 'this' is OK |
| alwaysUseOnTileEvent | Always emit OnTileEvent event |
A HashSet is used to track which tile has events. HashSets ignore repeated adds of the same TilePlusBase instance. Normally, the OnTileEvent is not emitted if the HashSet.Add returns false because the same instance is added more than once. If you really want the OnTileEvent to be emitted for each add attempt, regardless of whether it's the same instance, alwaysUseOnTileEvent should be set to true.
◆ ProcessEvents()
| bool TilePlus.TpEvents.ProcessEvents |
( |
List< TilePlusBase >? | output = null, |
|
|
bool | handleEventsWithActions = true ) |
|
static |
Get and/or process (using EventActions) all events. CLEARS THE SET OF PENDING EVENTS ON EXIT.
- Parameters
-
| output | List for result, if null: see remarks. If not null, it's cleared |
| handleEventsWithActions | default is true. If true, automatically handle events where the tile has an Event Action. Any tiles that had posted events but don't have Event Actions will be returned in the output list (if it was provided on entry). If there are none then the list is returned empty. If this param is FALSE and output == null then nothing can occur so a warning is sent to the console. |
If output is null then an internal list is allocated from a pool. This is only useful if you don't need the list back because all operations in response to the events are handled by TPT tile event actions. If 'output' is null and handleEventsWithActions is false then nothing happens at all.
If a tile has NO event actions it's added to the output list, hence, if you will have events from tiles NOT handled by event actions you really neeed the output list.
the internal set of pending tile events is ALWAYS cleared when this method exits. Alternatively, use GetAllEvents and process them yourself, followed by ClearPendingEvents.
◆ RemoveEvent()
Remove a single Tile from all event queues.
- Parameters
-
| instance | the tile instance that originally sent the event |
- Returns
- true if successful
◆ AnyEvents
| bool TilePlus.TpEvents.AnyEvents |
|
staticget |
Are there any events to handle?
◆ NumEvents
| int TilePlus.TpEvents.NumEvents |
|
staticget |
◆ OnTileEvent
| ? Action<Guid> TilePlus.TpEvents.OnTileEvent |
|
static |
Subscribe to get notified when your tile sends a event notice in immediate mode or for communication. Note that this includes the GUID of the tile in case you need to access the tile. To avoid memory leaks avoid making persistent copies of TPT tile references outside of the subscriber's event handler for this event. See: TpLib.GetTilePlusBaseFromGuid(Guid,bool)
The documentation for this class was generated from the following file:
- /Users/jms/Documents/Tpt_55/TPT55/Assets/Plugins/TilePlus/Runtime/StaticLib/TpEvents.cs