global::CreatureTemplate describes a species to world simulation and pathing code. It holds terrain costs, connection costs, AI requirements, abstract movement settings, save behavior, and relationships. The template does not construct the creature’s body, graphics, state, or realized AI.

The constructor receives a global::CreatureTemplate.Type, an optional ancestor, tile and connection resistance lists, and a default relationship. An ancestor can supply a useful starting profile. Any copied value still needs to match the new creature’s body and movement code.

Fields consumed outside the template

Template memberConsumer and effect
AIglobal::AbstractCreature creates abstract AI, and realization later expects compatible realized AI
requireAImapglobal::AbstractCreature.RequiresAIMapToEnterRoom() can reject rooms without an AI map
doPreBakedPathingPreBakedPathingIndex exposes a template index for prepared path data
preBakedPathingAncestorAllows prepared path data to follow an ancestor selected by the template
canAutoAbstractPathParticipates in decisions about movement while the creature is unrealized
saveCreatureMarks whether the creature belongs in cycle save data
hibernateOffScreenChanges how an unrealized creature behaves around hibernation

global::CreatureTemplate.ConnectionResistance(global::MovementConnection.MovementType) and AccessibilityResistance(global::AItile.Accessibility) return global::PathCost values. A cost includes both expense and legality. A low expense makes an allowed option cheaper. It does not turn a forbidden movement into an allowed one.

How room navigation uses the template

Pathing combines template data with navigation data prepared for the current room:

flowchart TD
    A[Template costs] --> B[Room AI map]
    B --> C[PathFinder]
    C --> D[Route cost]
    D --> E[Movement code]

global::AImap.IsConnectionAllowedForCreature(global::MovementConnection,global::CreatureTemplate) checks a movement connection against the creature type. Accessibility mapping also tests the template’s connection legality. global::PathFinder.CoordinateCost(global::WorldCoordinate) resolves accessibility through the template.

global::PathFinder.SetUpWorld() builds cells for world nodes and links for routes such as side exits, sky access, sea access, and region transportation. Its constructor starts from the destination stored by the creature’s abstract AI. NewRoom, Reset, SetDestination, and RestartPathFinding then maintain route state as rooms and goals change.

This arrangement puts two limits on template edits. An allowed connection still needs corresponding room data. A room without the required AI map remains unavailable when requireAImap is set. The realized movement code must also be able to execute every connection that pathfinding selects.

Before using a movement profile in a room, check:

  1. The room has an AI map when the template requires one.
  2. The body fits the permitted tiles, shortcuts, and entrances.
  3. Each allowed MovementType has realized movement code.
  4. Between-room links agree with the creature’s abstract movement.
  5. Prebaked path settings point to suitable data or a suitable ancestor.

Registration is a separate operation

global::StaticWorld.InitStaticWorld() builds the template collection and establishes built-in relationships. global::StaticWorld.GetCreatureTemplate(global::CreatureTemplate.Type) indexes StaticWorld.creatureTemplates using the ExtEnum type index. A new type needs a template at that index before a world or save parser asks for it. Relationships must be established after all referenced types exist.

global::StaticWorld.InitCustomTemplates() is called during static world setup and provides a template insertion point. Template registration alone leaves the vanilla creation chains unchanged. global::AbstractCreature.Realize() and InitiateAI() dispatch by creature type, so a direct custom creature also needs creation paths for its realized body and realized AI. Fisobs creatures documents an optional library layer that hooks these points. Creature AI lifecycle follows the resulting abstract and realized creature states.

Sources

  • global::CreatureTemplate..ctor, PreBakedPathingIndex, ConnectionResistance(global::MovementConnection.MovementType), and AccessibilityResistance(global::AItile.Accessibility) in Assembly-CSharp.dll, SHA-256 B6BE1D4E18CE219D21091B51564CB6A11C1E4106B41DE903EB8E58849CB16FDB.
  • global::StaticWorld.InitStaticWorld(), global::StaticWorld.GetCreatureTemplate(global::CreatureTemplate.Type), global::AImap.IsConnectionAllowedForCreature(global::MovementConnection,global::CreatureTemplate), and global::PathFinder in the same assembly. See Runtime reference.