void OnDisable() { // abort all specialmovement if any is ongoing // gets called on death and respawn StopAllCoroutines(); _MOVEFLAGS = MOVEMENTFLAGS.DASHREADY; }
// gets called from healthcomponent on getting hit public void HandleKnockback(Vector2 knockbackForce, float knockbackTime) { // stop all specialmovement when getting knockedback (ex if in dash when taking a hit) StopAllCoroutines(); _MOVEFLAGS = MOVEMENTFLAGS.DASHREADY; StartCoroutine(DoKnockback(knockbackForce, knockbackTime)); }
// takes in multiple flags , only returns true if none of the flags is set // if you only need to check if 1 flag is not set you can just use "!HasFlag()" bool DontHaveFlags(MOVEMENTFLAGS flags) { return((_MOVEFLAGS & flags) == 0); }
bool HasFlag(MOVEMENTFLAGS flag) { return((_MOVEFLAGS & flag) == flag); }
void RemoveFlag(MOVEMENTFLAGS flag) { _MOVEFLAGS &= (~flag); }
void AddFlag(MOVEMENTFLAGS flag) { _MOVEFLAGS |= flag; }