Exemplo n.º 1
0
    public bool b(int A_0, c A_1)
    {
        ev cq = PluginCore.cq;

        if (!cq.n.f.ContainsKey(A_0))
        {
            return(false);
        }
        if (!dh.a(A_0))
        {
            return(false);
        }
        cf local1 = cq.n.f[A_0];

        aj.c c = cq.d.a(PluginCore.cq.p.d(A_0));
        MyQuad <int, eDamageElement, ePrismaticDamageBehavior, int> quad = null;

        if (c.g)
        {
            quad = A_1.a();
        }
        TimeSpan span = TimeSpan.FromSeconds((double)er.i("DebuffPrecastSeconds"));

        if (((((!c.h || (cq.i.a(A_0, this.a("Magic Yield Other I")) > span)) && (!c.m || (cq.i.a(A_0, this.a("Weakening Curse I")) > span))) && ((!c.f || (cq.i.a(A_0, this.a("Imperil Other I")) > span)) && (!c.j || (cq.i.a(A_0, this.a("Gravity Well")) > span)))) && (((!c.k || (cq.i.a(A_0, this.a("Broadside of a Barn")) > span)) && (!c.l || (cq.i.a(A_0, this.a("Fester Other I")) > span))) && ((!c.n || (cq.i.a(A_0, this.a("Festering Curse I")) > span)) && (!c.o || (cq.i.a(A_0, this.a("Corruption I")) > TimeSpan.Zero))))) && (((!c.p || (cq.i.a(A_0, this.a("Destructive Curse I")) > TimeSpan.Zero)) && (!c.q || (cq.i.a(A_0, this.a("Corrosion I")) > TimeSpan.Zero))) && ((!c.g || (cq.i.a(A_0, this.a(cq.h.a(quad.b, eCombatSpellType.Vuln))) > span)) && ((c.c == eDamageElement.None) || (cq.i.a(A_0, this.a(cq.h.a(c.c, eCombatSpellType.Vuln))) > span)))))
        {
            return(false);
        }
        return(true);
    }
Exemplo n.º 2
0
    public int a(int A_0, c A_1)
    {
        if (!dh.a(A_0))
        {
            return(0);
        }
        MyQuad <int, eDamageElement, ePrismaticDamageBehavior, int> quad = A_1.a();
        int            a    = quad.a;
        eDamageElement b    = quad.b;
        int            num2 = 0;

        if (PluginCore.cq.i.a(A_0, PluginCore.cq.h.a(b, eCombatSpellType.Vuln)) > TimeSpan.Zero)
        {
            num2++;
        }
        CombatState state = 8;

        if (dh.b(a) && (dh.c(a) == PluginCore.cg))
        {
            state = PluginCore.cq.n.a(PluginCore.cq.aw.get_WorldFilter().get_Item(a).get_ObjectClass());
        }
        if (state != 8)
        {
            if (PluginCore.cq.i.a(A_0, PluginCore.cq.e.a("Imperil Other I")) > TimeSpan.Zero)
            {
                num2 += 2;
            }
            return(num2);
        }
        if (PluginCore.cq.i.a(A_0, PluginCore.cq.e.a("Magic Yield Other I")) > TimeSpan.Zero)
        {
            num2 += 2;
        }
        return(num2);
    }
Exemplo n.º 3
0
 public MyQuad <int, eDamageElement, ePrismaticDamageBehavior, int> a()
 {
     if (this.n == null)
     {
         this.n = PluginCore.cq.n.d(this.a);
     }
     return(this.n);
 }
Exemplo n.º 4
0
 public void TestQuadNoNegativeSides()
 {
     MyQuad testquad = new MyQuad();
     testquad.Side1Top = 2;
     testquad.Side2Right = 2;
     testquad.Side3Bottom = 2;
     testquad.Side4Left = -2;
 }
Exemplo n.º 5
0
        public void TestQuadNoNegativeSides()
        {
            MyQuad testquad = new MyQuad();

            testquad.Side1Top    = 2;
            testquad.Side2Right  = 2;
            testquad.Side3Bottom = 2;
            testquad.Side4Left   = -2;
        }
Exemplo n.º 6
0
        public void QuadriLateralCanComputePerimeter()
        {
            MyQuad Quad = new MyQuad();
            Quad.Side1Top = 2;
            Quad.Side2Right = 2;
            Quad.Side3Bottom = 2;
            Quad.Side4Left = 2;

            Assert.AreEqual(Quad.Perimeter(), 8);
        }
Exemplo n.º 7
0
        public void QuadriLateralCanComputePerimeter()
        {
            MyQuad Quad = new MyQuad();

            Quad.Side1Top    = 2;
            Quad.Side2Right  = 2;
            Quad.Side3Bottom = 2;
            Quad.Side4Left   = 2;

            Assert.AreEqual(Quad.Perimeter(), 8);
        }
Exemplo n.º 8
0
        //  This method is like a constructor (which we can't use because billboards are allocated from a pool).
        //  It starts/initializes a billboard. Refs used only for optimalization
        public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
                          ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
        {
            MaterialEnum      = materialEnum;
            BlendMaterial     = blendMaterial;
            BlendTextureRatio = textureBlendRatio;

            MyUtils.AssertIsValid(quad.Point0);
            MyUtils.AssertIsValid(quad.Point1);
            MyUtils.AssertIsValid(quad.Point2);
            MyUtils.AssertIsValid(quad.Point3);


            //  Billboard vertexes
            Position0 = quad.Point0;
            Position1 = quad.Point1;
            Position2 = quad.Point2;
            Position3 = quad.Point3;

            UVOffset = uvOffset;

            EnableColorize = colorize;

            if (EnableColorize)
            {
                Size = (Position0 - Position2).Length();
            }

            //  Distance for sorting
            //  IMPORTANT: Must be calculated before we do color and alpha misting, because we need distance there
            DistanceSquared = Vector3.DistanceSquared(MyCamera.Position, origin);

            //  Color
            Color = color;

            Near   = near;
            Lowres = lowres;

            //  Alpha depends on distance to camera. Very close bilboards are more transparent, so player won't see billboard errors or rotating billboards
            var mat = MyTransparentMaterialConstants.GetMaterialProperties(MaterialEnum);

            if (mat.AlphaMistingEnable)
            {
                Color *= MathHelper.Clamp(((float)Math.Sqrt(DistanceSquared) - mat.AlphaMistingStart) / (mat.AlphaMistingEnd - mat.AlphaMistingStart), 0, 1);
            }

            ContainedBillboards.Clear();
        }
Exemplo n.º 9
0
        //  This method is like a constructor (which we can't use because billboards are allocated from a pool).
        //  It starts/initializes a billboard. Refs used only for optimalization
        public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
        ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
        {
            MaterialEnum = materialEnum;
            BlendMaterial = blendMaterial;
            BlendTextureRatio = textureBlendRatio;

            MyUtils.AssertIsValid(quad.Point0);
            MyUtils.AssertIsValid(quad.Point1);
            MyUtils.AssertIsValid(quad.Point2);
            MyUtils.AssertIsValid(quad.Point3);
            

            //  Billboard vertexes
            Position0 = quad.Point0;
            Position1 = quad.Point1;
            Position2 = quad.Point2;
            Position3 = quad.Point3;

            UVOffset = uvOffset;

            EnableColorize = colorize;

            if (EnableColorize)
                Size = (Position0 - Position2).Length();

            //  Distance for sorting
            //  IMPORTANT: Must be calculated before we do color and alpha misting, because we need distance there
            DistanceSquared = Vector3.DistanceSquared(MyCamera.Position, origin);

            //  Color
            Color = color;

            Near = near;
            Lowres = lowres;

            //  Alpha depends on distance to camera. Very close bilboards are more transparent, so player won't see billboard errors or rotating billboards
            var mat = MyTransparentMaterialConstants.GetMaterialProperties(MaterialEnum);
            if (mat.AlphaMistingEnable)
                Color *= MathHelper.Clamp(((float)Math.Sqrt(DistanceSquared) - mat.AlphaMistingStart) / (mat.AlphaMistingEnd - mat.AlphaMistingStart), 0, 1);

            ContainedBillboards.Clear();
        }
Exemplo n.º 10
0
    public bool b(double A_0)
    {
        this.e.Clear();
        if (PluginCore.cq.l.f)
        {
            return(this.a(A_0));
        }
        bool flag  = er.b("DebuffEachFirst", "All") || er.b("DebuffEachFirst", "Priority");
        bool flag2 = er.b("DebuffEachFirst", "All");
        ev   cq    = PluginCore.cq;
        ReadOnlyCollection <cv> onlys = PluginCore.cq.p.a(ObjectClass.Monster);
        double num   = er.h("AttackMinimumDistance");
        bool   flag3 = er.j("TargetLock");

        this.a = new c();
        this.b = 0;
        int    num2 = 0;
        double num3 = er.h("RingDistance");
        int    num4 = er.e("TargetSelectMethod");
        double num5 = 0.0;

        if (num4 == 3)
        {
            num5 = er.h("TargetSelectAngleRange");
        }
        foreach (cv cv in onlys)
        {
            c c = new c();
            c.a(cv, A_0, num, flag3);
            if (!c.m)
            {
                continue;
            }
            num2++;
            if ((c.e < num3) && cq.d.a(cv).i)
            {
                this.b++;
            }
            if (!flag2)
            {
                if (c.d > this.a.d)
                {
                    goto Label_052A;
                }
                if (c.d >= this.a.d)
                {
                    goto Label_01CE;
                }
                continue;
            }
            if (c.h && !this.a.h)
            {
                goto Label_052A;
            }
            if (!c.h && this.a.h)
            {
                continue;
            }
            if (c.d > this.a.d)
            {
                goto Label_052A;
            }
            if (c.d < this.a.d)
            {
                continue;
            }
Label_01CE:
            if (flag)
            {
                if (c.h && !this.a.h)
                {
                    goto Label_052A;
                }
                if (!c.h && this.a.h)
                {
                    continue;
                }
            }
            if (c.g > this.a.g)
            {
                goto Label_052A;
            }
            if (c.g >= this.a.g)
            {
                if (c.i && !this.a.i)
                {
                    goto Label_052A;
                }
                if (c.i || !this.a.i)
                {
                    if ((c.e < num5) && (this.a.e < num5))
                    {
                        MyQuad <int, eDamageElement, ePrismaticDamageBehavior, int> quad  = c.a();
                        MyQuad <int, eDamageElement, ePrismaticDamageBehavior, int> quad2 = this.a.a();
                        int num6 = 0;
                        if (quad.a != PluginCore.cq.av.d())
                        {
                            num6++;
                        }
                        if (quad.d != PluginCore.cq.av.e())
                        {
                            num6++;
                        }
                        int num7 = 0;
                        if (quad2.a != PluginCore.cq.av.d())
                        {
                            num7++;
                        }
                        if (quad2.d != PluginCore.cq.av.e())
                        {
                            num7++;
                        }
                        if (num6 < num7)
                        {
                            goto Label_052A;
                        }
                        if (num6 > num7)
                        {
                            continue;
                        }
                    }
                    if (c.k && !this.a.k)
                    {
                        goto Label_052A;
                    }
                    if (c.k || !this.a.k)
                    {
                        switch (num4)
                        {
                        case 1:
                            if (c.e < this.a.e)
                            {
                                goto Label_052A;
                            }
                            if (c.e <= this.a.e)
                            {
                                if (c.f < this.a.f)
                                {
                                    goto Label_052A;
                                }
                                if (c.f <= this.a.f)
                                {
                                }
                            }
                            break;

                        case 2:
                            if (c.f < this.a.f)
                            {
                                goto Label_052A;
                            }
                            if (c.f <= this.a.f)
                            {
                                if (c.e < this.a.e)
                                {
                                    goto Label_052A;
                                }
                                if (c.e <= this.a.e)
                                {
                                }
                            }
                            break;

                        case 3:
                            goto Label_0379;
                        }
                    }
                }
            }
            continue;
Label_0379:
            if ((c.e >= num5) || (this.a.e <= num5))
            {
                if ((c.e > num5) && (this.a.e < num5))
                {
                    continue;
                }
                if (c.e < num5)
                {
                    if (c.f < this.a.f)
                    {
                        goto Label_052A;
                    }
                    if (c.f <= this.a.f)
                    {
                        if (c.e < this.a.e)
                        {
                            goto Label_052A;
                        }
                        if (c.e <= this.a.e)
                        {
                        }
                    }
                    continue;
                }
                if (c.e >= this.a.e)
                {
                    if (c.e > this.a.e)
                    {
                        continue;
                    }
                    if (c.f >= this.a.f)
                    {
                        if (c.f <= this.a.f)
                        {
                        }
                        continue;
                    }
                }
            }
Label_052A:
            this.a = c;
        }
        PluginCore.cq.n.d = this.a.b;
        PluginCore.cq.an.b(this.a.b);
        l.c(num2);
        l.b(this.b);
        l.a(onlys.Count);
        return(this.a.b != 0);
    }
Exemplo n.º 11
0
    public void b()
    {
        ev cq = PluginCore.cq;

        if (this.a != null)
        {
            MyQuad <int, eDamageElement, ePrismaticDamageBehavior, int> quad = this.a.a();
            if (((eDamageElement)quad.b) == eDamageElement.Random)
            {
                quad.b = (eDamageElement)this.d;
                this.d++;
                if (this.d == 7)
                {
                    this.d = 0;
                }
            }
            bool           flag  = (this.a.b().b == eDamageElement.Fists) && PluginCore.cq.h.c(PluginCore.cq.e.a("Tusker Fists"));
            int            num   = quad.a;
            eDamageElement b     = quad.b;
            TimeSpan       span  = TimeSpan.FromSeconds((double)er.i("DebuffPrecastSeconds"));
            float          num2  = 1f;
            CombatState    state = 8;
            if (dh.b(num) && (dh.c(num) == PluginCore.cg))
            {
                state = PluginCore.cq.n.a(PluginCore.cq.aw.get_WorldFilter().get_Item(num).get_ObjectClass());
                if (state == 2)
                {
                    fn.a a = PluginCore.cq.n.d(num);
                    if ((a.i == 1) && (PluginCore.cq.n.c(quad.d) != a1.c))
                    {
                        if ((b == eDamageElement.Slash) && a.d)
                        {
                            num2 = 0.5f;
                        }
                        else
                        {
                            num2 = 0f;
                        }
                    }
                    else if (((b == eDamageElement.Pierce) && a.d) && !a.f)
                    {
                        num2 = 0.2f;
                    }
                    else if (((b == eDamageElement.Pierce) && a.d) && (a.f && (PluginCore.cq.n.c(quad.d) == a1.c)))
                    {
                        num2 = 0.49f;
                    }
                    else if (((b == eDamageElement.Pierce) && a.d) && (a.f && (PluginCore.cq.n.c(quad.d) != a1.d)))
                    {
                        num2 = 0.2f;
                    }
                    else
                    {
                        num2 = 1f;
                    }
                }
            }
            if (er.j("UseRecklessness") && dh.b(eGameSkillID.Recklessness))
            {
                if (num2 < 0.11f)
                {
                    num2 = 0.11f;
                }
                if (num2 > 0.9f)
                {
                    num2 = 0.9f;
                }
            }
            bool flag2 = !cq.d.a(this.a.a).s;
            bool i     = cq.d.a(this.a.a).i;
            bool r     = cq.d.a(this.a.a).r;
            if (cq.d.a(this.a.a).h&& (cq.i.a(this.a.b, this.a(cq.e.a("Magic Yield Other I"))) <= span))
            {
                this.a("Magic Yield Other I", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).m&& (cq.i.a(this.a.b, this.a(cq.e.a("Weakening Curse I"))) <= span))
            {
                this.a("Weakening Curse I", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).n&& (cq.i.a(this.a.b, this.a(cq.e.a("Festering Curse I"))) <= span))
            {
                this.a("Festering Curse I", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).o&& (cq.i.a(this.a.b, this.a(cq.e.a("Corruption I"))) <= TimeSpan.Zero))
            {
                this.a("Corruption I", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).p&& (cq.i.a(this.a.b, this.a(cq.e.a("Destructive Curse I"))) <= TimeSpan.Zero))
            {
                this.a("Destructive Curse I", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).q&& (cq.i.a(this.a.b, this.a(cq.e.a("Corrosion I"))) <= TimeSpan.Zero))
            {
                this.a("Corrosion I", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).f&& (cq.i.a(this.a.b, this.a(cq.e.a("Imperil Other I"))) <= span))
            {
                this.a("Imperil Other I", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).g&& (cq.i.a(this.a.b, this.a(cq.h.a(b, eCombatSpellType.Vuln))) <= span))
            {
                this.a(cq.h.a(b, eCombatSpellType.Vuln), this.a.b, num);
            }
            else if ((cq.d.a(this.a.a).c != eDamageElement.None) && (cq.i.a(this.a.b, this.a(cq.h.a(cq.d.a(this.a.a).c, eCombatSpellType.Vuln))) <= span))
            {
                this.a(cq.h.a(cq.d.a(this.a.a).c, eCombatSpellType.Vuln), this.a.b, num);
            }
            else if (cq.d.a(this.a.a).j&& (cq.i.a(this.a.b, this.a(cq.e.a("Gravity Well"))) <= span))
            {
                this.a("Gravity Well", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).k&& (cq.i.a(this.a.b, this.a(cq.e.a("Broadside of a Barn"))) <= span))
            {
                this.a("Broadside of a Barn", this.a.b, num);
            }
            else if (cq.d.a(this.a.a).l&& (cq.i.a(this.a.b, this.a(cq.e.a("Fester Other I"))) <= span))
            {
                this.a("Fester Other I", this.a.b, num);
            }
            else if (flag)
            {
                if (state != 8)
                {
                    PluginCore.cq.v.d();
                    if (!PluginCore.cq.n.a(8, 0, true))
                    {
                        return;
                    }
                }
                else
                {
                    PluginCore.cq.v.d();
                    if (!PluginCore.cq.n.a(8, num, false))
                    {
                        return;
                    }
                }
                cv cv  = PluginCore.cq.p.d(PluginCore.cg);
                cv cv2 = this.a.a;
                if (cv != null)
                {
                    dz dz = cv.b(PluginCore.cq.ax.get_Actions());
                    dz w  = cv2.w;
                    if (!PluginCore.cq.aq.a(dz.a(w) - 0.062831853071795868))
                    {
                        return;
                    }
                }
                this.a("Tusker Fists", this.a.b);
            }
            else if (state == 8)
            {
                PluginCore.cq.aq.b();
                PluginCore.cq.v.d();
                if (PluginCore.cq.n.a(8, num, false))
                {
                    if ((i && (this.b >= er.i("MinimumRingTargets"))) || ((i && !flag2) && (!r && (this.b > 0))))
                    {
                        if (b == eDamageElement.DrainAuto)
                        {
                            PluginCore.cq.ao.a(this.a.b, true);
                        }
                        else
                        {
                            MySpell spell = cq.h.a(b, eCombatSpellType.Ring);
                            if (spell.HasScarabsInInventory)
                            {
                                this.a(spell, this.a.b);
                            }
                            else
                            {
                                this.a(this.a(b, this.a), this.a.b);
                            }
                        }
                    }
                    else if ((flag2 && !r) || ((!flag2 && !r) && i))
                    {
                        if (b == eDamageElement.DrainAuto)
                        {
                            PluginCore.cq.ao.a(this.a.b, false);
                        }
                        else
                        {
                            this.a(this.a(b, this.a), this.a.b);
                        }
                    }
                    else if (!flag2 && r)
                    {
                        if (b == eDamageElement.DrainAuto)
                        {
                            PluginCore.cq.ao.a(this.a.b, false);
                        }
                        else
                        {
                            MySpell spell2 = PluginCore.cq.h.a(PluginCore.cq.h.a(b, eCombatSpellType.Streak));
                            if (spell2 != null)
                            {
                                this.a(spell2, this.a.b);
                            }
                            else
                            {
                                ai.a(string.Format("No streak spell usable for element '{0}', using bolt/arc instead.", er.a(b)));
                                this.a(this.a(b, this.a), this.a.b);
                            }
                        }
                    }
                    else if (flag2 && r)
                    {
                        MySpell spell3 = PluginCore.cq.h.a(PluginCore.cq.h.a(b, eCombatSpellType.Streak));
                        int     num3   = 0;
                        if (spell3 != null)
                        {
                            if (PluginCore.cq.an.d() > 0)
                            {
                                num3 = PluginCore.cq.an.d() / 7;
                            }
                            else
                            {
                                num3 = spell3.Difficulty / 7;
                            }
                        }
                        bool flag5 = ((PluginCore.cq.an.h() == this.a.b) && (PluginCore.cq.an.b() > 0)) && (PluginCore.cq.an.b() < num3);
                        if (b == eDamageElement.DrainAuto)
                        {
                            PluginCore.cq.ao.a(this.a.b, false);
                        }
                        else if (flag5 && (spell3 != null))
                        {
                            this.a(spell3, this.a.b);
                        }
                        else
                        {
                            if (flag5)
                            {
                                ai.a(string.Format("No streak spell usable for element '{0}', using bolt/arc instead.", er.a(b)));
                            }
                            this.a(this.a(b, this.a), this.a.b);
                        }
                    }
                }
            }
            else
            {
                PluginCore.cq.aq.b();
                if (PluginCore.cq.n.a(state, num, false, b, quad.c, quad.d))
                {
                    PluginCore.cq.v.a(this.a.b, num2, null);
                }
            }
        }
    }
Exemplo n.º 12
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
                   ref Vector4 color, ref Vector3 origin, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, blendMaterial, textureBlendRatio, ref color, ref origin, Vector2.Zero, colorize, near, lowres);
 }
Exemplo n.º 13
0
        //  Update position, check collisions, etc. and draw if particle still lives.
        //  Return false if particle dies/timeouts in this tick.
        public bool Draw(MyBillboard billboard)
        {
            MyTransparentGeometry.StartParticleProfilingBlock("Distance calculation");
            //  This time is scaled according to planned lifespan of the particle

            // Distance for sorting
            Vector3 campos = MyCamera.Position;

            Vector3.DistanceSquared(ref campos, ref m_actualPosition, out billboard.DistanceSquared);

            MyTransparentGeometry.EndParticleProfilingBlock();

            // If distance to camera is really small don't draw it.
            if (billboard.DistanceSquared <= 1)
            {
                return(false);
            }

            MyTransparentGeometry.StartParticleProfilingBlock("Quad calculation");

            MyTransparentGeometry.StartParticleProfilingBlock("actualRadius");
            float actualRadius = 1;

            Radius.GetInterpolatedValue <float>(m_normalizedTime, out actualRadius);
            MyTransparentGeometry.EndParticleProfilingBlock();

            billboard.ContainedBillboards.Clear();

            billboard.Near   = m_generation.GetEffect().Near;
            billboard.Lowres = m_generation.GetEffect().LowRes || MyRenderConstants.RenderQualityProfile.LowResParticles;

            float alpha = 1;

            if (Type == MyParticleTypeEnum.Point)
            {
                MyTransparentGeometry.StartParticleProfilingBlock("GetBillboardQuadRotated");
                MyUtils.GetBillboardQuadRotated(billboard, ref m_actualPosition, actualRadius, m_actualAngle);
                MyTransparentGeometry.EndParticleProfilingBlock();
            }
            else if (Type == MyParticleTypeEnum.Line)
            {
                if (MyMwcUtils.IsZero(Velocity.LengthSquared()))
                {
                    Velocity = MyMwcUtils.GetRandomVector3Normalized();
                }

                MyQuad quad = new MyQuad();

                MyPolyLine polyLine = new MyPolyLine();
                polyLine.LineDirectionNormalized = MyMwcUtils.Normalize(Velocity);

                if (m_actualAngle > 0)
                {
                    polyLine.LineDirectionNormalized = Vector3.TransformNormal(polyLine.LineDirectionNormalized, Matrix.CreateRotationY(MathHelper.ToRadians(m_actualAngle)));
                }

                polyLine.Point0   = m_actualPosition;
                polyLine.Point1.X = m_actualPosition.X + polyLine.LineDirectionNormalized.X * actualRadius;
                polyLine.Point1.Y = m_actualPosition.Y + polyLine.LineDirectionNormalized.Y * actualRadius;
                polyLine.Point1.Z = m_actualPosition.Z + polyLine.LineDirectionNormalized.Z * actualRadius;

                if (m_actualAngle > 0)
                { //centerize
                    polyLine.Point0.X = polyLine.Point0.X - polyLine.LineDirectionNormalized.X * actualRadius * 0.5f;
                    polyLine.Point0.Y = polyLine.Point0.Y - polyLine.LineDirectionNormalized.Y * actualRadius * 0.5f;
                    polyLine.Point0.Z = polyLine.Point0.Z - polyLine.LineDirectionNormalized.Z * actualRadius * 0.5f;
                    polyLine.Point1.X = polyLine.Point1.X - polyLine.LineDirectionNormalized.X * actualRadius * 0.5f;
                    polyLine.Point1.Y = polyLine.Point1.Y - polyLine.LineDirectionNormalized.Y * actualRadius * 0.5f;
                    polyLine.Point1.Z = polyLine.Point1.Z - polyLine.LineDirectionNormalized.Z * actualRadius * 0.5f;
                }

                polyLine.Thickness = Thickness;
                MyUtils.GetPolyLineQuad(out quad, ref polyLine);

                if (this.m_generation.AlphaAnisotropic)
                {
                    float angle     = 1 - Math.Abs(Vector3.Dot(MyMwcUtils.Normalize(MyCamera.ForwardVector), polyLine.LineDirectionNormalized));
                    float alphaCone = (float)Math.Pow(angle, 0.5f);
                    alpha = alphaCone;
                }

                billboard.Position0 = quad.Point0;
                billboard.Position1 = quad.Point1;
                billboard.Position2 = quad.Point2;
                billboard.Position3 = quad.Point3;
            }
            else if (Type == MyParticleTypeEnum.Trail)
            {
                if (Quad.Point0 == Quad.Point2) //not moving particle
                {
                    return(false);
                }
                if (Quad.Point1 == Quad.Point3) //not moving particle was previous one
                {
                    return(false);
                }
                if (Quad.Point0 == Quad.Point3) //not moving particle was previous one
                {
                    return(false);
                }

                billboard.Position0 = Quad.Point0;
                billboard.Position1 = Quad.Point1;
                billboard.Position2 = Quad.Point2;
                billboard.Position3 = Quad.Point3;

                //if (this.m_generation.AlphaAnisotropic)

                /*   { //Trails are anisotropic by default (nobody wants them to see ugly)
                 *     Vector3 lineDir = Vector3.Normalize(Quad.Point1 - Quad.Point0);
                 *     float angle = 1 - Math.Abs(Vector3.Dot(MyMwcUtils.Normalize(MyCamera.ForwardVector), lineDir));
                 *     float alphaCone = (float)Math.Pow(angle, 0.3f);
                 *     alpha = alphaCone;
                 * }*/
            }
            else
            {
                throw new NotSupportedException(Type + " is not supported particle type");
            }

            MyTransparentGeometry.EndParticleProfilingBlock();

            MyTransparentGeometry.StartParticleProfilingBlock("Material calculation");

            Vector4 color;

            Color.GetInterpolatedValue <Vector4>(m_normalizedTime, out color);

            int   material1         = (int)MyTransparentMaterialEnum.Test;
            int   material2         = (int)MyTransparentMaterialEnum.Test;
            float textureBlendRatio = 0;

            if ((Flags & ParticleFlags.BlendTextures) != 0)
            {
                float prevTime, nextTime, difference;
                Material.GetPreviousValue(m_normalizedTime, out material1, out prevTime);
                Material.GetNextValue(m_normalizedTime, out material2, out nextTime, out difference);

                if (prevTime != nextTime)
                {
                    textureBlendRatio = (m_normalizedTime - prevTime) * difference;
                }
            }
            else
            {
                Material.GetInterpolatedValue <int>(m_normalizedTime, out material1);
            }

            MyTransparentGeometry.EndParticleProfilingBlock();

            //This gets 0.44ms for 2000 particles
            MyTransparentGeometry.StartParticleProfilingBlock("billboard.Start");


            billboard.MaterialEnum      = (MyTransparentMaterialEnum)material1;
            billboard.BlendMaterial     = (MyTransparentMaterialEnum)material2;
            billboard.BlendTextureRatio = textureBlendRatio;
            billboard.EnableColorize    = false;

            billboard.Color = color * alpha * m_generation.GetEffect().UserColorMultiplier;

            MyTransparentGeometry.EndParticleProfilingBlock();

            return(true);
        }
Exemplo n.º 14
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum, MyTransparentMaterialEnum blendMaterial, float textureBlendRatio,
 ref Vector4 color, ref Vector3 origin, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, blendMaterial, textureBlendRatio, ref color, ref origin, Vector2.Zero, colorize, near, lowres);
 }
Exemplo n.º 15
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum,
                   ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, MyTransparentMaterialEnum.Test, 0, ref color, ref origin, uvOffset, colorize, near, lowres);
 }
Exemplo n.º 16
0
        } //Create Cuboid


        public static void CutOutCuboid(MyVoxelMap voxelMap, MyCuboid cuboid, MyMwcVoxelMaterialsEnum? material)
        {
            BoundingBox aabb = cuboid.GetAABB();


            MyMwcVector3Int minCorner = voxelMap.GetVoxelCoordinateFromMeters(aabb.Min - new Vector3(MyVoxelConstants.VOXEL_SIZE_IN_METRES));
            MyMwcVector3Int maxCorner = voxelMap.GetVoxelCoordinateFromMeters(aabb.Max + new Vector3(MyVoxelConstants.VOXEL_SIZE_IN_METRES));

            voxelMap.FixVoxelCoord(ref minCorner);
            voxelMap.FixVoxelCoord(ref maxCorner);

            MyMwcVector3Int tempVoxelCoord;
            for (tempVoxelCoord.X = minCorner.X; tempVoxelCoord.X <= maxCorner.X; tempVoxelCoord.X++)
            {
                for (tempVoxelCoord.Y = minCorner.Y; tempVoxelCoord.Y <= maxCorner.Y; tempVoxelCoord.Y++)
                {
                    for (tempVoxelCoord.Z = minCorner.Z; tempVoxelCoord.Z <= maxCorner.Z; tempVoxelCoord.Z++)
                    {
                        Vector3 position = voxelMap.GetVoxelCenterPositionAbsolute(ref tempVoxelCoord);
                        BoundingBox voxelAABB = new BoundingBox(position - new Vector3(MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF), position + new Vector3(MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF));

                        bool isInside = true;

                        for (int i = 0; i < cuboid.Sides.Length; i++)
                        {
                            MyPlane side = cuboid.Sides[i].Plane;
                            float distance = MyUtils.GetDistanceFromPointToPlane(ref position, ref side);
                            if (distance > 0)
                            {
                                isInside = false;
                                break;
                            }
                        }

                        float minDistance = float.MaxValue;

                        for (int i = 0; i < cuboid.Sides.Length; i++)
                        {
                            MyQuad quad = new MyQuad();
                            quad.Point0 = cuboid.Sides[i].Lines[0].From;
                            quad.Point1 = cuboid.Sides[i].Lines[1].From;
                            quad.Point2 = cuboid.Sides[i].Lines[3].From;
                            quad.Point3 = cuboid.Sides[i].Lines[2].From;

                            float distance = MyUtils.GetDistancePointToQuad(ref position, ref quad);
                            if (distance < minDistance)
                            {
                                minDistance = distance;
                            }
                        }


                        byte newContent = 0;


                        if (isInside)
                        {
                            if (minDistance > MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF)
                            {
                                newContent = MyVoxelConstants.VOXEL_CONTENT_EMPTY;
                            }
                            else
                            {
                                //  This formula will work even if diff is positive or negative
                                //newContent = MyVoxelConstants.VOXEL_CONTENT_EMPTY;
                                newContent = (byte)(MyVoxelConstants.VOXEL_ISO_LEVEL - minDistance / MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF * MyVoxelConstants.VOXEL_ISO_LEVEL);
                                //newContent = (byte)(MyVoxelConstants.VOXEL_CONTENT_FULL - (byte)(MyVoxelConstants.VOXEL_ISO_LEVEL - minDistance / MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF * MyVoxelConstants.VOXEL_ISO_LEVEL));
                            }
                        }
                        else
                        {
                            if (minDistance > MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF)
                            {
                                newContent = MyVoxelConstants.VOXEL_CONTENT_FULL;
                            }
                            else
                            {
                                //newContent = MyVoxelConstants.VOXEL_CONTENT_FULL;
                                //  This formula will work even if diff is positive or negative
                                //newContent = (byte)(MyVoxelConstants.VOXEL_ISO_LEVEL - minDistance / MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF * MyVoxelConstants.VOXEL_ISO_LEVEL);
                                newContent = (byte)(MyVoxelConstants.VOXEL_CONTENT_FULL - (byte)(MyVoxelConstants.VOXEL_ISO_LEVEL - minDistance / MyVoxelConstants.VOXEL_SIZE_IN_METRES_HALF * MyVoxelConstants.VOXEL_ISO_LEVEL));
                            }
                        }

                        byte originalContent = voxelMap.GetVoxelContent(ref tempVoxelCoord);

                        if (newContent < originalContent)
                        {
                            voxelMap.SetVoxelContent(newContent, ref tempVoxelCoord);
                            if (material.HasValue)
                                voxelMap.SetVoxelMaterialAndIndestructibleContent(material.Value, 0, ref tempVoxelCoord);
                        }
                    }
                }
            }

            voxelMap.InvalidateCache(minCorner, maxCorner);
            voxelMap.CalcAverageDataCellMaterials();
        } //CutOut Cuboid
Exemplo n.º 17
0
 public void TestQuadHasDefaultSize()
 {
     MyQuad testQuad = new MyQuad();
     testQuad.Perimeter();
 }
Exemplo n.º 18
0
        //  Update position, check collisions, etc. and draw if particle still lives.
        //  Return false if particle dies/timeouts in this tick.
        public bool Draw(MyBillboard billboard)
        {
            //  Check for timeout
            int elapsedMiliseconds = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_timeStarted;
            if (elapsedMiliseconds >= m_lifespanInMiliseconds) return false;

            //  This time is scaled according to planned lifespan of the particle
            float normalizedTimeElapsed = (float)elapsedMiliseconds / (float)m_lifespanInMiliseconds;

            MyQuad quad = new MyQuad();
            Vector3 actualPosition;

            if (m_type == MyParticleType.LINE_PARTICLE)
            {
                actualPosition = m_startPosition;
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else if (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT)
            {
                Matrix worldMatrix = m_physObject.WorldMatrix;
                actualPosition = MyUtils.GetTransform(ref m_startPosition, ref worldMatrix);
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else if (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT_COCKPIT_GLASS)
            {
                actualPosition = MyUtils.GetTransform(ref m_startPosition, ref ((MySmallShip)m_physObject).PlayerHeadForCockpitInteriorWorldMatrix);
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }            
            else if (m_type == MyParticleType.POINT_PARTICLE)
            {
                actualPosition = m_startPosition + m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else if (m_type == MyParticleType.POINT_PARTICLE_RELATIVE_TO_PHYS_OBJECT)
            {
                Matrix worldMatrix = m_physObject.WorldMatrix;
                actualPosition = MyUtils.GetTransform(ref m_startPosition, ref worldMatrix);
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else
            {
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }

            // Distance for sorting
            Vector3 campos = MyCamera.Position;
            Vector3.DistanceSquared(ref campos, ref actualPosition, out billboard.DistanceSquared);

            // If distance to camera is really small don't draw it.
            if (billboard.DistanceSquared <= MyMwcMathConstants.EPSILON)
            {
                return true;
            }

            if ((m_type == MyParticleType.LINE_PARTICLE) ||
                (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT) ||
                (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT_COCKPIT_GLASS))
            {
                float actualLength = MathHelper.Lerp(m_lineSpecific_startLength, m_lineSpecific_endLength, normalizedTimeElapsed);

                MyPolyLine polyLine;
                polyLine.LineDirectionNormalized = m_lineSpecific_directionNormalized;
                polyLine.Point0 = actualPosition;
                polyLine.Point1 = actualPosition + polyLine.LineDirectionNormalized * actualLength;
                polyLine.Thickness = m_lineSpecific_thickness;

                //  Billboard vertexes
                MyUtils.GetPolyLineQuad(out quad, ref polyLine);
            }
            else if ((m_type == MyParticleType.POINT_PARTICLE) || (m_type == MyParticleType.POINT_PARTICLE_RELATIVE_TO_PHYS_OBJECT))
            {
                //  Billboard vertexes
                float actualRadius = MathHelper.Lerp(m_pointSpecific_startRadius, m_pointSpecific_endRadius, normalizedTimeElapsed);
                float angle = m_pointSpecific_startAngle + normalizedTimeElapsed * m_pointSpecific_rotationSpeed;
                MyUtils.GetBillboardQuadRotated(billboard, ref actualPosition, actualRadius, angle);
            }
            else
            {
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }

            //  Color and alpha depend on time
            Vector4 color;
            color.X = MathHelper.Lerp(m_startColor.X, m_endColor.X, normalizedTimeElapsed);
            color.Y = MathHelper.Lerp(m_startColor.Y, m_endColor.Y, normalizedTimeElapsed);
            color.Z = MathHelper.Lerp(m_startColor.Z, m_endColor.Z, normalizedTimeElapsed);
            color.W = MathHelper.Lerp(m_startColor.W, m_endColor.W, normalizedTimeElapsed);
            //billboard.Color.W *= 1.0f - normalizedTimeElapsed;
            //billboard.Color.W *= 1 - (float)Math.Pow(normalizedTimeElapsed, 2);            
            //billboard.Color.W *= normalizedTimeElapsed * (1 - normalizedTimeElapsed) * (1 - normalizedTimeElapsed) * 6.7f;

            billboard.Start(ref quad, m_materialEnum, ref color, ref m_startPosition);

            //  Yes, draw this particle
            return true;
        }
Exemplo n.º 19
0
        public void TestQuadHasDefaultSize()
        {
            MyQuad testQuad = new MyQuad();

            testQuad.Perimeter();
        }
Exemplo n.º 20
0
        //  Update position, check collisions, etc. and draw if particle still lives.
        //  Return false if particle dies/timeouts in this tick.
        public bool Draw(MyBillboard billboard)
        {
            //  Check for timeout
            int elapsedMiliseconds = MyMinerGame.TotalGamePlayTimeInMilliseconds - m_timeStarted;

            if (elapsedMiliseconds >= m_lifespanInMiliseconds)
            {
                return(false);
            }

            //  This time is scaled according to planned lifespan of the particle
            float normalizedTimeElapsed = (float)elapsedMiliseconds / (float)m_lifespanInMiliseconds;

            MyQuad  quad = new MyQuad();
            Vector3 actualPosition;

            if (m_type == MyParticleType.LINE_PARTICLE)
            {
                actualPosition  = m_startPosition;
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else if (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT)
            {
                Matrix worldMatrix = m_physObject.WorldMatrix;
                actualPosition  = MyUtils.GetTransform(ref m_startPosition, ref worldMatrix);
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else if (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT_COCKPIT_GLASS)
            {
                actualPosition  = MyUtils.GetTransform(ref m_startPosition, ref ((MySmallShip)m_physObject).PlayerHeadForCockpitInteriorWorldMatrix);
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else if (m_type == MyParticleType.POINT_PARTICLE)
            {
                actualPosition = m_startPosition + m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else if (m_type == MyParticleType.POINT_PARTICLE_RELATIVE_TO_PHYS_OBJECT)
            {
                Matrix worldMatrix = m_physObject.WorldMatrix;
                actualPosition  = MyUtils.GetTransform(ref m_startPosition, ref worldMatrix);
                actualPosition += m_velocity * ((float)elapsedMiliseconds / 1000.0f);
            }
            else
            {
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }

            // Distance for sorting
            Vector3 campos = MyCamera.Position;

            Vector3.DistanceSquared(ref campos, ref actualPosition, out billboard.DistanceSquared);

            // If distance to camera is really small don't draw it.
            if (billboard.DistanceSquared <= MyMwcMathConstants.EPSILON)
            {
                return(true);
            }

            if ((m_type == MyParticleType.LINE_PARTICLE) ||
                (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT) ||
                (m_type == MyParticleType.LINE_PARTICLE_RELATIVE_TO_PHYS_OBJECT_COCKPIT_GLASS))
            {
                float actualLength = MathHelper.Lerp(m_lineSpecific_startLength, m_lineSpecific_endLength, normalizedTimeElapsed);

                MyPolyLine polyLine;
                polyLine.LineDirectionNormalized = m_lineSpecific_directionNormalized;
                polyLine.Point0    = actualPosition;
                polyLine.Point1    = actualPosition + polyLine.LineDirectionNormalized * actualLength;
                polyLine.Thickness = m_lineSpecific_thickness;

                //  Billboard vertexes
                MyUtils.GetPolyLineQuad(out quad, ref polyLine);
            }
            else if ((m_type == MyParticleType.POINT_PARTICLE) || (m_type == MyParticleType.POINT_PARTICLE_RELATIVE_TO_PHYS_OBJECT))
            {
                //  Billboard vertexes
                float actualRadius = MathHelper.Lerp(m_pointSpecific_startRadius, m_pointSpecific_endRadius, normalizedTimeElapsed);
                float angle        = m_pointSpecific_startAngle + normalizedTimeElapsed * m_pointSpecific_rotationSpeed;
                MyUtils.GetBillboardQuadRotated(billboard, ref actualPosition, actualRadius, angle);
            }
            else
            {
                throw new MyMwcExceptionApplicationShouldNotGetHere();
            }

            //  Color and alpha depend on time
            Vector4 color;

            color.X = MathHelper.Lerp(m_startColor.X, m_endColor.X, normalizedTimeElapsed);
            color.Y = MathHelper.Lerp(m_startColor.Y, m_endColor.Y, normalizedTimeElapsed);
            color.Z = MathHelper.Lerp(m_startColor.Z, m_endColor.Z, normalizedTimeElapsed);
            color.W = MathHelper.Lerp(m_startColor.W, m_endColor.W, normalizedTimeElapsed);
            //billboard.Color.W *= 1.0f - normalizedTimeElapsed;
            //billboard.Color.W *= 1 - (float)Math.Pow(normalizedTimeElapsed, 2);
            //billboard.Color.W *= normalizedTimeElapsed * (1 - normalizedTimeElapsed) * (1 - normalizedTimeElapsed) * 6.7f;

            billboard.Start(ref quad, m_materialEnum, ref color, ref m_startPosition);

            //  Yes, draw this particle
            return(true);
        }
Exemplo n.º 21
0
 public void Start(ref MyQuad quad, MyTransparentMaterialEnum materialEnum,
     ref Vector4 color, ref Vector3 origin, Vector2 uvOffset, bool colorize = false, bool near = false, bool lowres = false)
 {
     Start(ref quad, materialEnum, MyTransparentMaterialEnum.Test, 0, ref color, ref origin, uvOffset, colorize, near, lowres);
 }
Exemplo n.º 22
0
        public static void DrawTransparentPyramid(ref Vector3 start, ref MyQuad backQuad, ref Vector4 vctColor, int divideRatio, float thickness, MyTransparentMaterialEnum? lineMaterial = null) 
        {
            Vector3 vctZero = Vector3.Zero;            
            m_lineBuffer.Clear();
            GenerateLines(start, backQuad.Point0, backQuad.Point1, ref m_lineBuffer, divideRatio);
            GenerateLines(start, backQuad.Point1, backQuad.Point2, ref m_lineBuffer, divideRatio);
            GenerateLines(start, backQuad.Point2, backQuad.Point3, ref m_lineBuffer, divideRatio);
            GenerateLines(start, backQuad.Point3, backQuad.Point0, ref m_lineBuffer, divideRatio);

            foreach (MyLine line in m_lineBuffer) 
            {
                Vector3 dir = line.To - line.From;
                float len = dir.Length();
                if (len > 0.1f)
                {
                    dir = MyMwcUtils.Normalize(dir);

                    MyTransparentGeometry.AddLineBillboard(lineMaterial ?? MyTransparentMaterialEnum.ProjectileTrailLine, vctColor, line.From, dir, len, thickness);
                }
            }
        }