GetObjects() 공개 정적인 메소드

public static GetObjects ( ) : GameObject>.Dictionary
리턴 GameObject>.Dictionary
        public void UpdateObjectTree()
        {
            MainWindow.mainWindow.ObjectTree.Children.Clear();

            foreach (GameObject obj in objectManager.GetObjects())
            {
                MapGameObject mapObject = obj as MapGameObject;

                if (mapObject != null)
                {
                    CheckBoxPair checkPair = new CheckBoxPair();
                    string       name      = "";

                    foreach (KeyValuePair <string, GameObjectProperty> property in mapObject.Properties)
                    {
                        if (property.Key == "Name")
                        {
                            name = property.Value.CurrentValue;
                        }
                    }

                    checkPair.MainLabel.Text = name;

                    checkPair.MainCheckBox.IsChecked = mapObject.Visible;

                    checkPair.MainCheckBox.Click += (sender, e) =>
                    {
                        mapObject.Visible = (bool)checkPair.MainCheckBox.IsChecked;
                    };

                    MainWindow.mainWindow.ObjectTree.Children.Add(checkPair);
                }
            }
        }
    private Tree FindTree(Vector3 manPosition)
    {
        var trees = ObjectManager.GetObjects(ObjectType.TREE);

        var nearestTree = trees[0];
        var minDistance = Vector3.Distance(nearestTree.transform.position, manPosition);

        foreach (var tree in trees)
        {
            var treeComponent = tree.GetComponent <Tree>();
            if (!treeComponent.CanBeMoreWorkers())
            {
                continue;
            }

            var distance = Vector3.Distance(tree.transform.position, manPosition);
            if (distance < minDistance)
            {
                nearestTree = tree;
                minDistance = distance;
            }
        }

        return(nearestTree.GetComponent <Tree>());
    }
예제 #3
0
    public static WorldData EncodeWorldData(ObjectManager manager, EventLibrary library)
    {
        string ids = "";
        foreach (IHasState obj in manager.GetObjects())
            ids += ((Component)obj).gameObject.name + ": " + obj.Id + "\n";
        Debug.Log(ids);

        StateData initialState = 
            new StateData(
                new WorldState(
                    manager.GetObjects().Cast<IHasState>()));
        EventData[] events = 
            library.GetSignatures().Convert(s => new EventData(s)).ToArray();

        return new WorldData(initialState, events);
    }
예제 #4
0
 private void Awake()
 {
     manager      = FindObjectOfType <ObjectManager>();
     imageManager = FindObjectOfType <SelectedObjectHighlight>();
     objects      = manager.GetObjects();
     objectImages = imageManager.GetImages();
     render       = GetComponentInChildren <SpriteRenderer>();
 }
예제 #5
0
        private void buttonLocateInstances_Click(object sender, EventArgs e)
        {
            if (!File.Exists(WorldImport.Instance.WorldFile))
            {
                MessageBox.Show("Need a valid world to search from.");
                return;
            }
            List <WorldImport.ObjectInstance> list = WorldImport.Instance.FindInstances(this.m_currentEntry.IdString);

            if (list.Count == 0)
            {
                MessageBox.Show("No instance of this entry could be found.");
                return;
            }
            using (WorldLocateInstanceForm worldLocateInstanceForm = new WorldLocateInstanceForm())
            {
                worldLocateInstanceForm.Instances = list;
                if (worldLocateInstanceForm.ShowDialog(this) == DialogResult.OK)
                {
                    WorldImport.ObjectInstance selectedInstance = worldLocateInstanceForm.SelectedInstance;
                    if (selectedInstance != null)
                    {
                        int num  = selectedInstance.sectorX - 3;
                        int num2 = selectedInstance.sectorY - 3;
                        if (WorldImport.Instance.ImportWorld(num, num2, (!string.IsNullOrEmpty(selectedInstance.layer)) ? new string[]
                        {
                            selectedInstance.layer
                        } : new string[0]))
                        {
                            Vec3 v = new Vec3(selectedInstance.localX, selectedInstance.localY, selectedInstance.localZ);
                            v.X += (float)((selectedInstance.sectorX - num) * 64);
                            v.Y += (float)((selectedInstance.sectorY - num2) * 64);
                            foreach (EditorObject current in ObjectManager.GetObjects())
                            {
                                if (current.IsValid && current.Entry.Id == this.m_currentEntry.Id)
                                {
                                    Vec3 position = current.Position;
                                    if ((position - v).Length <= 0.1f)
                                    {
                                        MainForm.Instance.CurrentTool = ToolObject.Instance;
                                        ToolObject.Instance.SwitchMode(ToolObject.Instance.MoveModeObj);
                                        EditorObjectSelection selection = EditorObjectSelection.Create();
                                        selection.AddObject(current);
                                        ToolObject.Instance.SetSelection(selection, current);
                                        Camera.Focus(current);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            ContentLoader.LoadTexture("Ryu Intro Sheet", Texture2D.FromStream(GraphicsDevice, File.Open("Ryu Intro Sheet.png", FileMode.Open)));

            // Test, remove later.
            GameObjectAnimated ryuIntro = new GameObjectAnimated();

            ryuIntro.CurrentAnimation = Animation.ReadAnimationFile("intro_ryu_idle.pcaf");
            ryuIntro.CurrentAnimation.Play();

            objManager.GetObjects().Add(ryuIntro);

            GameCamera MainCamera = new GameCamera(new Rectangle(0, 0, 256, 224))
            {
                IsEnabled = true
            };

            objManager.GetObjects().Add(MainCamera);

            GraphicsDevice.PresentationParameters.RenderTargetUsage = RenderTargetUsage.PreserveContents;

            base.Initialize();
        }
예제 #7
0
        public static List <TorCharacter> GetTorCharacters()
        {
            using (BuddyTor.Memory.AcquireFrame())
            {
                //List<TorCharacter> objects = ObjectManager.GetObjects<TorCharacter>().ToList();

                /*
                 * if (Me.Companion != null)
                 * objects.Add(Me.Companion);
                 */
                var npcs    = ObjectManager.GetObjects <TorNpc>();
                var objects = npcs.Cast <TorCharacter>().ToList();

                return(objects);
            }
        }
        public static IEnumerable <TorPlayer> PartyPlayers(this TorPlayer torPlayer,
                                                           TorPlayerPredicateDelegate playerQualifier = null)
        {
            playerQualifier = playerQualifier ?? (ctx => true);             // resolve playerQualifier to something sane

            var playerGroupId = torPlayer.GroupId;

            // If we're solo, only have the torPlayer on the list...
            // We can't build this list using the 'normal' query, as all solo players have the common GroupId of zero.
            // We don't want a list of 'solo' players (what the normal query would do), we want a list with only the solo torPlayer on it.
            if (playerGroupId == 0)
            {
                return(ObjectManager.GetObjects <TorPlayer>().Where(p => (p == BuddyTor.Me) && playerQualifier(p)));
            }

            // NB: IsInParty() is implemented in terms of PartyPlayers().  Be careful not to implement this method in terms of
            // IsInParty(); otherwise, infinite recursive descent will occur.
            return
                (ObjectManager.GetObjects <TorPlayer>().Where(p => !p.IsDeleted && playerQualifier(p) && (p.GroupId == playerGroupId)));
        }
예제 #9
0
    void Update()
    {
        if (queue.notEmpty())
        {
            CallResponse call = queue.remove();

            try{
                //Debug.Log("Trying to eval '" + call.getCall() + "'");

                if (call.getCall().Equals("\n"))
                {
                    call.setResponse("");
                }
                else
                {
                    if (!call.getCall().StartsWith("util."))
                    {
                        TraceLogger.LogTrace(call.getCall());
                    }

                    object ret = Eval.eval(call.getCall(), ObjectManager.GetObjects(), new Util());

                    string response = "";
                    if (ret != null)
                    {
                        response = ret.ToString();
                    }

                    //Debug.Log("Response was " + response);
                    call.setResponse(response);
                }
                call.respond();
            } catch (Exception e) {
                Debug.Log(e.Message);
                Debug.Log(e.StackTrace);
                call.setResponse("Error: " + e.ToString().Replace("\n", ""));
                TraceLogger.LogError(call.getResponse());
                call.respond();
            }
        }
    }
예제 #10
0
        public static List <TorCharacter> GetTorCharacters()
        {
            using (BuddyTor.Memory.AcquireFrame())
            {
                //List<TorCharacter> objects = ObjectManager.GetObjects<TorCharacter>().ToList();

                /*
                 * if (Me.Companion != null)
                 * objects.Add(Me.Companion);
                 */
                var npcs    = ObjectManager.GetObjects <TorNpc>();
                var objects = npcs.Cast <TorCharacter>().ToList();

                if (DefaultCombat.IsHealer)
                {
                    var players = ObjectManager.GetObjects <TorPlayer>();

                    objects.AddRange(players);
                }

                return(objects);
            }
        }
예제 #11
0
        public void Search(float startingX, float startingY, float startingZ)
        {
            float targetX, targetY, targetZ, dX, dY, dZ, distance;

            if (settings.Mining || settings.Herbing)
            {
                objectManager.PopulateList();
                foreach (WorkWork.Memory.Object obj in objectManager.GetObjects())
                {
                    if (obj.Type == 5)
                    {
                        string name = magic.ReadASCIIString(magic.ReadUInt(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectNameOffset1) + (uint)TbcOffsets.ObjectOffsets.GameObjectNameOffset2), 40);
                        if (settings.Herbing)
                        {
                            foreach (string herb in Herbs)
                            {
                                if (name.ToLower().Contains(herb))
                                {
                                    targetX  = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetX);
                                    targetY  = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetY);
                                    targetZ  = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetZ);
                                    dX       = targetX - startingX;
                                    dY       = targetY - startingY;
                                    dZ       = targetZ - startingZ;
                                    distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ);
                                    if (distance <= 30)
                                    {
                                        bot.GetPathing.WalkToPoint(targetX, targetY, targetZ, true, startingX, startingY, startingZ);
                                        bot.GetOther.Interact();
                                        bot.GetPathing.WalkToPoint(startingX, startingY, startingZ, true, targetX, targetY, targetZ);
                                        return;
                                    }
                                }
                            }
                        }
                        if (settings.Mining)
                        {
                            foreach (string node in Nodes)
                            {
                                if (name.Contains(node))
                                {
                                    targetX  = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetX);
                                    targetY  = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetY);
                                    targetZ  = magic.ReadFloat(magic.ReadUInt(obj.BaseAddress + (uint)TbcOffsets.ObjectOffsets.GameObjectOffset) + (uint)TbcOffsets.ObjectOffsets.GameObjectOffsetZ);
                                    dX       = targetX - startingX;
                                    dY       = targetY - startingY;
                                    dZ       = targetZ - startingZ;
                                    distance = (float)Math.Sqrt(dX * dX + dY * dY + dZ * dZ);
                                    if (distance <= 30)
                                    {
                                        bot.GetPathing.WalkToPoint(targetX, targetY, targetZ, true, startingX, startingY, startingZ);
                                        bot.GetOther.Interact();
                                        bot.GetPathing.WalkToPoint(startingX, startingY, startingZ, true, targetX, targetY, targetZ);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #12
0
파일: Combat.cs 프로젝트: nirinium/WorkWork
        public bool CombatMode()
        {
            ulong target = magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid);
            bool  stuck  = false;
            //Investigate
            bool combatSuccessful = false;

            if (target == 0)
            {
                keyboardSim.KeyDown(targetKey);

                keyboardSim.KeyUp(targetKey);
            }
            else
            {
                objectManager.PopulateList();
                List <WorkWork.Memory.Object> objs = objectManager.GetObjects();
                for (int i = 0; i < objs.Count; i++)
                {
                    WorkWork.Memory.Object obj = objs[i];
                    int type = obj.Type;
                    if ((type == 4 && !settings.IgnorePlayers) || (type == 3 && !settings.IgnoreMobs))
                    {
                        ulong guid = obj.Guid;
                        if (target == guid && obj.Health > 0 && !stuck)
                        {
                            if (type == 3)
                            {
                                string name = obj.Name;
                                foreach (String ignoredMob in profile.GetIgnoredMobs())
                                {
                                    if (name == ignoredMob)
                                    {
                                        stuck = true;
                                        keyboardSim.KeyDown(targetKey);

                                        keyboardSim.KeyUp(targetKey);
                                    }
                                }
                            }
                            foreach (WorkWork.Memory.Object ignoredObjects in ignoredMobs)
                            {
                                if (ignoredObjects.Guid == guid)
                                {
                                    stuck = true;
                                    keyboardSim.KeyDown(targetKey);

                                    keyboardSim.KeyUp(targetKey);
                                }
                                else
                                {
                                    foreach (ulong ignoredMobGuid in profile.getIgnoredMobsGuid)
                                    {
                                        if (guid == ignoredMobGuid)
                                        {
                                            stuck = true;
                                            keyboardSim.KeyDown(targetKey);

                                            keyboardSim.KeyUp(targetKey);
                                        }
                                    }
                                }
                            }

                            var watch        = Stopwatch.StartNew();
                            int startingHP   = objectManager.GetPlayer().Health;
                            int startingMP   = objectManager.GetPlayer().Mana;
                            int currentCombo = 0;
                            while (obj.Health > 0 && !halt && !stuck)
                            {
                                currentCombo = DpsRotation(obj, currentCombo);
                                if (AutoAttack() && objectManager.GetPlayer().Health > 0)
                                {
                                    bot.GetPathing.WalkToMob(obj, 5);
                                }
                                if (watch.ElapsedMilliseconds > averageTime * 3 && averageTime > 0)
                                {
                                    ignoredMobs.Add(obj);
                                    stuck = true;
                                }
                                if (halt || (objectManager.GetPlayer().Health <= 0) || bot.GetPathing.Dead || magic.ReadFloat((uint)TbcOffsets.General.PlayerCorpseX) != 0)
                                {
                                    stuck = true;
                                }
                            }
                            watch.Stop();
                            if (!stuck)
                            {
                                int counter;
                                int endingHP = objectManager.GetPlayer().Health;
                                if (endingHP < startingHP)
                                {
                                    endingHP  = startingHP - endingHP;
                                    endingHP += endingHP / 2;
                                    healthPerMob[hpCounter] = endingHP;
                                    hpCounter++;
                                    if (hpCounter == 10)
                                    {
                                        hpCounter = 0;
                                    }
                                    counter           = 0;
                                    bot.AverageHealth = 0;
                                    foreach (int hp in healthPerMob)
                                    {
                                        if (hp > 0)
                                        {
                                            counter++;
                                            bot.AverageHealth += hp;
                                        }
                                    }
                                    if (counter > 0)
                                    {
                                        bot.AverageHealth /= counter;
                                    }
                                }
                                if (objectManager.GetPlayer().MaxMana > 0)
                                {
                                    int endingMP = objectManager.GetPlayer().Mana;
                                    if (endingMP < startingMP)
                                    {
                                        endingMP  = startingMP - endingMP;
                                        endingMP += endingMP / 2;
                                        manaPerMob[mpCounter] = endingMP;
                                        mpCounter++;
                                        if (mpCounter == 10)
                                        {
                                            mpCounter = 0;
                                        }
                                        counter         = 0;
                                        bot.AverageMana = 0;
                                        foreach (int mp in manaPerMob)
                                        {
                                            if (mp > 0)
                                            {
                                                counter++;
                                                bot.AverageMana += mp;
                                            }
                                        }
                                        if (counter > 0)
                                        {
                                            bot.AverageMana /= counter;
                                        }
                                    }
                                }
                                if (magic.ReadUInt(magic.ReadUInt((uint)TbcOffsets.General.PlayerBase) + (uint)TbcOffsets.General.CombatStateOffset) == (int)TbcOffsets.CombatState.InCombat && magic.ReadUInt64((uint)TbcOffsets.General.TargetGuid) != 0)
                                {
                                    CombatMode();
                                }

                                timePerMob[timeCounter] = watch.ElapsedMilliseconds;
                                timeCounter++;
                                if (timeCounter == 10)
                                {
                                    timeCounter = 0;
                                }
                                averageTime = 0;
                                counter     = 0;
                                foreach (long temp in timePerMob)
                                {
                                    if (temp > 0)
                                    {
                                        counter++;
                                        averageTime += temp;
                                    }
                                }
                                if (counter > 0)
                                {
                                    averageTime /= counter;
                                }
                                if (objectManager.GetPlayer().Health > 0)
                                {
                                    if (settings.Looting)
                                    {
                                        bot.GetPathing.WalkToMob(obj, 3);
                                        bot.GetOther.Interact();
                                        if (settings.Skinning)
                                        {
                                            bot.GetOther.Interact();
                                        }
                                    }
                                    combatSuccessful = true;
                                    bot.MobsKilled++;
                                    statistics.Changed = true;
                                    bot.GetOther.Regen();
                                    afterCombatSpells(currentCombo, "aftercombat");
                                }
                            }
                            break;
                        }
                        else if (target == guid && obj.Health <= 0)
                        {
                            keyboardSim.KeyDown(targetKey);
                            keyboardSim.KeyUp(targetKey);
                            break;
                        }
                    }
                }
            }


            return(combatSuccessful);
        }
예제 #13
0
        public override void OnStart()
        {
            RotationSpell l_Spell;

            m_RotationBook = new RotationBook();

            if (WoW.ObjectManager.ActivePlayer.Specialization == WowPlayer.Specializations.MageFire)
            {
                Console.WriteLine("[Mage] Loading fire rotation book ...");

                // Pyroblast when Hot Streak proc
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.Pyroblast);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.HasAura((int)Auras.HotStreak));

                // Fireball
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.Fireball);
                l_Spell.Match = MatchType.MatchAll;
            }
            else if (WoW.ObjectManager.ActivePlayer.Specialization == WowPlayer.Specializations.MageArcane)
            {
                Console.WriteLine("[Mage] Loading arcane rotation book ...");
                #region Arcane

                // Arcane Familiar
                l_Spell                 = m_RotationBook.AddSpell("Combat", (int)Spells.ArcaneFamiliar);
                l_Spell.CastOn          = EvaluedUnitType.SelfPlayer;
                l_Spell.Match           = MatchType.MatchAll;
                l_Spell.CancelOtherCast = true;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && !p_Unit.HasAura((int)Auras.ArcaneFamiliar));

                // Invisibility if HP < 30%
                l_Spell                 = m_RotationBook.AddSpell("Combat", (int)Spells.Invisibility);
                l_Spell.CastOn          = EvaluedUnitType.SelfPlayer;
                l_Spell.Match           = MatchType.MatchAll;
                l_Spell.CancelOtherCast = true;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.HealthPercent < 30);

                // Evocation if Mana <= 20%
                l_Spell        = m_RotationBook.AddSpell("Combat", (int)Spells.Evocation);
                l_Spell.CastOn = EvaluedUnitType.SelfPlayer;
                l_Spell.Match  = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.GetPowerPercent(WowUnit.PowerType.Mana) <= 20);

                // Arcane Power
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.ArcanePower);
                l_Spell.CastOn        = EvaluedUnitType.SelfPlayer;
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;

                // Time Warp
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.TimeWarp);
                l_Spell.CastOn        = EvaluedUnitType.SelfPlayer;
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;

                // Mirror Image
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.MirrorImage);
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && p_Unit.HealthPercent > 20);

                // Rune of Power
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.RuneOfPower);
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && p_Unit.Position.Distance3D(ObjectManager.ActivePlayer.Position) - p_Unit.CombatReach < 45);

                // Arcane Missiles on proc
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.ArcaneMissiles);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.HasAura((int)Auras.ArcaneMissiles));

                // Nether Tempest
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.NetherTempest);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && !p_Unit.HasAura((int)Auras.NetherTempest));

                // Charged Up
                l_Spell        = m_RotationBook.AddSpell("Combat", (int)Spells.ChargedUp);
                l_Spell.Match  = MatchType.MatchAll;
                l_Spell.CastOn = EvaluedUnitType.SelfPlayer;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.GetPower(WowUnit.PowerType.ArcaneCharges) == 0);

                // Arcane Barrage on 4 charges
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.ArcaneBarrage);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.GetPower(WowUnit.PowerType.ArcaneCharges) >= 4);

                // Arcane Orb when more than 2 adds (including current target) are in front of player
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.ArcaneOrb);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                p_Unit.IsFacingHeading(x.Position, 0.8f) &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 40.0f &&
                                                                                x.CanAttack) > 2);

                // Ring of Frost when more than 2 adds (including current target)
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.RingOfFrost);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.IsAoE = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 10.0f &&
                                                                                x.CanAttack) > 2);

                // Supernova when more than 2 adds (including current target)
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.Supernova);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 8.0f &&
                                                                                x.CanAttack) > 2);

                // Arcane Blast
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.ArcaneBlast);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.GetPower(WowUnit.PowerType.ArcaneCharges) < 4);

                #endregion
            }
            else if (WoW.ObjectManager.ActivePlayer.Specialization == WowPlayer.Specializations.MageFrost)
            {
                Console.WriteLine("[Mage] Loading frost rotation book ...");
                #region Frost

                // Invisibility if HP < 30%
                l_Spell                 = m_RotationBook.AddSpell("Combat", (int)Spells.Invisibility);
                l_Spell.CastOn          = EvaluedUnitType.SelfPlayer;
                l_Spell.Match           = MatchType.MatchAll;
                l_Spell.CancelOtherCast = true;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.HealthPercent < 30);

                // Icy Veins
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.IcyVeins);
                l_Spell.CastOn        = EvaluedUnitType.SelfPlayer;
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;

                // Time Warp
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.TimeWarp);
                l_Spell.CastOn        = EvaluedUnitType.SelfPlayer;
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;

                // Mirror Image
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.MirrorImage);
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && p_Unit.HealthPercent > 20);

                // Rune of Power
                l_Spell               = m_RotationBook.AddSpell("Combat", (int)Spells.RuneOfPower);
                l_Spell.Match         = MatchType.MatchAll;
                l_Spell.IsBigCooldown = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && p_Unit.Position.Distance3D(ObjectManager.ActivePlayer.Position) - p_Unit.CombatReach < 45);

                // Flurry when Brain Freeze proc
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.Flurry);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.HasAura((int)Auras.BrainFreeze));

                // Ice Lance when Fingers of Frost proc
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.IceLance);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null && p_Unit.HasAura((int)Auras.FingersOfFrost));

                // Cone of Cold when more than 2 adds (including current target) are in front of player
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.ConeOfCold);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && ObjectManager.ActivePlayer.IsFacingHeading(p_Unit.Position));
                l_Spell.AddEvaluator(EvaluedUnitType.SelfPlayer, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                p_Unit.IsFacingHeading(x.Position) &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 10.0f &&
                                                                                x.CanAttack) > 2);

                // Frozen Orb when more than 2 adds (including current target)
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.FrozenOrb);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 8.0f &&
                                                                                x.CanAttack) > 2);

                // Comet Storm when more than 2 adds (including current target)
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.CometStorm);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.IsAoE = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 5.0f &&
                                                                                x.CanAttack) > 2);

                // Blizzard when more than 2 adds (including current target)
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.Blizzard);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.IsAoE = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 8.0f &&
                                                                                x.CanAttack) > 2);

                // Ice Nova when more than 2 adds (including current target)
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.IceNova);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 8.0f &&
                                                                                x.CanAttack) > 2);

                // Ring of Frost when more than 2 adds (including current target)
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.RingOfFrost);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.IsAoE = true;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null &&
                                     ObjectManager.GetObjects <WowUnit>().Count(x =>
                                                                                !x.IsDead &&
                                                                                x.Position.Distance3D(p_Unit.Position) - x.CombatReach < 10.0f &&
                                                                                x.CanAttack) > 2);

                // Glacial Spike
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.GlacialSpike);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && p_Unit.HealthPercent > 20);

                // Ray of Frost
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.RayOfFrost);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => p_Unit != null && p_Unit.HealthPercent > 20);

                // Frostbolt
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.FrostBolt);
                l_Spell.Match = MatchType.MatchAll;

                #endregion
            }
            else
            {
                Console.WriteLine("[Mage] Loading no spec rotation book");
                #region NoSpec

                // Frostbolt
                l_Spell       = m_RotationBook.AddSpell("Combat", (int)Spells.FrostBolt);
                l_Spell.Match = MatchType.MatchAll;
                l_Spell.AddEvaluator(EvaluedUnitType.EvaluedUnit, p_Unit => ObjectManager.ActivePlayer.IsFacingHeading(p_Unit.Position));

                #endregion
            }
        }