A class in Root.Township, the global namespace.
Server: when a child entity is destroyed in play, respawns a saved copy after a random delay and parents it back under this entity.
Constructors
| Member | What it is |
|---|
RespawnOnDestroy() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
4 private and internal fields
| Member | What it is |
|---|
private float maximumTimeToRespawn | Longest respawn delay in seconds. |
private float minimumTimeToRespawn | Shortest respawn delay in seconds. |
private Timeline.IEntry respawnEntry | Pending respawn on the timeline. |
private SavableSavedDynamicObject respawnObject | Saved copy of the object to respawn. In this code it's only set from save data. |
Methods
| Member | What it is |
|---|
override void InitializeAsServer(SpawnData spawnData) | Subscribes to the destroy event of every child entity. |
3 private and internal methods
| Member | What it is |
|---|
private void CheckRespawn(NetworkEntity entity, bool isUnload) | Schedules a respawn on the timeline when a child is destroyed, but not when it's only unloaded. |
private void OnDestroy() | Cancels a pending respawn. |
private void Respawn() | Spawns the saved object, initializes it as server, watches it again and parents it here. |