Skip to content

Buildings Functionality

hugh5 edited this page Aug 28, 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.

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

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

public class BaseEntityConfig {
    public int health = 1;
    public int baseAttack = 0;
}
public class TownHallConfig extends BaseEntityConfig {
    public int level = 1;
}
public class BarracksConfig extends BaseEntityConfig{
    public int level = 1;
}

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