RespawnSystemModel
A class in Root.Township, ATT.Respawn.
State of every respawn shrine (fuel and bound players), saved and sent to clients as JSON. Made from the shrine list in RespawnSystemSettings or from a save.
- Listed in ATT, Features and other game namespaces
- Inherits or implements
IRespawnSystemModel, IEnumerable<IRespawnShrineModel>,IEnumerable - Attributes
DefaultMember
Constructors
| Member | What it is |
|---|---|
RespawnSystemModel() | Creates a RespawnSystemModel from saveData. |
RespawnSystemModel(RespawnSystemSaveData saveData) | Creates a RespawnSystemModel from saveData. |
Fields
2 private and internal fields
| Member | What it is |
|---|---|
private static Logger logger | Class logger. |
private Dictionary<Guid, RespawnShrineModel> respawnShrineModels | Shrine models by shrine ID. The global shrine is not in it. |
Properties
| Member | What it is |
|---|---|
Guid GlobalShrineGuid { get; } | Id of the global (default) shrine everyone falls back to. |
bool HasModelChanged { get; private set; } | True when something changed since the last sync was written. |
IRespawnShrineModel this[Guid id] { get; } | The shrine model with this id. Throws for an unknown id. |
Methods
| Member | What it is |
|---|---|
bool AddSubscriber(Guid shrineId, int playerId) | Binds a player id to a shrine. Always true for the global shrine, which has no list. |
void DecrementFuel(float timeSinceLastDecrementInSeconds) | Burns fuel for shrines that have players bound. A shrine that runs dry loses all its players. |
Guid GetActiveShrineIdForPlayer(int playerId) | The shrine a player id is bound to, or the global shrine's id. |
IEnumerator<IRespawnShrineModel> GetEnumerator() | Enumerates the shrine models (not including the global shrine). |
float GetRemainingPoweredTimeForShrineNormalized(Guid shrineId) | Fuel as a fraction of the shrine's capacity. 0 for the global shrine. |
RespawnSystemSaveData GetSaveData() | Save data with the global shrine id and the shrines as JSON. |
IEnumerable<int> GetShrineSubscriberIds(Guid shrineId) | Player ids bound to a shrine. Empty for the global shrine. |
bool RemoveSubscriber(Guid shrineId, int playerId) | Unbinds a player id from a shrine. Always true for the global shrine. |
void SetFuel(Guid shrineId, float value) | Sets a shrine's fuel. |
void SyncToClients(IPlayer player, ref Stream stream) | Writes or reads all shrines as a JSON string. Writing clears the changed and emptied flags. |