PlayerEventsManager
A class in Root.Township, the global namespace.
Gameplay events about one player gathered in one place: interactions, tool hits, health, downed, killed, combat and whether they are armed. A component on the player template; get it from Player.PlayerEventsManager.
- Listed in Global namespace: P
- Inherits or implements
PlayerComponent - Nested types
OnPathHitGenerated
Constructors
| Member | What it is |
|---|---|
PlayerEventsManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
1 private and internal field
| Member | What it is |
|---|---|
private PlayerCharacter character | The player's current PlayerCharacter. |
Properties
| Member | What it is |
|---|---|
Dictionary<Interactable, ImpactTool> HeldTools { get; } | Impact tools the player is holding, by the interactable they hold. |
bool IsArmed { get; private set; } | True while the player holds a tool that has impactors (a weapon or other hitting tool). |
Events
| Member | What it is |
|---|---|
event CombatEventHandler CausedCombat | Raised when the player's character causes combat with another entity. |
event Action<DamageData> Downed | Raised when the player's character is downed. |
event HealthObject.HealthChangedHandler HealthChanged | Raised when the player's character health changes. |
event InteractionHandler InteractionEnded | Raised when either hand ends an interaction. |
event InteractionHandler InteractionStarted | Raised when either hand starts an interaction. |
event Action<DamageData> Killed | Raised when the player's character is killed. |
event Action<bool> OnArmedChanged | Raised when IsArmed changes. |
event Action<PlayerCharacter> OnCharacterAdded | Raised when a new player character is linked and its events are hooked up. |
event ImpactTool.OnGeneratedHit OnHitWithTool | Raised when a held impact tool generates a hit. |
event PlayerEventsManager.OnPathHitGenerated PathHitGenerated | Raised by PathImpactHit when a hit counts toward a progression path (forging and so on). |
Methods
| Member | What it is |
|---|---|
void PathImpactHit(ProgressionPath path, ImpactHitWithTool hitWithTool, Pickup hitPickup) | Raises PathHitGenerated. Called by impact detectors and forged models. |
11 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Listens for the player's controller being set. |
private void CheckArmed() | Sets IsArmed to whether any held tool has impactors, and raises OnArmedChanged if it changed. |
private void Hit(ImpactHitWithTool hit, ImpactTool tool) | Passes a held tool's hit on as OnHitWithTool. |
private void OnCausedCombat(PlayerController attacker, NetworkEntity attackee, float distanceRatioBetweenCombatantsSquared, float damage) | Passes the character's CausedCombat event on. |
private void OnDowned(DamageData hit) | Passes the character's downed event on as Downed. |
private void OnHealthChanged(HealthObject healthObject, float changeAmount, DamageData impact) | Passes the character's health change on as HealthChanged. |
private void OnInteractionEnded(Interactor interactor, Interactable interactable) | Stops tracking a tool once no hand of this player holds it, then raises InteractionEnded. |
private void OnInteractionStarted(Interactor interactor, Interactable interactable) | Starts tracking a picked-up ImpactTool in HeldTools, then raises InteractionStarted. |
private void OnKilled(DamageData hit) | Passes the character's killed event on as Killed. |
private void UpdateInitializedController() | Once the character is linked, hooks both hands' interaction events and the health and combat events, then raises OnCharacterAdded. |
private void Updateplayercontroller(Player player, PlayerController playerController) | When the player's controller is a PlayerCharacter, stores it and waits for it to be linked. |
Used in
Members of other types that take, return or hold a PlayerEventsManager: