Beispiel #1
0
        public static void SetSkillName(
            CombatantEx combatant)
        {
            if (combatant == null)
            {
                return;
            }

            if (combatant.ActorType != Actor.Type.PC &&
                combatant.ActorType != Actor.Type.Monster)
            {
                combatant.CastSkillName = string.Empty;
                return;
            }

            var skills = XIVPluginHelper.Instance.SkillList;

            if (combatant.IsCasting)
            {
                if (skills != null &&
                    skills.ContainsKey((uint)combatant.CastBuffID))
                {
                    var skill = skills[(uint)combatant.CastBuffID];
                    combatant.CastSkillName = skill.Name;
                    combatant.CastSkillType = skill.AttackType;
                }
                else
                {
                    combatant.CastSkillName =
                        $"UNKNOWN:{combatant.CastBuffID}";
                }
            }
            else
            {
                combatant.CastSkillName = string.Empty;
            }
        }
Beispiel #2
0
 public static Actor.Type GetActorType(
     CombatantEx c)
 => ParseOrDefaultToActorType(c?.Type ?? 0);
Beispiel #3
0
        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);
        }
Beispiel #4
0
 public static double GetHorizontalDistance(CombatantEx from, CombatantEx to) =>
 Math.Round(
     (double)Math.Sqrt(
         Math.Pow(from.PosX - to.PosX, 2) +
         Math.Pow(from.PosY - to.PosY, 2)),
     1, MidpointRounding.AwayFromZero);
        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);
        }