/// <summary> /// Creates a new beats cursor instance. /// </summary> private BeatsCursor CreateCursor() { var cursor = new BeatsCursor(); cursor.OnRelease += () => OnCursorStateRelease(cursor); return(cursor); }
/// <summary> /// Unlinks events attached to the hit cursor and removes the reference to it. /// </summary> private void UnlinkHitCursor() { if (hitCursor != null) { hitCursor.OnResult -= OnHitCursorResult; hitCursor.OnRelease -= OnHitCursorRelease; } hitCursor = null; }
protected BaseInputter(HitBarDisplay hitBar, HitObjectHolder hitObjectHolder) { this.hitBar = hitBar; this.hitObjectHolder = hitObjectHolder; hitBarCursor = CreateCursor(); hitBar.LinkCursor(hitBarCursor); keyRecycler = new ManagedRecycler <BeatsKey>(CreateKey); keyRecycler.Precook(3); }
/// <summary> /// Associates the specified hit cursor as a link to this key. /// </summary> public void SetHitCursor(BeatsCursor cursor) { UnlinkHitCursor(); hitCursor = cursor; if (hitCursor != null) { hitCursor.OnResult += OnHitCursorResult; hitCursor.OnRelease += OnHitCursorRelease; } }
/// <summary> /// Event called on game session hard disposal. /// </summary> protected virtual void OnHardDispose() { GameSession.OnSoftInit -= OnSoftInit; GameSession.OnSoftDispose -= OnSoftDispose; GameSession.OnHardDispose -= OnHardDispose; hitBar.UnlinkCursor(); hitBar = null; hitObjectHolder = null; hitBarCursor = null; keyRecycler = null; pointerEvent = null; raycastResults = null; }
/// <summary> /// Invokes the OnCursorRelease event. /// </summary> protected void InvokeCursorRelease(BeatsCursor cursor) => OnCursorRelease?.Invoke(cursor);
/// <summary> /// Invokes the OnCursorPress event. /// </summary> protected void InvokeCursorPress(BeatsCursor cursor) => OnCursorPress?.Invoke(cursor);
/// <summary> /// Event called on cursor release state. /// </summary> private void OnCursorStateRelease(BeatsCursor cursor) { InvokeCursorRelease(cursor); cursor.OnRecycleDestroy(); }