![]() |
BomberUnits
...a Unity learning project
|
This is a convenience wrapper for Photons networked event system. More...
Inheritance diagram for NetEvent< NetDataType >:
Collaboration diagram for NetEvent< NetDataType >:Classes | |
| class | UnityEventWithCustType |
| It is somehow necessary to create this and get rid of the template parameter. More... | |
Public Member Functions | |
| NetEvent (Target target=Target.All, bool reliable=true, bool cachedForRoom=false) | |
| Constructor taking optional settings. More... | |
| NetEvent (NetDataType defaultData, Target target=Target.All, bool reliable=true, bool cachedForRoom=false) | |
| Optional constructor allowing to give the event default data Invoke() can be called without repeating the default data now. More... | |
| void | AddListener (UnityAction< NetDataType > callback) |
| The given callback will receive data of the defined type. | |
| void | RemoveListener (UnityAction< NetDataType > callback) |
| Removes the given callback from receiving events. | |
| void | Invoke (NetDataType data, string userID="") |
| Sends the event to the set targets, calling the registered callbacks with the given data. More... | |
| void | Invoke (string userID="") |
| This version of Invoke does not require data. The event has to have default data set though! | |
| void | OnEvent (EventData photonEvent) |
| Forwards the Photon Event to the held Unity event, which distributes to registered callbacks. | |
Private Member Functions | |
| ~NetEvent () | |
| The destructor has to remove the registration for Photon event data. | |
| int | GetSpecificTargetActorNr (string userID) |
| Get the actorNr for a specified userID. Returns -1 if the user cannot be found or was not given. | |
Private Attributes | |
| byte | eventCode |
| UnityEventWithCustType | localEvent |
| Target | target |
| NetDataType | defaultData |
| bool | reliable |
| bool | cachedForRoom |
| bool | hasDefaultData |
This is a convenience wrapper for Photons networked event system.
It primarily allows for quick raising and registering to these events, removing some low-level actions. They can be set up for any Type of data package implementing INetDataPkg for serialization. Usage:
Internally, instances of these classes map the single existing PhotonEvent (identified via ID) to local UnityEvents, which can be comfortably subscribed to.
| NetDataType | : | INetDataPkg | |
| NetDataType | : | new() |
Definition at line 36 of file NetEvent.cs.
Constructor taking optional settings.
This most importantly registers this instance to receive Photon event data.
Definition at line 60 of file NetEvent.cs.
|
inline |
Optional constructor allowing to give the event default data Invoke() can be called without repeating the default data now.
Definition at line 75 of file NetEvent.cs.
|
inline |
Sends the event to the set targets, calling the registered callbacks with the given data.
You can optionally hand the id of a user to send only to that user.
Definition at line 103 of file NetEvent.cs.