Skip to content

Deleting Items (CookingAndServingHandler)

Princess-Nx edited this page Aug 28, 2024 · 7 revisions

Description

The CookingAndServingHandler class is a component responsible for managing the cooking and serving logic of ingredients within the game. It handles the state transitions of ingredients as they are cooked, updates their visual representation, and manages the serving and disposal of meals. The class operates within an entity-component-system (ECS) architecture, where it interacts with other components such as IngredientComponent and TextureRenderComponent.

Core Mechanics

  1. Cooking management: Starts and stops the cooking process, updating the state of the ingredient based on the elapsed time.
  2. Texture management: Updates visual representation of the ingredient based on its state.
  3. Serving and Disposal: Manages the serving of the meal and its disposal once served.

Key Methods:

  • create(): Initializes the handler by retrieving the 'IngredientComponent' and 'TextureRenderComponent' from the entity. It updates the texture based on the initial state of the ingredient.

Screenshot 2024-08-29 001840

  • updateTexture(): Updates the texture of the ingredient based on its state and name. Uses a switch statement to determine the correct texture path based on the ingredient's name. Adjusts the texture path depending on the item’s cooking state (raw, cooked, or burnt). Sets the updated texture on the 'TextureRenderComponent'.

  • serveMeal(): Serves the meal if the ingredient is cooked. It sets the 'isServed' flag to true and prints a message indicating that the meal has been served.

Screenshot 2024-08-29 005851

  • deleteMeal(): Disposes of the meal entity if it has been served. It removes the entity from the game and prints a message indicating that the meal has been removed.

Screenshot 2024-08-29 005855

  • updateState(): Updates the state of the ingredient based on elapsed cooking time. Checks if the cooking duration has passed and updates the ingredient's state to "cooked" or "burnt" as appropriate. Calls updateTexture() to update the visual representation of the ingredient. Stops cooking if the item has burnt.

Screenshot 2024-08-29 013218 Screenshot 2024-08-29 013223

Example:

Scenario: Cooking a Fish

Initialization: A CookingAndServingHandler is created with a GameTime instance and attached to a fish entity that has IngredientComponent and TextureRenderComponent.

Start Cooking: Call startCooking(). If the fish is raw, the cooking process begins and the texture is updated to reflect cooking status.

Update State: As time progresses, updateState() is called to check if the fish should be cooked or burnt.

Serve Meal: Once cooked, call serveMeal() to mark the fish as served.

Dispose: After serving, call deleteMeal() to remove the fish entity from the game.

Dependencies

IngredientComponent: Must be present on the entity to provide information about the ingredient's state and cooking time. TextureRenderComponent: Must be present on the entity to update the visual representation of the ingredient. GameTime: Provides the current time for managing cooking durations.

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