Skip to main content

ShakeInput

A class in Root.Township, the global namespace.

Skill input method that turns on when the player shakes the held item. Created by ShakeInputStructure.GetNewInput and driven by the held pickup's skill handling.

Constructors​

MemberWhat it is
ShakeInput()Creates a ShakeInput with default values.

Fields​

3 private and internal fields
MemberWhat it is
private ShakeDetectorHelper shakeHelperDetector that measures shaking of the pickup's rigidbody.
private float shakenTimeReal time of the last detected shake.
private ShakeInputStructure shakeStructureThe ShakeInputStructure settings this input was registered with.

Properties​

MemberWhat it is
HeldPickupHandler Handler { get; private set; }The held pickup handler this input was registered with.
bool IsActive { get; private set; }True from a detected shake until HeldDeactivation seconds have passed.
2 private and internal properties
MemberWhat it is
private bool ISkillInputMethod.NeedsUpdate { get; }Always true, so Update is called every frame.
private bool ISkillInputMethod.ReceivesHits { get; }Always false. Shake input ignores impacts.

Events​

MemberWhat it is
event Action<bool, ISkillInputMethod> ChangedActiveRaised with true when a shake is detected and false when it times out or is reset.

Methods​

6 private and internal methods
MemberWhat it is
private void ISkillInputMethod.Clear()Does nothing.
private void OnShaken()Called by the shake detector. Activates the input, records the time and raises ChangedActive.
private bool ISkillInputMethod.ReceiveHit(HeldPickupHandler handler, ImpactHitWithTool hitWithTool, ProfessionSkill skill)Ignores the hit and returns false.
private void ISkillInputMethod.RegisterHandler(HeldPickupHandler pickupHandler, SkillInputStructure structure, ProfessionSkill skill)Stores the handler and builds a ShakeDetectorHelper on the pickup's rigidbody using the structure's thresholds.
private void ISkillInputMethod.Reset(bool isCallingEvent)Deactivates the input, raising ChangedActive only if asked to.
private void ISkillInputMethod.Update()While active, deactivates after the hold time runs out; while inactive, checks the rigidbody for a new shake.