Add a custom Action
¶
Refer to the ExamineAction.ts
in the backend for an example.
- Create a class with the name
[Name]Action
, for exampleSmellAction
. - Extend the class from
Action
. -
Implement the required abstract functions. All actions need:
- A public static readonly
Alias
attribute with an unique alias. - This alias has to be provided through an empty constructor.
- A
name
function to return the name of the action.
- A public static readonly
-
Create an interface* with the name
[Name]
, for exampleSmell
. - Add one or more abstract functions to the interface to describe the action. Make sure the return type is always
ActionResult | undefined
. - Register the action in the constructor of the
GameService
usingthis.registerAction
, for examplethis.registerAction(SmellAction)
.
* Interface in TypeScript: export abstract class
with @Interface
decorator.