Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            // Whip up a proxy. This has a Target, but note that it is not
            // instantiated here because it is "costly". (We are imagining it to
            // be costly for demonstration purposes. If we weren't using a
            // proxy the ITarget would always be instantiated here which is
            // costly as stated before. There might also be a situation where
            // you aren't sure you're actually going to use the object and in
            // this situation you should only instantiate it if you're sure
            // your gonna use it (like right before you call its methods).

            ITarget proxy = new TargetProxy();

            // Lazy<TargetProxy> proxy = new Lazy<TargetProxy>(); // lazy version

            Console.WriteLine(
                "--- If lazy, proxy instantiated below. If not lazy, above ---");

            // Whip up a client
            Client client = new Client(proxy);

            // Client client = new Client(proxy.Value); // lazy version

            // Call the methods you want on your ITarget (which really go
            // through the proxy). Note Target is created here because we are
            // finally attempting to use it.
            client.UseTargetMethodThroughProxy();
            Console.WriteLine(Environment.NewLine);

            // Call it again, note Target is not created again.
            client.UseTargetMethodThroughProxy();
        }
Exemplo n.º 2
0
        public SimcraftImpl()
        {
            //Write("go!");
            try
            {
                dbc = Serializer.DeSerializeObject(FindDatabase());
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }

            spell_data_t[] a = new spell_data_t[dbc.Spells.Values.Count];
            dbc.Spells.Values.CopyTo(a, 0);

            foreach (var v in a)
            {
                dbc.Spells[v.id, v.token] = v;
            }

            Write("Count "+dbc.Spells.Count);

            Directory.CreateDirectory(SimcraftProfilePath);

            try
            {

                RoutineManager.Current = null;

                SimcNames.Populate();
                MainCache = new ProxyCacheEntry();
                inst = this;
                active_dot = new ActiveDot();
                //trinket = new TrinketProxy(() => StyxWoW.Me.ToUnit(), this);
                health = new HealthProxy(() => StyxWoW.Me.ToUnit());
                energy = new EnergyProxy(() => StyxWoW.Me.ToUnit());
                focus = new FocusProxy(() => StyxWoW.Me.ToUnit());
                chi = new ChiProxy(() => StyxWoW.Me.ToUnit());
                rage = new RageProxy(() => StyxWoW.Me.ToUnit());
                buff = new BuffProxy(() => StyxWoW.Me.ToUnit(), PlayerAuras);
                debuff = new DebuffProxy(() => conditionUnit);
                talent = new TalentProxy(() => StyxWoW.Me.ToUnit());
                cooldown = new CooldownProxy(() => StyxWoW.Me.ToUnit());
                spell = new SpellProxy(() => StyxWoW.Me.ToUnit());
                combo_points = new ComboPointProxy(() => StyxWoW.Me.ToUnit());

                target = new TargetProxy(() => conditionUnit);
                runic_power = new RunicPowerProxy(() => StyxWoW.Me.ToUnit());
                disease = new DiseaseProxy(this);
                blood = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Blood);
                unholy = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Unholy);
                frost = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Frost);
                death = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Death);
                glyph = new GlyphProxy(() => StyxWoW.Me.ToUnit());
                set_bonus = new SetBonusProxy();
                prev_gcd = new PrevGcdProxy();
                prev = new PrevGcdProxy();
                pet = new PetProxy("def");
                eclipse_energy = new EclipseProxy(() => StyxWoW.Me.ToUnit());
                mana = new ManaProxy(() => StyxWoW.Me.ToUnit());
                holy_power = new HolyPowerProxy(() => StyxWoW.Me.ToUnit());
                seal = new SealProxy();
                actions = new ActionProxy();
                stat = new StatProxy();
                obliterate = new ObliterateProxy();

                MainCache["gcd"].SetRetrievalDelegate(() =>
                {
                    var rem = (Decimal)SpellManager.GlobalCooldownLeft.TotalSeconds;
                    var g = BaseGcd();
                    g = g / ((100+spell_haste)/ 100);
                    return new Gcd((Decimal)_conditionSpell.gcd, Math.Max(g, 1), rem);
                });

                MainCache["GlobalCooldown"].SetRetrievalDelegate(() =>
                {
                    return SpellManager.GlobalCooldownLeft.TotalMilliseconds > 1000/15;
                });

                MainCache["WoWTime"].SetRetrievalDelegate(() =>
                {
                    return Lua.GetReturnVal<double>("return GetTime()",0);
                });

                var s = new spell_data_t();
                s.name = "Storm, Earth, and Fire";
                s.token = "storm_earth_and_fire";
                s.id = 138130;
                dbc.Spells.Add(138130, s);

                GenerateApls(SimcraftProfilePath);

                var settings = SimCSettings.currentSettings;
                if (settings.Specs.ContainsKey(Me.Specialization))
                {
                    var aplFileName = settings.Specs[Me.Specialization];
                    try
                    {
                        var apl = apls[aplFileName];
                        apl.CreateBehavior();
                        apl.PrintResolutionTable();
                        current_action_list = apl;
                    }
                    catch (KeyNotFoundException)
                    {
                        throw new ApplicationException(
                            string.Format("settings are incorrect for current spec {0}, it reference unexistent file {1}",
                            Me.Specialization, aplFileName));
                    }
                }
                else
                {
                    try
                    {
                        var apl = apls.Values.First(o => o.Class == Me.Class);
                        var filename = apls.Keys.First(k => apls[k] == apl);
                        settings.Specs[Me.Specialization] = filename;
                        SimCSettings.Save();
                        Write(string.Format("Settings does not tell which *.simc " +
                            "use for current spec({0}) so picking most appropriate: {1}",
                            Me.Specialization, filename));
                        apl.CreateBehavior();
                        apl.PrintResolutionTable();
                        current_action_list = apl;
                    }
                    catch (Exception)
                    {
                        throw new ApplicationException(
                            string.Format("There's not *.simc for current spec({0})",
                            Me.Specialization));
                    }
                }
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }
        }
Exemplo n.º 3
0
        public SimcraftImpl()
        {
            //Write("go!");
            try
            {
                dbc = Serializer.DeSerializeObject(FindDatabase());
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }

            spell_data_t[] a = new spell_data_t[dbc.Spells.Values.Count];
            dbc.Spells.Values.CopyTo(a, 0);

            foreach (var v in a)
            {
                dbc.Spells[v.id, v.token] = v;
            }

            Write("Count "+dbc.Spells.Count);

            Directory.CreateDirectory(SimcraftProfilePath);

            try
            {

                RoutineManager.Current = null;

                SimcNames.Populate();
                MainCache = new ProxyCacheEntry();
                inst = this;
                active_dot = new ActiveDot();
                //trinket = new TrinketProxy(() => StyxWoW.Me.ToUnit(), this);
                health = new HealthProxy(() => StyxWoW.Me.ToUnit());
                energy = new EnergyProxy(() => StyxWoW.Me.ToUnit());
                focus = new FocusProxy(() => StyxWoW.Me.ToUnit());
                chi = new ChiProxy(() => StyxWoW.Me.ToUnit());
                rage = new RageProxy(() => StyxWoW.Me.ToUnit());
                buff = new BuffProxy(() => StyxWoW.Me.ToUnit(), PlayerAuras);
                debuff = new DebuffProxy(() => conditionUnit);
                talent = new TalentProxy(() => StyxWoW.Me.ToUnit());
                cooldown = new CooldownProxy(() => StyxWoW.Me.ToUnit());
                spell = new SpellProxy(() => StyxWoW.Me.ToUnit());
                combo_points = new ComboPointProxy(() => StyxWoW.Me.ToUnit());

                target = new TargetProxy(() => conditionUnit);
                runic_power = new RunicPowerProxy(() => StyxWoW.Me.ToUnit());
                disease = new DiseaseProxy(this);
                blood = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Blood);
                unholy = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Unholy);
                frost = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Frost);
                death = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Death);
                glyph = new GlyphProxy(() => StyxWoW.Me.ToUnit());
                set_bonus = new SetBonusProxy();
                prev_gcd = new PrevGcdProxy();
                prev = new PrevGcdProxy();
                pet = new PetProxy("def");
                eclipse_energy = new EclipseProxy(() => StyxWoW.Me.ToUnit());
                mana = new ManaProxy(() => StyxWoW.Me.ToUnit());
                holy_power = new HolyPowerProxy(() => StyxWoW.Me.ToUnit());
                seal = new SealProxy();
                actions = new ActionProxy();
                stat = new StatProxy();
                obliterate = new ObliterateProxy();

                MainCache["gcd"].SetRetrievalDelegate(() =>
                {
                    var rem = (Decimal)SpellManager.GlobalCooldownLeft.TotalSeconds;
                    var g = BaseGcd();
                    g = g / ((100+spell_haste)/ 100);
                    return new Gcd((Decimal)_conditionSpell.gcd, Math.Max(g, 1), rem);
                });

                MainCache["GlobalCooldown"].SetRetrievalDelegate(() =>
                {
                    return SpellManager.GlobalCooldownLeft.TotalMilliseconds > 1000/15;
                });

                MainCache["WoWTime"].SetRetrievalDelegate(() =>
                {
                    return Lua.GetReturnVal<double>("return GetTime()",0);
                });

                var s = new spell_data_t();
                s.name = "Storm, Earth, and Fire";
                s.token = "storm_earth_and_fire";
                s.id = 138130;
                dbc.Spells.Add(138130, s);

            }
            catch (Exception e)
            {
                Write(e.ToString());
            }
        }
Exemplo n.º 4
0
        public SimcraftImpl()
        {
            //Write("go!");
            try
            {
                dbc = Serializer.DeSerializeObject(FindDatabase());
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }

            spell_data_t[] a = new spell_data_t[dbc.Spells.Values.Count];
            dbc.Spells.Values.CopyTo(a, 0);

            foreach (var v in a)
            {
                dbc.Spells[v.id, v.token] = v;
            }

            Write("Count " + dbc.Spells.Count);

            Directory.CreateDirectory(SimcraftProfilePath);

            try
            {
                RoutineManager.Current = null;

                SimcNames.Populate();
                MainCache  = new ProxyCacheEntry();
                inst       = this;
                active_dot = new ActiveDot();
                //trinket = new TrinketProxy(() => StyxWoW.Me.ToUnit(), this);
                health       = new HealthProxy(() => StyxWoW.Me.ToUnit());
                energy       = new EnergyProxy(() => StyxWoW.Me.ToUnit());
                focus        = new FocusProxy(() => StyxWoW.Me.ToUnit());
                chi          = new ChiProxy(() => StyxWoW.Me.ToUnit());
                rage         = new RageProxy(() => StyxWoW.Me.ToUnit());
                buff         = new BuffProxy(() => StyxWoW.Me.ToUnit(), PlayerAuras);
                debuff       = new DebuffProxy(() => conditionUnit);
                talent       = new TalentProxy(() => StyxWoW.Me.ToUnit());
                cooldown     = new CooldownProxy(() => StyxWoW.Me.ToUnit());
                spell        = new SpellProxy(() => StyxWoW.Me.ToUnit());
                combo_points = new ComboPointProxy(() => StyxWoW.Me.ToUnit());

                target         = new TargetProxy(() => conditionUnit);
                runic_power    = new RunicPowerProxy(() => StyxWoW.Me.ToUnit());
                disease        = new DiseaseProxy(this);
                blood          = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Blood);
                unholy         = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Unholy);
                frost          = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Frost);
                death          = new RuneProxy(() => StyxWoW.Me.ToUnit(), RuneType.Death);
                glyph          = new GlyphProxy(() => StyxWoW.Me.ToUnit());
                set_bonus      = new SetBonusProxy();
                prev_gcd       = new PrevGcdProxy();
                prev           = new PrevGcdProxy();
                pet            = new PetProxy("def");
                eclipse_energy = new EclipseProxy(() => StyxWoW.Me.ToUnit());
                mana           = new ManaProxy(() => StyxWoW.Me.ToUnit());
                holy_power     = new HolyPowerProxy(() => StyxWoW.Me.ToUnit());
                seal           = new SealProxy();
                actions        = new ActionProxy();
                stat           = new StatProxy();
                obliterate     = new ObliterateProxy();

                MainCache["gcd"].SetRetrievalDelegate(() =>
                {
                    var rem = (Decimal)SpellManager.GlobalCooldownLeft.TotalSeconds;
                    var g   = BaseGcd();
                    g       = g / ((100 + spell_haste) / 100);
                    return(new Gcd((Decimal)_conditionSpell.gcd, Math.Max(g, 1), rem));
                });

                MainCache["GlobalCooldown"].SetRetrievalDelegate(() =>
                {
                    return(SpellManager.GlobalCooldownLeft.TotalMilliseconds > 1000 / 15);
                });

                MainCache["WoWTime"].SetRetrievalDelegate(() =>
                {
                    return(Lua.GetReturnVal <double>("return GetTime()", 0));
                });


                var s = new spell_data_t();
                s.name  = "Storm, Earth, and Fire";
                s.token = "storm_earth_and_fire";
                s.id    = 138130;
                dbc.Spells.Add(138130, s);
            }
            catch (Exception e)
            {
                Write(e.ToString());
            }
        }