Skip to main content

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.

Constructors​

MemberWhat it is
PlayerEventsManager()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

1 private and internal field
MemberWhat it is
private PlayerCharacter characterThe player's current PlayerCharacter.

Properties​

MemberWhat 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​

MemberWhat it is
event CombatEventHandler CausedCombatRaised when the player's character causes combat with another entity.
event Action<DamageData> DownedRaised when the player's character is downed.
event HealthObject.HealthChangedHandler HealthChangedRaised when the player's character health changes.
event InteractionHandler InteractionEndedRaised when either hand ends an interaction.
event InteractionHandler InteractionStartedRaised when either hand starts an interaction.
event Action<DamageData> KilledRaised when the player's character is killed.
event Action<bool> OnArmedChangedRaised when IsArmed changes.
event Action<PlayerCharacter> OnCharacterAddedRaised when a new player character is linked and its events are hooked up.
event ImpactTool.OnGeneratedHit OnHitWithToolRaised when a held impact tool generates a hit.
event PlayerEventsManager.OnPathHitGenerated PathHitGeneratedRaised by PathImpactHit when a hit counts toward a progression path (forging and so on).

Methods​

MemberWhat it is
void PathImpactHit(ProgressionPath path, ImpactHitWithTool hitWithTool, Pickup hitPickup)Raises PathHitGenerated. Called by impact detectors and forged models.
11 private and internal methods
MemberWhat 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: