Verse Library verse

01 Snippet

Establishes an abstract base type and extensible subclasses for managing distinct NPC behavioral commands.

extracted-snippets/documentation/fortnite/verse-starter-04-representing-command-data-for-in-unreal-editor-for-fortnite/01-snippet.verse

# Source URL: https://dev.epicgames.com/documentation/fortnite/verse-starter-04-representing-command-data-for-in-unreal-editor-for-fortnite
# Local doc:  epic-docs/documentation/fortnite/verse-starter-04-representing-command-data-for-in-unreal-editor-for-fortnite.md
# This file contains the data representation of all the commands that the NPC can receive
# and utilities for the data to help with debugging and troubleshooting issues.

# Each type of command that the NPC can perform will be an instance of this class.
# The class has the unique specifier to make instances of the class comparable.
# The class has the computes specifier to be able to instantiate it at module-scope.
# The class has the abstract specifier so it cannot be instantiated directly, and
# requires subclasses to implement any non-initialized functions, like DebugString().
command := class<computes><unique><abstract>:
    DebugString():string

# The Commands module contains definitions of commands that the NPC can perform.
# This example uses instances of command subclasses instead of the enum type
# so you can add more commands after the initial published version of the project.
Commands := module:
    # The following are subclasses of the command class
    # that implement the abstract command class and define what commands are valid.
    # Each has their own implementation of DebugString(), for example,
    # so when you print a command value it has the correct string associated with it.
    # Since the command class is abstract, it means these subclasses are the only valid commands,
    # otherwise there will be a compiler error.
    forward_command<public> := class<computes><unique>(command):
        DebugString<override>():string = "Forward"

    turnright_command<public> := class<computes><unique>(command):
        DebugString<override>():string = "TurnRight"

    turnleft_command<public> := class<computes><unique>(command):

Sign in free to read the full source 🌴

This Verse Library file is members-only. Create a free account to view the complete source and download the .verse file.

Sign in with Discord

Comments

    Sign in to vote, comment, or suggest an edit. Sign in