CharacterFactory

Network-enabled factory for spawning Character instances with CharacterData. Extends NetworkScriptableFactory to support networked character spawning with variant support.

Definition

Namespace: Paragon.Townskeep.CharacterSystem Assembly: Townskeep.dll

public class CharacterFactory : NetworkScriptableFactory<Character, CharacterData>

Inheritance: ScriptableFactoryScriptableFactory<Character>ScriptableFactory<Character, CharacterData>NetworkScriptableFactory<Character, CharacterData>CharacterFactory Implements: IScriptableFactory, IScriptableFactory<Character, CharacterData>, INetworkScriptableFactory<Character, CharacterData>

Remarks

CharacterFactory is the concrete factory responsible for creating Character instances across the network. It inherits all spawning, pooling, and data variant functionality from the Paragon factory system and adds network spawning via NetworkScriptableFactory.

The factory overrides GetHashCode() to return CharacterData.CharacterID, which is used by CharacterDatabase to index factories for O(1) lookup by character ID.

Quick Lookup

Goal
How

Spawn a networked character

factory.NetworkSpawn(variantIndex, ownerClientId)

Spawn async (wait for network)

await factory.NetworkSpawnAsync(variantIndex, ownerClientId)

Get factory data

factory.GetData()

Get factory hash (character ID)

factory.GetHashCode()

Methods

GetHashCode (override)

Returns the CharacterID from the factory's CharacterData, used as the hash key in CharacterDatabase.

Returns: int — The CharacterData.CharacterID value.

NetworkSpawn (inherited)

Spawns a networked Character instance.

Parameter
Type
Description

variantIndex

int

Data variant to use (0 = source data)

ownerClientId

ulong?

Network owner client ID, or null for server-owned

predicted

bool

Whether to use client-side prediction

Returns: The spawned Character instance.

NetworkSpawnAsync (inherited)

Async version that waits for the NetworkObject to be fully spawned on the network.

Usage Example

See Also

Last updated