FakePlayerHealth
A class in Root.Township, the global namespace.
A training dummy that shows the damage it takes as popups and a text list of recent hits. The server works out the damage and syncs the popup to clients.
- Listed in Global namespace: E to H
- Inherits or implements
HealthObject - Documented in Items, interaction and damage
Constructors
| Member | What it is |
|---|---|
FakePlayerHealth() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|---|
private float damage | Last damage value, sent with the popup. |
private Queue<float> lastDamages | Recent damage values shown in the text. |
private float minDamageValue | Damage at or below this isn't added to the text list. |
private Vector3 point | Last hit point, sent with the popup. |
private int showLastXDamages | How many recent hits to list (0 to 10). |
private MethodSync syncPopup | Method sync that sends popups to clients. |
private Text textCanvas | UI text that lists recent damage. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the method sync used to send damage popups. |
override void ReceiveDamage(float healthDamage, float crippleDamage, DamageData damage = null) | Server: for impact hits, applies the server's PvP rules to player tool hits, records the damage and sends a popup to clients. Doesn't lower any health. |
4 private and internal methods
| Member | What it is |
|---|---|
private void OnValidate() | Editor: shows the text only if showLastXDamages is above 0. |
private void ShowPopup(Vector3 position, float damage) | Spawns a red damage popup at a position. |
private void SyncPopup(IPlayer player, Stream stream) | Sends the hit point and damage. Client: shows the popup when received. |
private void UpdateLastDamageText() | Trims the recent damage list to showLastXDamages and writes it to the text. |