This is a 'union' of the most likely Types of objects one might like to send. For the UnityObject and object values the type is is available. The optional info string can be used to provide context (ie target switching actions based on what the string is), debug info, or left empty.
More...
|
| override void | Reset () |
| | Reset this instance. Useful if pooled.
|
| void | UpdateInstance (Object? sourceInstance, UnityEngine.Object unityEngineObject, object csObject, string info="", EventsPropagationMode mode=EventsPropagationMode.None) |
| | UPDATE INSTANCE. When pooling, use this to set the main values since Ctor can't be used.
|
| | ObjectPacket (Object? sourceInstance=null) |
| | Use this for pooling or creating an empty instance. Not necc to provide a sourceInstance value. This artifice is required because the base class doesn't have (nor can have) a parameterless constructor.
|
| | ObjectPacket (Object sourceInstance, string info="", EventsPropagationMode eventsPropagation=EventsPropagationMode.None) |
| | Initializes a new instance of the class with just the source instance.
|
| | ObjectPacket (Object? unityObject, Object? sourceInstance=null, string info="", EventsPropagationMode eventsPropagation=EventsPropagationMode.None) |
| | Initializes a new instance of the class with just a unityObject.
|
| | ObjectPacket (Object? unityObject, object? objectValue, Object? sourceInstance=null, EventsPropagationMode eventsPropagation=EventsPropagationMode.None, string info="") |
| | Initializes a new instance of the class with a GameObject and a c# object.
|
| | ObjectPacket (object? objectValue, Object? sourceInstance=null, EventsPropagationMode eventsPropagation=EventsPropagationMode.None, string info="") |
| | Initializes a new instance of the class with just a c# object.
|
| override string | ToString () |
|
| EventsPropagationMode | EventsPropagation [get, set] |
| | Control events pass-thru when this packet is sent to tiles that can post events. The default value is zero which means NO events pass thru. Note that this is a FLAGS enum.
|
| string | Command [get, set] |
| | optional 'command' string, can be used for anything but typically is a string value used by the message target. E.G., Command_ZoneAction is the value when a TpTileZoneAction emits this packet. Please note that the 'command' XY_ZZ_Y is reserved for use by the Service manager's messaging scheme.
|
| bool | HasCommand [get] |
| | true if command string isn't empty.
|
| Object? | UnityObject [get, set] |
| | UnityEngine.Object.
|
| bool | HasUnityObject [get] |
| | True if there's a Unity Object in this instance.
|
| Type? | UnityObjectType [get] |
| | The type of the Unity Object.
|
| object? | ObjectValue [get, set] |
| | c# object
|
| bool | HasObject [get] |
| | True if there's a C# object in this instance.
|
| Type? | ObjectType [get] |
| | The type of the c# object.
|
| bool? | BoolValue [get, set] |
| | Optional Arbitrary Boolean value.
|
| bool | HasBoolValue [get] |
| | True if the bool in this instance is valid.
|
| int? | IntValue [get, set] |
| | Optional Arbitrary Integer value.
|
| bool | HasIntValue [get] |
| | True if the Int in this instance is valid.
|
| string | StringValue [get, set] |
| | Optional Arbitrary String value.
|
| bool | HasStringValue [get] |
| | True if the string in this instance is neither null nor empty.
|
| Object? | SourceInstance [get, set] |
| | The instance that's the source of the message. Can be null.
|
| ulong | Id [get, set] |
| | The ID of this packet. Packet recepients can test this to see if they're being sent the same message repeatedly. Note that 0 is not used except internally.
|
This is a 'union' of the most likely Types of objects one might like to send. For the UnityObject and object values the type is is available. The optional info string can be used to provide context (ie target switching actions based on what the string is), debug info, or left empty.
This was created primarily for tile-to-tile messaging and event propogation but it can obviously be used for other things.
This is a class with a lot of fields etc so pooling might be used. There's a reset method if you decide to do so. Normally that should be used when an instance is returned to the pool so that references are not held. -------------—*******************-----------------— NOTE: if not pooling, use Reset if possible when done with the instance so that GC can work properly. -------------—*******************-----------------— There's a pool for this object set up in TpMessaging. Example: using (TpMessaging.S_ObjectPacketInPool.Get(out var packet)) { //init packet via properties or UpdateInstance TpMessaging.SendMessage<EmptyPacket, ObjectPacket, ITpMessaging<EmptyPacket, ObjectPacket>>(..) }
Useful for TPT tiles since they can't have scene references. For that use case, a GameObject can be passed as the UnityEngine.Object reference as an 'injection'.
This class is also useful for passing around messages between tiles, as can be seen in 'Zone Actions' and the TileUi demo and customized tiles for UI use.
NOTE that since there are object and Object refs in here, don't cache these unless you null the objects after use (use Reset) or you'll have memory leaks. If pooling, use RESET when returning to the pool. The pool in TpMessaging does this.
Optional string, int, and bool values are provided as properties. When you create an instance of this packet set those as appropriate.
The int and bool values are nullable so be sure to use .hasValue or use the supplied 'Has' properties, and use int.Value or bool.Value.
HasInfoString, HasBoolValue, HasIntValue, and HasStringValue are updated when the corresponding properties are Set, so use those rather than .hasValue or explicit null checks if possible. The packet may be evaluated by many tiles so these 'Has' properties are much more efficient.
Similarly, use HasUnityObject and HasObject rather than explicit null checks.
Use HasInfoString instead of string.Empty, for efficiency.
All of the 'Has' values are pre-created in the constructor (when it sets the properties) or when you directly write to any of the properties including the three optional properties BoolValue, IntValue, StringValue.