Exemplo n.º 1
0
        public void RefreshCombatantList()
        {
            if (!this.IsAvalable)
            {
                return;
            }

            var newList       = new List <Combatant>();
            var newDictionary = new Dictionary <uint, Combatant>();

            dynamic list = this.pluginScancombat.GetCombatantList();

            foreach (dynamic item in list.ToArray())
            {
                if (item == null)
                {
                    continue;
                }

                var combatant = new Combatant();

                combatant.ID        = (uint)item.ID;
                combatant.OwnerID   = (uint)item.OwnerID;
                combatant.Job       = (int)item.Job;
                combatant.type      = (byte)item.type;
                combatant.Level     = (int)item.Level;
                combatant.CurrentHP = (int)item.CurrentHP;
                combatant.MaxHP     = (int)item.MaxHP;
                combatant.CurrentMP = (int)item.CurrentMP;
                combatant.MaxMP     = (int)item.MaxMP;
                combatant.CurrentTP = (int)item.CurrentTP;

                // 名前を登録する
                // TYPEによって分岐するため先にTYPEを設定しておくこと
                combatant.SetName((string)item.Name);

                newList.Add(combatant);
                newDictionary.Add(combatant.ID, combatant);
            }

            lock (this.combatantListLock)
            {
                this.combatantList       = newList;
                this.combatantDictionary = newDictionary;
            }
        }
Exemplo n.º 2
0
        public void RefreshCombatantList()
        {
            if (!this.IsAvalable)
            {
#if DEBUG
                lock (this.combatantListLock)
                {
                    foreach (var entity in this.DummyCombatants)
                    {
                        entity.SetName(entity.Name);
                    }

                    this.combatantList       = this.DummyCombatants;
                    this.combatantDictionary = this.DummyCombatants.ToDictionary(x => x.ID);
                }
#endif

                return;
            }

            dynamic list  = this.pluginScancombat.GetCombatantList();
            var     count = (int)list.Count;

            var newList       = new List <Combatant>(count);
            var newDictionary = new Dictionary <uint, Combatant>(count);

            foreach (dynamic item in list.ToArray())
            {
                if (item == null)
                {
                    continue;
                }

                var combatant = new Combatant();

                combatant.ID        = (uint)item.ID;
                combatant.OwnerID   = (uint)item.OwnerID;
                combatant.Job       = (int)item.Job;
                combatant.type      = (byte)item.type;
                combatant.Level     = (int)item.Level;
                combatant.CurrentHP = (int)item.CurrentHP;
                combatant.MaxHP     = (int)item.MaxHP;
                combatant.CurrentMP = (int)item.CurrentMP;
                combatant.MaxMP     = (int)item.MaxMP;
                combatant.CurrentTP = (int)item.CurrentTP;

                var name = (string)item.Name;

                // 名前を登録する
                // TYPEによって分岐するため先にTYPEを設定しておくこと
                combatant.SetName(name);

                newList.Add(combatant);
                newDictionary.Add(combatant.ID, combatant);
            }

            lock (this.combatantListLock)
            {
                this.combatantList       = null;
                this.combatantDictionary = null;

                this.combatantList       = newList;
                this.combatantDictionary = newDictionary;
            }
        }