Skip to content

Human Wander Task

Ahmad Abu-Aysha edited this page Sep 11, 2023 · 6 revisions

Introduction

The HumanWanderTask is the primary logic added to the human entity AITaskComponent in the EngineerFactory. It manages the behaviour of the engineer entity, and includes the HumanWaitTask, HumanMovementTask and EngineerCombatTask subtasks. All engineer movement, detection of mobs, attacking, taking damage, and death are managed through this task or its subtasks.

The death of engineer entities is linked to game loss state. When the task logic detects that the entity has died, it updates the GameEndService.

Usage

Instantiation of the HumanWanderTask requires two arguments, float waitTime which determines the wait delay, and float maxRange which sets the detection and attacking range of engineer entities. For example, after defining an engineer entity and adding an AITaskComponent: (Example from EngineerFactory)

Entity engineer = createBaseHumanNPC();
AITaskComponent aiComponent = new AITaskComponent();

engineer.addComponent(aiComponent);

engineer.getComponent(AITaskComponent.class).addTask(new HumanWanderTask(COMBAT_TASK_PRIORITY, ENGINEER_RANGE));

Sequence Diagram

The following sequence diagram shows an example lifecycle of HumanWanderTask and its subtasks

HumanWanderTaskSequenceDiagram

UML Diagram

The following UML Diagram shows the Class structure of HumanWanderTask and its subtasks.

EngineerFactoryUML

Clone this wiki locally