Page 1 of 1

Listener argument

Posted: Mon Feb 25, 2019 3:49 pm
by GorkaGames
How do I get the argument on a listener? This is my custom condition script for Tracking message but I don¡t konw how to get the argument true / fasle:

public override void StartChecking(System.Action trueAction)
{
base.StartChecking(trueAction);
MessageSystem.AddListener(this, QuestMachineMessages.QuestTrackToggleChangedMessage, this.quest.id.ToString());
}

public void OnMessage(MessageArgs messageArgs)
{

if ((messageArgs.message == QuestMachineMessages.QuestTrackToggleChangedMessage) && (messageArgs.parameter == this.quest.id.ToString()) && messageArgs.)
{
SetTrue();
}
}

Re: Listener argument

Posted: Mon Feb 25, 2019 3:59 pm
by Tony Li
Hi,

Code: Select all

if ((messageArgs.message == QuestMachineMessages.QuestTrackToggleChangedMessage) && 
   (messageArgs.parameter == this.quest.id.ToString()) && 
   ((bool)messageArgs.firstValue == true))
Here is the API reference: MessageArgs.

MessageArgs contains:
  • (string) message: The message.
  • (string) parameter: The optional parameter that was sent with the message.
  • (object[]) values: An array of objects passed as additional arguments. They can be mixed types (bool, int, etc.).
  • (object) sender: The object that sent this message.
  • (object) target: The object that this message is intended for. May be null if it's a general message for everyone.
There are also aliases "firstValue" and "intValue". These are just aliases for:
  • firstValue = values[0]
  • intValue = (int)values[0]