/// <summary> /// Tries to handle a click on a building. /// </summary> /// <param name="building">The clicked building.</param> /// <param name="e">Event data.</param> /// <param name="worldPosition">Position of the intersection of raycast used for click and the building geometry.</param> /// <returns>True if the event was handled and should not be propagated to other things behind the clicked building.</returns> protected virtual bool HandleBuildingClick(IBuilding building, MouseButtonUpEventArgs e, Vector3 worldPosition) { //Right clicked enemy building if ((MouseButton)e.Button == MouseButton.Right) { if (building.Player == input.Player) { return(false); } var executed = false; foreach (var selectedUnit in GetAllSelectedUnitSelectors()) { executed |= selectedUnit.Order(new AttackOrder(building)); } return(executed); } var formationController = building.GetFormationController(worldPosition); if (formationController == null) { return(false); } formationController.MoveToFormation(new UnitGroup(GetAllSelectedUnitSelectors())); return(true); }