Skip to content

Forager Worker Unit

HaroldHS edited this page Sep 12, 2022 · 3 revisions

Foragers are a worker unit that is responsible for taking wood attributes from a resource.

How to create a Forager

Foragers are created by ForagerFactory.java which uses WorkerFactory.java to create the worker. So, Foragers have components from WorkerFactory as well. Here is how to create a Forager entity:

Entity newForager = ForagerFactory.createForager();

How Foragers Collect Wood from Resource Entities

Foragers have a component called WorkerInventoryComponent which stores all resource types such as stone, metal, and wood that have been collected by the forager. The resource entity itself has a component called ResourceStatsComponent which is the number of each resource types it possesses. The process of adding the amount of stone/metal/wood in Miner's inventory and reducing the amount of stone/metal/wood in a resource is mainly implemented in ResourceCollectComponent.

How Forager flee from enemies by retreating to base

Forager has the same retreat mechanism like Miner Worker Unit.

Unit Tests Written for Foragers

The unit tests for foragers tests each of the components it possesses when its instantiated in ForagerFactory. There are 3 unit tests performed for the Forager:

  • shouldDetectForagerComponents() : Check whether ForagerComponent could be added to Forager. ForagerComponent is used by ResourceCollectComponent to perform verification for calling collectStone() and collectMetal.
  • shouldDetectCollectStatsComponent : Check whether CollectStatsComponent is working properly.
  • shouldCollectAndUnloadResources() : Check whether the Forager unit can functionally obtain wood from a tree and load it to the base.

Table of Contents

Home

Game

Game Home

Design Influences

Gameplay Features

Style

Story

Friendly Units
Map
City
Buildings
Unit Selections

Spell

Game User Testing: Theme of Unit Selection & Spell System

UI User Testing

Tutorial

Resource Stats Display

Loading Screen Bar

Health Bars
In Game menu
  • Feature
  • User Testing:In Game Menu

Landscape Tile Design

Landscape Tile Design Feedback

Weather Design

Weather Design Feedback

Camera Movement

Enemy design

Enemy Units

Enemy AI

How Animation Works

Map Flooding

Game Engine

Getting Started

Entities and Components

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Troubleshooting

MacOS Setup Guide

Clone this wiki locally