Skip to content

Spawn Recipe Commands

Zachary Adams edited this page Oct 3, 2024 · 2 revisions

Overview

SpawnRecipeCommands is a class package responsible for spawning recipes into the players inventory in the game. This command is useful for developers or players during debugging or testing to quickly generate specific meals using predefined ingredients. The class allows users to specify a recipe and spawn it directly into the players inventory, replacing any exisiting item if necessary.

Usage

The SpawnRecipeCommands class is designed to handle the spawn command, which accecpts a single argument representing the name of a recipe in the format as follows;

  • "bananasplit"
  • "steakmeal"
  • "acaibowl"
  • "salad"
  • "fruitsalad" When executed, the command spawns the corresponding meal, populating it with the necessary ingredients and adding it to the players inventory.

Command Syntax

Upon the user pressing f1, the ingame terminal will appear in the bottom left of the screen, as signified by the > character. The user then types in the spawn keyword, follwed by an accepted recipe string as stated above. This will be in the form;

  • spawn <recipeName>

Error Handling

If the provided argument is invalid or unrecognised, the command will return false and log a debug message indicating the issue.

Creation

Method: action(ArrayList<String> args)

This method processes the 'spawn' command by validating the input determining which recipe to create based on the argument. It handles interactions with the players inventory to ensure that items are added or replaced correctly.

Setup

Before creating any recipes, the player entity and their inventory component must be retrieved;

Entity player = ServiceLocator.getPlayerService().getPlayer();
InventoryComponent playerInventory = player.getComponent(InventoryComponent.class);

Recipe Creation Process

In order to populate a recipe, the required ingredients must be created. Using banana split as an example;

Entity strawberry = ItemFactory.createBaseItem("strawberry");
Entity chocolate = ItemFactory.createBaseItem("chocolate");
Entity banana = ItemFactory.createBaseItem("banana");

As the creation of a recipe requires an array list, the ingredients of the recipe must be added to this;

ArrayList<IngredientComponent> bananaSplitIngredients = new ArrayList<>();
bananaSplitIngredients.add(strawberry.getComponent(IngredientComponent.class));
bananaSplitIngredients.add(chocolate.getComponent(IngredientComponent.class));
bananaSplitIngredients.add(banana.getComponent(IngredientComponent.class));

Then the recipe can be created using this array, and added to the players inventory as follows;

Entity bananaSplitEntity = ItemFactory.createMeal("bananaSplit", bananaSplitIngredients);
ItemComponent bananaSplitItem = bananaSplitEntity.getComponent(MealComponent.class);
playerInventory.addItem(bananaSplitItem);

Table of Contents

Home

Team Design Document

Game Features

Inventory System
Scoring System
Food Recipes
Level System
Player Actions
Ordering System
Stations
Items
Map Design
Customers
Pause Menu
Upgrades
End of Day Display
Day Night Cycle
Moral System
Debug Terminal
Game Interactions Tutorial
Backstory Cutscenes

Game

Getting Started

Entities and Components

World Backstory

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Map Design

Test Plans

Sensor Component

Customer Sensor Component

Interaction Component

Inventory Component

Inventory Display

Station Meal Component

Station Progress Display

Keyboard Input Component

Fire Extinguisher Handler Component

Score System

HoverBox Component

MainGameActions Create Docket Triggers

End Day Display Component

Cutscene Area

Docket

Docket Line Display

Docket Meal Display

Main Game Order Button Display

Order Actions

Recipe

Ticket Details Component

BackstoryCutscene Test Plan

BackstoryCutsceneDisplay Test Plan

Test Plan for Tutorial

Keybinds

Keybinds Test Plan

Test Plan for MainGameOrderTicketDisplay

Test Plan for MainGameOrderBtnDisplay

Test Plan for Docket

Test Plan for DocketLineDisplay

Test Plan for OrderActions

Ticket Details

Test plan for RandomComboService

Test plan for LoanUpgrade

Test plan for UpgradesDisplay

Test plan for RageUpgrade

Test plan for SpeedBoostUpgrade

Test plan for DancePartyUpgrade

Test plan for ExtortionUpgrade

Troubleshooting

MacOS Setup Guide

Clone this wiki locally