Difference between revisions of "Mission Task Events"

From Bit Phoenix Software
Jump to navigation Jump to search
(Created page with "In The Peacenet, the mission system allows ''mission tasks'' to receive signals from the game when various events occur in-game. This includes programs opening or closing...")
 
Line 1: Line 1:
In [[The Peacenet]], the mission system allows ''mission tasks'' to receive signals from the game when various events occur in-game.  This includes programs opening or closing, systems being hacked, files being written, and more.
+
[[The Peacenet]]'s mission system can be signaled by the rest of the game when the player performs certain actions.  This signals are called '''Mission Task Events''' and are the basis for many of the supported [[Mission Tasks]] in the game.  If you want to write your own [[Mission Tasks]] or send your own signals to the mission system, it is helpful to know how these work.
  
This article documents this mission task event system and how it works.
+
== Anatomy ==
  
== Event structure ==
+
A '''Mission Task Event''' is simply a signal that flows into the mission system, with a name and arguments.  Everything is a glorified string.  The arguments come in the form of key-value-pairs.
  
Events come into the mission system with a '''name''' and an '''event argument map'''. The '''name''' is a simple <code>FString</code> (<code>String</code> in Blueprint), and the argument map is a <code>TMap<FString, FString></code> (<code>Map of Strings to Strings</code> in Blueprint).  This allows the event system to receive completely arbitrary signals from the game without needing to care
+
The event name is used to signal to the mission what event occurred, while the arguments are used to supply extra data along with the event for context.
  
* where they came from
+
For example, an event signalling a Terminal Command running may come in with the name <code>CommandComplete</code> and the arguments
* what gameplay mechanic they belong to
 
& what they are
 
  
before your specific '''Mission Task''' gets ahold of the signal.
+
Command: cat
 +
Arguments: /etc/hostname
  
== Sending a signal ==
+
signifying that the player ran the command <code>cat /etc/hostname</code>.
  
If you'd like to send a signal to the mission system, you will need a pointer to the [[Peacenet World State Actor]].  This can be retrieved using the <code>GetPeacenet()</code> methods of a [[User Context]], [[System Context]], [[Window Object]], [[Program Object]], [[Terminal Command Object]], or any other object that is attached to the Peacenet world.
+
== Pipeline ==
  
With this pointer, simply call <code>SendGameEvent("Event Name", { { "Argument 1", "Value 1" }, { "Argument 2", "Value 2" } })</code>.  The game will automatically dispatch the event for you if a mission is in progress.  Calls to this function will be ignored when the player is in '''free roam'''.
+
Mission task events can be pushed out from anywhere in the game where one has access to a <code>Peacenet World State Actor</code>.  In '''Blueprint''', this can be done by using the '''Get Peacenet''' nodes on a '''User Context''' or '''System Context'''.
  
== Receiving a signal ==
+
The event is pushed to the '''World State Actor''', which first determines if the player is in a mission at the moment.  If so, the '''Mission State Actor''' receives the event, which then forwards it to the currently running '''Mission Task''' through an overrideable function.
  
Inside a '''Mission Task Object''', you can receive a signal from the game in both C++ and Blueprint.
+
== Common events ==
  
=== C++ ===
+
Below are some details about some common events sent by the game.
  
In your header file, add:
+
=== <code>CommandComplete</code> ===
  
protected:
+
Occurs when a Terminal command is finished running.
    virtual void NativeEvent(FString EventName, TMap<FString, FString> InEventArgs) override;
 
  
to override the event handling function of '''MissionTask'''.
+
==== Arguments ====
  
In the source file, add:
+
Command: <name of command>
 +
Arguments: <command-line arguments>
 +
 +
'''Note''': Commands may send extra data along with the event, but this isn't guaranteed.  This data is that of the command's '''Docopt Argument Map'''.  So in the case of <code>cd</code>, the event arguments may look like this:
  
  void UMyMissionTask::NativeEvent(FString EventName, TMap<FString, FString> InEventArgs)
+
  Command: cd
  {
+
  Arguments: /etc
    // foo
+
  <path>: /etc
  }
 
  
to handle the eventYou can check the event name and arguments against this page's reference of common events.
+
This is because the <code>cd</code> command uses '''Docopt''' for argument parsing, and thus has an internal map of keys to valuesThis map is sent along with the command event for your convenience, but not all commands will do this.
 
 
== Common events ==
 
  
None yet.
 
  
 
[[Category:Peacenet]]
 
[[Category:Peacenet]]
 
[[Category:Peacenet Developer Reference]]
 
[[Category:Peacenet Developer Reference]]

Revision as of 20:25, 6 April 2019

The Peacenet's mission system can be signaled by the rest of the game when the player performs certain actions. This signals are called Mission Task Events and are the basis for many of the supported Mission Tasks in the game. If you want to write your own Mission Tasks or send your own signals to the mission system, it is helpful to know how these work.

Anatomy

A Mission Task Event is simply a signal that flows into the mission system, with a name and arguments. Everything is a glorified string. The arguments come in the form of key-value-pairs.

The event name is used to signal to the mission what event occurred, while the arguments are used to supply extra data along with the event for context.

For example, an event signalling a Terminal Command running may come in with the name CommandComplete and the arguments

Command: cat
Arguments: /etc/hostname

signifying that the player ran the command cat /etc/hostname.

Pipeline

Mission task events can be pushed out from anywhere in the game where one has access to a Peacenet World State Actor. In Blueprint, this can be done by using the Get Peacenet nodes on a User Context or System Context.

The event is pushed to the World State Actor, which first determines if the player is in a mission at the moment. If so, the Mission State Actor receives the event, which then forwards it to the currently running Mission Task through an overrideable function.

Common events

Below are some details about some common events sent by the game.

CommandComplete

Occurs when a Terminal command is finished running.

Arguments

Command: <name of command>
Arguments: <command-line arguments>

Note: Commands may send extra data along with the event, but this isn't guaranteed. This data is that of the command's Docopt Argument Map. So in the case of cd, the event arguments may look like this:

Command: cd
Arguments: /etc
<path>: /etc

This is because the cd command uses Docopt for argument parsing, and thus has an internal map of keys to values. This map is sent along with the command event for your convenience, but not all commands will do this.