protected override void Hit() { if (!IsLocallyControlled) { return; } try { Cleanup(); switch (ActiveAction) { case MyHandItemActionEnum.Tertiary: { if (_vertices.Count == 0) { return; } if (_hintInfo == null) { _hintInfo = MyAPIGateway.Utilities.CreateNotification(""); } var sb = new StringBuilder(); if (!TargetIsStatic) { sb.AppendLine("Can't place node on dynamic physics"); } else { using (new TemporaryVertex(this)) if (_vertices.Count >= 2) { var jointData = EdgePlacerSystem.ComputeEdgeParameters(_vertices[_vertices.Count - 2], _vertices[_vertices.Count - 1]); sb.Append($"Length {jointData.Length:F1} m"); if (PlacedDefinition != null && jointData.Length > PlacedDefinition.Distance.Max) { sb.AppendLine($" >= {PlacedDefinition.Distance.Max:F1} m"); } else if (PlacedDefinition != null && jointData.Length < PlacedDefinition.Distance.Min) { sb.AppendLine($" <= {PlacedDefinition.Distance.Min:F1} m"); } else { sb.AppendLine(); } if (jointData.BendRadians.HasValue) { var b = jointData.BendRadians.Value; sb.Append($"Curve {b * 180 / Math.PI:F0}º"); if (PlacedDefinition != null && b > PlacedDefinition.MaxAngleRadians) { sb.AppendLine($" >= {PlacedDefinition.MaxAngleDegrees}º"); } else { sb.AppendLine(); } } if (jointData.Grade.HasValue) { var g = jointData.Grade.Value; sb.Append($"Grade {g * 100:F0}%"); if (PlacedDefinition != null && Math.Abs(g) > PlacedDefinition.MaxGradeRatio) { sb.AppendLine($" {(g < 0 ? "<= -" : ">= ")}{PlacedDefinition.MaxGradeRatio * 100:F0}%"); } else { sb.AppendLine(); } } } } _hintInfo.Text = sb.ToString(); _hintInfo.Show(); // resets alive time + adds to queue if it's not in it return; } case MyHandItemActionEnum.Secondary: { _vertices.Clear(); var entity = Target.Entity?.Components.Get <BendyShapeProxy>()?.Owner ?? Target.Entity; var dynCon = entity?.Components.Get <BendyComponent>(); if (dynCon == null || dynCon.Graph != Graph) { return; } EdgePlacerSystem.RaiseRemoveEdge(Holder.EntityId, entity.EntityId); return; } case MyHandItemActionEnum.Primary: { _vertices.Add(CreateVertex(Target.Position)); if (_vertices.Count < 2) { return; } var pts = _vertices.Select(x => x.Position).ToArray(); _vertices.RemoveRange(0, _vertices.Count - 1); EdgePlacerSystem.RaisePlaceEdge(new EdgePlacerSystem.EdgePlacerConfig() { EntityPlacing = Holder.EntityId, Placed = Definition.Placed }, pts ); return; } case MyHandItemActionEnum.None: default: return; } } finally { Cleanup(); } }