Skip to content

Adding_Orders

Jack Brett edited this page Jun 14, 2024 · 3 revisions

Orders (that exist on Nodes) are the fundamental functionality of games created in LUTE and can be seen as the main functions that drive behaviours in your experience. Quite often, you may wish to create new behaviours or modify exisiting ones - this can be done so rather easily with the way Orders have been defined.

Creating a New Order

You can either create new class to implement a new Order or you can use the built-in Asset creation menu to create a new Order:

createOrderMenu

Upon creating a new Order, you can enter a category, name and description for this Order. Upon creating, the new class file is placed in the 'User Created' sub folder contained within the Orders folder.

newOrder

Upon opening up this new Order, your file will look similar to this (minus some possible comments for ease of use):

using UnityEngine;

[OrderInfo("Other",
              "Example Order",
              "A simple example of an order.")]
[AddComponentMenu("")]
public class ExampleOrder : Order
{
    public override void OnEnter()
    {
        Debug.Log("Example Order OnEnter");
        Continue();
    }

    public override string GetSummary()
    {
        return "Example Order";
    }

    public override Color GetButtonColour()
    {
        return base.GetButtonColour();
    }

    public override bool HasReference(Variable variable)
    {
        return base.HasReference(variable);
    }

    public override LocationVariable ReferencesLocation()
    {
        return base.ReferencesLocation();
    }
}
  • OrderInfo This attribute adds the Order to the AddOrder drop down list in Node Inspector Editor. The first param defines its Category, the second the name it will show up as, and the third its tooltip in the AddOrder menu.

  • AddComponentMenu This is a unity attribute, which when given an empty string prevents the class from showing up in the AddComponent menu on regular gameobjects.

  • Inheriting from Orders keep a list of methods to execute, and this base class defines what orders can do and when they will be called. See the Order.cs parent class for more details.

Common Methods

  • OnEnter is called by the order when the order is asked to start running. Most orders compete their task within the OnEnter and have seperate classes/objects for specific behaviours.

  • The Continue method is called to notify the calling Node that this Order has completed its task and the Order should continue to the next Order in the list.

  • The GetSummary method is used to display a summary of the Order on the Node/Order Inspector - oftentimes this is similar to the description but you may wish to provide additional details on how to use the specific Order.

  • GetButtonColour Returns a colour to set as the tint of the order in the order list on a given node.

  • HasReference - If your order uses any Variables then returning the comparison against all of them, as above, allows variable references to be tinted in the variable list to show usage.

  • ReferencesLocation can be used to inform other classes and methods that this specific order requires a reference to a location - useful for specific condition checks.

Data

As mentioned in Coding_Standard it is suggested to use protected parameters which are serialised to allow for accesibility across multiple files. Additionally, tooltips are recommended to help others understand what specific parameters are used for. For example:

[Tooltip("This is a tooltip of an example integer to be used in this order.")]
[SerializeField] protected int exampleInt;

Duplicating an Exisiting Order

Some Orders are useful as they are rather generic but you may wish to customise them further or edit them to be used with a specific prefab. You can easily duplicate an Order by:

  1. Right-Clicking on an Order
  2. Select LUTE>Orders>Copy Order

Upon duplication, the same Order file is copied into the 'User Created' folder where you can then modify the class to fit your needs. We suggest using a duplicated Order if you wish to customise an existing order you have found when desiging your experience. Any changes to exisiting orders will be done so at the risk of the developer and could potentially be overwritten when importing newly released packages.

Clone this wiki locally