Skip to content

Commit

Permalink
Merge pull request #74 from inworld-ai/mwMap
Browse files Browse the repository at this point in the history
Fixed bug with GetTask in InworldMessenger
  • Loading branch information
mattkwilson authored Sep 4, 2024
2 parents 7433b4e + cc65b3d commit 323c94b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Runtime/Scripts/Character/InworldCharacter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ protected virtual bool HandleText(TextPacket packet)
}
protected virtual void HandleTask(CustomPacket taskPacket)
{
if (!InworldMessenger.GetTask(taskPacket.custom.name, out string taskName)) return;
if (!InworldMessenger.GetTask(taskPacket, out string taskName)) return;

if (m_VerboseLog)
{
Expand Down
15 changes: 10 additions & 5 deletions Runtime/Scripts/Util/InworldMessenger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ static InworldMessenger()
}
public static string NextTurn => k_ConversationNextTurn;
public static int GoalCompleteHead => k_GoalComplete.Length + 1; // YAN: With a dot in the end.
public static bool GetTask(string triggerName, out string taskName)
{
taskName = null;
if (!string.IsNullOrEmpty(triggerName) && triggerName.StartsWith(k_Task))
taskName = triggerName.Remove(0, k_Task.Length);
public static bool GetTask(CustomPacket taskPacket, out string taskName)
{
taskName = null;
if (taskPacket.custom.type != CustomEvent.Type.TASK)
return false;

string triggerName = taskPacket.custom.name;

if (!string.IsNullOrEmpty(triggerName) && triggerName.StartsWith($"{k_Task}."))
taskName = triggerName.Replace($"{k_Task}.", "");

return !string.IsNullOrEmpty(triggerName);
}
Expand Down

0 comments on commit 323c94b

Please sign in to comment.