|
Brunot
|
to update/initialize submodules (like when cloning the repo, use the commmand
This function lets add a function to the Messaging system. Specifically, it will be called whenever the specified event is broadcasted
Full definition:
Although this function looks pretty scary at first, it's actually not that bad once you break it down.
Parameter 0 / typename classType: this is the name of the class that has the function you are linking. Since you are connecting a function that belongs to a specific instance of a class, just pass in the type of the class the object is.
Parameter 1 / const std::string& eventName: This is the name of the event that you want to connect the function to.
Parameter 2 / void (classType::*functionToLink)(const Message&): Okay this is the scariest one. However, it's just a function pointer to a function that returns void and takes a const Message& parameter.
Parameter 3 / const std::string& functionName: This is the name of the function that you want to connect. This can technically be anything, but you should try and make it always match the name of the function
Parameter 4 / pointerToSelf: This is a pointer to the instance of a class that you want to be attached to the function. Basically, when the event occurs, this specific instance will receive it.
example call:
This removes all functions of a given name that belong to a specific class
Full definition:
Parameter 1 / const std::string& functionToRemove: The name of the function that you want to be removed. This is why it's important to have the functionName in connect match the actual function name, because otherwise it's basically impossible to find it without looking for how it was connected.
Parameter 2 / GameObject* owner: The entity that the function belongs to.
Example call:
This function sends a message to all functions linked to the event
Full definition:
Parameter 1 / const std::string& eventName: The name of the event that you want to be broadcasted.
Parameter 2 / const Message& message: The message you want to send to the linked functions. You will need to create a Message. (you should create a derived class from Message that holds the data you want if one doesn't currently exist.)
For an example of how to use Paths, see the detailed description of Path