// gets called by other units public override int CheckRetal(List <HexEntry> enemyRecentPath, IUnitController enemy) { List <IUnitController> affectedCombats = CheckHit(enemyRecentPath) .Where(x => x == unitController) .ToList(); if (affectedCombats.Count > 0 && enemy != unitController && enemy.SimHealth() > 0 && enemy.SimPosition.Terrain != Terrain.Pit) // && enemy.PlayerOwner != unitController.PlayerOwner) { -- Flail hits allies { return(unitController.DamageOutput); } else { return(0); } }
// We need to simulate a path's outcomes to avoid making changes to the unit's actual state. private List <Outcome> SimulatePath(List <HexEntry> path) { List <Outcome> outcomes = new List <Outcome>(); for (int i = 1; i < path.Count; i++) { if (path[i].SimOccupant != null) //&& path[i].SimOccupant != unitController) { // Necessary because if a unit is pushed midpath, the pathgenerator doesn't understand that { break; } unitController.SimPosition = path[i]; // Keep track of data to feed the Outcome constructor List <AttackResult> combat = unitController.Weapon.CombatResults(unitController.SimRecentPath); // Contains all simulatepush calls outcomes.Add(new Outcome(unitController, path[i], true, combat)); if (unitController.SimHealth() <= 0) { break; } } foreach (HexEntry hex in scenarioLoader.HexGrid.Values) { hex.SimOccupant = null; } foreach (int player in gameManager.playerDirectory.Keys) { foreach (IUnitController unit in selectionManager.UnitsByPlayer[player]) { unit.ResetSimulationState(); } } return(outcomes); }