Class UnityCharacterService
Unity MonoBehaviour implementation of ICharacterService.
Manages per-character state using a dictionary keyed by CharacterId.
Stores archetype SO references for Unity-only data access (prefab, death window).
Inheritance
UnityCharacterService
Assembly: Serenity.UnityCharacter.Infrastructure.dll
Syntax
public class UnityCharacterService : MonoBehaviour, ICharacterService, IService, IFoundationSettings
Constructors
UnityCharacterService()
Declaration
public UnityCharacterService()
Properties
AliveCharacterCount
Declaration
public int AliveCharacterCount { get; }
Property Value
Guid
Declaration
public string Guid { get; set; }
Property Value
Id
Declaration
public string Id { get; set; }
Property Value
LogService
Declaration
public ILogService LogService { get; set; }
Property Value
Methods
ActivateCharacter(CharacterId)
Declaration
public void ActivateCharacter(CharacterId id)
Parameters
ConfigureCharacters(CharacterConfig[])
Declaration
public void ConfigureCharacters(CharacterConfig[] configs)
Parameters
FinishCharacterDeath(CharacterId)
Declaration
public void FinishCharacterDeath(CharacterId id)
Parameters
HitCharacter(CharacterId, int)
Declaration
public bool HitCharacter(CharacterId id, int damage = 1)
Parameters
Returns
InitializeService(ILogService)
Initializes the service with required dependencies.
Declaration
public void InitializeService(ILogService logService)
Parameters
| Type |
Name |
Description |
| ILogService |
logService |
The logging service for diagnostic output.
|
RegisterCharacter(CharacterId, object, int)
Declaration
public void RegisterCharacter(CharacterId id, object character, int maxHealth)
Parameters
SetCharacterConfigs(ICharacterConfig[])
Replaces the current archetype configuration with the provided ScriptableObject array.
Called by the installer after label-based auto-discovery, or can be called manually.
Overrides any previously applied configs (including inspector-assigned ones).
Declaration
public void SetCharacterConfigs(ICharacterConfig[] configs)
Parameters
| Type |
Name |
Description |
| ICharacterConfig[] |
configs |
Array of archetype ScriptableObjects to apply. Null entries are skipped.
|
TryGetCharacterSO(object, out ICharacterConfig)
Gets the Unity authoring data for a specific archetype.
Provides access to prefab, death window, and other Unity-only fields.
Declaration
public bool TryGetCharacterSO(object character, out ICharacterConfig configSO)
Parameters
| Type |
Name |
Description |
| object |
character |
The character to look up.
|
| ICharacterConfig |
configSO |
The authoring ScriptableObject if found.
|
Returns
| Type |
Description |
| bool |
True if the archetype SO was found.
|
TryGetSnapshot(CharacterId, out CharacterSnapshot)
Declaration
public bool TryGetSnapshot(CharacterId id, out CharacterSnapshot snapshot)
Parameters
Returns
UnregisterCharacter(CharacterId)
Declaration
public void UnregisterCharacter(CharacterId id)
Parameters
Implements