Message data.
More...
#include <framework/message.h>
|
enum | Type : message_t {
NONE
, PING
, MOVE_PICK_UP
, OPEN
,
CLOSE
, LOCK
, UNLOCK
, TOGGLE
,
KILL
, TRIGGER
, START
, STOP
,
ACTIVATE
, ACTIVATE_ONCE
, SELECT
, SET_PROGRESS
,
SET_ANIMATION
, SET_FLAG_ON
, SET_FLAG_OFF
, LAST_MESSAGE
} |
|
Message data.
Fill in the struct fields and then use Message::Send() to send it out to listeners.
◆ Type
Enumerator |
---|
NONE | |
PING | |
MOVE_PICK_UP | |
OPEN | |
CLOSE | |
LOCK | |
UNLOCK | |
TOGGLE | |
KILL | |
TRIGGER | |
START | |
STOP | |
ACTIVATE | |
ACTIVATE_ONCE | |
SELECT | |
SET_PROGRESS | |
SET_ANIMATION | |
SET_FLAG_ON | |
SET_FLAG_OFF | |
LAST_MESSAGE | |
◆ AllocateData() [1/3]
template<typename T >
static T * tram::Message::AllocateData |
( |
| ) |
|
|
inlinestatic |
◆ AllocateData() [2/3]
template<typename T >
static T * tram::Message::AllocateData |
( |
const T & |
data | ) |
|
|
inlinestatic |
◆ AllocateData() [3/3]
void * tram::Message::AllocateData |
( |
size_t |
ammount | ) |
|
|
static |
Allocates space for message data.
This allocation is useful for storing the additional data (Message::data pointer), for messages, since all allocated space will be cleared once all messages have been dispatched. This only applies to messages that are sent without a time delay, if you're sending messages with a delay, then you'll need to allocate memory for their data yourself.
- Note
- Remember to only use POD data types.
◆ Dispatch()
void tram::Message::Dispatch |
( |
| ) |
|
|
static |
Dispatches sent messsages.
Dispatches the messages that have been sent using the Message::Send() function.
◆ GetLast()
Returns the last message_t plus one.
Useful for iterating over all registered messages, i.e. in a while (++message < Message::GetLast());
or a similar loop.
◆ GetName()
Gets a nessage type name.
◆ GetType()
Finds a message type from a name.
◆ Register()
message_t tram::Message::Register |
( |
const char * |
name | ) |
|
|
static |
Registers a new message type.
- Returns
- Unique message type number.
◆ Send() [1/2]
void tram::Message::Send |
( |
const Message & |
message | ) |
|
|
static |
◆ Send() [2/2]
void tram::Message::Send |
( |
const Message & |
message, |
|
|
float |
delay |
|
) |
| |
|
static |
Semds a message into the future.
Same as Message::Send(), but the actual sending will be delayed until specified ammount of ticks have passed.
- Parameters
-
message | Message to be sent. |
when | How many ticks need to pass until the message will be sent out, i.e. if you want to send a message out in 1 secons, set this parameter to 60. |
◆ SetInterceptCallback()
void tram::Message::SetInterceptCallback |
( |
void(const Message &) |
| ) |
|
|
static |
union { ... } tram::Message::@40 |
◆ data
tram::Message::data = nullptr |
Pointer to arbitrary data.
Can be set to a nullptr. Some message types have specific data, e.g. structs or other types that they need their data pointers to be pointing to. For your own message types, you can use this pointer for whatever purpose you want. If uncertain, set this to a nullptr.
◆ data_int
◆ data_value
tram::Message::data_value |
◆ receiver
ID of the Entity that will receive the message.
Set to the ID of an Entity.
◆ sender
ID of the Entity that sent the message.
Either set to the ID of an Entity, or can be set to zero.
◆ type
The documentation for this struct was generated from the following files:
- C:/Users/Poga/Desktop/painis/tram-sdk/src/framework/message.h
- C:/Users/Poga/Desktop/painis/tram-sdk/src/framework/message.cpp