Interface IHittableService
Service interface for managing hit points and hit/destroyed reactions on non-Character world objects (props, destructibles, reactive scenery).
Namespace: Serenity.Hittable.Application.Interfaces.Services
Assembly: Serenity.Hittable.Application.dll
Syntax
public interface IHittableService : IService, IFoundationSettings
Remarks
Scope boundary: this service is NOT for Characters. A Character owns its own health lifecycle end-to-end via CharacterState (RemainingHealth, TakeHit, death) in the Character module, and that ownership must not be duplicated or replaced here. IHittableService exists for everything else that can take a hit: crates, glass, barrels, destructible scenery pieces, and similar reactive world objects. Never register a Character's id with this service.
Unregistered ids: every query and mutation on an unknown HittableId is a silent no-op rather than a thrown exception - TakeHit(HittableId, int) returns Ignored, Unregister(HittableId) and IsRegistered(HittableId) return false, Reset(HittableId) does nothing, and GetSnapshot(HittableId) returns a default HittableSnapshot.
Signal dispatch is not performed inside this interface - it is the implementation's or the game layer's responsibility, mirroring the Combo module's convention.
Methods
GetSnapshot(HittableId)
Returns an immutable snapshot of the specified hittable's state.
Declaration
HittableSnapshot GetSnapshot(HittableId id)
Parameters
| Type | Name | Description |
|---|---|---|
| HittableId | id | The hittable identity. |
Returns
| Type | Description |
|---|---|
| HittableSnapshot | A HittableSnapshot of the hittable's current state, or a default value for an unknown id. |
InitializeService(ILogService)
Initializes the service.
Declaration
void InitializeService(ILogService logService)
Parameters
| Type | Name | Description |
|---|---|---|
| ILogService | logService |
IsRegistered(HittableId)
Checks whether a hittable with the specified identity is registered.
Declaration
bool IsRegistered(HittableId id)
Parameters
| Type | Name | Description |
|---|---|---|
| HittableId | id | The hittable identity. |
Returns
| Type | Description |
|---|---|
| bool | True if registered; otherwise false. |
Register(HittableId, int)
Registers a hittable with the specified identity and health configuration.
Declaration
void Register(HittableId id, int maxHealth)
Parameters
| Type | Name | Description |
|---|---|---|
| HittableId | id | The hittable identity. |
| int | maxHealth | The maximum health. A negative value makes the hittable indestructible; zero starts it already at zero health. Registering an id that is already registered re-initializes it. |
Reset(HittableId)
Restores full health and un-destroys the specified hittable.
Declaration
void Reset(HittableId id)
Parameters
| Type | Name | Description |
|---|---|---|
| HittableId | id | The hittable identity. |
TakeHit(HittableId, int)
Applies a hit to the specified hittable.
Declaration
HitOutcome TakeHit(HittableId id, int damage = 1)
Parameters
| Type | Name | Description |
|---|---|---|
| HittableId | id | The hittable identity. |
| int | damage | The damage to apply. Defaults to 1. |
Returns
| Type | Description |
|---|---|
| HitOutcome | The outcome of the hit; Ignored for an unknown id. |
Unregister(HittableId)
Unregisters a hittable.
Declaration
bool Unregister(HittableId id)
Parameters
| Type | Name | Description |
|---|---|---|
| HittableId | id | The hittable identity. |
Returns
| Type | Description |
|---|---|
| bool | True if a registered hittable was removed; false if the id was unknown. |