private void UpdateRepairyard(Repairyard repairyard) { this.repairyardDisposables?.Dispose(); this.repairyardDisposables = new LivetCompositeDisposable(); foreach (var dock in repairyard.Docks.Values) { dock.Completed += this.HandleRepairyardCompleted; this.repairyardDisposables.Add(() => dock.Completed -= this.HandleRepairyardCompleted); } }
/// <summary> /// 入渠ドックに変化があったとき呼ばれる /// </summary> /// <param name="repairyard">repairyard</param> private void UpdateRepairyard(Repairyard repairyard) { Repairyard = repairyard; this.repairyardDisposables?.Dispose(); this.repairyardDisposables = new LivetCompositeDisposable(); foreach (var dock in repairyard.Docks.Values) { repairyardDisposables.Add(dock.Subscribe(nameof(dock.State), () => RepairState = dock.State)); } }
private static void UpdateRepairyard(Repairyard repairyard) { foreach (var dock in repairyard.Docks.Values) { dock.Completed += (sender, args) => { if (Settings.Current.NotifyRepairingCompleted) { PluginHost.Instance.GetNotifier().Show( Resources.Repairyard_NotificationMessage_Title, string.Format(Resources.Repairyard_NotificationMessage, args.DockId, args.Ship.Info.Name), () => Application.Instance.MainWindowViewModel.Activate()); } }; } }
/// <summary> /// 艦隊に編成されている艦娘の状態から、再出撃可能かどうかを判定します。 /// </summary> /// <param name="ships">艦隊に編成されている艦娘。</param> internal void Update(Ship[] ships, Repairyard repairyard) { try { if (ships.Length == 0) { this.ReadyTime = null; this.UpdateCore(); if (this.CriticaledShips.Count > 0) { this.CriticalCleared(this, new EventArgs()); this.CriticaledShips.Clear(); } return; } var reason = CanReSortieReason.NoProblem; if (ships.Any(s => s.IsBadlyDamaged)) { reason |= CanReSortieReason.Wounded; // We only send out the event once, when the ships has reached critical from its previous state. IEnumerable <Ship> CriticalShips = ships.Where(s => s.IsBadlyDamaged); foreach (Ship s in CriticalShips) { if (this.CriticalCondition != null && !repairyard.CheckRepairing(s.Id) && (this.CriticaledShips.Count == 0 || (this.CriticaledShips.Count > 0 && !this.CriticaledShips[s.Id]))) { this.CriticalCondition(this, new ShipCriticalConditionEventArgs(s)); this.CriticaledShips.Add(s.Id, true); } } int RepairingCritShips = ships.Where(s => s.IsBadlyDamaged && repairyard.CheckRepairing(s.Id)).Count(); if (this.CriticalCleared != null && ships.Where(s => s.IsBadlyDamaged).Count() == RepairingCritShips) { this.CriticalCleared(this, new EventArgs()); this.CriticaledShips.Clear(); } } else if (this.CriticalCleared != null && this.CriticaledShips.Count > 0) { this.CriticaledShips.Clear(); this.CriticalCleared(this, new EventArgs()); } if (ships.Any(s => s.Fuel.Current < s.Fuel.Maximum || s.Bull.Current < s.Bull.Maximum)) { reason |= CanReSortieReason.LackForResources; } var min = ships.Min(x => x.Condition); if (min < 40) { reason |= CanReSortieReason.BadCondition; // コンディションの最小値が前回から変更された場合のみ、再出撃可能時刻を更新する // (サーバーから来るコンディション値が 3 分に 1 回しか更新されないので、毎回カウントダウンし直すと最大 3 分くらいズレる) if (min != this.minCondition) { this.ReadyTime = DateTimeOffset.Now.Add(TimeSpan.FromMinutes(40 - min)); } } else { this.ReadyTime = null; } this.minCondition = min; this.Reason = reason; this.UpdateCore(); } catch (Exception ex) { Debug.WriteLine(ex); } }
/// <summary> /// 艦隊に編成されている艦娘の状態から、再出撃可能かどうかを判定します。 /// </summary> /// <param name="ships">艦隊に編成されている艦娘。</param> internal void Update(Ship[] ships, Repairyard repairyard) { try { if (ships.Length == 0) { this.ReadyTime = null; this.UpdateCore(); if (this.CriticaledShips.Count > 0) { this.CriticalCleared(this, new EventArgs()); this.CriticaledShips.Clear(); } return; } var reason = CanReSortieReason.NoProblem; if (ships.Any(s => s.IsBadlyDamaged)) { reason |= CanReSortieReason.Wounded; // We only send out the event once, when the ships has reached critical from its previous state. IEnumerable<Ship> CriticalShips = ships.Where(s => s.IsBadlyDamaged); foreach (Ship s in CriticalShips) { if (this.CriticalCondition != null && !repairyard.CheckRepairing(s.Id) && (this.CriticaledShips.Count == 0 || (this.CriticaledShips.Count > 0 && !this.CriticaledShips[s.Id]))) { this.CriticalCondition(this, new ShipCriticalConditionEventArgs(s)); this.CriticaledShips.Add(s.Id, true); } } int RepairingCritShips = ships.Where(s => s.IsBadlyDamaged && repairyard.CheckRepairing(s.Id)).Count(); if (this.CriticalCleared != null && ships.Where(s => s.IsBadlyDamaged).Count() == RepairingCritShips) { this.CriticalCleared(this, new EventArgs()); this.CriticaledShips.Clear(); } } else if (this.CriticalCleared != null && this.CriticaledShips.Count > 0) { this.CriticaledShips.Clear(); this.CriticalCleared(this, new EventArgs()); } if (ships.Any(s => s.Fuel.Current < s.Fuel.Maximum || s.Bull.Current < s.Bull.Maximum)) { reason |= CanReSortieReason.LackForResources; } var min = ships.Min(x => x.Condition); if (min < 40) { reason |= CanReSortieReason.BadCondition; // コンディションの最小値が前回から変更された場合のみ、再出撃可能時刻を更新する // (サーバーから来るコンディション値が 3 分に 1 回しか更新されないので、毎回カウントダウンし直すと最大 3 分くらいズレる) if (min != this.minCondition) { this.ReadyTime = DateTimeOffset.Now.Add(TimeSpan.FromMinutes(40 - min)); } } else { this.ReadyTime = null; } this.minCondition = min; this.Reason = reason; this.UpdateCore(); } catch (Exception ex) { Debug.WriteLine(ex); } }