@zerospacegg/iolin
Version:
Pure TypeScript implementation of ZeroSpace game data processing (PKL-free)
226 lines • 8.1 kB
TypeScript
/**
* Entity - Base class for top-level game objects with their own files
* Extends Universal with game-specific properties and path-based ID generation
*/
import type { DomainType, EnergyType } from "./ability.js";
import { Attack, DeathTrigger, Heal, Passive, Siege, Spell, Upgrade, WeaponSwitch } from "./ability.js";
import type { ArmorType, HotKey, Tier } from "./core.js";
import { Turret } from "./turret.js";
import { Universal } from "./universal.js";
/**
* Entity summary interface for search index and lightweight operations
* Moved from meta/search-index.ts to allow sharing between search and entity systems
*/
export interface EntitySummary {
readonly src: string;
readonly id: string;
readonly slug: string;
uuid: string;
readonly type: string;
readonly subtype: string;
readonly name: string;
readonly shortName: string;
readonly faction: string;
readonly tier: string;
readonly hotkey: string;
inGame: boolean;
readonly hasLore: boolean;
readonly tags: string[];
readonly children: string[];
readonly isChildOf: string;
readonly childCollection: string;
readonly childName: string;
}
/**
* Generate type description for an entity or entity summary
* Works with both full Entity instances and lightweight EntitySummary objects
*
* @param entityOrSummary - Either an Entity instance or EntitySummary object
* @returns Formatted type description (e.g., "Grell Co-Op Unit", "Protectorate Hero")
*/
export declare function typeDesc(entityOrSummary: Entity | EntitySummary): string;
/**
* Entity class for top-level game objects that have their own files
* Usage: new Entity("Name", (entity) => { entity.description = "..."; }, import.meta.filename)
*/
export declare abstract class Entity extends Universal {
static src: string;
static get id(): string;
static get slug(): string;
/**
* Permanent unique identifier for change detection and entity tracking.
*
* This UUID is used to detect whether an entity was renamed vs completely replaced:
* - If a unit gets renamed (e.g., "Stinger" → "Scout"), UUID stays the same
* - If a unit gets completely replaced with different functionality, UUID changes
*
* REQUIRED: Every final entity class MUST define this as a static readonly field:
* ```typescript
* class Stinger extends GrellArmyUnit {
* readonly uuid = "234bc62d-ee5e-4033-ab5c-73abd6ae9947";
* // ...
* }
* ```
*
* This is NOT game data - it's metadata for the transformation system.
*/
uuid: string;
name: string;
/**
* Returns the parent entity's UUID if this is a coop variant, undefined otherwise.
* Used for artwork inheritance from PvP to coop variants.
*/
get parentUUID(): string | undefined;
/**
* Sets a variant UUID by appending a suffix to the current UUID.
* Used by coop entities to create composite UUIDs like "parent-uuid:coop-mera".
*
* @param variantSuffix - The suffix to append (e.g., "coop-mera")
*/
protected setVariantUUID(variantSuffix: string): void;
/**
* Required commander level for coop entities (null/undefined for regular entities)
*
* For coop entities, this specifies the minimum commander level required to unlock
* this entity. Regular PvP entities should leave this undefined.
*
* @example
* ```typescript
* // For coop entities, specify minimum commander level
* commanderLevel = 5; // Unlocked at commander level 5
* ```
*/
_idParts?: readonly string[];
_tags: string[];
_lore?: string;
_shortName?: string;
protected _setIdParts(value: readonly string[] | undefined): void;
protected _addTags(...tags: string[]): void;
protected _removeTags(...tags: string[]): void;
protected _removeTagsStartingWith(prefix: string): void;
/**
* Dynamic tag predicates - array of [predicate, tag] pairs for computed tags
*/
protected dynamicTaggers: Array<[
<T extends Entity>(entity: T) => boolean,
string | (<T extends Entity>(entity: T) => string)
]>;
readonly attacks: Record<string, Attack>;
readonly heals: Record<string, Heal>;
readonly spells: Record<string, Spell>;
readonly passives: Record<string, Passive>;
readonly sieges: Record<string, Siege>;
readonly weaponSwitches: Record<string, WeaponSwitch>;
readonly upgrades: Record<string, Upgrade>;
readonly turrets: Record<string, Turret>;
readonly sacrifices: Record<string, Spell>;
readonly onDeath: Record<string, DeathTrigger>;
faction?: string;
factionName?: string;
tier: string;
private _description?;
hexiteCost: number;
fluxCost: number;
buildCount: number;
cooldown?: number;
energyCost?: number;
energyCostType?: EnergyType;
buildTime?: number;
rebuildable: boolean;
rebuildTime: number;
domain: DomainType;
hotkey: HotKey;
timedLife: number;
gathersFlux?: number;
gathersRichFlux?: number;
gathersHexite?: number;
gathersEmptyHexite?: number;
supply?: number;
hp?: number;
vision?: number;
providesDetection?: boolean;
speed?: number;
shields?: number;
abesEnergy?: number;
energy?: number;
startingEnergy?: number;
armor?: number;
armorType: ArmorType;
stunResist?: number;
providesSupply?: number;
providesBiomass?: number;
providesUpgradesFor?: string[];
upgradedBy?: string[];
untargetable: boolean;
carryCapacity?: number;
maxAddOns?: number;
internalId?: string;
internalPath?: string;
internalTags?: string[];
internalSecondaryTags?: string[];
turnSpeed?: number;
pushability?: number;
healthRegen?: number;
inGame: boolean;
fromFuture: boolean;
maxOwned?: number;
creates?: string[];
createdBy?: string[];
unlocks?: string[];
unlockedBy: string[];
unlocksMercTier?: Tier;
/** Short display name - defaults to name */
get shortName(): string;
/** Set short display name */
set shortName(value: string);
constructor(props?: Partial<Entity>);
/** Auto-generated slug from filename or name */
get slug(): string;
/** Auto-generated ID from src path or type/subtype/slug */
get id(): string;
/** Source file path from static src property */
get src(): string;
/** ZeroSpace.gg library path */
get zsggPath(): string;
/**
* Protected getter for manual tags only (to avoid circular dependency)
*/
protected get manualTags(): string[];
/**
* Generate commander level ID for coop entities
* @param level - Commander level number
* @returns Commander level ID string
* @throws Error if entity is not a coop commander entity
*/
protected commanderLevelId(level: number): string;
/**
* Complete tag list combining manual and dynamic tags
*/
get tags(): string[];
/** Pretty formatted type description for display */
get typeDesc(): string;
/** Get all child entity IDs for ecosystem linking */
get children(): Record<string, [string, string]>;
/** Apply turret transformations and return new instance - chainable! */
withTurrets(): any;
/** Apply upgrade transformations and return new instance - chainable! */
withUpgrades(upgradeNames?: string[]): any;
/** Create a snapshot of this entity for transformation chaining */
protected createSnapshot(): any;
/**
* Add tags to this entity.
* @param tags - Tags to add to the entity
*/
tag(...tags: string[]): void;
get lore(): string | undefined;
set lore(value: string | undefined);
get description(): string | undefined;
set description(value: string | undefined);
/** Check if entity has ability of specific type */
hasAbilityType(type: string): boolean;
/**
* JSON.stringify() calls this automatically
*/
toJSON(): Record<string, any>;
}
//# sourceMappingURL=entity.d.ts.map