Esempio n. 1
0
        public void DrawMotes()
        {
            this.nextMoteTick = this.age + Rand.Range((int)(55 - Mathf.Clamp((LightEnergy / 2), 0, 55)), (int)(65 - Mathf.Clamp((LightEnergy / 2), 0, 60)));
            Vector3 rndVec = this.ExactPosition;

            rndVec.x += Rand.Range(-.1f, .1f);
            rndVec.z += Rand.Range(-.1f, .1f);
            //Vector3 angle = TM_Calc.GetVector(rndVec, this.ExactPosition);
            ThingDef mote           = ThingDef.Named("Mote_Twinkle");
            int      directionAngle = 0;
            float    moteSpeed      = Rand.Range(.25f, .6f);

            if (this.solAction == SoLAction.Sleeping)
            {
                directionAngle = Rand.Range(170, 190);
            }
            if (this.solAction == SoLAction.ChargeAttacking)
            {
                directionAngle = (int)Vector3Utility.ToAngleFlat(this.DrawPos - this.destination) - 90;
                TM_MoteMaker.ThrowGenericMote(mote, rndVec, this.Map, Rand.Range(.4f, .6f), Rand.Range(.2f, .4f), Rand.Range(0f, .5f), Rand.Range(.3f, .5f), Rand.Range(-50, 50), moteSpeed, directionAngle, Rand.Range(0, 360));
            }
            if (solAction == SoLAction.Guarding)
            {
                Vector3 barrierPos = this.assignedTarget.DrawPos;
                barrierPos.x += Rand.Range(-.25f, .25f);
                barrierPos.z += Rand.Range(-.25f, .25f);
                TM_MoteMaker.ThrowEnchantingMote(barrierPos, assignedTarget.Map, .25f);
            }
            if (solAction == SoLAction.Circling)
            {
                directionAngle = (int)Vector3Utility.ToAngleFlat(this.DrawPos - this.assignedTarget.DrawPos) - 90;
                TM_MoteMaker.ThrowGenericMote(mote, rndVec, this.Map, Rand.Range(.4f, .6f), Rand.Range(.2f, .4f), Rand.Range(0f, .5f), Rand.Range(.3f, .5f), Rand.Range(-50, 50), Rand.Range(1f, 2f), directionAngle, Rand.Range(0, 360));
            }
            TM_MoteMaker.ThrowGenericMote(mote, rndVec, this.Map, Rand.Range(.2f, .3f), Rand.Range(.2f, .4f), Rand.Range(0f, .5f), Rand.Range(.3f, .5f), Rand.Range(-50, 50), moteSpeed, directionAngle, Rand.Range(0, 360));
        }
Esempio n. 2
0
        public override void Draw()
        {
            bool flag = this.flyingThing != null;

            if (flag && solAction != SoLAction.Sleeping && solAction != SoLAction.Limbo)
            {
                Material mat = FlyingObject_SpiritOfLight.sol_down;
                if (drawEnum == 1)
                {
                    drawEnum = -1;
                    mat      = FlyingObject_SpiritOfLight.sol_up;
                }
                else if (drawEnum == 0)
                {
                    drawEnum = 1;
                    mat      = FlyingObject_SpiritOfLight.sol_side;
                }
                else
                {
                    drawEnum = 0;
                }

                Vector3 vector = this.DrawPos;
                vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead);
                Vector3    s      = new Vector3(.4f, pawn.DrawPos.y, .4f);
                Matrix4x4  matrix = default(Matrix4x4);
                Quaternion q      = Quaternion.AngleAxis(0f, Vector3.up);
                if (this.solAction == SoLAction.Attacking || this.solAction == SoLAction.Returning || this.solAction == SoLAction.ChargeAttacking || solAction == SoLAction.Goto || solAction == SoLAction.Circling)
                {
                    q = (Vector3Utility.ToAngleFlat(this.DrawPos - this.destination) - 90).ToQuat();
                }
                if (this.solAction == SoLAction.ChargeAttacking)
                {
                    Matrix4x4 matrix2 = default(Matrix4x4);
                    float     bScale  = Mathf.Clamp(.6f + (5f / (float)this.ticksToImpact), .6f, 2.5f);
                    Vector3   s2      = new Vector3(bScale, pawn.DrawPos.y, bScale);
                    matrix2.SetTRS(vector, q, s2);
                    Graphics.DrawMesh(MeshPool.plane10, matrix2, FlyingObject_SpiritOfLight.sol_blade, 0);
                }
                if (this.solAction == SoLAction.Guarding && this.assignedTarget != null)
                {
                    Vector3    barrierPos = this.assignedTarget.DrawPos;
                    Quaternion barrierRot = Quaternion.AngleAxis(Rand.Range(0, 360), Vector3.up);
                    Matrix4x4  matrix2    = default(Matrix4x4);
                    float      bScale     = 1.4f;
                    Vector3    s2         = new Vector3(bScale, pawn.DrawPos.y, bScale);
                    matrix2.SetTRS(barrierPos, barrierRot, s2);
                    Graphics.DrawMesh(MeshPool.plane10, matrix2, FlyingObject_SpiritOfLight.sol_barrier, 0);
                }
                matrix.SetTRS(vector, q, s);
                Graphics.DrawMesh(MeshPool.plane10, matrix, mat, 0);
            }

            base.Comps_PostDraw();
        }
Esempio n. 3
0
        public override void Tick()
        {
            age++;
            Vector3 exactPosition = this.ExactPosition;

            this.ticksToImpact--;

            if (!initialized)
            {
                Initialize();
                if (this.glowing && this.glowCenter != default(IntVec3))
                {
                    this.shouldGlow = true;
                }
            }

            if (Find.TickManager.TicksGame % this.chargeFrequency == 0)
            {
                LightEnergy += ChargeAmount;
            }

            bool dFlag = false;

            if (this.pawn.DestroyedOrNull())
            {
                dFlag = true;
                this.Destroy(DestroyMode.Vanish);
            }
            else if (!this.pawn.Spawned || this.pawn.Map != this.Map || this.pawn.Map == null)
            {
                solAction = SoLAction.Limbo;
                dFlag     = true;
                this.delayCount++;
                if (delayCount >= 300)
                {
                    StopGlow();
                    this.shouldGlow = false;
                    this.Destroy(DestroyMode.Vanish);
                }
                if (this.delayCount == 10)
                {
                    MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, 1f);
                    MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .7f);
                    MoteMaker.ThrowLightningGlow(this.ExactPosition, this.Map, .4f);
                }
            }
            else if (this.shouldDismiss)
            {
                if (this.glowing)
                {
                    this.glowCenter = default(IntVec3);
                    StopGlow();
                    this.Destroy(DestroyMode.Vanish);
                }
            }

            if (!dFlag)
            {
                bool flag = !this.ExactPosition.InBounds(base.Map);
                if (flag)
                {
                    if (!this.pawn.DestroyedOrNull() && this.pawn.Spawned)
                    {
                        base.Position      = pawn.Position;
                        this.destination   = GetCasterOffset_Exact;
                        this.speed         = speed_dash;
                        this.ticksToImpact = this.StartingTicksToImpact;
                    }
                    this.ticksToImpact++;
                    base.Position = this.ExactPosition.ToIntVec3();
                }
                else if (this.solAction == SoLAction.Limbo)
                {
                    UpdateAction(this.solAction);
                }
                else
                {
                    base.Position = this.ExactPosition.ToIntVec3();
                    if (Find.TickManager.TicksGame % ActionDelay == 0)
                    {
                        DoAction();
                    }
                    bool flag2 = this.ticksToImpact <= 0;
                    if (flag2)
                    {
                        if (this.shouldDismiss)
                        {
                            bool flag3 = this.DestinationCell.InBounds(base.Map);
                            if (flag3)
                            {
                                base.Position = this.DestinationCell;
                            }
                            this.ImpactSomething();
                        }
                        else
                        {
                            UpdateSoLPower();
                            if (this.curveVariance > 0)
                            {
                                if ((this.curvePoints.Count() - 1) > this.destinationCurvePoint)
                                {
                                    this.origin = curvePoints[destinationCurvePoint];
                                    this.destinationCurvePoint++;
                                    this.destination   = this.curvePoints[this.destinationCurvePoint];
                                    this.ticksToImpact = this.StartingTicksToImpact;
                                }
                                else
                                {
                                    bool flag3 = this.DestinationCell.InBounds(base.Map);
                                    if (flag3)
                                    {
                                        base.Position = this.DestinationCell;
                                    }
                                    this.origin = this.ExactPosition;
                                    solAction   = SoLAction.Pending;
                                    UpdateAction(solAction);
                                }
                            }
                            else
                            {
                                bool flag3 = this.DestinationCell.InBounds(base.Map);
                                if (flag3)
                                {
                                    base.Position = this.DestinationCell;
                                }
                                if (this.solAction == SoLAction.ChargeAttacking)
                                {
                                    ActualLightCost(5f);
                                    int moteAngle = Mathf.RoundToInt(Vector3Utility.ToAngleFlat(this.origin - this.destination) - 90f);
                                    TM_Action.DamageEntities(this.assignedTarget, null, Rand.Range(10f, 15f) * LightPotency, TMDamageDefOf.DamageDefOf.TM_BurningLight, this.pawn);
                                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_LightShield, this.ExactPosition, this.Map, 1.5f, .1f, 0f, .2f, 0, 2f, moteAngle, moteAngle);
                                }

                                this.origin = this.destination;
                                solAction   = SoLAction.Pending;
                                UpdateAction(solAction);
                            }
                        }
                    }

                    if (this.nextMoteTick <= this.age && solAction != SoLAction.Limbo)
                    {
                        DrawMotes();
                    }
                }
            }
        }