Civil System - IsaacMulcahy/RPG-AI-SYSTEM-WIKI GitHub Wiki

Overview

The Civil System covers the day-to-day life of NPC's and population of civil areas. NPC's that are managed by the Civil System have their own Work Controller that takes input from the Civil Job System to assign Jobs, Houses and Workplaces to each NPC spawned in by the local Civil Manager.

How it works

It works by importing a set of Civil Job System parameters (creation: Flowchart, Setup: Manager) via the Global Civil Manager using the CivilJobData class, this is a static class so only one set of Civil Job parameters can be loaded at a time.

Regions are then used for population of the sections of the world when enabled. The local Civil Manager if enabled will then find Houses and Workplaces within it's section and figure out the max population and spawn in that amount of NPC's.

How to setup

To setup the Civil System the world needs a Region added in with at least one Workplace and House (See Manager to import templates to your scene).

Objects

Houses

The house component is used to provide a home to an NPC, the maxResidents can be set in the editor view but the default is five. Entrance can be set up having a child GameObject called ‘entrance’ or manually typed in.

Rooms

The room system is designed to tie into the ownership system, if an item is within the collider for the bedroom of the NPC which is assigned then the items are considered personal items of the NPC

Workplaces

These places provide work for NPC's. Their Entrances work in the same way as House Entrances and are the first place the NPC will attempt to get to when work begins. Job Data is an array of JobData, each entity of the JobData has a job type(name of job in the flowchart), how many people can do this job for this workplace and how many people are doing the job. Assets are specific to the workplace and can be used when performing actions.

Workers are the NPC's who have been assigned to the workplace, this is used for requirements and to help with debugging.

Zones

These are a set size of '25' (can be changed in Actions) from the coordinates provided (can be changed in Actions)

Route

These are set node by node and the order is important.

Regions

These are used to define sections within your scenes for the AI System. These regions will be used to populate the location they are based in and all NPC's will be a child of it's Region. This allows for easy enabling and disabling of sections of your scenes which can increase performance. The region checks for Houses and Workplaces within it's area (defined by size) and uses the 'Civil Mananger' component to handle the spawning and management of the this area. Each Region can also have it's own character pool which allow for different models to be used for the characters.

Items

This is used to define what a Resource is used in finding objects within the world. It uses the enum ITEMS and ITEMS_TYPES as well as a boolean to whether the item is InUse which is used to prevent NPC's from using the same objects. More info can be found on the Item page

CivilJobData

Used to import the data used in the Civil System on load of the scene (called from the Global Civil System), this is a singleton class (Meaning there is only ever one instance of it) which imports the Job System which contains the definitions of the Jobs and is used by the Work Controller