internal void RemoveShipIfExists(Ship rpShip) { if (RepairingShips == null) { return; } var rIndex = RepairingShips.FindIndex(r => r.Item1 == rpShip); if (rIndex != -1) { rpShip.UpdateAnchorageRepairStatus(false); RepairingShips.RemoveAt(rIndex); } }
internal void Update(IEnumerable <Ship> rpShipsToBeRepaired) { var rShips = rpShipsToBeRepaired.Select(r => Tuple.Create(r, r.HP)).ToList(); var rReset = false; if (RepairingShips == null || !RepairingShips.Select(r => r.Item1).SequenceEqual(rpShipsToBeRepaired)) { if (RepairingShips != null) { foreach (var rShip in RepairingShips.Select(r => r.Item1).Except(rpShipsToBeRepaired)) { rShip.UpdateAnchorageRepairStatus(false); } } rReset = true; } else { for (var i = 0; i < RepairingShips.Count; i++) { if (RepairingShips[i].Item2 != rShips[i].Item2) { rReset = true; break; } } } if (rReset) { foreach (var rShip in rShips) { rShip.Item1.UpdateAnchorageRepairStatus(true); rShip.Item1.AnchorageRepairStatus.Update(); } RepairingShips = rShips; Reset(); } }