public override void Tick()
        {
            //base.Tick();
            this.drawTicks--;
            if (this.drawTicks <= 0)
            {
                this.shouldDrawPawn = false;
            }
            Vector3 exactPosition = this.ExactPosition;

            this.ticksToImpact--;
            bool flag = !this.ExactPosition.InBounds(base.Map);

            if (flag)
            {
                this.ticksToImpact++;
                base.Position = this.ExactPosition.ToIntVec3();
                this.Destroy(DestroyMode.Vanish);
            }
            else if (!this.ExactPosition.ToIntVec3().Walkable(base.Map))
            {
                this.earlyImpact = true;
                this.ImpactSomething();
            }
            else
            {
                base.Position = this.ExactPosition.ToIntVec3();
                FleckMaker.ThrowDustPuff(base.Position, base.Map, Rand.Range(0.8f, 1.2f));
                if (Find.TickManager.TicksGame % 4 == 0)
                {
                    ApplyDashDamage();
                }
                bool flag2 = this.ticksToImpact <= 0;
                if (flag2)
                {
                    bool flag3 = this.DestinationCell.InBounds(base.Map);
                    if (flag3)
                    {
                        base.Position = this.DestinationCell;
                    }
                    this.ImpactSomething();
                }
            }
        }
Exemple #2
0
        public void InitiateMassSummon(Map map, LocalTargetInfo target)
        {
            IntVec3 curCell;
            IEnumerable <IntVec3> targets = GenRadial.RadialCellsAround(target.Cell, Mathf.RoundToInt(7 * comp.arcaneDmg), true);
            int transportedItemCount      = 0;

            for (int i = 0; i < targets.Count(); i++)
            {
                curCell = targets.ToArray <IntVec3>()[i];
                if (curCell.InBounds(map) && curCell.IsValid)
                {
                    List <Thing> thingList = curCell.GetThingList(map);
                    for (int j = 0; j < thingList.Count(); j++)
                    {
                        if (thingList[j] != null && thingList[j].def.mote == null)
                        {
                            Thing targetThing = thingList[j];
                            if (targetThing != this.CasterPawn)
                            {
                                if (targetThing is Pawn)
                                {
                                    FleckMaker.ThrowLightningGlow(targetThing.DrawPos, targetThing.Map, 1f);
                                    FleckMaker.ThrowHeatGlow(targetThing.Position, targetThing.Map, 1f);
                                    targetThing.DeSpawn();
                                    GenSpawn.Spawn(targetThing, this.CasterPawn.Position, this.CasterPawn.Map);
                                    transportedItemCount++;
                                    j--;
                                }
                                else if (targetThing != null && targetThing.def.EverHaulable)
                                {
                                    FleckMaker.ThrowLightningGlow(targetThing.DrawPos, targetThing.Map, .6f);
                                    FleckMaker.ThrowHeatGlow(targetThing.Position, targetThing.Map, 1f);
                                    targetThing.DeSpawn();
                                    GenPlace.TryPlaceThing(targetThing, this.CasterPawn.Position, this.CasterPawn.Map, ThingPlaceMode.Near, null);
                                    transportedItemCount++;
                                    j--;
                                }
                            }
                        }
                    }
                    FleckMaker.ThrowSmoke(curCell.ToVector3Shifted(), map, .6f);
                }
            }
        }
Exemple #3
0
        public void DrawHediffExtras()
        {
            var loc  = pawn.DrawPos;
            var map  = pawn.Map;
            var size = 1f;

            if (!loc.ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }

            var dataStatic = FleckMaker.GetDataStatic(loc, map, FleckDefOf.Smoke, Rand.Range(1.5f, 2.5f) * size);

            dataStatic.rotationRate  = Rand.Range(-30f, 30f);
            dataStatic.velocityAngle = Rand.Range(30, 40);
            dataStatic.velocitySpeed = Rand.Range(0.5f, 0.7f);
            dataStatic.instanceColor = Color.yellow;
            map.flecks.CreateFleck(dataStatic);
        }
Exemple #4
0
        public static void ApplyCleaveDamage(DamageInfo dinfo, Pawn caster, Pawn target, Map map, int ver)
        {
            bool flag = !dinfo.InstantPermanentInjury;

            if (flag)
            {
                bool flag2 = dinfo.Instigator != null;
                if (flag2)
                {
                    bool flag3 = caster != null && caster.PositionHeld != default(IntVec3) && !caster.Downed;
                    if (flag3)
                    {
                        System.Random random = new System.Random();
                        int           rnd    = GenMath.RoundRandom(random.Next(0, 100));
                        if (rnd < (ver * 15))
                        {
                            target.TakeDamage(dinfo);
                            FleckMaker.ThrowMicroSparks(target.Position.ToVector3(), map);
                        }
                        target.TakeDamage(dinfo);
                        FleckMaker.ThrowMicroSparks(target.Position.ToVector3(), map);
                        for (int i = 0; i < 8; i++)
                        {
                            IntVec3 intVec       = target.PositionHeld + GenAdj.AdjacentCells[i];
                            Pawn    cleaveVictim = new Pawn();
                            cleaveVictim = intVec.GetFirstPawn(map);
                            if (cleaveVictim != null && cleaveVictim.Faction != caster.Faction && cleaveVictim.HostileTo(caster.Faction))
                            {
                                cleaveVictim.TakeDamage(dinfo);
                                FleckMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), map);
                                rnd = GenMath.RoundRandom(random.Next(0, 100));
                                if (rnd < (ver * 15))
                                {
                                    cleaveVictim.TakeDamage(dinfo);
                                    FleckMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), map);
                                }
                                DrawCleaving(cleaveVictim, caster, 10);
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        public virtual void AbsorbedDamage(DamageInfo dinfo)
        {
            SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(Pawn.Position, Pawn.Map, false));
            this.impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
            Vector3 loc = Pawn.TrueCenter() + this.impactAngleVect.RotatedBy(180f) * 0.5f;
            float   num = Mathf.Min(10f, 2f + dinfo.Amount / 10f);

            FleckMaker.Static(loc, Pawn.Map, FleckDefOf.ExplosionFlash, num);
            int num2 = (int)num;

            for (int i = 0; i < num2; i++)
            {
                Rand.PushState();
                AdeptusFleckMaker.ThrowDustPuff(loc, Pawn.Map, Rand.Range(0.8f, 1.2f));
                Rand.PopState();
            }
            this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            this.KeepDisplaying();
        }
        public override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, ThingDef.Named("Gun_Autopistol"), this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                DamageDef  damageDef        = this.def.projectile.damageDef;
                float      amount           = (float)base.DamageAmount;
                float      armorPenetration = base.ArmorPenetration;
                float      y            = this.ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                Building wall = hitThing as Building;
                if (wall != null)
                {
                    if ((wall.def.building.isNaturalRock) || (wall.def == ThingDefOf.Wall))
                    {
                        DamageInfo dinfo2 = new DamageInfo(damageDef, amount * 5, armorPenetration * 3, y, launcher, null, null, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                        hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                    }
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                FleckMaker.Static(this.ExactPosition, map, FleckDefOf.ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    FleckMaker.WaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
                }
            }
        }
Exemple #7
0
        protected virtual void Reset()
        {
            if (this.Pawn.Spawned)
            {
                if (Props.resetSound != null)
                {
                    Props.resetSound.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
                }
                else
                {
                    SoundDefOf.EnergyShield_Reset.PlayOneShot(new TargetInfo(this.Pawn.Position, this.Pawn.Map));
                }

                FleckMaker.ThrowLightningGlow(this.Pawn.TrueCenter(), this.Pawn.Map, 3f);
            }

            ticksToReset = -1;
            energy       = EnergyOnReset;
        }
Exemple #8
0
        public void DamageBuildings(int amt)
        {
            IntVec3 c = this.RandomAdjacentCell8Way();

            if (c.InBounds(base.Map))
            {
                Building   firstBuilding = c.GetFirstBuilding(base.Map);
                DamageInfo dinfo         = new DamageInfo(DamageDef, (float)amt, 0f, -1f, null, null, null, DamageInfo.SourceCategory.ThingOrUnknown, null);
                if (firstBuilding != null)
                {
                    //	if (Find.Selector.SelectedObjects.Contains(firstBuilding)) Log.Message("Damaging firstBuilding " + firstBuilding);
                    firstBuilding.TakeDamage(dinfo);
                    if (Def.damageMote)
                    {
                        FleckMaker.ThrowDustPuff(firstBuilding.Position, base.Map, 0.2f);
                    }
                }
            }
        }
        public void DrawOrb(Vector3 orbVec, Map map)
        {
            Vector3 vector  = orbVec;
            float   xOffset = Rand.Range(-0.6f, 0.6f);
            float   zOffset = Rand.Range(-0.6f, 0.6f);

            orbVec.x += xOffset;
            orbVec.z += zOffset;
            FleckMaker.ThrowLightningGlow(orbVec, map, 0.4f);
            float num = Mathf.Lerp(1.2f, 1.55f, 5f);

            vector.y = Altitudes.AltitudeFor(AltitudeLayer.MoteOverhead);
            float     angle  = (float)Rand.Range(0, 360);
            Vector3   s      = new Vector3(0.4f, 0.4f, 0.4f);
            Matrix4x4 matrix = default(Matrix4x4);

            matrix.SetTRS(vector, Quaternion.AngleAxis(0f, Vector3.up), s);
            Graphics.DrawMesh(MeshPool.plane10, matrix, FlyingObject_LightningTrap.OrbMat, 0);
        }
Exemple #10
0
        protected override DamageWorker.DamageResult ApplyMeleeDamageToTarget(LocalTargetInfo target)
        {
            DamageWorker.DamageResult damageResult     = new DamageWorker.DamageResult();
            BodyPartGroupDef          bodyPartGroupDef = null;
            HediffDef hediffDef        = null;
            float     num              = verbProps.AdjustedMeleeDamageAmount(this, CasterPawn);
            float     armorPenetration = verbProps.AdjustedArmorPenetration(this, CasterPawn);
            ThingDef  source           = (base.EquipmentSource == null) ? CasterPawn.def : base.EquipmentSource.def;

            bodyPartGroupDef = verbProps.AdjustedLinkedBodyPartsGroup(tool);
            DamageInfo dinfo = new DamageInfo(TMDamageDefOf.DamageDefOf.TM_Cleave, (num * .6f), armorPenetration, -1f, this.CasterPawn, null, source);

            damageResult.totalDamageDealt = Mathf.Min((float)target.Thing.HitPoints, dinfo.Amount);
            for (int i = 0; i < 8; i++)
            {
                IntVec3 intVec       = target.Cell + GenAdj.AdjacentCells[i];
                Pawn    cleaveVictim = new Pawn();
                cleaveVictim = intVec.GetFirstPawn(target.Thing.Map);
                if (cleaveVictim != null && cleaveVictim.Faction != caster.Faction)
                {
                    Vector3 direction = (cleaveVictim.Position - CasterPawn.Position).ToVector3();
                    dinfo.SetBodyRegion(BodyPartHeight.Undefined, BodyPartDepth.Outside);
                    dinfo.SetWeaponBodyPartGroup(bodyPartGroupDef);
                    dinfo.SetWeaponHediff(hediffDef);
                    dinfo.SetAngle(direction);
                    dinfo.SetAmount(Rand.Range(.8f, 1.2f) * num * .6f);
                    cleaveVictim.TakeDamage(dinfo);
                    FleckMaker.ThrowMicroSparks(cleaveVictim.Position.ToVector3(), target.Thing.Map);
                    TM_MoteMaker.ThrowCrossStrike(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, 1f);
                    TM_MoteMaker.ThrowBloodSquirt(cleaveVictim.Position.ToVector3Shifted(), cleaveVictim.Map, 1f);
                    DrawCleaving(cleaveVictim, base.CasterPawn, 10);
                }
            }
            TM_MoteMaker.ThrowCrossStrike(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, 1f);
            TM_MoteMaker.ThrowBloodSquirt(target.Thing.Position.ToVector3Shifted(), target.Thing.Map, 1f);
            target.Thing.TakeDamage(dinfo);
            if (target != null && !target.Thing.DestroyedOrNull())
            {
                base.ApplyMeleeDamageToTarget(target);
            }
            return(damageResult);
        }
Exemple #11
0
        public static bool ImpactSomethingCallback(ProjectileCE projectile, Thing launcher)
        {
            bool flyOverhead = projectile.def.projectile.flyOverhead;

            if (!flyOverhead)
            {
                return(false);
            }
            Map map = projectile.Map;

            getShields(map);
            Vector3 destination = projectile.ExactPosition;

            foreach (Building building in shields)
            {
                var  shield    = building as Building_Shield;
                var  generator = shield.GetComp <Comp_ShieldGenerator>();
                bool isActive  = (bool)generator.IsActive();
                if (!isActive)
                {
                    continue;
                }
                bool blockIndirect = (bool)generator.BlockIndirect_Active();
                if (!blockIndirect)
                {
                    continue;
                }
                int   fieldRadius   = (int)generator.FieldRadius_Active();
                int   fieldRadiusSq = fieldRadius * fieldRadius;
                float DistanceSq    = projectile.Position.DistanceToSquared(shield.Position) - fieldRadiusSq;
                if (DistanceSq > 0)
                {
                    continue;
                }
                HitSoundDef.PlayOneShot((SoundInfo) new TargetInfo(shield.Position, map, false));
                FleckMaker.ThrowLightningGlow(destination, map, 0.5f);
                int damage = (projectile.def.projectile.GetDamageAmount(launcher));
                generator.FieldIntegrity_Current -= damage;
                return(true);
            }
            return(false);
        }
Exemple #12
0
        /// <summary>
        ///     Impacts a pawn/object or the ground.
        /// </summary>
        public override void Impact_Override(Thing hitThing)
        {
            //Log.Message("Impact override");
            base.Impact_Override(hitThing);
            if (hitThing != null)
            {
                //Log.Message("Hit thing found: " + hitThing.ToString() );

                var damageAmountBase = def.projectile.GetDamageAmount(1f);
                var dinfo            = new DamageInfo(def.projectile.damageDef, damageAmountBase,
                                                      def.projectile.GetArmorPenetration(1f), ExactRotation.eulerAngles.y,
                                                      launcher, weapon: equipmentDef, intendedTarget: hitThing);
                var battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(launcher, hitThing, intendedTarget.Thing, launcher.def, def, targetCoverDef);
                Find.BattleLog.Add(battleLogEntry_RangedImpact);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                //Log.Message("Hit thing taken damage: " + dinfo.Amount.ToString() + " " + dinfo.Def.label);

                //hitThing.TakeDamage(dinfo);
                if (canStartFire && Rand.Range(0f, 1f) > startFireChance)
                {
                    hitThing.TryAttachFire(0.05f);
                }
                if (hitThing is Pawn pawn)
                {
                    PostImpactEffects(launcher as Pawn, pawn);
                    FleckMaker.ThrowMicroSparks(destination, Map);
                    FleckMaker.Static(destination, Map, FleckDefOf.ShotHit_Dirt);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(SoundInfo.InMap(new TargetInfo(Position, Map)));
                FleckMaker.Static(ExactPosition, Map, FleckDefOf.ShotHit_Dirt);
                FleckMaker.ThrowMicroSparks(ExactPosition, Map);
            }
            var hitPawn = hitThing as Pawn;

            if (hitPawn?.stances != null && hitPawn.BodySize <= def.projectile.stoppingPower + 0.001f)
            {
                hitPawn.stances.StaggerFor(95);
            }
        }
Exemple #13
0
        public override void Tick()
        {
            //base.Tick();
            Vector3 exactPosition = this.ExactPosition;

            this.ticksToImpact--;
            bool flag = !this.ExactPosition.InBounds(base.Map);

            if (flag)
            {
                this.ticksToImpact++;
                base.Position = this.ExactPosition.ToIntVec3();
                this.Destroy(DestroyMode.Vanish);
            }
            else
            {
                base.Position = this.ExactPosition.ToIntVec3();
                if (Find.TickManager.TicksGame % 2 == 0)
                {
                    FleckMaker.ThrowDustPuff(base.Position, base.Map, Rand.Range(0.8f, 1.2f));
                }

                if (Find.TickManager.TicksGame % 3 == 0)
                {
                    Vector3 shiftVec = this.ExactPosition;
                    shiftVec.x += Rand.Range(-.3f, .3f);
                    shiftVec.z += Rand.Range(-.3f, .3f);
                    TM_MoteMaker.ThrowArcaneMote(shiftVec, base.Map, Rand.Range(.5f, .6f), .1f, .02f, .2f, 200, .3f);
                }

                bool flag2 = this.ticksToImpact <= 0;
                if (flag2)
                {
                    bool flag3 = this.DestinationCell.InBounds(base.Map);
                    if (flag3)
                    {
                        base.Position = this.DestinationCell;
                    }
                    this.ImpactSomething();
                }
            }
        }
        private static void TryHealRandomInjury(Pawn_HealthTracker __instance, Pawn pawn, float healAmount, Building_BaseMechanoidPlatform platform = null)
        {
            IEnumerable <Hediff_Injury> hediffs = __instance.hediffSet.GetHediffs <Hediff_Injury>().Where((Hediff_Injury i) => HediffUtility.CanHealNaturally(i));

            if (hediffs.Count() == 0)
            {
                return;
            }
            Hediff_Injury hediff_Injury = hediffs.RandomElement();

            hediff_Injury.Heal(healAmount);
            if (pawn.Map != null && !pawn.Position.Fogged(pawn.Map))
            {
                FleckMaker.ThrowMetaIcon(pawn.Position, pawn.Map, WTH_DefOf.WTH_Fleck_HealingCrossGreen);
            }
            if (platform != null)
            {
                platform.refuelableComp.ConsumeFuel((platform.GetStatValue(WTH_DefOf.WTH_PartConsumptionRate) * healTickInterval) / GenDate.TicksPerDay);//TODO no magic number
            }
        }
        // Token: 0x06000041 RID: 65 RVA: 0x0000385C File Offset: 0x00001A5C
        public void AbsorbedDamage(DamageInfo dinfo)
        {
            var wearer = Wearer;

            SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(wearer.Position, wearer.Map));
            impactAngleVect = Vector3Utility.HorizontalVectorFromAngle(dinfo.Angle);
            var loc = wearer.TrueCenter() + (impactAngleVect.RotatedBy(180f) * 0.5f);
            var num = Mathf.Min(10f, 2f + (dinfo.Amount / 10f));

            FleckMaker.Static(loc, wearer.Map, FleckDefOf.ExplosionFlash, num);
            var num2 = (int)num;

            for (var i = 0; i < num2; i++)
            {
                FleckMaker.ThrowDustPuff(loc, wearer.Map, Rand.Range(0.8f, 1.2f));
            }

            lastAbsorbDamageTick = Find.TickManager.TicksGame;
            KeepDisplaying();
        }
        public override void OrderForceTarget(LocalTargetInfo target)
        {
            Map     map    = CasterPawn.Map;
            IntVec3 intVec = RCellFinder.BestOrderedGotoDestNear(target.Cell, CasterPawn, AcceptableDestination);
            Job     job    = JobMaker.MakeJob(RimWorld.JobDefOf.CastJump, intVec);

            job.verbToUse = this;
            if (CasterPawn.jobs.TryTakeOrderedJob(job))
            {
                FleckMaker.Static(intVec, map, FleckDefOf.FeedbackGoto);
            }
            bool AcceptableDestination(IntVec3 c)
            {
                if (ValidJumpTarget(map, c))
                {
                    return(CanHitTargetFrom(caster.Position, c));
                }
                return(false);
            }
        }
Exemple #17
0
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;

            bool flag = pawn != null && !pawn.Dead;

            if (flag)
            {
                if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_HediffStrongBack))
                {
                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.def.defName.Contains("TM_HediffStrongBack"))
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                        }
                    }
                }
                else
                {
                    float val = .5f;
                    if (caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_FieldTraining.FirstOrDefault((MightPowerSkill x) => x.label == "TM_FieldTraining_ver").level >= 3)
                    {
                        val = 1.5f;
                    }
                    if (caster.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_FieldTraining.FirstOrDefault((MightPowerSkill x) => x.label == "TM_FieldTraining_ver").level >= 8)
                    {
                        val = 2.5f;
                    }

                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_HediffStrongBack, val);
                    FleckMaker.ThrowDustPuff(pawn.Position, pawn.Map, 1f);
                }
            }
            return(true);
        }
        public override void Tick()
        {
            //base.Tick();
            Vector3 exactPosition = this.ExactPosition;

            this.ticksToImpact--;
            bool flag = !this.ExactPosition.InBounds(base.Map);

            if (flag)
            {
                this.ticksToImpact++;
                base.Position = this.ExactPosition.ToIntVec3();
                this.Destroy(DestroyMode.Vanish);
            }
            else
            {
                base.Position = this.ExactPosition.ToIntVec3();
                if (Find.TickManager.TicksGame % 2 == 0)
                {
                    FleckMaker.ThrowDustPuff(base.Position, base.Map, Rand.Range(0.8f, 1.2f));
                }

                //if(Find.TickManager.TicksGame % 10 == 0 && this.assignedTarget != null)
                //{
                //    this.origin = this.ExactPosition;
                //    this.destination = this.assignedTarget.DrawPos;
                //    this.ticksToImpact = this.StartingTicksToImpact;
                //}

                bool flag2 = this.ticksToImpact <= 0;
                if (flag2)
                {
                    bool flag3 = this.DestinationCell.InBounds(base.Map);
                    if (flag3)
                    {
                        base.Position = this.DestinationCell;
                    }
                    this.ImpactSomething();
                }
            }
        }
Exemple #19
0
        private bool TryLaunchCookOffProjectile()
        {
            if (AmmoDef == null || AmmoDef.cookOffProjectile == null || Find.Maps.IndexOf(Map) < 0)
            {
                return(false);
            }

            // Spawn projectile if enabled
            if (!Controller.settings.RealisticCookOff)
            {
                ProjectileCE projectile = (ProjectileCE)ThingMaker.MakeThing(AmmoDef.cookOffProjectile);
                GenSpawn.Spawn(projectile, PositionHeld, MapHeld);

                // Launch in random direction
                projectile.canTargetSelf        = true;
                projectile.minCollisionDistance = 0f;
                projectile.logMisses            = false;
                projectile.Launch(this,
                                  new Vector2(DrawPos.x, DrawPos.z),
                                  Mathf.Acos(2 * UnityEngine.Random.Range(0.5f, 1f) - 1),
                                  UnityEngine.Random.Range(0, 360),
                                  0.1f,
                                  AmmoDef.cookOffProjectile.projectile.speed * AmmoDef.cookOffSpeed,
                                  this);
            }
            // Create sound and flash effects
            if (AmmoDef.cookOffFlashScale > 0.01)
            {
                FleckMaker.Static(Position, Map, FleckDefOf.ShotFlash, AmmoDef.cookOffFlashScale);
            }
            if (AmmoDef.cookOffSound != null)
            {
                AmmoDef.cookOffSound.PlayOneShot(new TargetInfo(Position, Map));
            }
            if (AmmoDef.cookOffTailSound != null)
            {
                AmmoDef.cookOffTailSound.PlayOneShotOnCamera();
            }

            return(true);
        }
        // Token: 0x0600002C RID: 44 RVA: 0x00003554 File Offset: 0x00001754
        public override void TickRare()
        {
            base.TickRare();
            if (fermentTicks < TargetTicks)
            {
                fermentTicks++;
                var heat = 4f;
                if (def.defName == AYCharcoalKiln)
                {
                    FleckMaker.ThrowSmoke(Position.ToVector3(), Map, 1f);
                    heat = 12f;
                }

                GenTemperature.PushHeat(Position, Map, heat);
            }

            if (fermentTicks >= TargetTicks)
            {
                PlaceProduct();
            }
        }
Exemple #21
0
        public new void SpawnSmokeParticles()
        {
            if (Warpfire.fireCount < 15)
            {
                FleckMaker.ThrowSmoke(this.DrawPos, base.Map, this.fireSize);
            }
            if (this.fireSize > 0.5f && this.parent == null)
            {
                ThrowFireGlow(base.Position, base.Map, this.fireSize);
            }
            float num = this.fireSize / 2f;

            if (num > 1f)
            {
                num = 1f;
            }
            num = 1f - num;
            Rand.PushState();
            this.ticksUntilSmoke = Warpfire.SmokeIntervalRange.Lerped(num) + (int)(10f * Rand.Value);
            Rand.PopState();
        }
        private void BreakShield(DamageInfo dinfo)
        {
            float fTheta;

            if (Active)
            {
                SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(parent));
                int num = Mathf.CeilToInt(Props.radius * 2f);
                fTheta = (float)Math.PI * 2f / (float)num;
                for (int i = 0; i < num; i++)
                {
                    FleckMaker.ConnectingLine(PosAtIndex(i), PosAtIndex((i + 1) % num), FleckDefOf.LineEMP, parent.Map, 1.5f);
                }
            }
            dinfo.SetAmount((float)Props.disarmedByEmpForTicks / 30f);
            stunner.Notify_DamageApplied(dinfo);
            Vector3 PosAtIndex(int index)
            {
                return(new Vector3(Props.radius * Mathf.Cos(fTheta * (float)index) + (float)parent.Position.x, 0f, Props.radius * Mathf.Sin(fTheta * (float)index) + (float)parent.Position.z));
            }
        }
        // Token: 0x06000024 RID: 36 RVA: 0x00002880 File Offset: 0x00000A80
        public virtual void ExtraCrafterTickAction()
        {
            var status = crafterStatus;

            if (status != CrafterStatus.Filling)
            {
                if (status != CrafterStatus.Crafting)
                {
                    return;
                }

                if (powerComp.PowerOn && Current.Game.tickManager.TicksGame % 100 == 0)
                {
                    FleckMaker.ThrowSmoke(Position.ToVector3(), Map, 1.33f);
                }
            }
            else if (powerComp.PowerOn && Current.Game.tickManager.TicksGame % 300 == 0)
            {
                FleckMaker.ThrowSmoke(Position.ToVector3(), Map, 1f);
            }
        }
 private void Initialize()
 {
     if (pawn != null)
     {
         FleckMaker.Static(pawn.TrueCenter(), pawn.Map, FleckDefOf.ExplosionFlash, 12f);
         SoundDefOf.Ambient_AltitudeWind.sustainFadeoutTime.Equals(30.0f);
         FleckMaker.ThrowDustPuff(pawn.Position, pawn.Map, Rand.Range(1.2f, 1.8f));
         CompAbilityUserMight comp = pawn.GetComp <CompAbilityUserMight>();
         verVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_PsionicDash, "TM_PsionicDash", "_ver", true);
         pwrVal = TM_Calc.GetMightSkillLevel(pawn, comp.MightData.MightPowerSkill_PsionicDash, "TM_PsionicDash", "_pwr", true);
         //this.pwrVal = comp.MightData.MightPowerSkill_PsionicDash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicDash_pwr").level;
         //this.verVal = comp.MightData.MightPowerSkill_PsionicDash.FirstOrDefault((MightPowerSkill x) => x.label == "TM_PsionicDash_ver").level;
         this.arcaneDmg = comp.mightPwr;
         //if (pawn.story.traits.HasTrait(TorannMagicDefOf.Faceless))
         //{
         //    this.pwrVal = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_pwr").level;
         //    this.verVal = comp.MightData.MightPowerSkill_Mimic.FirstOrDefault((MightPowerSkill x) => x.label == "TM_Mimic_ver").level;
         //}
     }
     //flyingThing.ThingID += Rand.Range(0, 2147).ToString();
 }
        public void DrawHediffExtras()
        {
            // MoteMaker.ThrowExplosionInteriorMote(new Vector3(this.pawn.TrueCenter().x, 0, this.pawn.TrueCenter().z), this.pawn.Map, ThingDef.Named("Mote_ElectricalSpark"));
            // MoteMaker.ThrowSmoke(this.pawn.DrawPos,this.pawn.Map,2f);
            var loc  = pawn.DrawPos;
            var map  = pawn.Map;
            var size = 2f;

            if (!loc.ShouldSpawnMotesAt(map) || map.moteCounter.SaturatedLowPriority)
            {
                return;
            }

            var dataStatic = FleckMaker.GetDataStatic(loc, map, FleckDefOf.Smoke, Rand.Range(1.5f, 2.5f) * size);

            dataStatic.rotationRate  = Rand.Range(-30f, 30f);
            dataStatic.velocityAngle = Rand.Range(30, 40);
            dataStatic.velocitySpeed = Rand.Range(0.5f, 0.7f);
            dataStatic.instanceColor = Color.red;
            map.flecks.CreateFleck(dataStatic);
        }
        // Token: 0x06000030 RID: 48 RVA: 0x00003B44 File Offset: 0x00001D44
        public void Break()
        {
            var wearer = Wearer;

            if (wearer?.Map != null)
            {
                SoundDefOf.EnergyShield_Broken.PlayOneShot(new TargetInfo(wearer.Position, wearer.Map));
                FleckMaker.Static(wearer.TrueCenter(), wearer.Map, FleckDefOf.ExplosionFlash, 12f);
                for (var i = 0; i < 6; i++)
                {
                    FleckMaker.ThrowDustPuff(
                        wearer.TrueCenter() + (Vector3Utility.HorizontalVectorFromAngle(Rand.Range(0, 360)) *
                                               Rand.Range(0.3f, 0.6f)), wearer.Map, Rand.Range(0.8f, 1.2f));
                }
            }

            energy       = 0f;
            ticksToReset = StartingTicksToReset;
            ActiveCamo   = false;
            CamoState    = 2;
        }
Exemple #27
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def      = this.def;
            CellRect cellRect = CellRect.CenteredOn(base.Position, 1);

            cellRect.ClipInsideMap(map);

            IntVec3    c = cellRect.CenterCell;
            TerrainDef terrain;
            float      radius = this.def.projectile.explosionRadius;

            IntVec3 curCell;
            IEnumerable <IntVec3> cells = GenRadial.RadialCellsAround(c, radius, true);

            for (int i = 0; i < cells.Count(); i++)
            {
                curCell = cells.ToArray <IntVec3>()[i];
                if (curCell.InBounds(map) && curCell.IsValid)
                {
                    terrain = curCell.GetTerrain(map);
                    if (terrain.defName == "Sand" || terrain.defName == "Gravel")
                    {
                        map.terrainGrid.SetTerrain(curCell, TerrainDef.Named("Soil"));
                        FleckMaker.ThrowDustPuff(curCell, map, .75f);
                    }
                    else if (terrain.defName == "SoftSand")
                    {
                        map.terrainGrid.SetTerrain(curCell, TerrainDef.Named("Sand"));
                        FleckMaker.ThrowDustPuff(curCell, map, .75f);
                    }
                    else
                    {
                        //Messages.Message("TerraformNotSandOrGravel".Translate(), MessageTypeDefOf.RejectInput);
                    }
                }
            }
        }
Exemple #28
0
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;

            bool flag = pawn != null && !pawn.Dead;

            if (flag)
            {
                if (pawn.health.hediffSet.HasHediff(TorannMagicDefOf.TM_HediffHeavyBlow))
                {
                    using (IEnumerator <Hediff> enumerator = pawn.health.hediffSet.GetHediffs <Hediff>().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Hediff rec = enumerator.Current;
                            if (rec.def == TorannMagicDefOf.TM_HediffHeavyBlow)
                            {
                                pawn.health.RemoveHediff(rec);
                            }
                        }
                    }
                }
                else
                {
                    //if (pawn.story.traits.HasTrait(TorannMagicDefOf.TM_Wayfarer))
                    //{
                    int lvl = pawn.GetComp <CompAbilityUserMight>().MightData.MightPowerSkill_FieldTraining.FirstOrDefault((MightPowerSkill x) => x.label == "TM_FieldTraining_pwr").level;
                    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_HediffHeavyBlow, .95f + (.19f * lvl));
                    FleckMaker.ThrowDustPuff(pawn.Position, pawn.Map, 1f);
                    //}
                    //else
                    //{
                    //    HealthUtility.AdjustSeverity(pawn, TorannMagicDefOf.TM_HediffHeavyBlow, .5f);
                    //    FleckMaker.ThrowDustPuff(pawn.Position, pawn.Map, 1f);
                    //}
                }
            }
            return(true);
        }
        public override void Tick()
        {
            //base.Tick();
            Vector3 exactPosition = this.ExactPosition;

            this.ticksToImpact--;
            bool flag = !this.ExactPosition.InBounds(base.Map);

            if (flag)
            {
                this.ticksToImpact++;
                base.Position = this.ExactPosition.ToIntVec3();
                this.Destroy(DestroyMode.Vanish);
            }
            else if (!this.ExactPosition.ToIntVec3().Walkable(base.Map))
            {
                this.earlyImpact = true;
                this.impactForce = (this.DestinationCell - this.ExactPosition.ToIntVec3()).LengthHorizontal + (this.speed * .2f);
                this.ImpactSomething();
            }
            else
            {
                base.Position = this.ExactPosition.ToIntVec3();
                if (Find.TickManager.TicksGame % 3 == 0)
                {
                    FleckMaker.ThrowDustPuff(base.Position, base.Map, Rand.Range(0.6f, .8f));
                }

                bool flag2 = this.ticksToImpact <= 0;
                if (flag2)
                {
                    bool flag3 = this.DestinationCell.InBounds(base.Map);
                    if (flag3)
                    {
                        base.Position = this.DestinationCell;
                    }
                    this.ImpactSomething();
                }
            }
        }
Exemple #30
0
        // Token: 0x0600139E RID: 5022 RVA: 0x00096118 File Offset: 0x00094518
        public override void FireEvent()
        {
            base.FireEvent();
            if (!this.strikeLoc.IsValid)
            {
                this.strikeLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(this.map) && !this.map.roofGrid.Roofed(sq), this.map, 1000);
            }
            this.boltMesh = LightningBoltMeshPool.RandomBoltMesh;
            if (!this.strikeLoc.Fogged(this.map))
            {
                GenExplosion.DoExplosion(this.strikeLoc, this.map, 3f, AdeptusDamageDefOf.OG_WarpStormStrike, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                Vector3 loc = this.strikeLoc.ToVector3Shifted();
                Rand.PushState();
                bool chance = Rand.Chance(thingDefSpawnChance);
                Rand.PopState();
                if (chance && thingDeftoSpawn != null)
                {
                    GenSpawn.Spawn(ThingMaker.MakeThing(thingDeftoSpawn, null), strikeLoc, map);
                }
                for (int i = 0; i < 4; i++)
                {
                    Rand.PushState();
                    chance = Rand.Chance(kindDefSpawnChance);
                    Rand.PopState();
                    if (chance && kindDeftoSpawn != null)
                    {
                        PawnKindDef           pawnkind = kindDeftoSpawn != null ? kindDeftoSpawn : null;
                        PawnGenerationRequest pawnGenerationRequest = new PawnGenerationRequest(pawnkind, Find.FactionManager.FirstFactionOfDef(pawnkind.defaultFactionType), PawnGenerationContext.NonPlayer, -1, true, false, true, false, true, true, 20f);
                        Pawn pawn = PawnGenerator.GeneratePawn(pawnGenerationRequest);
                        GenSpawn.Spawn(pawn, strikeLoc, map, 0);
                    }
                    FleckMaker.ThrowSmoke(loc, this.map, 1.5f);
                    FleckMaker.ThrowMicroSparks(loc, this.map);
                    FleckMaker.ThrowLightningGlow(loc, this.map, 1.5f);
                }
            }
            SoundInfo info = SoundInfo.InMap(new TargetInfo(this.strikeLoc, this.map, false), MaintenanceType.None);

            SoundDefOf.Thunder_OnMap.PlayOneShot(info);
        }