private void IdeOverlaysCanvas_Draw(CanvasControl sender, CanvasDrawEventArgs args) { // Git diff indicators int i = 0; foreach (var modification in _DiffIndicators.Span) { switch (modification) { case LineModificationType.Modified: DrawDiffMarker(args.DrawingSession, GetOffsetAt(i), ModifiedGitDiffMarkerStrokeColor, ModifiedGitDiffMarkerOutlineColor); break; case LineModificationType.Saved: DrawDiffMarker(args.DrawingSession, GetOffsetAt(i), SavedGitDiffMarkerStrokeColor, SavedGitDiffMarkerOutlineColor); break; } i++; } // Indentation indicators i = 0; foreach (var indicator in _IndentationIndicators.Span) { if (!(indicator is null)) { // Manually perform the type checks and unsafe casts to skip // the multiple null and type checking produced by the C# compiler if (indicator.GetType() == typeof(FunctionIndicator)) { FunctionIndicator function = Unsafe.As <FunctionIndicator>(indicator); DrawFunctionDeclaration(args.DrawingSession, GetOffsetAt(i) + IndentationIndicatorsVerticalOffsetMargin, function.Type); } else if (indicator.GetType() == typeof(BlockIndicator)) { BlockIndicator block = Unsafe.As <BlockIndicator>(indicator); DrawIndentationBlock(args.DrawingSession, GetOffsetAt(i) + IndentationIndicatorsVerticalOffsetMargin, block.Depth, block.Type, block.IsWithinFunction); } else if (indicator.GetType() == typeof(LineIndicator)) { LineIndicator line = Unsafe.As <LineIndicator>(indicator); DrawLine(args.DrawingSession, GetOffsetAt(i) + IndentationIndicatorsVerticalOffsetMargin, line.Type); } } i++; } // Breakpoints markers foreach (var pair in BreakpointIndicators) { DrawBreakpointIndicator(args.DrawingSession, pair.Value); } }
void LeftClickLogistics() { hitCooldown = hitCooldown > 0 ? hitCooldown -= Time.deltaTime : hitCooldown = 0; // If not holding left-click, reset breakTime if (!Input.GetMouseButton(0) && CurrentBlockName() != "Nothing") { breakTime = hit.collider.GetComponent <BlockIndicator>().blockBreakTime; hit.collider.GetComponent <BlockIndicator>().crackAnimator.SetBool("Break", false); savedBlock = CurrentBlockName(); } // If saved block is not equal to the current block, reset breakTime if (savedBlock != CurrentBlockName()) { if (currentBlock != null) { breakTime = currentBlock.blockBreakTime; currentBlock.crackAnimator.SetBool("Break", false); } savedBlock = CurrentBlockName(); } // Select Between Attacking and Breaking if (!HelperFunctions.IsPointerOverUIElement()) { if (!crouch && hitCooldown <= 0f && Input.GetMouseButtonDown(0) && CurrentBlockName() == "Nothing") { Attack(); saturation -= 0.05f; hitCooldown = cooldown; } else if (Input.GetMouseButton(0) && CurrentBlockName() != "Nothing") { if (breakTime > 0) { breakTime -= Time.deltaTime; currentBlock = hit.collider.GetComponent <BlockIndicator>(); currentBlock.crackAnimator.SetFloat("Playback Speed", 1 / hit.collider.GetComponent <BlockIndicator>().blockBreakTime); currentBlock.crackAnimator.SetBool("Break", true); } else if (breakTime <= 0) { breakTime = 0; Break(); breakTime = hit.collider.GetComponent <BlockIndicator>().blockBreakTime; currentBlock = null; } } } }