Example #1
0
        // Token: 0x06004F05 RID: 20229 RVA: 0x001A99DC File Offset: 0x001A7BDC
        public override void Impact()
        {
            for (int i = 0; i < 6; i++)
            {
                AdeptusMoteMaker.ThrowDustPuff(base.Position.ToVector3Shifted() + Gen.RandomHorizontalVector(1f), base.Map, 1.2f);
            }
            //    MoteMaker.ThrowLightningGlow(base.Position.ToVector3Shifted(), base.Map, 2f);
            GenClamor.DoClamor(this, 15f, ClamorDefOf.Impact);
            if (this.def.skyfaller.CausesExplosion)
            {
                GenExplosion.DoExplosion(base.Position, base.Map, this.def.skyfaller.explosionRadius, this.def.skyfaller.explosionDamage, null, GenMath.RoundRandom((float)this.def.skyfaller.explosionDamage.defaultDamage * this.def.skyfaller.explosionDamageFactor), -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false, null, (!this.def.skyfaller.damageSpawnedThings) ? this.innerContainer.ToList <Thing>() : null);
            }
            this.SpawnThings();
            this.innerContainer.ClearAndDestroyContents(DestroyMode.Vanish);
            CellRect cellRect = this.OccupiedRect();

            for (int i = 0; i < cellRect.Area * this.def.skyfaller.motesPerCell; i++)
            {
                AdeptusMoteMaker.ThrowDustPuff(cellRect.RandomVector3, base.Map, 2f);
            }
            if (this.def.skyfaller.MakesShrapnel)
            {
                SkyfallerShrapnelUtility.MakeShrapnel(base.Position, base.Map, this.shrapnelDirection, this.def.skyfaller.shrapnelDistanceFactor, this.def.skyfaller.metalShrapnelCountRange.RandomInRange, this.def.skyfaller.rubbleShrapnelCountRange.RandomInRange, true);
            }
            if (this.def.skyfaller.cameraShake > 0f && base.Map == Find.CurrentMap)
            {
                Find.CameraDriver.shaker.DoShake(this.def.skyfaller.cameraShake);
            }
            if (this.def.skyfaller.impactSound != null)
            {
                this.def.skyfaller.impactSound.PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None));
            }
            this.Destroy(DestroyMode.Vanish);
        }
Example #2
0
        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);
                }
            }
            else
            {
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                AdeptusMoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
                }
            }
        }
Example #3
0
 public override void ExplosionStart(Explosion explosion, List <IntVec3> cellsToAffect)
 {
     if (this.def.explosionHeatEnergyPerCell > 1.401298E-45f)
     {
         GenTemperature.PushHeat(explosion.Position, explosion.Map, this.def.explosionHeatEnergyPerCell * (float)cellsToAffect.Count);
     }
     AdeptusMoteMaker.MakeStaticMote(explosion.DrawPos, explosion.Map, ThingDefOf.Mote_ExplosionFlash, explosion.radius * 6f);
 }
 private void Initialize()
 {
     if (this.pawn != null)
     {
         Rand.PushState();
         AdeptusMoteMaker.ThrowDustPuff(this.pawn.DrawPos, this.pawn.Map, Rand.Range(1.2f, 1.8f));
         Rand.PopState();
     }
 }
Example #5
0
        public override void Tick()
        {
            base.Tick();
            Vector3 exactPosition = this.ExactPosition;

            //    this.ticksToImpact = UpdateTicksToImpact;
            this.ticksToImpact--;
            if (this.ticksToImpact == 15)
            {
                this.HitRoof();
            }
            if (this.landed || base.Map == null)
            {
                return;
            }
            bool flag  = !this.ExactPosition.InBounds(base.Map);
            bool flag2 = flag;

            if (flag2)
            {
                this.ticksToImpact++;
                base.Position = this.ExactPosition.ToIntVec3();
                this.Destroy(DestroyMode.Vanish);
            }
            else
            {
                base.Position = this.ExactPosition.ToIntVec3();
                bool flag3 = Find.TickManager.TicksGame % 2 == 0;
                if (flag3)
                {
                    if (this.FlightArc != null)
                    {
                        float f = this.FlightArc.Evaluate(this.TimeInAnimation);
                        exactPosition.z += this.FlightArc.Evaluate(this.TimeInAnimation);
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        Rand.PushState();
                        AdeptusMoteMaker.ThrowDustPuff(this.DrawPos, base.Map, Rand.Range(0.3f, 0.6f));
                        Rand.PopState();
                    }
                }
                bool flag4 = this.ticksToImpact <= 0;
                bool flag5 = flag4;
                if (flag5)
                {
                    bool flag6 = this.DestinationCell.InBounds(base.Map);
                    bool flag7 = flag6;
                    if (flag7)
                    {
                        base.Position = this.DestinationCell;
                    }
                    this.ImpactSomething();
                }
            }
        }
Example #6
0
 public virtual void Reset()
 {
     if (Pawn.Spawned)
     {
         SoundDefOf.EnergyShield_Reset.PlayOneShot(new TargetInfo(Pawn.Position, Pawn.Map, false));
         AdeptusMoteMaker.ThrowLightningGlow(Pawn.TrueCenter(), Pawn.Map, 3f);
     }
     this.ticksToReset = -1;
     this.energy       = this.EnergyOnReset;
 }
Example #7
0
 // Token: 0x06002740 RID: 10048 RVA: 0x0012AD78 File Offset: 0x00129178
 private void Reset()
 {
     if (base.Wearer.Spawned)
     {
         SoundDefOf.EnergyShield_Reset.PlayOneShot(new TargetInfo(base.Wearer.Position, base.Wearer.Map, false));
         AdeptusMoteMaker.ThrowLightningGlow(base.Wearer.TrueCenter(), base.Wearer.Map, 3f);
     }
     this.ticksToReset = -1;
     this.energy       = this.EnergyOnReset;
 }
Example #8
0
 /*
  *      protected override void SpawnThings()
  *      {
  *
  *              if (this.Contents.spawnWipeMode == null)
  *              {
  *                      base.SpawnThings();
  *                      return;
  *              }
  *              for (int i = this.innerContainer.Count - 1; i >= 0; i--)
  *              {
  *                      GenSpawn.Spawn(this.innerContainer[i], base.Position, base.Map, this.Contents.spawnWipeMode.Value);
  *              }
  *
  *      }
  */
 // Token: 0x06007932 RID: 31026 RVA: 0x00239D78 File Offset: 0x00237F78
 public override void Impact()
 {
     for (int i = 0; i < 6; i++)
     {
         AdeptusMoteMaker.ThrowDustPuff(base.Position.ToVector3Shifted() + Gen.RandomHorizontalVector(1f), base.Map, 1.2f);
     }
     AdeptusMoteMaker.ThrowLightningGlow(base.Position.ToVector3Shifted(), base.Map, 2f);
     GenClamor.DoClamor(this, 15f, ClamorDefOf.Impact);
     base.Impact();
 }
Example #9
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));
     AdeptusMoteMaker.MakeStaticMote(base.Wearer.TrueCenter(), base.Wearer.Map, ThingDefOf.Mote_ExplosionFlash, 12f);
     for (int i = 0; i < 6; i++)
     {
         Rand.PushState();
         AdeptusMoteMaker.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));
         Rand.PopState();
     }
     this.energy       = 0f;
     this.ticksToReset = this.StartingTicksToReset;
 }
Example #10
0
        public override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            if (this.ticksToImpact <= 0)
            {
                base.Impact(hitThing);
            }
            else
            {
                BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);
                Find.BattleLog.Add(battleLogEntry_RangedImpact);
                if (hitThing != null)
                {
                    DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, (float)base.DamageAmount, base.ArmorPenetration, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, 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);
                    }
                    if (this.def.projectile.extraDamages == null)
                    {
                        return;
                    }
                    using (List <ExtraDamage> .Enumerator enumerator = this.def.projectile.extraDamages.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            ExtraDamage extraDamage = enumerator.Current;
                            Rand.PushState();
                            if (Rand.Chance(extraDamage.chance))
                            {
                                DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                                hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact);
                            }
                            Rand.PopState();
                        }
                        return;
                    }
                }
                SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
                if (base.Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f);
                    return;
                }
                AdeptusMoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
            }
        }
Example #11
0
        protected virtual void Ignite()
        {
            Map map = Map;

            Destroy();
            float ignitionChance = def.projectile.explosionChanceToStartFire;
            var   radius         = def.projectile.explosionRadius;
            var   cellsToAffect  = SimplePool <List <IntVec3> > .Get();

            cellsToAffect.Clear();
            cellsToAffect.AddRange(def.projectile.damageDef.Worker.ExplosionCellsToHit(Position, map, radius));

            AdeptusMoteMaker.MakeStaticMote(ExactPosition, map, ThingDefOf.Mote_ExplosionFlash, radius * 4f);
            for (int i = 0; i < 4; i++)
            {
                MoteMaker.ThrowSmoke(Position.ToVector3Shifted() + Gen.RandomHorizontalVector(radius * 0.7f), map, radius * 0.6f);
            }

            Rand.PushState();
            if (Rand.Chance(ignitionChance))
            {
                foreach (var vec3 in cellsToAffect)
                {
                    var fireSize = radius - vec3.DistanceTo(Position);
                    if (fireSize > 0.1f)
                    {
                        if (this.def.projectile.damageDef == AdeptusDamageDefOf.OG_Chaos_Deamon_Warpfire)
                        {
                            WarpfireUtility.TryStartWarpfireIn(vec3, map, fireSize);
                        }
                        else
                        {
                            FireUtility.TryStartFireIn(vec3, map, fireSize);
                        }
                    }
                }
            }
            Rand.PopState();

            //Fire explosion should be tiny.
            if (this.def.projectile.explosionEffect != null)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(this.Position, map, false), new TargetInfo(this.Position, map, false));
                effecter.Cleanup();
            }
            GenExplosion.DoExplosion(this.Position, map, this.def.projectile.explosionRadius, this.def.projectile.damageDef, this.launcher, this.def.projectile.GetDamageAmount(1, null), this.def.projectile.GetArmorPenetration(1, null), this.def.projectile.soundExplode, this.equipmentDef, this.def, null, this.def.projectile.postExplosionSpawnThingDef, this.def.projectile.postExplosionSpawnChance, this.def.projectile.postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, this.def.projectile.preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff);
        }
Example #12
0
        // Token: 0x0600005B RID: 91 RVA: 0x00003DCC File Offset: 0x00001FCC
        private void AbsorbedDamage(DamageInfo dinfo)
        {
            SoundDefOf.EnergyShield_AbsorbDamage.PlayOneShot(new TargetInfo(base.Wearer.Position, base.Wearer.Map, false));

            float num = Mathf.Min(10f, 2f + (float)dinfo.Amount / 10f);

            AdeptusMoteMaker.MakeStaticMote(base.Wearer.DrawPos, base.Wearer.Map, ThingDefOf.Mote_ExplosionFlash, num);
            int num2 = (int)num;

            for (int i = 0; i < num2; i++)
            {
                Rand.PushState();
                AdeptusMoteMaker.ThrowDustPuff(base.Wearer.DrawPos, base.Wearer.Map, Rand.Range(0.8f, 1.2f));
                Rand.PopState();
            }
        }
Example #13
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);

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

            for (int i = 0; i < num2; i++)
            {
                Rand.PushState();
                AdeptusMoteMaker.ThrowDustPuff(loc, Pawn.Map, Rand.Range(0.8f, 1.2f));
                Rand.PopState();
            }
            this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            this.KeepDisplaying();
        }
Example #14
0
        public static void ThrowExplosionCell(IntVec3 cell, Map map, ThingDef moteDef, Color?color = null)
        {
            if (!cell.ShouldSpawnMotesAt(map))
            {
                return;
            }
            Mote moteThrown = (Mote)ThingMaker.MakeThing(moteDef, null);

            moteThrown.exactRotation = (float)(90 * Rand.RangeInclusive(0, 3));
            moteThrown.exactPosition = cell.ToVector3Shifted();
            if (color.HasValue)
            {
                moteThrown.instanceColor = color.Value;
                //    moteThrown.instanceColor = new Color(0.368f, 0f, 1f);
            }
            GenSpawn.Spawn(moteThrown, cell, map, WipeMode.Vanish);
            if (Rand.Value < 0.7f)
            {
                AdeptusMoteMaker.ThrowDustPuff(cell.ToVector3Shifted(), map, 1.2f, null, color);
            }
        }
Example #15
0
        public override void PostPreApplyDamage(DamageInfo dinfo, out bool absorbed)
        {
            //Log.Message(string.Format("Bypassing: {0}", !Props.BypassingDamageDefs.Any(def => dinfo.Def == def)));

            Rand.PushState();
            bool invSave = Rand.Chance(Props.InvunerableSaveChance);

            Rand.PopState();
            if (dinfo.Def != null && base.parent is Pawn pawn && pawn != null && invSave && !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);
                AdeptusMoteMaker.MakeStaticMote(loc, base.parent.Map, ThingDefOf.Mote_ExplosionFlash, num);
                int num2 = (int)num;
                for (int i = 0; i < num2; i++)
                {
                    Rand.PushState();
                    AdeptusMoteMaker.ThrowDustPuff(loc, base.parent.Map, Rand.Range(0.8f, 1.2f));
                    float angle = (float)Rand.Range(0, 360);
                    Rand.PopState();
                    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;
                    }
                    Vector3   s      = new Vector3(num3, 1f, num3);
                    Matrix4x4 matrix = default;
                    matrix.SetTRS(vector, Quaternion.AngleAxis(angle, Vector3.up), s);
                    Graphics.DrawMesh(MeshPool.plane10, matrix, CompInvunerableSaveOGStatic.BubbleMat, 0);
                }
                this.lastAbsorbDamageTick = Find.TickManager.TicksGame;
            }
        public override bool TryCastShot()
        {
            Pawn casterPawn = this.CasterPawn;

            if (!casterPawn.Spawned)
            {
                return(false);
            }
            if (casterPawn.stances.FullBodyBusy)
            {
                return(false);
            }
            Thing thing = this.currentTarget.Thing;

            if (!this.CanHitTarget(thing))
            {
                Log.Warning(string.Concat(new object[]
                {
                    casterPawn,
                    " meleed ",
                    thing,
                    " from out of melee position."
                }), false);
            }
            else
            {
                //	Log.Message("Verb_MeleeAttackDamage_Polearm CanHitTarget");
            }
            casterPawn.rotationTracker.Face(thing.DrawPos);
            if (!this.IsTargetImmobile(this.currentTarget) && casterPawn.skills != null)
            {
                casterPawn.skills.Learn(SkillDefOf.Melee, 200f * this.verbProps.AdjustedFullCycleTime(this, casterPawn), false);
            }
            Pawn pawn = thing as Pawn;

            if (pawn != null && !pawn.Dead && (casterPawn.MentalStateDef != MentalStateDefOf.SocialFighting || pawn.MentalStateDef != MentalStateDefOf.SocialFighting))
            {
                pawn.mindState.meleeThreat             = casterPawn;
                pawn.mindState.lastMeleeThreatHarmTick = Find.TickManager.TicksGame;
            }
            Map      map     = thing.Map;
            Vector3  drawPos = thing.DrawPos;
            SoundDef soundDef;
            bool     result;

            if (Rand.Chance(this.GetNonMissChance(thing)))
            {
                if (!Rand.Chance(this.GetDodgeChance(thing)))
                {
                    if (thing.def.category == ThingCategory.Building)
                    {
                        soundDef = this.SoundHitBuilding();
                    }
                    else
                    {
                        soundDef = this.SoundHitPawn();
                    }
                    if (this.verbProps.impactMote != null)
                    {
                        AdeptusMoteMaker.MakeStaticMote(drawPos, map, this.verbProps.impactMote, 1f);
                    }
                    BattleLogEntry_MeleeCombat battleLogEntry_MeleeCombat = this.CreateCombatLog((ManeuverDef maneuver) => maneuver.combatLogRulesHit, true);
                    result = true;
                    DamageWorker.DamageResult damageResult = this.ApplyMeleeDamageToTarget(this.currentTarget);
                    if (damageResult.stunned && damageResult.parts.NullOrEmpty <BodyPartRecord>())
                    {
                        Find.BattleLog.RemoveEntry(battleLogEntry_MeleeCombat);
                    }
                    else
                    {
                        damageResult.AssociateWithLog(battleLogEntry_MeleeCombat);
                        if (damageResult.deflected)
                        {
                            battleLogEntry_MeleeCombat.RuleDef             = this.maneuver.combatLogRulesDeflect;
                            battleLogEntry_MeleeCombat.alwaysShowInCompact = false;
                        }
                    }
                }
                else
                {
                    result   = false;
                    soundDef = this.SoundDodge(thing);
                    MoteMaker.ThrowText(drawPos, map, "TextMote_Dodge".Translate(), 1.9f);
                    this.CreateCombatLog((ManeuverDef maneuver) => maneuver.combatLogRulesDodge, false);
                }
            }
            else
            {
                result   = false;
                soundDef = this.SoundMiss();
                this.CreateCombatLog((ManeuverDef maneuver) => maneuver.combatLogRulesMiss, false);
            }
            soundDef.PlayOneShot(new TargetInfo(thing.Position, map, false));
            if (casterPawn.Spawned)
            {
                casterPawn.Drawer.Notify_MeleeAttackOn(thing);
            }
            if (pawn != null && !pawn.Dead && pawn.Spawned)
            {
                pawn.stances.StaggerFor(95);
            }
            if (casterPawn.Spawned)
            {
                casterPawn.rotationTracker.FaceCell(thing.Position);
            }
            if (casterPawn.caller != null)
            {
                casterPawn.caller.Notify_DidMeleeAttack();
            }
            return(result);
        }