コード例 #1
0
        private static bool TryFindDirectFleeDestination(IntVec3 root, float dist, Rot4 dirExcluded, Pawn pawn, out IntVec3 result)
        {
            for (int i = 0; i < 30; i++)
            {
                result = root + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * dist);
                if (result.Walkable(pawn.Map) && result.DistanceToSquared(pawn.Position) < result.DistanceToSquared(root) && GenSight.LineOfSight(root, result, pawn.Map, true, null, 0, 0))
                {
                    return(true);
                }
            }
            Region region = RegionAndRoomQuery.GetRegion(pawn, RegionType.Set_Passable);

            for (int j = 0; j < 30; j++)
            {
                IntVec3 randomCell = CellFinder.RandomRegionNear(region, 15, TraverseParms.For(pawn, Danger.Deadly, TraverseMode.ByPawn, false), null, null, RegionType.Set_Passable).RandomCell;
                if (randomCell.Walkable(pawn.Map) && (float)(root - randomCell).LengthHorizontalSquared > dist * dist)
                {
                    using (PawnPath pawnPath = pawn.Map.pathFinder.FindPath(pawn.Position, randomCell, pawn, PathEndMode.OnCell))
                    {
                        if (PawnPathUtility.TryFindCellAtIndex(pawnPath, (int)dist + 3, out result))
                        {
                            return(true);
                        }
                    }
                }
            }
            result = pawn.Position;
            return(false);
        }
コード例 #2
0
        private static IntVec3 GenerateShrapnelLocation(IntVec3 center, float angleOffset, float distanceFactor)
        {
            float num = SkyfallerShrapnelUtility.ShrapnelAngleDistribution.Evaluate(Rand.Value);
            float d   = SkyfallerShrapnelUtility.ShrapnelDistanceFromAngle.Evaluate(num) * Rand.Value * distanceFactor;

            return((Vector3Utility.HorizontalVectorFromAngle(num + angleOffset) * d).ToIntVec3() + center);
        }
コード例 #3
0
        private void AbsorbedDamage(DamageInfo dinfo)
        {
            this.m_energy -= dinfo.Amount;


            Verse.Sound.SoundStarter.PlayOneShot(SoundAbsorbDamage, (SoundInfo) new TargetInfo(this.Position, this.Map, false));
            Vector3 impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
            Vector3 loc             = this.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f;
            float   num             = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f);

            MoteMaker.MakeStaticMote(loc.ToIntVec3(), this.Map, ThingDefOf.Mote_ExplosionFlash, num);
            int num2 = (int)num;

            for (int i = 0; i < num2; i++)
            {
                MoteMaker.ThrowDustPuff(loc, this.Map, Rand.Range(0.8f, 1.2f));
            }
            //this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            //this.KeepDisplaying();

            if (this.m_energy < 0f)
            {
                this.Break();
            }
        }
コード例 #4
0
 public override void PostDraw()
 {
     base.PostDraw();
     if (TicksLeft > 0)
     {
         Vector3 drawPos = parent.DrawPos;
         float   num     = ((float)parent.Map.Size.z - drawPos.z) * 1.41421354f;
         Vector3 a       = Vector3Utility.FromAngleFlat(angle - 90f);
         Vector3 a2      = drawPos + a * num * 0.5f;
         a2.y = AltitudeLayer.MetaOverlays.AltitudeFor();
         float   num2 = Mathf.Min((float)TicksPassed / 10f, 1f);
         Vector3 b    = a * ((1f - num2) * num);
         float   num3 = 0.975f + Mathf.Sin((float)TicksPassed * 0.3f) * 0.025f;
         if (TicksLeft < fadeOutDuration)
         {
             num3 *= (float)TicksLeft / (float)fadeOutDuration;
         }
         Color color = Props.color;
         color.a *= num3;
         MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color);
         Matrix4x4 matrix = default(Matrix4x4);
         matrix.SetTRS(a2 + a * BeamEndHeight * 0.5f + b, Quaternion.Euler(0f, angle, 0f), new Vector3(Props.width, 1f, num));
         Graphics.DrawMesh(MeshPool.plane10, matrix, BeamMat, 0, null, 0, MatPropertyBlock);
         Vector3 pos = drawPos + b;
         pos.y = AltitudeLayer.MetaOverlays.AltitudeFor();
         Matrix4x4 matrix2 = default(Matrix4x4);
         matrix2.SetTRS(pos, Quaternion.Euler(0f, angle, 0f), new Vector3(Props.width, 1f, BeamEndHeight));
         Graphics.DrawMesh(MeshPool.plane10, matrix2, BeamEndMat, 0, null, 0, MatPropertyBlock);
     }
 }
コード例 #5
0
        public void Action_CircleTarget(Thing target, out Vector3 destTarget)
        {
            Vector3 drawCenter = target.DrawPos;
            Vector3 rndDir     = Vector3Utility.FromAngleFlat(Rand.Range(0, 360));
            Vector3 startPos   = drawCenter + (rndDir * 3f);
            Vector3 endPos     = drawCenter + (rndDir * -3f);

            this.speed          = speed_jog;
            this.solAction      = SoLAction.Circling;
            destTarget          = startPos;
            doublesidedVariance = 1;
            if (Rand.Chance(.5f))
            {
                doublesidedVariance = -1;
            }
            List <Vector3> totalCircle = new List <Vector3>();

            totalCircle.Clear();
            CalculateCurvePoints(startPos, endPos, 90, 10);
            totalCircle.AddRange(this.curvePoints);
            CalculateCurvePoints(endPos, startPos, 90, 10);
            totalCircle.AddRange(this.curvePoints);
            this.curvePoints = totalCircle;
            this.destinationCurvePoint++;
            this.destination         = this.curvePoints[this.destinationCurvePoint];
            this.ticksToImpact       = this.StartingTicksToImpact;
            this.delayCount          = 0;
            this.doublesidedVariance = 0;
        }
コード例 #6
0
ファイル: Projectile_LightLance.cs プロジェクト: bluba/TMagic
        private void Initialize()
        {
            caster = this.launcher as Pawn;
            this.launchPosition = caster.Position;
            CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();

            pwrVal         = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_LightLance, "TM_LightLance", "_pwr", true);
            verVal         = TM_Calc.GetMagicSkillLevel(caster, comp.MagicData.MagicPowerSkill_LightLance, "TM_LightLance", "_ver", true);
            this.arcaneDmg = comp.arcaneDmg;
            if (caster.health.hediffSet.HasHediff(TorannMagicDefOf.TM_LightCapacitanceHD))
            {
                HediffComp_LightCapacitance hd = caster.health.hediffSet.GetFirstHediffOfDef(TorannMagicDefOf.TM_LightCapacitanceHD).TryGetComp <HediffComp_LightCapacitance>();
                this.lightPotency = hd.LightPotency;
            }
            this.radius = Mathf.Clamp(1.8f + (.25f * verVal) * lightPotency, 1f, 3f);
            this.angle  = (Quaternion.AngleAxis(90, Vector3.up) * TM_Calc.GetVector(caster.Position, base.Position)).ToAngleFlat();
            this.CheckSpawnSustainer();
            this.burnTime += (pwrVal * 22);
            lanceAngle     = Vector3Utility.FromAngleFlat(this.angle - 90);             //angle of beam
            lanceAngleInv  = Vector3Utility.FromAngleFlat(this.angle + 90);             //opposite angle of beam
            drawPosStart   = this.launchPosition.ToVector3Shifted() + lanceAngle;       //this.parent.DrawPos;
            drawPosEnd     = base.Position.ToVector3Shifted() + lanceAngleInv;
            lanceLength    = (drawPosEnd - drawPosStart).magnitude;
            lanceVector    = drawPosStart + (lanceAngle * lanceLength * 0.5f);
            lanceVectorInv = drawPosEnd + (lanceAngleInv * lanceLength * .5f);          //draw for double beam
            lanceVector.y  = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);         //graphic depth
        }
コード例 #7
0
        private void SpawnRequestedReinforcements()
        {
            Building_OrbitalRelay orbitalRelay = OG_Util.FindOrbitalRelay(this.Faction);

            if (orbitalRelay != null)
            {
                for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedOfficersNumber; pawnIndex++)
                {
                    Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostOfficerDef);
                    GenSpawn.Spawn(pawn, this.Position);
                }
                for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedHeavyGuardsNumber; pawnIndex++)
                {
                    Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostHeavyGuardDef);
                    GenSpawn.Spawn(pawn, this.Position);
                }
                for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedGuardsNumber; pawnIndex++)
                {
                    Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostGuardDef);
                    GenSpawn.Spawn(pawn, this.Position);
                }
                for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedScoutsNumber; pawnIndex++)
                {
                    Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostScoutDef);
                    GenSpawn.Spawn(pawn, this.Position);
                }
                for (int pawnIndex = 0; pawnIndex < orbitalRelay.requestedTechniciansNumber; pawnIndex++)
                {
                    Pawn pawn = OG_Inhabitants.GeneratePawn(OG_Util.OutpostTechnicianDef);
                    GenSpawn.Spawn(pawn, this.Position + Vector3Utility.RandomHorizontalOffset(4f).ToIntVec3());
                }
            }
        }
コード例 #8
0
        public static IntVec3 GenerateShrapnelLocation(IntVec3 center, float angleOffset)
        {
            float num = IncidentWorker_ShipPartCrash.ShrapnelAngleDistribution.Evaluate(Rand.Value);
            float d   = IncidentWorker_ShipPartCrash.ShrapnelDistanceFromAngle.Evaluate(num) * Rand.Value;

            return((Vector3Utility.HorizontalVectorFromAngle(num + angleOffset) * d).ToIntVec3() + center);
        }
コード例 #9
0
        public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed)
        {
            //Log.Message(string.Format("Bypassing: {0}", !Props.BypassingDamageDefs.Any(def => dinfo.Def == def)));
            if (dinfo.Def != null && base.parent is Pawn pawn && pawn != null && Rand.Chance(Props.InvunerableSaveChance) && !Props.BypassingDamageDefs.Any(def => dinfo.Def == def))
            {
                absorbed = true;
                SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(base.parent.Position, base.parent.Map, false));
                Vector3 impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
                Vector3 loc             = base.parent.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f;
                float   num             = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f);
                MoteMaker.MakeStaticMote(loc, base.parent.Map, ThingDefOf.Mote_ExplosionFlash, num);
                int num2 = (int)num;
                for (int i = 0; i < num2; i++)
                {
                    MoteMaker.ThrowDustPuff(loc, base.parent.Map, Rand.Range(0.8f, 1.2f));


                    float   num3   = Mathf.Lerp(1.2f, 1.55f, 2f);
                    Vector3 vector = pawn.Drawer.DrawPos;
                    vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead);
                    int num4 = Find.TickManager.TicksGame - this.lastAbsorbDamageTick;
                    if (num4 < 8)
                    {
                        float num5 = (float)(8 - num4) / 8f * 0.05f;
                        vector += impactAngleVect * num5;
                        num3   -= num5;
                    }
                    float     angle  = (float)Rand.Range(0, 360);
                    Vector3   s      = new Vector3(num3, 1f, num3);
                    Matrix4x4 matrix = default(Matrix4x4);
                    matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s);
                    Graphics.DrawMesh(MeshPool.plane10, matrix, CompInvunerableSaveOGStatic.BubbleMat, 0);
                }
                this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            }
コード例 #10
0
        /// <summary>
        /// The for arrows ballanced mote thrower
        /// Original: MoteThrower.ThrowHorseshoe
        /// </summary>
        public static void ShootArrow(Pawn thrower, IntVec3 targetCell)
        {
            if (!thrower.Position.ShouldSpawnMotesAt(thrower.Map) || thrower.Map.moteCounter.Saturated)
            {
                return;
            }

            float   speed  = Rand.Range(4.0f, 6.5f) * 1.8f;
            Vector3 vector = targetCell.ToVector3Shifted() + Vector3Utility.RandomHorizontalOffset((1f - (float)thrower.skills.GetSkill(SkillDefOf.Shooting).Level / 20f) * 1.8f);

            vector.y = thrower.DrawPos.y;
            MoteThrown moteThrown = (MoteThrown)ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed("Mote_ArcheryArrow"), null);

            moteThrown.Scale         = 1f;
            moteThrown.rotationRate  = 0f;
            moteThrown.exactPosition = thrower.DrawPos;
            moteThrown.exactRotation = (vector - moteThrown.exactPosition).AngleFlat(); // this corrects the angle of the arrow
            moteThrown.SetVelocity((vector - moteThrown.exactPosition).AngleFlat(), speed);
            moteThrown.airTimeLeft = ((moteThrown.exactPosition - vector).MagnitudeHorizontal() / speed);
            if (moteThrown.airTimeLeft > 1f) // reduce the airtime randomly to let the arrows be too short from time to time
            {
                moteThrown.airTimeLeft -= Rand.Value;
            }
            GenSpawn.Spawn(moteThrown, thrower.Position, thrower.Map);
        }
コード例 #11
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));
        }
コード例 #12
0
        public static bool TryFindDirectFleeDestination(IntVec3 root, float dist, Pawn pawn, out IntVec3 result)
        {
            for (int i = 0; i < 30; i++)
            {
                result = root + IntVec3.FromVector3(Vector3Utility.HorizontalVectorFromAngle((float)Rand.Range(0, 360)) * dist);
                if (result.Walkable(pawn.Map) && result.DistanceToSquared(pawn.Position) < result.DistanceToSquared(root) && GenSight.LineOfSight(root, result, pawn.Map, skipFirstCell: true))
                {
                    return(true);
                }
            }
            Region region = pawn.GetRegion();

            for (int j = 0; j < 30; j++)
            {
                Region  region2    = CellFinder.RandomRegionNear(region, 15, TraverseParms.For(pawn));
                IntVec3 randomCell = region2.RandomCell;
                if (randomCell.Walkable(pawn.Map) && (float)(root - randomCell).LengthHorizontalSquared > dist * dist)
                {
                    using (PawnPath path = pawn.Map.pathFinder.FindPath(pawn.Position, randomCell, pawn))
                    {
                        if (PawnPathUtility.TryFindCellAtIndex(path, (int)dist + 3, out result))
                        {
                            return(true);
                        }
                    }
                }
            }
            result = pawn.Position;
            return(false);
        }
コード例 #13
0
 public override void PostDraw()
 {
     base.PostDraw();
     if (this.TicksLeft > 0)
     {
         Vector3 drawPos = base.parent.DrawPos;
         IntVec3 size    = base.parent.Map.Size;
         float   num     = (float)(((float)size.z - drawPos.z) * 1.4142135381698608);
         Vector3 a       = Vector3Utility.FromAngleFlat((float)(this.angle - 90.0));
         Vector3 a2      = drawPos + a * num * 0.5f;
         a2.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
         float   num2 = Mathf.Min((float)((float)this.TicksPassed / 10.0), 1f);
         Vector3 b    = a * (float)((1.0 - num2) * num);
         float   num3 = (float)(0.97500002384185791 + Mathf.Sin((float)((float)this.TicksPassed * 0.30000001192092896)) * 0.02500000037252903);
         if (this.TicksLeft < this.fadeOutDuration)
         {
             num3 *= (float)this.TicksLeft / (float)this.fadeOutDuration;
         }
         Color color = this.Props.color;
         color.a *= num3;
         CompOrbitalBeam.MatPropertyBlock.SetColor(ShaderPropertyIDs.Color, color);
         Matrix4x4 matrix = default(Matrix4x4);
         matrix.SetTRS(a2 + a * this.BeamEndHeight * 0.5f + b, Quaternion.Euler(0f, this.angle, 0f), new Vector3(this.Props.width, 1f, num));
         Graphics.DrawMesh(MeshPool.plane10, matrix, CompOrbitalBeam.BeamMat, 0, null, 0, CompOrbitalBeam.MatPropertyBlock);
         Vector3 pos = drawPos + b;
         pos.y = Altitudes.AltitudeFor(AltitudeLayer.MetaOverlays);
         Matrix4x4 matrix2 = default(Matrix4x4);
         matrix2.SetTRS(pos, Quaternion.Euler(0f, this.angle, 0f), new Vector3(this.Props.width, 1f, this.BeamEndHeight));
         Graphics.DrawMesh(MeshPool.plane10, matrix2, CompOrbitalBeam.BeamEndMat, 0, null, 0, CompOrbitalBeam.MatPropertyBlock);
     }
 }
コード例 #14
0
        public void AbsorbedDamage(DamageInfo dinfo)
        {
            Apparel_MedievalShield.SoundAbsorbDamage.PlayOneShot(new TargetInfo(this.wearer.Position, this.wearer.Map, false));
            this.impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
            Vector3 loc = this.wearer.TrueCenter() + this.impactAngleVect.RotatedBy(180f) * 0.5f;

            MoteMaker.MakeStaticMote(loc, this.wearer.Map, ThingDefOf.Mote_ShotHit_Spark, 1f);
        }
コード例 #15
0
 public void AbsorbedDamage(DamageInfo dinfo)
 {
     Apparel_Shield.SoundAbsorbDamage.PlayOneShotOnCamera(null);
     this.impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
     Vector3 loc = this.Wearer.TrueCenter() + this.impactAngleVect.RotatedBy(180f) * 0.5f;
     // this.HitPoints -= (int)dinfo.Amount;
     // MoteThrown.ThrowStatic(loc, ThingDefOf.Mote_ShotHit_Spark, 1f);
     // MoteThrown.SetVelocity(loc.magnitude, 1f);
 }
コード例 #16
0
        private void AbsorbedDamage(DamageInfo dinfo)
        {
            PhysicalShield.SoundAbsorbDamage.PlayOneShot(new TargetInfo(Wearer.Position, Wearer.Map));
            impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
            Vector3 vector = Wearer.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f;

            lastAbsorbDamageTick = Find.TickManager.TicksGame;
            KeepDisplaying();
        }
コード例 #17
0
    private void Update()
    {
        transform.position = Vector3Utility.QuadraticLerp(initialPosition, midPoint, playerPosition, t += speed);

        if (t >= 1 && !waitingForDestroy)
        {
            Destroy(gameObject, 5);
            waitingForDestroy = true;
        }
    }
コード例 #18
0
        private static void SpawnChipChunksAt(IntVec3 position)
        {
            int partsNumber = Rand.Range(2, 5);

            for (int partIndex = 0; partIndex < partsNumber; partIndex++)
            {
                IntVec3 spawnCell = position + Vector3Utility.RandomHorizontalOffset(5f).ToIntVec3();
                GenSpawn.Spawn(ThingDefOf.ShipChunk, spawnCell);
            }
        }
コード例 #19
0
 private void Break()
 {
     SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(Pawn.Position, Pawn.Map));
     MoteMaker.MakeStaticMote(Pawn.TrueCenter(), Pawn.Map, ThingDefOf.Mote_ExplosionFlash, 12f);
     for (int i = 0; i < 6; i++)
     {
         MoteMaker.ThrowDustPuff(Pawn.TrueCenter() + Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f), Pawn.Map, Rand.Range(0.8f, 1.2f));
     }
     Energy = 0f;
 }
コード例 #20
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();
        }
コード例 #21
0
        internal void Update(RtsCameraController camera, GameTime gameTime)
        {
            var currentTimeFraction = (float)((gameTime.TotalGameTime - _startTime).TotalSeconds / _duration.TotalSeconds);

            currentTimeFraction = Math.Min(currentTimeFraction, 1);

            var pos          = currentTimeFraction * (_points.Count - 1);
            var integralPart = (int)Math.Truncate(pos);
            var decimalPart  = pos - integralPart;

            // TODO: Not sure how right this is
            // Near the end of the path 2-3 points are the same, so the movement becomes more linear?
            var point1 = integralPart;
            var point2 = Math.Min(point1 + 1, _points.Count - 1);
            var point0 = Math.Max(point1 - 1, 0);
            var point3 = Math.Min(point2 + 1, _points.Count - 1);

            camera.TerrainPosition = Interpolation.CatmullRom(
                _points[point0],
                _points[point1],
                _points[point2],
                _points[point3],
                decimalPart);

            if (_lookToward != null)
            {
                var lookDirection = Vector3.Normalize(_lookToward.Value - camera.TerrainPosition);
                camera.SetLookDirection(lookDirection);
            }
            else if (_endDirection != null)
            {
                var lookDirection = Vector3.Normalize(Vector3Utility.Slerp(_startDirection, _endDirection.Value, currentTimeFraction));

                camera.SetLookDirection(lookDirection);
            }

            if (_endPitch != null)
            {
                var pitch = MathUtility.Lerp(_startPitch, _endPitch.Value, currentTimeFraction);

                camera.Pitch = pitch;
            }

            if (_endZoom != null)
            {
                var zoom = MathUtility.Lerp(_startZoom, _endZoom.Value, currentTimeFraction);

                camera.Zoom = zoom;
            }

            if (gameTime.TotalGameTime > _endTime)
            {
                Finished = true;
            }
        }
コード例 #22
0
 // Token: 0x0600005C RID: 92 RVA: 0x00003EBC File Offset: 0x000020BC
 private void Break()
 {
     SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(base.Wearer.Position, base.Wearer.Map, false));
     MoteMaker.MakeStaticMote(base.Wearer.TrueCenter(), base.Wearer.Map, ThingDefOf.Mote_ExplosionFlash, 12f);
     for (int i = 0; i < 6; i++)
     {
         MoteMaker.ThrowDustPuff(base.Wearer.TrueCenter() + Vector3Utility.HorizontalVectorFromAngle((float)Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f), base.Wearer.Map, Rand.Range(0.8f, 1.2f));
     }
     this.energy       = 0f;
     this.ticksToReset = this.StartingTicksToReset;
 }
 private void Break()
 {
     SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(Pawn.Position, Pawn.Map));
     FleckMaker.Static(Pawn.TrueCenter(), Pawn.Map, FleckDefOf.ExplosionFlash, 12f);
     for (int i = 0; i < 6; i++)
     {
         Vector3 loc = Pawn.TrueCenter() + Vector3Utility.HorizontalVectorFromAngle((float)Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f);
         FleckMaker.ThrowDustPuff(loc, Pawn.Map, Rand.Range(0.8f, 1.2f));
     }
     energy       = 0f;
     ticksToReset = StartingTicksToReset;
 }
コード例 #24
0
        public void HitShield(Projectile proj)
        {
            this.lastInterceptAngle = Vector3Utility.AngleToFlat(proj.DrawPos, GenThing.TrueCenter(this.parent));
            this.lastIntercepted    = Find.TickManager.TicksGame;
            float dmg = proj.DamageAmount;

            if (proj.def.projectile.damageDef == DamageDefOf.EMP)
            {
                dmg *= zzShieldHurtRate_EMP;
                dmg += ShieldEnergyCurrent * zzShieldHurtRateExtra_EMP;
            }
            else if (proj.def.projectile.damageDef == DamageDefOf.Flame)
            {
                dmg *= zzShieldHurtRate_Flame;
            }

            dmg = Mathf.Max(0, dmg * zzShieldHurtRate);

            //判定为爆炸弹丸
            if (proj.def.projectile.explosionRadius != 0)
            {
                //受到伤害取决于弹丸威力*伤害半径^2
                dmg *= Mathf.Max(1f, proj.def.projectile.explosionRadius * proj.def.projectile.explosionRadius) * zzShieldHurtRate_AOE;

                MoteMaker.ThrowMicroSparks(this.parent.DrawPos, this.parent.Map);
                GenExplosion.DoExplosion(proj.Position, this.parent.Map, Mathf.Min(proj.def.projectile.explosionRadius * 0.66f, 3f),
                                         DefDatabase <DamageDef> .GetNamed("zz_ShieldExplosion", true),
                                         null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, null);
                //Log.Message("爆炸伤害:"+ dmg * proj.def.projectile.explosionRadius+" = "+ dmg+" * "+ proj.def.projectile.explosionRadius);
            }
            //判定为普通弹丸
            else
            {
                //还用旧的伤害效果
                //On hit effects
                MoteMaker.ThrowLightningGlow(proj.ExactPosition, this.parent.Map, 0.5f);
                //On hit sound
                ShieldManagerMapComp.HitSoundDef.PlayOneShot((SoundInfo) new TargetInfo(proj.Position, proj.Map, false));
                //Log.Message("子弹伤害:" + dmg );
            }

            if (dmg >= 0)
            {
                ShieldEnergyCurrent -= dmg;
                if (CanAddMote())
                {
                    ThrowDamageMote(dmg, parent.Map, proj.Position.ToVector3(), "-" + dmg.ToString("F0") + "/ " + ShieldEnergyCurrent.ToString("F0"));
                }
            }

            proj.Destroy();
        }
コード例 #25
0
        // Token: 0x06000029 RID: 41 RVA: 0x00002DD8 File Offset: 0x00000FD8
        internal void JPRotatePilot(Pawn pilot, IntVec3 targCell, out float angle)
        {
            angle = Vector3Utility.AngleToFlat(pilot.Position.ToVector3(), targCell.ToVector3());
            float offsetAngle = angle + 90f;

            if (offsetAngle > 360f)
            {
                offsetAngle -= 360f;
            }
            Rot4 facing = Rot4.FromAngleFlat(offsetAngle);

            pilot.Rotation = facing;
        }
コード例 #26
0
        private void Break()
        {
            this.ShieldState = ShieldStatePawn.Charging;

            Verse.Sound.SoundStarter.PlayOneShot(SoundBreak, (SoundInfo) new TargetInfo(this.Position, this.Map, false));
            MoteMaker.MakeStaticMote(this.TrueCenter(), this.Map, ThingDefOf.Mote_ExplosionFlash, 12f);
            for (int i = 0; i < 6; i++)
            {
                UnityEngine.Vector3 loc = this.TrueCenter() + Vector3Utility.HorizontalVectorFromAngle((float)Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f);
                MoteMaker.ThrowDustPuff(loc, this.Map, Rand.Range(0.8f, 1.2f));
            }
            this.m_energy = 0;
        }
コード例 #27
0
        // Token: 0x06000033 RID: 51 RVA: 0x0000369C File Offset: 0x0000189C
        public void TurretTopTick()
        {
            LocalTargetInfo currentTarget = this.parentTurret.CurrentTarget;
            bool            isValid       = currentTarget.IsValid;

            if (isValid)
            {
                this.CurRotation        = Vector3Utility.AngleFlat(currentTarget.Cell.ToVector3Shifted() - this.parentTurret.DrawPos);
                this.ticksUntilIdleTurn = Rand.RangeInclusive(150, 350);
            }
            else
            {
                bool flag = this.ticksUntilIdleTurn > 0;
                if (flag)
                {
                    this.ticksUntilIdleTurn--;
                    bool flag2 = this.ticksUntilIdleTurn == 0;
                    if (flag2)
                    {
                        bool flag3 = (double)Rand.Value < 0.5;
                        if (flag3)
                        {
                            this.idleTurnClockwise = true;
                        }
                        else
                        {
                            this.idleTurnClockwise = false;
                        }
                        this.idleTurnTicksLeft = 140;
                    }
                }
                else
                {
                    bool flag4 = this.idleTurnClockwise;
                    if (flag4)
                    {
                        this.CurRotation += 0.26f;
                    }
                    else
                    {
                        this.CurRotation -= 0.26f;
                    }
                    this.idleTurnTicksLeft--;
                    bool flag5 = this.idleTurnTicksLeft <= 0;
                    if (flag5)
                    {
                        this.ticksUntilIdleTurn = Rand.RangeInclusive(150, 350);
                    }
                }
            }
        }
コード例 #28
0
        public override bool TryAbsorbDamage(DamageInfo dinfo)
        {
            if (currentEnergy == 0f || dinfo.Def == DamageDefOf.SurgicalCut)
            {
                return(false);
            }
            if (!pawn.Drafted && !pawn.IsFighting() && Rand.Chance(0.2f))
            {
                if (pawn.IsColonist)
                {
                    Messages.Message("MessageTextForgotAura".Translate().Formatted(pawn.Named("PAWN")).AdjustedFor(pawn, "PAWN").CapitalizeFirst(), pawn, MessageTypeDefOf.NegativeEvent);
                }
                return(false);
            }

            if (pawn.health.hediffSet.HasHediff(RWBYDefOf.RWBY_AmplifiedAura))
            {
                currentEnergy -= dinfo.Amount / 200f; // amplified Aura takes half the damage
            }
            else
            {
                currentEnergy -= dinfo.Amount / 100f;
            }
            if (currentEnergy > 0f) // normal absorb
            {
                RWBYDefOf.AuraFlicker.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map, false));
                this.impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
                Vector3 loc = pawn.TrueCenter() + impactAngleVect.RotatedBy(180f) * 0.5f;
                float   num = Mathf.Min(10f, 2f + dinfo.Amount / 10f);
                MoteMaker.MakeStaticMote(loc, pawn.Map, ThingDefOf.Mote_ExplosionFlash, num);
                int num2 = (int)num;
                for (int i = 0; i < num2; i++)
                {
                    MoteMaker.ThrowDustPuff(loc, pawn.Map, Rand.Range(0.8f, 1.2f));
                }
                lastAbsorbDamageTick = Find.TickManager.TicksGame;
            }
            else // break
            {
                RWBYDefOf.AuraBreak.PlayOneShot(new TargetInfo(pawn.Position, pawn.Map, false));
                MoteMaker.MakeStaticMote(pawn.TrueCenter(), pawn.Map, ThingDefOf.Mote_ExplosionFlash, 12f);
                for (int i = 0; i < 6; i++)
                {
                    Vector3 loc = pawn.TrueCenter() + Vector3Utility.HorizontalVectorFromAngle((float)Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f);
                    MoteMaker.ThrowDustPuff(loc, pawn.Map, Rand.Range(0.8f, 1.2f));
                }
                currentEnergy = 0f;
            }

            return(true);
        }
コード例 #29
0
 public virtual void Break()
 {
     SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(Pawn.Position, Pawn.Map, false));
     FleckMaker.Static(Pawn.TrueCenter(), Pawn.Map, FleckDefOf.ExplosionFlash, 12);
     for (int i = 0; i < 6; i++)
     {
         Rand.PushState();
         Vector3 loc = Pawn.TrueCenter() + Vector3Utility.HorizontalVectorFromAngle((float)Rand.Range(0, 360)) * Rand.Range(0.3f, 0.6f);
         AdeptusFleckMaker.ThrowDustPuff(loc, Pawn.Map, Rand.Range(0.8f, 1.2f));
         Rand.PopState();
     }
     this.energy       = 0f;
     this.ticksToReset = this.StartingTicksToReset;
 }
コード例 #30
0
        internal static void RotatePawn(Pawn pawn, IntVec3 targCell, out float angle)
        {
            angle = Vector3Utility.AngleToFlat(pawn.Position.ToVector3(), targCell.ToVector3());
            float num  = angle + 90f;
            bool  flag = num > 360f;

            if (flag)
            {
                num -= 360f;
            }
            Rot4 rotation = Rot4.FromAngleFlat(num);

            pawn.Rotation = rotation;
        }