Esempio n. 1
0
 public override void CompTick()
 {
     base.CompTick();
     // Throw smoke mote
     foreach (IntVec3 currentCell in damagedCells)
     {
         if (Props.smoke)
         {
             if (Rand.Value < Props.smokeChance)
             {
                 ThrowSmokeBlack(parent.Position.ToVector3Shifted(), 0.5f);
             }
         }
         if (Props.spark)
         {
             // Setup a new spark effect
             sparks = new Effecter(DefDatabase <EffecterDef> .GetNamed("ElectricShort"));
             // If we have a spark effecter
             if (sparks != null)
             {
                 if (Rand.Value < Props.sparkChance)
                 {
                     // Continue effect
                     sparks.EffectTick(parent.Position, parent);
                     sparks.Cleanup();
                     sparks = null;
                 }
             }
         }
     }
 }
        protected virtual void Ignite()
        {
            Map map = Map;

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

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

            MoteMaker.MakeStaticMote(Position, 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);
            }


            //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);
        }
        // Token: 0x060000F0 RID: 240 RVA: 0x00008BAC File Offset: 0x00006DAC
        protected virtual void Explode(Thing hitThing, bool destroy = false)
        {
            Map     map    = base.Map;
            IntVec3 intVec = (hitThing != null) ? hitThing.PositionHeld : IntVec3Utility.ToIntVec3(this.destinationInt);

            if (destroy)
            {
                this.Destroy(0);
            }
            bool flag = this.def.projectile.explosionEffect != null;

            if (flag)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(intVec, map, false), new TargetInfo(intVec, map, false));
                effecter.Cleanup();
            }
            IntVec3   intVec2                      = intVec;
            Map       map2                         = map;
            float     explosionRadius              = this.def.projectile.explosionRadius;
            DamageDef damageDef                    = this.def.projectile.damageDef;
            Thing     launcher                     = this.launcher;
            int       damageAmount                 = this.def.projectile.GetDamageAmount(1f, null);
            SoundDef  soundExplode                 = this.def.projectile.soundExplode;
            ThingDef  equipmentDef                 = this.equipmentDef;
            ThingDef  def                          = this.def;
            ThingDef  postExplosionSpawnThingDef   = this.def.projectile.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = this.def.projectile.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = this.def.projectile.postExplosionSpawnThingCount;
            ThingDef  preExplosionSpawnThingDef    = this.def.projectile.preExplosionSpawnThingDef;

            GenExplosion.DoExplosion(intVec2, map2, explosionRadius, damageDef, launcher, damageAmount, 0f, soundExplode, equipmentDef, def, null, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff);
        }
Esempio n. 4
0
        protected virtual void Explode()
        {
            Map map = Map;

            Destroy(DestroyMode.Vanish);
            if (this.def.projectile.explosionEffect != null)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(Position, map, false), new TargetInfo(Position, map, false));
                effecter.Cleanup();
            }
            IntVec3   position         = Position;
            Map       map2             = map;
            float     explosionRadius  = this.def.projectile.explosionRadius;
            Thing     launcher         = this.launcher;
            DamageDef damageDef        = ((ProjectileProperties_BallistaArrow)this.def.projectile).shockWaveDef; //BallistaDamageDefOf.ShockWaveHeavy;
            int       damageAmount     = damageDef.defaultDamage;
            float     armorPenetration = damageDef.defaultArmorPenetration;
            SoundDef  soundExplode     = this.def.projectile.soundExplode;
            ThingDef  equipmentDef     = this.equipmentDef;
            ThingDef  def   = this.def;
            Thing     thing = intendedTarget.Thing;
            ThingDef  postExplosionSpawnThingDef   = this.def.projectile.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = this.def.projectile.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = this.def.projectile.postExplosionSpawnThingCount;
            ThingDef  preExplosionSpawnThingDef    = this.def.projectile.preExplosionSpawnThingDef;

            GenExplosion.DoExplosion(position, map2, explosionRadius, damageDef, launcher, damageAmount, armorPenetration, soundExplode, equipmentDef, def, thing, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff);
        }
Esempio n. 5
0
        protected override void Explode()
        {
            Map map = base.Map;

            Destroy();
            if (base.def.projectile.explosionEffect != null)
            {
                Effecter effecter = base.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(base.Position, map), new TargetInfo(base.Position, map));
                effecter.Cleanup();
            }
            IntVec3   position         = base.Position;
            Map       map2             = map;
            float     explosionRadius  = base.def.projectile.explosionRadius;
            DamageDef damageDef        = base.def.projectile.damageDef;
            Thing     launcher         = base.launcher;
            int       damageAmount     = base.DamageAmount;
            float     armorPenetration = base.ArmorPenetration;
            SoundDef  soundExplode     = SoundDefOfLocal.Explosion_Bomb;
            ThingDef  equipmentDef     = base.equipmentDef;
            ThingDef  def   = base.def;
            Thing     thing = intendedTarget.Thing;
            ThingDef  postExplosionSpawnThingDef   = base.def.projectile.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = base.def.projectile.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = base.def.projectile.postExplosionSpawnThingCount;
            ThingDef  preExplosionSpawnThingDef    = base.def.projectile.preExplosionSpawnThingDef;

            GenExplosion.DoExplosion(position, map2, explosionRadius, damageDef, launcher, damageAmount, armorPenetration, soundExplode, equipmentDef, def, thing, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, base.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, base.def.projectile.preExplosionSpawnChance, base.def.projectile.preExplosionSpawnThingCount, base.def.projectile.explosionChanceToStartFire, base.def.projectile.explosionDamageFalloff);
        }
Esempio n. 6
0
        public static void CriticalOverheatExplosion(Verb_Shoot __instance)
        {
            Map map = __instance.caster.Map;

            if (__instance.Projectile.projectile.explosionEffect != null)
            {
                Effecter effecter = __instance.Projectile.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(__instance.EquipmentSource.Position, map, false), new TargetInfo(__instance.EquipmentSource.Position, map, false));
                effecter.Cleanup();
            }
            IntVec3   position         = __instance.caster.Position;
            Map       map2             = map;
            float     explosionRadius  = __instance.Projectile.projectile.explosionRadius;
            DamageDef damageDef        = __instance.Projectile.projectile.damageDef;
            Thing     launcher         = __instance.EquipmentSource;
            int       DamageAmount     = __instance.Projectile.projectile.GetDamageAmount(__instance.EquipmentSource, null);
            float     ArmorPenetration = __instance.Projectile.projectile.GetArmorPenetration(__instance.EquipmentSource, null);
            SoundDef  soundExplode     = __instance.Projectile.projectile.soundExplode;
            ThingDef  equipmentDef     = __instance.EquipmentSource.def;
            ThingDef  def   = __instance.EquipmentSource.def;
            Thing     thing = __instance.EquipmentSource;
            ThingDef  postExplosionSpawnThingDef   = __instance.Projectile.projectile.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = __instance.Projectile.projectile.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = __instance.Projectile.projectile.postExplosionSpawnThingCount;
            ThingDef  preExplosionSpawnThingDef    = __instance.Projectile.projectile.preExplosionSpawnThingDef;

            GenExplosion.DoExplosion(position, map2, explosionRadius, damageDef, launcher, DamageAmount, ArmorPenetration, soundExplode, equipmentDef, def, thing);//, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, EquipmentSource.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, EquipmentSource.def.projectile.preExplosionSpawnChance, EquipmentSource.def.projectile.preExplosionSpawnThingCount, EquipmentSource.def.projectile.explosionChanceToStartFire, EquipmentSource.def.projectile.explosionDamageFalloff);
            return;
        }
Esempio n. 7
0
 protected virtual void ExplodeOnImpact()
 {
     if (!this.SpawnedOrAnyParentSpawned)
     {
         return;
     }
     if (props.destroyThingOnExplosionSize <= explosionRadius && !this.Destroyed)
     {
         this.Kill(null, null);
     }
     if (props.explosionEffect != null)
     {
         Effecter effecter = props.explosionEffect.Spawn();
         effecter.Trigger(new TargetInfo(this.PositionHeld, map, false), new TargetInfo(this.PositionHeld, map, false));
         effecter.Cleanup();
     }
     if (def.projectileWhenLoaded?.projectile != null)
     {
         GenExplosion.DoExplosion(this.PositionHeld, map, explosionRadius, projectile.damageDef, this, projectile.GetDamageAmount(1), projectile.GetArmorPenetration(1), projectile.soundExplode, null, def.projectileWhenLoaded, null,
                                  projectile.postExplosionSpawnThingDef, projectile.postExplosionSpawnChance, projectile.postExplosionSpawnThingCount, projectile.applyDamageToExplosionCellsNeighbors, projectile.preExplosionSpawnThingDef,
                                  projectile.preExplosionSpawnChance, projectile.preExplosionSpawnThingCount, projectile.explosionChanceToStartFire, projectile.explosionDamageFalloff);
     }
     else
     {
         GenExplosion.DoExplosion(this.PositionHeld, map, explosionRadius, props.explosiveDamageType, this, props.damageAmountBase, props.armorPenetrationBase, props.explosionSound, null, null, null, props.postExplosionSpawnThingDef,
                                  props.postExplosionSpawnChance, props.postExplosionSpawnThingCount, props.applyDamageToExplosionCellsNeighbors, props.preExplosionSpawnThingDef, props.preExplosionSpawnChance, props.preExplosionSpawnThingCount, props.chanceToStartFire,
                                  props.damageFalloff);
     }
 }
Esempio n. 8
0
        public void ReverseHealLinkedPawn(float severity)
        {
            Hediff bloodHediff = this.linkedPawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("TM_BloodHD"), false);

            if (bloodHediff != null)
            {
                if (this.woundsHealed)
                {
                    if (bloodHediff.Severity < 1)
                    {
                        TM_Action.DamageEntities(this.linkedPawn, null, severity, TMDamageDefOf.DamageDefOf.TM_BloodBurn, this.Pawn);
                    }
                    else
                    {
                        bloodHediff.Severity -= severity / 3;
                        TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_BloodMist"), this.linkedPawn.DrawPos, this.Pawn.Map, Rand.Range(.6f, .7f), .2f, 0.05f, 1f, Rand.Range(-50, 50), Rand.Range(1.5f, 2f), (Quaternion.AngleAxis(-90, Vector3.up) * this.directionToLinkedPawn).ToAngleFlat(), Rand.Range(0, 360));
                    }
                }
            }
            else
            {
                this.removeNow = true;
            }

            if (severity > 1.25f)
            {
                Effecter BloodShieldEffect = TorannMagicDefOf.TM_BloodShieldEffecter.Spawn();
                BloodShieldEffect.Trigger(new TargetInfo(this.linkedPawn.Position, this.linkedPawn.Map, false), new TargetInfo(this.linkedPawn.Position, this.linkedPawn.Map, false));
                BloodShieldEffect.Cleanup();
            }
        }
 private void FinalizeEffecter()
 {
     this.effecter?.Cleanup();
     this.sound?.End();
     this.effecter = null;
     this.sound    = null;
 }
        public void AccelerateEffects(Pawn pawn, int intensity)
        {
            Effecter AccelEffect = TorannMagicDefOf.TM_TimeAccelerationEffecter.Spawn();

            AccelEffect.Trigger(new TargetInfo(pawn), new TargetInfo(pawn));
            AccelEffect.Cleanup();
        }
Esempio n. 11
0
        public static Toil WithEffect(this Toil toil, Func <EffecterDef> effecterDefGetter, Func <LocalTargetInfo> effectTargetGetter)
        {
            Effecter effecter = null;

            toil.AddPreTickAction(delegate
            {
                if (effecter == null)
                {
                    EffecterDef effecterDef = effecterDefGetter();
                    if (effecterDef == null)
                    {
                        return;
                    }
                    effecter = effecterDef.Spawn();
                }
                else
                {
                    effecter.EffectTick(toil.actor, effectTargetGetter().ToTargetInfo(toil.actor.Map));
                }
            });
            toil.AddFinishAction(delegate
            {
                if (effecter != null)
                {
                    effecter.Cleanup();
                    effecter = null;
                }
            });
            return(toil);
        }
Esempio n. 12
0
        protected override bool TryCastShot()
        {
            Pawn caster = base.CasterPawn;
            Pawn pawn   = this.currentTarget.Thing as Pawn;

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

            if (flag)
            {
                CompAbilityUserMight comp = caster.GetComp <CompAbilityUserMight>();
                int verVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_Custom, "TM_Taunt", "_ver", true);
                int pwrVal = TM_Calc.GetMightSkillLevel(caster, comp.MightData.MightPowerSkill_Custom, "TM_Taunt", "_pwr", true);
                radius      += (2f * verVal);
                tauntChance += (pwrVal * .05f);
                targetsMax  += pwrVal;

                SoundInfo info = SoundInfo.InMap(new TargetInfo(caster.Position, caster.Map, false), MaintenanceType.None);
                if (this.CasterPawn.gender == Gender.Female)
                {
                    info.pitchFactor = Rand.Range(1.1f, 1.3f);
                }
                else
                {
                    info.pitchFactor = Rand.Range(.7f, .9f);
                }
                TorannMagicDefOf.TM_Roar.PlayOneShot(info);
                Effecter RageWave = TorannMagicDefOf.TM_RageWaveED.Spawn();
                RageWave.Trigger(new TargetInfo(caster.Position, caster.Map, false), new TargetInfo(caster.Position, caster.Map, false));
                RageWave.Cleanup();
                SearchAndTaunt();
            }

            return(true);
        }
Esempio n. 13
0
        /*
         * protected virtual float Range
         * {
         *  get
         *  {
         *      return launcher.;
         *  }
         * }
         */

        protected virtual void Explode(Thing hitThing, bool destroy = false)
        {
            Map     map            = base.Map;
            IntVec3 targetPosition = hitThing?.PositionHeld ?? this.destination.ToIntVec3();

            if (destroy)
            {
                this.Destroy(DestroyMode.Vanish);
            }
            if (this.def.projectile.explosionEffect != null)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(targetPosition, map, false), new TargetInfo(targetPosition, map, false));
                effecter.Cleanup();
            }
            IntVec3   position         = targetPosition;
            Map       map2             = map;
            float     explosionRadius  = this.def.projectile.explosionRadius;
            DamageDef damageDef        = this.def.projectile.damageDef;
            Thing     launcher         = this.launcher;
            int       damageAmountBase = this.DamageAmount;
            float     armorPenetration = base.ArmorPenetration;
            SoundDef  soundExplode     = this.def.projectile.soundExplode;
            ThingDef  equipmentDef     = this.equipmentDef;
            ThingDef  def   = this.def;
            Thing     thing = this.intendedTarget.Thing;
            ThingDef  postExplosionSpawnThingDef   = this.def.projectile.postExplosionSpawnThingDef;
            float     postExplosionSpawnChance     = this.def.projectile.postExplosionSpawnChance;
            int       postExplosionSpawnThingCount = this.def.projectile.postExplosionSpawnThingCount;
            ThingDef  preExplosionSpawnThingDef    = this.def.projectile.preExplosionSpawnThingDef;

            GenExplosion.DoExplosion(position, map2, explosionRadius, damageDef, launcher, damageAmountBase, armorPenetration, soundExplode, equipmentDef, def, thing, postExplosionSpawnThingDef, postExplosionSpawnChance, postExplosionSpawnThingCount, this.def.projectile.applyDamageToExplosionCellsNeighbors, preExplosionSpawnThingDef, this.def.projectile.preExplosionSpawnChance, this.def.projectile.preExplosionSpawnThingCount, this.def.projectile.explosionChanceToStartFire, this.def.projectile.explosionDamageFalloff);
        }
Esempio n. 14
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            bool flag = base.Pawn != null;

            if (flag)
            {
                if (initializing)
                {
                    initializing = false;
                    this.Initialize();
                }
            }
            if (Find.TickManager.TicksGame % 30 == 0)
            {
                if (this.Pawn.CurJob != null && this.Pawn.CurJob.targetA != null && this.Pawn.CurJob.targetA.Thing is Pawn)
                {
                    severityAdjustment -= 20;
                }
                Effecter InvisEffect = TorannMagicDefOf.TM_InvisibilityEffecter.Spawn();
                InvisEffect.Trigger(new TargetInfo(this.Pawn.Position, this.Pawn.Map, false), new TargetInfo(this.Pawn.Position, this.Pawn.Map, false));
                InvisEffect.Cleanup();
            }
            if (Find.TickManager.TicksGame % 60 == 0)
            {
                severityAdjustment--;
            }
        }
Esempio n. 15
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            base.CompPostTick(ref severityAdjustment);
            if (Find.TickManager.TicksGame % 60 == 0)
            {
                //if (!werewolfFlagged && Pawn?.GetComp<CompWerewolf>() is CompWerewolf compWW && compWW.CurrentWerewolfForm != null)
                //{
                //    werewolfFlagged = true;
                //    baseRageDuration = null;
                //    rageRemaining = -999;
                //}

                if (Pawn.Spawned)
                {
                    if (effecter == null)
                    {
                        EffecterDef progressBar = EffecterDefOf.ProgressBar;
                        effecter = progressBar.Spawn();
                    }
                    else
                    {
                        LocalTargetInfo target = Pawn;
                        if (Pawn.Spawned)
                        {
                            effecter.EffectTick(Pawn, TargetInfo.Invalid);
                        }
                        MoteProgressBar mote = ((SubEffecter_ProgressBar)effecter.children[0]).mote;
                        if (mote != null)
                        {
                            float result = 1f - (float)(this.BaseRageDuration() - this.RageRemaining) / (float)this.BaseRageDuration();

                            mote.progress = Mathf.Clamp01(result);
                            mote.offsetZ  = -1.0f;
                        }
                    }
                }

                if (RageRemaining < 0 || !Pawn.Spawned || (Pawn.GetComp <CompWerewolf>() is CompWerewolf ww && !ww.IsTransformed))
                {
                    this.effecter.Cleanup();

                    //Log.Message("Rage ended");
                    severityAdjustment = -999.99f;
                    if (Pawn?.mindState?.mentalStateHandler?.CurState is MentalState_WerewolfFury fury)
                    {
                        fury.RecoverFromState();
                    }
                    if (Pawn?.GetComp <CompWerewolf>() is CompWerewolf compWerewolf)
                    {
                        if (compWerewolf.CurrentWerewolfForm != null)
                        {
                            compWerewolf.TransformBack();
                        }
                    }
                    return;
                }
                RageRemaining--;
            }
        }
Esempio n. 16
0
        protected override void Impact(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact(hitThing);
            ThingDef def = this.def;

            if (!this.initialized)
            {
                caster = this.launcher as Pawn;
                CompAbilityUserMagic comp = caster.GetComp <CompAbilityUserMagic>();
                MagicPowerSkill      pwr  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_OrbitalStrike.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_OrbitalStrike_pwr");
                MagicPowerSkill      ver  = caster.GetComp <CompAbilityUserMagic>().MagicData.MagicPowerSkill_OrbitalStrike.FirstOrDefault((MagicPowerSkill x) => x.label == "TM_OrbitalStrike_ver");
                verVal         = ver.level;
                pwrVal         = pwr.level;
                this.arcaneDmg = comp.arcaneDmg;
                ModOptions.SettingsRef settingsRef = new ModOptions.SettingsRef();
                if (settingsRef.AIHardMode && !caster.IsColonist)
                {
                    pwrVal = 3;
                    verVal = 3;
                }
                this.angle     = Rand.Range(-3f, 3f);
                this.strikeNum = 1;
                this.CheckSpawnSustainer();
                this.strikePos     = base.Position;
                this.targettingAge = 300 - (50 * verVal);
                this.beamDuration  = 120 - (10 * verVal);
                this.radius        = this.def.projectile.explosionRadius;
                this.initialized   = true;
            }

            if (this.sustainer != null)
            {
                this.sustainer.info.volumeFactor = (this.age) / (this.beamDuration + this.targettingAge);
                this.sustainer.Maintain();
                if (this.TicksLeft <= 0)
                {
                    this.sustainer.End();
                    this.sustainer = null;
                }
            }

            if (this.age == (this.targettingAge + this.beamDuration))
            {
                TM_MoteMaker.MakePowerBeamMoteColor(this.strikePos, base.Map, this.radius * 4f, 2f, .5f, .1f, .5f, colorInt.ToColor);
                GenExplosion.DoExplosion(this.strikePos, map, this.def.projectile.explosionRadius, DamageDefOf.Bomb, this.launcher as Pawn, Mathf.RoundToInt((25 + 5 * pwrVal) * this.arcaneDmg), 0, null, def, this.equipmentDef, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                Effecter OSEffect = TorannMagicDefOf.TM_OSExplosion.Spawn();
                OSEffect.Trigger(new TargetInfo(this.strikePos, this.Map, false), new TargetInfo(this.strikePos, this.Map, false));
                OSEffect.Cleanup();
            }
            else
            {
                if (Find.TickManager.TicksGame % 3 == 0)
                {
                    TM_MoteMaker.ThrowGenericMote(TorannMagicDefOf.Mote_BloodSquirt, this.strikePos.ToVector3Shifted(), this.Map, .3f, .1f, 0, 0, Rand.Range(-100, 100), 0, 0, Rand.Range(0, 360));
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 /// Stop the laser drill effecter.
 /// </summary>
 public void StopLaserDrillEffecter()
 {
     if (this.laserDrillEffecter != null)
     {
         this.laserDrillEffecter.Cleanup();
         this.laserDrillEffecter = null;
     }
 }
Esempio n. 18
0
 public void Tick(Pawn vehicle)
 {
     if (effecter == null)
     {
         effecter = def.Spawn();
     }
     effecter.EffectTick(vehicle, null);
 }
        public static void CoreAssignPawnDamage(Pawn p, int damage, Thing source, CompPower FencePowerComp,
                                                float drainPower)
        {
            // batteries
            CoreDrainPower(FencePowerComp, drainPower);

            int randomInRange;

            switch (damage)
            {
            case < 50:
                randomInRange = 1;
                break;

            case < 100:
                randomInRange = 2;
                break;

            case < 200:
                randomInRange = 3;
                break;

            default:
                randomInRange = 5;
                break;
            }

            var height = Rand.Value >= 0.666 ? BodyPartHeight.Middle : BodyPartHeight.Top;

            for (var i = 0; i < randomInRange; i++)
            {
                if (damage <= 0)
                {
                    break;
                }

                var num2 = Mathf.Max(1, Mathf.RoundToInt(Rand.Value * damage));
                damage -= num2;
                var dinfo = new DamageInfo(DamageDefOf.Burn, num2, -1, -1f, source);
                if (randomInRange > 2)
                {
                    dinfo = new DamageInfo(DamageDefOf.Flame, num2, -1, -1f, source);
                }

                dinfo.SetBodyRegion(height, BodyPartDepth.Outside);
                p.TakeDamage(dinfo);

                var sparks = new Effecter(DefDatabase <EffecterDef> .GetNamed("ConstructMetal"));
                // If we have a spark effecter

                for (var y = 0; y < randomInRange; y++)
                {
                    sparks.EffectTick(p, source);
                }

                sparks.Cleanup();
            }
        }
Esempio n. 20
0
 public void TimeEffects(Pawn pawn, int intensity)
 {
     for (int i = 0; i < intensity; i++)
     {
         Effecter AccelEffect = TorannMagicDefOf.TM_TimeReverseEffecter.Spawn();
         AccelEffect.Trigger(new TargetInfo(pawn), new TargetInfo(pawn));
         AccelEffect.Cleanup();
     }
 }
Esempio n. 21
0
        private bool CheckIntercept(Thing thing, CompProjectileInterceptor interceptor, bool withDebug = false)
        {
            Vector3 vector = thing.Position.ToVector3Shifted();
            float   num    = interceptor.Props.radius + def.projectile.SpeedTilesPerTick + 0.1f;

            var newExactPos = ExactPosition;

            if ((newExactPos.x - vector.x) * (newExactPos.x - vector.x) + (newExactPos.z - vector.z) * (newExactPos.z - vector.z) > num * num)
            {
                return(false);
            }
            if (!interceptor.Active)
            {
                return(false);
            }
            bool flag = false;

            if (interceptor.Props.interceptGroundProjectiles)
            {
                flag = !def.projectile.flyOverhead;
            }
            else
            {
                if (interceptor.Props.interceptAirProjectiles)
                {
                    flag = def.projectile.flyOverhead;
                }
            }
            if (!flag)
            {
                return(false);
            }
            if ((launcher == null || !launcher.HostileTo(thing)) && !((bool)interceptDebug.GetValue(interceptor)))
            {
                return(false);
            }
            if ((new Vector2(vector.x, vector.z) - new Vector2(lastExactPos.x, lastExactPos.z)).sqrMagnitude <= interceptor.Props.radius * interceptor.Props.radius)
            {
                return(false);
            }
            if (!GenGeo.IntersectLineCircleOutline(new Vector2(vector.x, vector.z), interceptor.Props.radius, new Vector2(lastExactPos.x, lastExactPos.z), new Vector2(newExactPos.x, newExactPos.z)))
            {
                return(false);
            }
            interceptAngleField.SetValue(interceptor, lastExactPos.AngleToFlat(thing.TrueCenter()));
            interceptTicksField.SetValue(interceptor, Find.TickManager.TicksGame);
            if (def.projectile.damageDef == DamageDefOf.EMP ||
                ((def.projectile as ProjectilePropertiesCE)?.secondaryDamage?.Any(x => x.def == DamageDefOf.EMP) ?? false))
            {
                interceptEMPField.SetValue(interceptor, Find.TickManager.TicksGame);
            }
            Effecter eff = new Effecter(EffecterDefOf.Interceptor_BlockedProjectile);

            eff.Trigger(new TargetInfo(newExactPos.ToIntVec3(), thing.Map, false), TargetInfo.Invalid);
            eff.Cleanup();
            return(true);
        }
Esempio n. 22
0
 public override void DoPostBlockEvent(Pawn pawn, bool successfullyBlocked, ThingWithComps shield)
 {
     if (successfullyBlocked)
     {
         Effecter effecter = effecter = EffecterDefOf.Mine.Spawn();
         IntVec3  position = pawn.Position;
         effecter.Trigger(pawn, pawn);
     }
 }
Esempio n. 23
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            this.FailOn(() => this.Map.zoneManager.ZoneAt(this.TargetLocA) == null || this.Map.zoneManager.ZoneAt(this.TargetLocA).GetType().ToString() != "IceIsNice.Zone_IceMine");
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, ReservationLayerDefOf.Floor));

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.Touch));

            Toil doWork = new Toil();

            doWork.initAction = delegate
            {
                this.workLeft       = this.BaseWorkAmount;
                this.ticksToPickHit = this.BaseTicksBetweenPickHits;
            };
            doWork.tickAction = delegate
            {
                Pawn actor = this.CurToil.actor;
                this.ticksToPickHit--;
                if (this.ticksToPickHit <= 0f)
                {
                    float num = (this.SpeedStat == null) ? 1f : this.pawn.GetStatValue(this.SpeedStat, true);
                    this.workLeft      -= num;
                    this.ticksToPickHit = this.BaseTicksBetweenPickHits;
                    if (this.effecter == null)
                    {
                        this.effecter = EffecterDefOf.Mine.Spawn();
                    }
                    TargetInfo tar = new TargetInfo(this.TargetLocA, this.Map);
                    this.effecter.Trigger(actor, tar);
                }
                if (actor.skills != null)
                {
                    actor.skills.Learn(SkillDefOf.Mining, 0.11f, false);
                }
                if (this.clearSnow)
                {
                    this.Map.snowGrid.SetDepth(this.TargetLocA, 0f);
                }
                if (this.workLeft <= 0f)
                {
                    this.Map.zoneManager.ZoneAt(this.TargetLocA).RemoveCell(this.TargetLocA);
                    this.Map.terrainGrid.SetTerrain(this.TargetLocA, DefDatabase <TerrainDef> .GetNamed("WaterMovingShallow", true));
                    actor.records.Increment(RecordDefOf.CellsMined);
                    //GenSpawn.Spawn(DefDatabase<ThingDef>.GetNamed(IceThingDef.Ice, true), this.TargetLocA, this.Map);
                    Thing yield = ThingMaker.MakeThing(DefDatabase <ThingDef> .GetNamed(IceThingDef.Ice, true), null);
                    yield.stackCount = 3;
                    GenPlace.TryPlaceThing(yield, this.TargetLocA, this.Map, ThingPlaceMode.Near, null);
                    this.ReadyForNextToil();
                    return;
                }
            };
            doWork.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch);
            doWork.WithProgressBar(TargetIndex.A, () => 1f - this.workLeft / (float)this.BaseWorkAmount, false, -0.5f);
            doWork.defaultCompleteMode = ToilCompleteMode.Never;
            yield return(doWork);
        }
Esempio n. 24
0
 private void ForceEndJobState()
 {
     this.JobState         = PS_Conditioning_JobState.Waiting;
     this.CurrentTicksLeft = 0f;
     if (ProgressBarEffector != null)
     {
         ProgressBarEffector.Cleanup();
         ProgressBarEffector = null;
     }
 }
Esempio n. 25
0
        // Token: 0x060051F1 RID: 20977 RVA: 0x001B9BC8 File Offset: 0x001B7DC8
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            Effecter effecter = this.flightEffecter;

            if (effecter != null)
            {
                effecter.Cleanup();
            }
            base.Destroy(mode);
        }
        public override void CompTick()
        {
            base.CompTick();
            Pawn pawn = this.parent as Pawn;

            if ((pawn.Map != null) && (pawn.Awake()) &&
                ((pawn.needs.food.CurLevelPercentage < pawn.needs.food.PercentageThreshHungry) ||
                 (Props.digAnywayEveryXTicks && this.parent.IsHashIntervalTick(Props.timeToDigForced))))
            {
                if (pawn.Position.GetTerrain(pawn.Map).affordances.Contains(TerrainAffordanceDefOf.Diggable))
                {
                    if (stopdiggingcounter <= 0)
                    {
                        if (Props.acceptedTerrains != null)
                        {
                            if (Props.acceptedTerrains.Contains(pawn.Position.GetTerrain(pawn.Map).defName))
                            {
                                ThingDef newThing  = ThingDef.Named(this.Props.customThingToDig);
                                Thing    newcorpse = GenSpawn.Spawn(newThing, pawn.Position, pawn.Map, WipeMode.Vanish);
                                newcorpse.stackCount = this.Props.customAmountToDig;
                                if (Props.spawnForbidden)
                                {
                                    newcorpse.SetForbidden(true);
                                }
                                if (this.effecter == null)
                                {
                                    this.effecter = EffecterDefOf.Mine.Spawn();
                                }
                                this.effecter.Trigger(pawn, newcorpse);
                            }
                        }
                        else
                        {
                            ThingDef newThing  = ThingDef.Named(this.Props.customThingToDig);
                            Thing    newcorpse = GenSpawn.Spawn(newThing, pawn.Position, pawn.Map, WipeMode.Vanish);
                            newcorpse.stackCount = this.Props.customAmountToDig;
                            if (Props.spawnForbidden)
                            {
                                newcorpse.SetForbidden(true);
                            }
                            if (this.effecter == null)
                            {
                                this.effecter = EffecterDefOf.Mine.Spawn();
                            }
                            this.effecter.Trigger(pawn, newcorpse);
                        }



                        stopdiggingcounter = Props.timeToDig;
                    }
                    stopdiggingcounter--;
                }
            }
        }
Esempio n. 27
0
        public void Setup(Thing launcher, Vector3 origin, Vector3 destination, Verb verb = null, Thing hitThing = null, Effecter effecter = null, EffecterDef effecterDef = null)
        {
            //SetColor(launcher);
            this.launcher    = launcher;
            this.verb        = verb;
            this.a           = origin;
            this.b           = destination;
            this.hitThing    = hitThing ?? null;
            this.effecter    = effecter ?? null;
            this.effecterDef = effecterDef ?? null;
            Map     map = verb?.Caster?.Map ?? launcher.Map;
            Vector3 dir = (destination - origin).normalized;

            dir.y = 0;

            Vector3 a = origin;// += dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength);

            if (verb != null)
            {
                if (verb.Muzzle(out float barrelLength, out float barrelOffset, out float bulletOffset, out FleckDef flareDef, out float flareSize, out FleckDef smokeDef, out float smokeSize))
                {
                    a    = origin -= dir * (barrelOffset * (verb.EquipmentSource.def.graphicData.drawSize.magnitude / 4));
                    a.y += 0.0367346928f;
                    if (flareDef != null)
                    {
                        IAdvancedVerb properties = verb.verbProps as IAdvancedVerb;
                        Rand.PushState();
                        AdeptusFleckMaker.Static(a, map, flareDef, flareSize, properties?.MuzzleFlareColor, properties != null && properties.MuzzleFlareRotates ? (float?)Rand.Range(0, 350) : null, projDef.lifetime);
                        Rand.PopState();
                    }
                    if (smokeDef != null)
                    {
                        AdeptusFleckMaker.ThrowSmoke(a, smokeSize, map, smokeDef);
                    }
                }

                FleckMaker.Static(a, launcher.Map, FleckDefOf.ShotFlash, verb.verbProps.muzzleFlashScale);
            }
            if (effecter == null)
            {
                TriggerEffect(effecterDef, b, hitThing);
            }
            ProjectileVFX ext = this.projDef.GetModExtensionFast <ProjectileVFX>();

            if (ext != null && destination.InBounds(launcher.Map))
            {
                Vector3  pos = destination;
                ThingDef explosionMoteDef = ext.ExplosionMoteDef ?? projDef.projectile.damageDef.explosionCellMote ?? null;
                SoundDef sound            = projDef.projectile.damageDef.soundExplosion;
                Color?   color            = ext.useGraphicColor ? projDef.graphic.color : (ext.useGraphicColorTwo ? projDef.graphic.colorTwo : projDef.projectile.damageDef.explosionColorCenter);
                float    scale            = ext.scaleWithProjectile ? projDef.graphic.drawSize.magnitude : 1f;
                ext.ImpactEffects(pos, map, explosionMoteDef, ext.ExplosionMoteSize * scale, color, sound, ext.ImpactMoteDef, ext.ImpactMoteSize * scale, ext.ImpactGlowMoteDef, ext.ImpactGlowMoteSize * scale, hitThing, null, (int)((projDef.lifetime - ticks) * 1.1f));
                //    ext.ImpactEffects(destination, launcher.Map, ext.ExplosionMoteDef ?? this.projDef.projectile.damageDef.explosionCellMote, ext.ExplosionMoteSize, this.projDef.projectile.damageDef.explosionColorCenter, this.projDef.projectile.damageDef.soundExplosion, ext.ImpactMoteDef, ext.ImpactMoteSize, ext.ImpactGlowMoteDef, ext.ImpactGlowMoteSize, hitThing);
            }
        }
Esempio n. 28
0
 /// <summary>
 /// Start or maintain the laser drill effecter.
 /// </summary>
 public void StartOrMaintainLaserDrillEffecter()
 {
     if (this.laserDrillEffecter == null)
     {
         this.laserDrillEffecter = new Effecter(DefDatabase <EffecterDef> .GetNamed("LaserDrill"));
     }
     else
     {
         this.laserDrillEffecter.EffectTick(new TargetInfo(this.targetPosition, this.Map), new TargetInfo(this.Position, this.Map));
     }
 }
Esempio n. 29
0
        public void CreateLightBurst(IntVec3 center, Map map, float radius)
        {
            GenClamor.DoClamor(this.CasterPawn, 2 * radius, ClamorDefOf.Ability);
            Effecter flashED = TorannMagicDefOf.TM_LightBurstED.Spawn();

            flashED.Trigger(new TargetInfo(center, map, false), new TargetInfo(center, map, false));
            flashED.Cleanup();
            TargetInfo ti = new TargetInfo(center, map, false);

            TM_MoteMaker.MakeOverlay(ti, TorannMagicDefOf.TM_Mote_PsycastAreaEffect, map, Vector3.zero, .1f, 0f, .05f, .1f, .1f, 4.3f);
        }
Esempio n. 30
0
        protected override Job TryGiveJob(Pawn pawn)
        {
            Need_Food food = pawn.needs.food;

            if (food == null || food.CurCategory < this.minCategory || food.CurLevelPercentage > this.maxLevelPercentage)
            {
                return(null);
            }
            Thing thing = null;

            if (!FerroFoods.Foods.NullOrEmpty())
            {
                foreach (var item in FerroFoods.Foods)
                {
                    thing = FindFerroFood(item, pawn);

                    if (thing != null)
                    {
                        break;
                    }
                }
            }
            else
            {
                return(null);
            }
            if (thing != null && pawn.Map.reservationManager.CanReserve(pawn, thing, 1))
            {
                // you need to set the jobdef here
                Job job3 = JobMaker.MakeJob(DefDatabase <JobDef> .GetNamed("JOBDEF", true), thing);
                job3.count = 1;// FoodUtility.WillIngestStackCountOf(pawn, thingDef, nutrition);
                return(job3);
            }
            else
            {
                if (pawn.Map != null && pawn.needs.food.CurLevelPercentage < pawn.needs.food.PercentageThreshHungry && pawn.Awake())
                {
                    ThingDef newThing  = FerroFoods.Foods.RandomElement();
                    Thing    newcorpse = null;
                    int      count     = Rand.Range(1, 10);
                    for (int i = 0; i < count; i++)
                    {
                        newcorpse = GenSpawn.Spawn(newThing, pawn.Position, pawn.Map, WipeMode.Vanish);
                    }

                    if (this.effecter == null)
                    {
                        this.effecter = EffecterDefOf.Mine.Spawn();
                    }
                    this.effecter.Trigger(pawn, newcorpse);
                }
            }
            return(null);
        }