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.
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
import { ACTION_GROUP_BUNDLE, CivilizationBuilder, Mod, UnitBuilder} from "civ7-modding-tools";const mod = new Mod({ id: 'binding-example-mod', version: '1.0',});// Create a civilizationconst dacia = new CivilizationBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, civilization: { type: 'CIVILIZATION_DACIA', name: 'Dacia', // Other properties... }});// Create a unique unitconst falxWarrior = new UnitBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, unit: { unitType: 'UNIT_FALX_WARRIOR', name: 'Falx Warrior', // Other properties... }});// Bind the unit to the civilizationdacia.bind([falxWarrior]);// Add to modmod.add([dacia, falxWarrior]);// Build the modmod.build('./dist');
You can bind multiple entities in a single operation:
// Create multiple entitiesconst dacia = new CivilizationBuilder({...});const falxWarrior = new UnitBuilder({...});const dacianFortress = new BuildingBuilder({...});const dacianWarfare = new ModifierBuilder({...});// Bind all entities to the civilization in one calldacia.bind([falxWarrior, dacianFortress, dacianWarfare]);// Now all entities are properly associated with the Dacia civilization
You can create chains of bindings for more complex relationships:
// Create entitiesconst dacia = new CivilizationBuilder({...});const falxWarrior = new UnitBuilder({...});const combatBonus = new ModifierBuilder({...});// Bind the combat bonus to the unitfalxWarrior.bind([combatBonus]);// Bind the unit to the civilizationdacia.bind([falxWarrior]);// The entire chain of relationships is maintained
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.
The key to creating age-specific content is using the appropriate actionGroupBundle when creating elements:
import { ACTION_GROUP_BUNDLE, Mod, UnitBuilder} from "civ7-modding-tools";const mod = new Mod({ id: 'age-specific-mod', version: '1.0',});// Antiquity Age version of a unitconst antiquityWarrior = new UnitBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, unit: { unitType: 'UNIT_WARRIOR', name: 'Warrior', combatStrength: 15, // Other properties specific to Antiquity Age }});// Exploration Age version of the same unitconst explorationWarrior = new UnitBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_EXPLORATION, unit: { unitType: 'UNIT_WARRIOR', name: 'Warrior', combatStrength: 25, // Updated properties for Exploration Age }});// Modern Age version of the same unitconst modernWarrior = new UnitBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_MODERN, unit: { unitType: 'UNIT_WARRIOR', name: 'Warrior', combatStrength: 35, // Updated properties for Modern Age }});// Add all versions to the modmod.add([antiquityWarrior, explorationWarrior, modernWarrior]);
// Use your custom builderconst customReligion = new ReligionBuilder({ actionGroupBundle: ACTION_GROUP_BUNDLE.AGE_ANTIQUITY, religion: { type: 'RELIGION_CUSTOM', name: 'Custom Religion', // Other properties... }});// Add to modmod.add([customReligion]);
// Instead of importing everything at onceimport { createAllDacianUnits } from "./src/units/all-units";// Lazy load specific units as neededconst getSpecificUnit = () => { return import("./src/units/specific-unit") .then(module => module.createSpecificUnit());};
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.