Skip to main content
This guide covers advanced techniques for creating sophisticated mods using the Civilization VII TypeScript Modding Tools. One of the most powerful features of the TypeScript Modding Tools is the ability to bind related entities together, simplifying the creation of cohesive mod components that work together seamlessly.

Understanding Entity Binding

Binding allows you to create relationships between different game elements without manually managing references. For example, when binding a unit to a civilization:
  • The unit is automatically associated with the civilization
  • The civilization automatically gains access to the unit
  • Cross-references are maintained correctly in the generated XML

Basic Binding Example

Binding Multiple Entities

You can bind multiple entities in a single operation:

Chain Binding

You can create chains of bindings for more complex relationships:

Age-Specific Content

Civilization VII’s Age system allows for different versions of game elements across different time periods. The TypeScript Modding Tools provide robust support for creating age-specific content.

Creating Age-Specific Elements

The key to creating age-specific content is using the appropriate actionGroupBundle when creating elements:

Managing Age Transitions

To properly manage age transitions, you need to ensure that:
  1. Each age version uses the same type identifier
  2. Each version is assigned to the correct age using actionGroupBundle
  3. Changes between ages are balanced and appropriate

Age-Specific Civilizations

You can create civilizations that change their abilities across different ages:

Working with Multiple Files

For larger mods, organizing your code across multiple files improves maintainability and allows for better collaboration.

Project Structure Example

A typical organized mod project might have this structure:

Component Files

Each component can be defined in its own file: src/civilizations/dacia.ts:
src/units/falx-warrior.ts:

Main Build File

The main build file imports and combines all components: build.ts:

Benefits of Multi-File Organization

This approach offers several advantages:
  1. Modularity: Each component is self-contained and can be developed independently
  2. Reusability: Components can be easily reused across different mods
  3. Maintenance: Easier to find and fix issues in smaller files
  4. Collaboration: Different team members can work on different files without conflicts
  5. Testing: Individual components can be tested in isolation

Manually Configuring Nodes

For maximum control, you can directly work with XML nodes instead of using the higher-level builders.

Working with Low-Level Node API

The low-level node API gives you direct access to the XML structure:

When to Use the Low-Level API

Consider using the low-level node API in these situations:
  1. When you need to create structures not supported by the builders
  2. When you’re implementing experimental features
  3. When working with custom database tables
  4. When you need precise control over the XML structure

Custom Database Modifications

You can directly modify database structures:

Creating Custom Builders

For truly advanced mods, you can extend the built-in tools by creating custom builders.

Creating a Custom Builder Class

Using a Custom Builder

Performance Optimization

When creating large mods, consider these performance optimization techniques:

Lazy Loading

Load components only when needed:

Reusing Components

Reuse components when appropriate:

Conclusion

Advanced techniques in the Civilization VII TypeScript Modding Tools allow you to create sophisticated mods with complex interactions between game elements. By mastering entity binding, age-specific content, multi-file organization, and low-level node configuration, you can create mods that are both powerful and maintainable. Remember that these advanced techniques build upon the foundation covered in the other how-to guides. As you become more comfortable with the tools, you’ll be able to create increasingly complex and impressive mods for Civilization VII.