protected override async void GetCombatant() { if ((DateTime.Now - this.combatantsTimestamp).TotalMilliseconds < Settings.Instance.MobList.RefreshRateMin) { return; } this.combatantsTimestamp = DateTime.Now; #region Test Mode // テストモード? if (Settings.Instance.MobList.TestMode) { var dummyPlayer = new Combatant() { ID = 1, PosX = 0, PosY = 0, PosZ = 0, }; var dummyTargets = new List <MobInfo>(); dummyTargets.Add(new MobInfo() { Name = "TEST:シルバーの吉田直樹", Rank = "EX", Combatant = new Combatant() { ID = 1, Name = "TEST:シルバーの吉田直樹", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 0, PosY = 10, PosZ = 10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:イクシオン", Rank = "EX", Combatant = new Combatant() { ID = 2, Name = "TEST:イクシオン", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 100, PosY = 100, PosZ = -10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:イクシオン", Rank = "EX", Combatant = new Combatant() { ID = 21, Name = "TEST:イクシオン", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 100, PosY = 100, PosZ = -10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:ソルト・アンド・ライト", Rank = "S", Combatant = new Combatant() { ID = 3, Name = "TEST:ソルト・アンド・ライト", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 10, PosY = 0, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:オルクス", Rank = "A", Combatant = new Combatant() { ID = 4, Name = "TEST:オルクス", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 100, PosY = -100, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:宵闇のヤミニ", Rank = "B", Combatant = new Combatant() { ID = 5, Name = "TEST:宵闇のヤミニ", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 0, PosY = -100, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:どこかのヒメちゃん", Rank = string.Empty, Combatant = new Combatant() { ID = 6, Name = "TEST:どこかのヒメちゃん", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = -100, PosY = -100, PosZ = 0, }, }); lock (this.TargetInfoLock) { this.TargetInfo = dummyTargets.First().Combatant; this.targetMobList = dummyTargets; } return; } #endregion Test Mode var combatants = FFXIVPlugin.Instance.GetCombatantList(); // 画面ダンプ用のCombatantsを更新する CombatantsViewModel.RefreshCombatants(combatants); var targets = default(IEnumerable <MobInfo>); await Task.Run(() => { targets = from x in combatants where ((x.MaxHP <= 0) || (x.MaxHP > 0 && x.CurrentHP > 0)) && Settings.Instance.MobList.TargetMobList.ContainsKey(x.Name) select new MobInfo() { Name = x.Name, Combatant = x, Rank = Settings.Instance.MobList.TargetMobList[x.Name].Rank, MaxDistance = Settings.Instance.MobList.TargetMobList[x.Name].MaxDistance, TTSEnabled = Settings.Instance.MobList.TargetMobList[x.Name].TTSEnabled, }; // 距離で絞り込む targets = targets.Where(x => x.Distance <= x.MaxDistance); }); lock (this.TargetInfoLock) { this.targetMobList = targets.ToList(); this.TargetInfo = this.targetMobList.FirstOrDefault()?.Combatant; if (this.TargetInfo == null) { var model = this.Model as MobListModel; if (model != null && model.MobList.Any()) { WPFHelper.BeginInvoke(model.ClearMobList); } } } }
protected override async void GetCombatant() { if ((DateTime.Now - this.combatantsTimestamp).TotalMilliseconds < Settings.Instance.MobList.RefreshRateMin) { return; } this.combatantsTimestamp = DateTime.Now; #region Test Mode // テストモード? if (Settings.Instance.MobList.TestMode) { var dummyPlayer = new Combatant() { ID = 1, PosX = 0, PosY = 0, PosZ = 0, }; var dummyTargets = new List <MobInfo>(); dummyTargets.Add(new MobInfo() { Name = "TEST:シルバーの吉田直樹", Rank = "EX", Combatant = new Combatant() { ID = 1, Name = "TEST:シルバーの吉田直樹", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 0, PosY = 10, PosZ = 10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:イクシオン", Rank = "EX", Combatant = new Combatant() { ID = 2, Name = "TEST:イクシオン", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 100, PosY = 100, PosZ = -10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:イクシオン", Rank = "EX", Combatant = new Combatant() { ID = 21, Name = "TEST:イクシオン", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 100, PosY = 100, PosZ = -10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:ソルト・アンド・ライト", Rank = "S", Combatant = new Combatant() { ID = 3, Name = "TEST:ソルト・アンド・ライト", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 10, PosY = 0, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:オルクス", Rank = "A", Combatant = new Combatant() { ID = 4, Name = "TEST:オルクス", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 100, PosY = -100, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:宵闇のヤミニ", Rank = "B", Combatant = new Combatant() { ID = 5, Name = "TEST:宵闇のヤミニ", type = ObjectType.Monster, MaxHP = 1, Player = dummyPlayer, PosX = 0, PosY = -100, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = Combatant.NameToInitial("Himeko Flower", ConfigBridge.Instance.PCNameStyle), Rank = "DEAD", Combatant = new Combatant() { ID = 7, Name = Combatant.NameToInitial("Himeko Flower", ConfigBridge.Instance.PCNameStyle), type = ObjectType.PC, Job = (byte)JobIDs.BLM, MaxHP = 43462, Player = dummyPlayer, PosX = -100, PosY = -100, PosZ = 0, }, }); lock (this.TargetInfoLock) { this.TargetInfo = dummyTargets.First().Combatant; this.targetMobList = dummyTargets; } return; } #endregion Test Mode var combatants = FFXIVPlugin.Instance.GetCombatantList(); // 画面ダンプ用のCombatantsを更新する CombatantsViewModel.RefreshCombatants(combatants); var targets = default(IEnumerable <MobInfo>); await Task.Run(() => { targets = from x in combatants where ((x.MaxHP <= 0) || (x.MaxHP > 0 && x.CurrentHP > 0)) && Settings.Instance.MobList.TargetMobList.ContainsKey(x.Name) select new MobInfo() { Name = x.Name, Combatant = x, Rank = Settings.Instance.MobList.TargetMobList[x.Name].Rank, MaxDistance = Settings.Instance.MobList.TargetMobList[x.Name].MaxDistance, TTSEnabled = Settings.Instance.MobList.TargetMobList[x.Name].TTSEnabled, }; // 戦闘不能者を検出する? if (Settings.Instance.MobList.IsEnabledDetectDeadmen) { var deadmenInfo = Settings.Instance.MobList.GetDetectDeadmenInfo; var party = FFXIVPlugin.Instance.GetPartyList(); var deadmen = from x in party where !x.IsPlayer && x.MaxHP > 0 && x.CurrentHP <= 0 select new MobInfo() { Name = x.NameForDisplay, Combatant = x, Rank = deadmenInfo.Rank, MaxDistance = deadmenInfo.MaxDistance, TTSEnabled = deadmenInfo.TTSEnabled, }; targets = targets.Concat(deadmen); } // 距離で絞り込む targets = targets.Where(x => x.Distance <= x.MaxDistance); }); lock (this.TargetInfoLock) { this.targetMobList = targets.ToList(); this.TargetInfo = this.targetMobList.FirstOrDefault()?.Combatant; if (this.TargetInfo == null) { var model = this.Model as MobListModel; if (model != null && model.MobList.Any()) { WPFHelper.BeginInvoke(model.ClearMobList); } } } }
protected override void GetCombatant() { lock (this.TargetInfoLock) { var now = DateTime.Now; if ((now - this.combatantsTimestamp).TotalMilliseconds < Settings.Instance.MobList.RefreshRateMin) { return; } this.combatantsTimestamp = now; } #region Test Mode // テストモード? if (Settings.Instance.MobList.TestMode) { var dummyTargets = new List <MobInfo>(); dummyTargets.Add(new MobInfo() { Name = "TEST:シルバーの吉田直樹", Rank = "EX", Combatant = new CombatantEx() { ID = 1, Name = "TEST:シルバーの吉田直樹", Type = (byte)Actor.Type.Monster, MaxHP = 1, PosX = 0, PosY = 10, PosZ = 10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:イクシオン", Rank = "EX", Combatant = new CombatantEx() { ID = 2, Name = "TEST:イクシオン", Type = (byte)Actor.Type.Monster, MaxHP = 1, PosX = 100, PosY = 100, PosZ = -10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:イクシオン", Rank = "EX", Combatant = new CombatantEx() { ID = 21, Name = "TEST:イクシオン", Type = (byte)Actor.Type.Monster, MaxHP = 1, PosX = 100, PosY = 100, PosZ = -10, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:ソルト・アンド・ライト", Rank = "S", Combatant = new CombatantEx() { ID = 3, Name = "TEST:ソルト・アンド・ライト", Type = (byte)Actor.Type.Monster, MaxHP = 1, PosX = 10, PosY = 0, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:オルクス", Rank = "A", Combatant = new CombatantEx() { ID = 4, Name = "TEST:オルクス", Type = (byte)Actor.Type.Monster, MaxHP = 1, PosX = 100, PosY = -100, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = "TEST:宵闇のヤミニ", Rank = "B", Combatant = new CombatantEx() { ID = 5, Name = "TEST:宵闇のヤミニ", Type = (byte)Actor.Type.Monster, MaxHP = 1, PosX = 0, PosY = -100, PosZ = 0, }, }); dummyTargets.Add(new MobInfo() { Name = CombatantEx.NameToInitial("TEST:Hime Hana", ConfigBridge.Instance.PCNameStyle), Rank = "DEAD", Combatant = new CombatantEx() { ID = 7, Name = CombatantEx.NameToInitial("TEST:Hime Hana", ConfigBridge.Instance.PCNameStyle), Type = (byte)Actor.Type.Monster, Job = (byte)JobIDs.BLM, MaxHP = 43462, PosX = -100, PosY = -100, PosZ = 0, }, }); lock (this.TargetInfoLock) { this.TargetInfo = dummyTargets.First().Combatant; this.targetMobList = dummyTargets; } return; } #endregion Test Mode if ((CombatantsManager.Instance.CombatantsMainCount + CombatantsManager.Instance.CombatantsOtherCount) <= 0) { return; } var targets = default(IEnumerable <MobInfo>); var combatants = CombatantsManager.Instance.GetCombatants(); // モブを検出する IEnumerable <MobInfo> GetTargetMobs() { foreach (var x in combatants) { if (string.IsNullOrEmpty(x?.Name)) { continue; } if (x.ActorType == Actor.Type.PC || x.ActorType == Actor.Type.Monster) { if (x.MaxHP <= 0 || (x.MaxHP > 0 && x.CurrentHP <= 0)) { continue; } } var targetInfo = Settings.Instance.MobList.GetTargetMobInfo(x.Name); if (string.IsNullOrEmpty(targetInfo.Name)) { continue; } yield return(new MobInfo() { Name = x.Name, Combatant = x, Rank = targetInfo.Rank, MaxDistance = targetInfo.MaxDistance, TTSEnabled = targetInfo.TTSEnabled, }); } } targets = GetTargetMobs(); // 戦闘不能者を検出する? var deadmenInfo = Settings.Instance.MobList.GetDetectDeadmenInfo; if (!string.IsNullOrEmpty(deadmenInfo.Name)) { var party = CombatantsManager.Instance.GetPartyList(); var deadmen = from x in party where x != null && !x.IsPlayer && x.ActorType == Actor.Type.PC && x.MaxHP > 0 && x.CurrentHP <= 0 select new MobInfo() { Name = x.NameForDisplay, Combatant = x, Rank = deadmenInfo.Rank, MaxDistance = deadmenInfo.MaxDistance, TTSEnabled = deadmenInfo.TTSEnabled, }; targets = targets.Concat(deadmen); } // クエリを実行する targets = targets.ToArray(); lock (this.TargetInfoLock) { this.targetMobList = targets .Where(x => x.Distance <= x.MaxDistance) .ToList(); this.TargetInfo = this.targetMobList.FirstOrDefault()?.Combatant; if (this.TargetInfo == null) { var model = this.Model as MobListModel; if (model != null && model.MobList.Any()) { WPFHelper.BeginInvoke(model.ClearMobList); } } } if (combatants != null) { CombatantsViewModel.RefreshCombatants(combatants.ToArray()); } }