コード例 #1
0
ファイル: FFXIVPluginHelper.cs プロジェクト: sqt/cactbot
 private static void SetCombatantInfo(Combatant combatant, string propertyName, object obj, string fieldName)
 {
     FieldInfo fi = obj.GetType().GetField(fieldName, BindingFlags.Public | BindingFlags.Instance);
     PropertyInfo propertyInfo = combatant.GetType().GetProperty(propertyName);
     propertyInfo.SetValue(combatant, Convert.ChangeType(fi.GetValue(obj), propertyInfo.PropertyType), null);
 }
コード例 #2
0
ファイル: BrowserBindings.cs プロジェクト: sqt/cactbot
 private static bool CombatantIsMob(Combatant c)
 {
     // Not a pet, not a player.
     return c.OwnerID == 0 && c.Job == 0;
 }
コード例 #3
0
ファイル: FFXIVPluginHelper.cs プロジェクト: sqt/cactbot
        public static List<Combatant> GetCombatantList()
        {
            List<Combatant> result = new List<Combatant>();
            try
            {
                var scanCombatants = GetScanCombatants();
                if (scanCombatants == null) return null;

                var item = scanCombatants.GetType().InvokeMember("GetCombatantList", BindingFlags.Public | BindingFlags.Instance | BindingFlags.InvokeMethod, null, scanCombatants, null);
                FieldInfo fi = item.GetType().GetField("_items", BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.GetField);

                Type[] nestedType = item.GetType().GetNestedTypes(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public);
                object tmp = fi.GetValue(item);
                if (tmp.GetType().IsArray)
                {
                    foreach (object temp in (Array)tmp)
                    {
                        if (temp == null)
                            break;

                        Combatant combatant = new Combatant();

                        SetCombatantInfo(combatant, "ID", temp, "ID");
                        SetCombatantInfo(combatant, "OwnerID", temp, "OwnerID");
                        SetCombatantInfo(combatant, "Job", temp, "Job");
                        SetCombatantInfo(combatant, "Name", temp, "Name");
                        SetCombatantInfo(combatant, "CurrentHP", temp, "CurrentHP");
                        SetCombatantInfo(combatant, "CurrentMP", temp, "CurrentMP");
                        SetCombatantInfo(combatant, "CurrentTP", temp, "CurrentTP");
                        SetCombatantInfo(combatant, "MaxHP", temp, "MaxHP");
                        SetCombatantInfo(combatant, "MaxMP", temp, "MaxMP");
                        SetCombatantInfo(combatant, "MaxTP", temp, "MaxTP");
                        SetCombatantInfo(combatant, "PosX", temp, "PosX");
                        SetCombatantInfo(combatant, "PosY", temp, "PosY");
                        SetCombatantInfo(combatant, "PosZ", temp, "PosZ");

                        result.Add(combatant);
                    }
                }
            }
            catch { }
            return result;
        }