Skip to content

Buildings Functionality

hugh5 edited this page Sep 10, 2022 · 7 revisions

What is a Building?

Building Entity

Buildings are spawned as an Entity() using the BuildingFactory that creates a new entity and adds necessary components to it. See Entity Component System for how this component system works.

Why use a factory? The game engine already uses the Abstract Factory Pattern, a great way of creating similar objects without specifying a concrete class, so it made sense to conform. he

Spawning and Adding Components in the BuildingFactory

  1. A base building is created first by calling createBaseBuilding() which returns an entity with a PhysicsComponent and ColliderCompenet.

This is where to put non unique components (components that every building will possess)

  1. The specific components are then added for that specific building

e.g. the TextureRenderComponent which requires the path of the image asset to be constructed which differs for different buildings

  1. Some of these components are also configured using a configuration file

e.g. townHall.addComponent(new CombatStatsComponent(config.health, config.baseAttack));

Building configs

The rationale for using configs - Configuring Entities

The current Config Classes extend from the BaseEntityConfig and adds support for a building level up system.
Visualisation of the BuildingFactory using BuildingConfigs in a class diagram: Config

The Building factory loads the configs and uses the fields in them to create and add components to the newly created building entity.
private static final BuildingConfigs configs = FileLoader.readClass(BuildingConfigs.class, "configs/buildings.json");

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