Setting Up the Cooking Catalog #

In this section, we’ll define the item catalog The various catalogs are where game content such as items, crafting recipes, grants/rewards, or stores is defined. , crafting catalog, and associated type definitions.


Define item types with protobufs #

The structure of instanced Unique items where two copies of the same item can have different qualities. and stackable Identical items where all copies of the same item are fully interchangeable. items are defined in protobuf A format for efficiently serializing structured data that's cross-platform and compatible with several languages. files defined by the engine. Custom protobuf definitions can be added to extension (ext) fields. These are predefined protobuf types that can be modified to extend engine functionality.

Run the following commands in the terminal from the platform directory:

make skip-tests protos engine ext

Edit inventoryContentExt.proto #

  1. Open 5-ext/ext-protos/src/main/proto/shared/inventoryContentExt.proto.
  2. Edit ExtInstancedSpec by inserting the following:
message ExtInstancedSpec {
  oneof data {
    IncompleteFoodSpec incomplete_food_spec = 1;
  }
}
The oneof data is what will later become DataCase. If you name it something like info, your protos will have an InfoCase instead.
  1. Define an IncompleteFoodSpec message below ExtInstancedSpec:
message IncompleteFoodSpec {
}
  1. Edit ExtPurchaseRequirements by inserting the following:
message ExtPurchaseRequirements {
  oneof data {
    CookingCompleteRequirements cooking_complete_requirements = 1;
  }
}
  1. Define a CookingCompleteRequirements message below ExtPurchaseRequirements:
message CookingCompleteRequirements {
  string consumed_catalog_id = 1;
}
  1. Edit ExtCraftingEntry by inserting the following:
message ExtCraftingEntry {
  oneof data {
    CookingSpec cooking_spec = 1;
    CookingCompleteSpec cooking_complete_spec = 2;
  }
}
  1. Define CookingSpec and CookingCompleteSpec messages below ExtCraftingEntry:
message CookingSpec {
  int64 cook_time_in_seconds = 1;
  string catalog_id_to_create = 2;
}

message CookingCompleteSpec {
  string catalog_id_to_create = 1;
}

Edit inventoryExt.proto: #

  1. Open 5-ext/ext-protos/src/main/proto/shared/inventoryExt.proto.
  2. Edit ExtInstancedItem by inserting the following:
message ExtInstancedItem  {
  oneof data {
    IncompleteFood incomplete_food = 2;
  }
}
  1. Create an IncompleteFood message below ExtInstancedItem:
message IncompleteFood {
  int64 timestamp_millis = 1;
}

Edit inventoryRpcExt.proto: #

  1. Open 5-ext/ext-protos/src/main/proto/shared/inventoryRpcExt.proto.
  2. Import the following files by adding the following code near the top of the file, next to the existing import(s):
import "shared/inventoryExt.proto";
  1. Edit ExtInstancedItemServerGrant by inserting the following:
message ExtInstancedItemServerGrant {
  oneof data {
    ext.IncompleteFood incomplete_food = 1;
  }
}

Build protos #

Run make ext using a terminal from the platform directory.

Define the item catalog #

If you haven’t yet initialized your 5-ext content, you’ll need to run the following command to create the content JSON files.

Run make init-inventory-content using a terminal from the platform directory.

The ItemCatalog defines shared identifiers and configurations for all game content managed by the platform. This is where designers create player inventory specifications. This section will cover creating instanced and stackable item specs, along with the crafting catalog.

Define instanced specs #

Cooking is a two step process. The first step is exchanging flour, milk, and eggs for an incompletePlainMuffin. This is an instanced item, as the incompletePlainMuffin has a time stamp stored in the ext field.

Add to the contents of platform/5-ext/content/src/InstancedSpecs.json with the following code:

[
  {
    "catalogId": "incompletePlainMuffin",
    "name": "incompletePlainMuffin",
    "tags": ["cooking_token"],
    "ext": {
      "incompleteFoodSpec": {
      }
    }
  }
]

Define stackable item specs #

Stackables are simple items that don’t have custom per-item data. Cooking ingredients and the completed muffin are implemented as stackable items.

Add to the contents of platform/5-ext/content/src/StackableSpecs.json with the following code:

[
  {
    "catalogId": "flour",
    "name": "flour",
    "limit": 10000,
    "tags": ["material", "cooking"]
  },
  {
    "catalogId": "milk",
    "name": "milk",
    "limit": 10000,
    "tags": ["material", "cooking"]
  },
  {
    "catalogId": "eggs",
    "name": "eggs",
    "limit": 10000,
    "tags": ["material", "cooking"]
  },
  {
    "catalogId": "plainMuffin",
    "name": "plainMuffin",
    "limit": 1000,
    "tags": ["food"]
  }
]

Define the crafting catalog #

The crafting catalog is where all crafting recipes are defined. We have defined each step of the cooking process as individual entries in the crafting catalog.

Add to the contents of platform/5-ext/content/src/5-ext/content/shared/CraftingEntries.json with the following code:

[
  {
    "id": "plainMuffinRecipe",
    "stackableCostByCatalogId": {
      "flour": {
        "cost": 10
      },
      "milk": {
        "cost": 1
      },
      "eggs": {
        "cost": 1
      }
    },
    "ext": {
      "cookingSpec": {
        "cookTimeInSeconds": 3,
        "catalogIdToCreate": "incompletePlainMuffin"
      }
    }
  },
  {
    "id": "completePlainMuffinId",
    "ext": {
      "cookingCompleteSpec": {
         "catalogIdToCreate": "plainMuffin"
      }
    },
    "requirements": {
      "ext": {
        "cookingCompleteRequirements": {
          "consumedCatalogId": "incompletePlainMuffin"
        }
      }
    }
  }
]

Apply content data #

In order to register the content you just defined with Pragma Engine, you must apply your content data changes. You may apply content data either using the command line with make or via an IntelliJ run configuration.

Applying content data using Make

In a terminal with platform as the working directory, run:

make ext-contentdata-apply
Applying content data using IntelliJ
From the IntelliJ toolbar in the upper right, ensure contentdata apply is selected, then click the play button.