private IEnumerable <CombatantEx> RefreshCore( IEnumerable <Combatant> source, bool isDummy = false) { var isFirstCombatant = true; var partyIDList = new List <uint>(32); var addeds = new List <CombatantEx>(128); this.OtherList.Clear(); foreach (var combatant in source) { switch (combatant.GetActorType()) { // 必要なCombatant case Actor.Type.PC: case Actor.Type.Monster: case Actor.Type.NPC: case Actor.Type.Aetheryte: case Actor.Type.Gathering: case Actor.Type.EventObject: break; // 上記以外は捨てる default: continue; } var isMain = combatant.GetActorType() switch { Actor.Type.PC => true, Actor.Type.Monster => true, _ => false, }; if (isMain) { var dic = this.MainDictionary; var key = combatant.ID; var isNew = !dic.ContainsKey(key); var ex = isNew ? new CombatantEx() : dic[key]; CombatantEx.CopyToEx(combatant, ex); if (isDummy) { ex.IsDummy = true; ex.PartyType = PartyTypeEnum.Party; } if (isFirstCombatant) { isFirstCombatant = false; CombatantEx.CopyToEx(ex, this.Player); } if (isNew) { addeds.Add(ex); dic[key] = ex; } if (ex.PartyType == PartyTypeEnum.Party) { partyIDList.Add(ex.ID); } } else { var ex = new CombatantEx(); CombatantEx.CopyToEx(combatant, ex); this.OtherList.Add(ex); } Thread.Yield(); } if (this.Player != null && this.Player.TargetID != 0 && this.MainDictionary.ContainsKey(this.Player.TargetID)) { var target = this.MainDictionary[this.Player.TargetID]; this.Player.TargetOfTargetID = target.TargetID; } if (partyIDList.Any()) { if (this.PartyCount <= 0 || this.PartyCount != partyIDList.Count) { this.RefreshPartyList(partyIDList); } } this.TryGarbage(); this.CombatantsPCCount = this.MainDictionary.Count(x => x.Value.ActorType == Actor.Type.PC); this.CombatantsMainCount = this.MainDictionary.Count; this.CombatantsOtherCount = this.OtherList.Count; return(addeds); }
private IEnumerable <CombatantEx> RefreshCore( IEnumerable <Combatant> source, bool isDummy = false) { var isFirstCombatant = true; var partyIDList = new List <uint>(32); var addeds = new List <CombatantEx>(128); this.OtherList.Clear(); var count = 0; var countPC = 0; var countOther = 0; foreach (var combatant in source) { var actorType = CombatantExtensions.GetActorType(combatant); switch (actorType) { // 必要なCombatant case Actor.Type.PC: countPC++; break; // 必要なCombatant case Actor.Type.Monster: case Actor.Type.NPC: case Actor.Type.Aetheryte: case Actor.Type.Gathering: case Actor.Type.EventObject: break; // 上記以外は捨てる default: Thread.Yield(); continue; } var isMain = actorType switch { Actor.Type.PC => true, Actor.Type.Monster => true, _ => false, }; if (isMain) { count++; var dic = this.MainDictionary; var key = combatant.ID; var ex = dic.AddOrUpdate( key, (key) => { var add = new CombatantEx(); CombatantEx.CopyToEx(combatant, add); addeds.Add(add); return(add); }, (key, current) => { CombatantEx.CopyToEx(combatant, current); return(current); }); if (isDummy) { ex.IsDummy = true; ex.PartyType = PartyType.Party; } if (isFirstCombatant) { isFirstCombatant = false; CombatantEx.CopyToEx(ex, this.Player); } if (ex.PartyType == PartyType.Party) { partyIDList.Add(ex.ID); } } else { countOther++; var ex = new CombatantEx(); CombatantEx.CopyToEx(combatant, ex); this.OtherList.Add(ex); } Thread.Yield(); } if (this.Player != null) { if (this.Player.TargetID != 0 && this.MainDictionary.ContainsKey(this.Player.TargetID)) { var target = this.MainDictionary[this.Player.TargetID]; this.Player.TargetOfTargetID = target.TargetID; } else { this.Player.TargetOfTargetID = 0; } } if (partyIDList.Any()) { if (this.PartyCount <= 0 || this.PartyCount != partyIDList.Count) { this.RefreshPartyList(partyIDList); } } this.TryGarbage(); this.CombatantsPCCount = countPC; this.CombatantsMainCount = count; this.CombatantsOtherCount = countOther; return(addeds); }