Skip to main content

TargetBasedSkill

An abstract class in Root.Township, the global namespace.

Base for charged tool skills that show a target on the struck object and fire when the player hits it, such as PowerStinger and PowerCrossSlash. The client reports the hit and the server runs the skill.

Constructors​

MemberWhat it is
protected TargetBasedSkill()Use ScriptableObject.CreateInstance instead of new; Unity loads the saved ones from assets.

Fields​

MemberWhat it is
protected TargetBasedSkill.ClientHitInput clientHitInputThe last hit the client reported: position, direction, up, damage and impact type.
4 private and internal fields
MemberWhat it is
private Dictionary<uint, ISkillInputMethod> activeHandlerMapActive skill inputs by tool entity ID, so a client-reported hit can be matched to its input on the server.
private Dictionary<uint, PooledObject> activeTargetsPooled target markers shown on the local player's charged tools, by tool entity ID.
private ImpactTypeFilter impactTypeFilterWhich tools and impact types this skill accepts.
private bool isExecutingOnClientSet while sending a client hit report, so the next message carries the hit instead of the base skill data.

Methods​

MemberWhat it is
virtual void ExecuteOnClient(uint toolIdentifier, Vector3 position, Vector3 direction, Vector3 up, ImpactHitWithTool hit)Client: stores the hit position, direction and damage, removes the target and sends the skill message to the server. Called by SkillHitTarget.
override void InputChangedState(bool isEnabled, ISkillInputMethod input)Remembers or forgets the input method for the tool, so the server can find it when the client's hit arrives.
override void SendSerializedMessage(IPlayer player, Stream stream)Carries the client's hit input and tool ID. On the server it runs the skill for the matching input and resets that input.
override bool ValidatePickup(HeldPickupHandler pickupHandler)True if the base check passes, the held item is a tool, and its impact types pass the skill's filter.
virtual bool ValidateTargetHit(ImpactHitWithTool hit)True if the hit's impact type passes the skill's filter.
protected override void EffectsRequested(NetworkEntity targetEntity, ToolBasedSkillStatus status, bool isLocalPlayer)Clears any old target on the entity and, when the skill is charged for the local player, places a new hit target on it.
protected abstract PooledObject PlaceTarget()Spawns the pooled hit target object for this skill.

Used in​

Members of other types that take, return or hold a TargetBasedSkill: