public override bool NotifyMouseClick(MouseEventArgs args) { if (_toolStep == ToolStep.SetOrigin) { _origin = Owner.Value.ConstrainToBounds(Owner.GetMapLocationFromClient(args.Location)); _toolStep = ToolStep.SetDestination; MessageChanged?.Invoke("Please click anywhere in the map to select the destination of the path."); return(true); } if (_toolStep == ToolStep.SetDestination) { var destination = Owner.Value.ConstrainToBounds(Owner.GetMapLocationFromClient(args.Location)); if (destination == _origin) { MessageChanged?.Invoke("Path destination cannot be the same as the origin."); return(false); } _destination = destination; _toolStep = ToolStep.Pathfind; _computedPath = _pathfinder.Compute(_origin, _destination); if (_computedPath.IsSuccess) { MessageChanged?.Invoke("Path computed successfully."); } else { MessageChanged?.Invoke("Failed to compute path."); } return(true); } return(false); }
protected override void OnToolActivated() { _toolStep = ToolStep.SetOrigin; _computedPath = null; MessageChanged?.Invoke("Please click anywhere in the map to select the origin of the path."); }