Beispiel #1
0
        protected virtual void Explode()
        {
            Map map = base.Map;

            this.Destroy(DestroyMode.Vanish);
            if (this.def.projectile.explosionEffect != null)
            {
                Effecter effecter = this.def.projectile.explosionEffect.Spawn();
                effecter.Trigger(new TargetInfo(base.Position, map, false), new TargetInfo(base.Position, map, false));
                effecter.Cleanup();
            }
            IntVec3   position         = base.Position;
            Map       map2             = map;
            float     explosionRadius  = this.def.projectile.explosionRadius;
            DamageDef damageDef        = this.def.projectile.damageDef;
            Thing     launcher         = this.launcher;
            int       damageAmount     = base.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, 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);
        }
 private void DoDestroyEffects(Map map)
 {
     if (def.building.destroyEffecter != null)
     {
         Effecter effecter = def.building.destroyEffecter.Spawn(base.Position, map);
         effecter.Trigger(new TargetInfo(base.Position, map), TargetInfo.Invalid);
         effecter.Cleanup();
     }
     else
     {
         if (!def.IsEdifice())
         {
             return;
         }
         GetDestroySound()?.PlayOneShot(new TargetInfo(base.Position, map));
         foreach (IntVec3 item in this.OccupiedRect())
         {
             int num = (def.building.isNaturalRock ? 1 : Rand.RangeInclusive(3, 5));
             for (int i = 0; i < num; i++)
             {
                 MoteMaker.ThrowDustPuffThick(item.ToVector3Shifted(), map, Rand.Range(1.5f, 2f), Color.white);
             }
         }
         if (Find.CurrentMap == map)
         {
             float num2 = def.building.destroyShakeAmount;
             if (num2 < 0f)
             {
                 num2 = ShakeAmountPerAreaCurve.Evaluate(def.Size.Area);
             }
             Find.CameraDriver.shaker.DoShake(num2);
         }
     }
 }
Beispiel #3
0
 public void Notify_TerrainDestroyed(IntVec3 c)
 {
     if (CanRemoveTopLayerAt(c))
     {
         TerrainDef terrainDef = TerrainAt(c);
         RemoveTopLayer(c, doLeavings: false);
         if (terrainDef.destroyBuildingsOnDestroyed)
         {
             c.GetFirstBuilding(map)?.Kill();
         }
         if (terrainDef.destroyEffectWater != null && TerrainAt(c) != null && TerrainAt(c).IsWater)
         {
             Effecter effecter = terrainDef.destroyEffectWater.Spawn();
             effecter.Trigger(new TargetInfo(c, map), new TargetInfo(c, map));
             effecter.Cleanup();
         }
         else if (terrainDef.destroyEffect != null)
         {
             Effecter effecter2 = terrainDef.destroyEffect.Spawn();
             effecter2.Trigger(new TargetInfo(c, map), new TargetInfo(c, map));
             effecter2.Cleanup();
         }
         ThingUtility.CheckAutoRebuildTerrainOnDestroyed(terrainDef, c, map);
     }
 }
Beispiel #4
0
 public SubEffecter Spawn(Effecter parent)
 {
     return((SubEffecter)Activator.CreateInstance(this.subEffecterClass, new object[]
     {
         this,
         parent
     }));
 }
Beispiel #5
0
 public void Tick(Pawn pawn)
 {
     if (effecter == null)
     {
         effecter = def.Spawn();
     }
     effecter.EffectTick(pawn, null);
 }
Beispiel #6
0
 public void Tick(Pawn pawn)
 {
     if (this.effecter == null)
     {
         this.effecter = this.def.Spawn();
     }
     this.effecter.EffectTick(pawn, null);
 }
        public Effecter Spawn(IntVec3 target, Map map, float scale = 1f)
        {
            Effecter   effecter   = new Effecter(this);
            TargetInfo targetInfo = new TargetInfo(target, map);

            effecter.scale = scale;
            effecter.Trigger(targetInfo, targetInfo);
            return(effecter);
        }
        public Effecter Spawn(Thing target, Map map, float scale = 1f)
        {
            Effecter effecter = new Effecter(this);

            effecter.offset = target.TrueCenter() - target.Position.ToVector3Shifted();
            effecter.scale  = scale;
            TargetInfo targetInfo = new TargetInfo(target.Position, map);

            effecter.Trigger(targetInfo, targetInfo);
            return(effecter);
        }
        private static void TriggerEffecter()
        {
            List <DebugMenuOption> list = new List <DebugMenuOption>();
            List <EffecterDef>     allDefsListForReading = DefDatabase <EffecterDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                EffecterDef localDef = allDefsListForReading[i];
                list.Add(new DebugMenuOption(localDef.defName, DebugMenuOptionMode.Tool, delegate
                {
                    Effecter effecter = localDef.Spawn();
                    effecter.Trigger(new TargetInfo(UI.MouseCell(), Find.CurrentMap), new TargetInfo(UI.MouseCell(), Find.CurrentMap));
                    effecter.Cleanup();
                }));
            }
            Find.WindowStack.Add(new Dialog_DebugOptionListLister(list));
        }
 public SubEffecter_SprayerChance(SubEffecterDef def, Effecter parent) : base(def, parent)
 {
 }
 public SubEffecter Spawn(Effecter parent)
 {
     return((SubEffecter)Activator.CreateInstance(subEffecterClass, this, parent));
 }
Beispiel #12
0
 public void Reset()
 {
     this.def              = null;
     this.effecter         = null;
     this.lastMaintainTick = -1;
 }
Beispiel #13
0
 public SubEffecter_SprayerContinuous(SubEffecterDef def, Effecter parent) : base(def, parent)
 {
 }
 public SubEffecter_Sustainer(SubEffecterDef def, Effecter parent)
     : base(def, parent)
 {
 }
 public SubEffecter_SprayerTriggered(SubEffecterDef def, Effecter parent) : base(def, parent)
 {
 }
Beispiel #16
0
 public void Reset()
 {
     def              = null;
     effecter         = null;
     lastMaintainTick = -1;
 }
Beispiel #17
0
 public SubEffecter_SoundTriggered(SubEffecterDef def, Effecter parent)
     : base(def, parent)
 {
 }
Beispiel #18
0
 public SubEffecter(SubEffecterDef subDef, Effecter parent)
 {
     this.def    = subDef;
     this.parent = parent;
 }
 public SubEffecter_ProgressBar(SubEffecterDef def, Effecter parent) : base(def, parent)
 {
 }
Beispiel #20
0
 public SubEffecter_InteractSymbol(SubEffecterDef def, Effecter parent) : base(def, parent)
 {
 }
 public SubEffecter_SoundIntermittent(SubEffecterDef def, Effecter parent) : base(def, parent)
 {
     this.ticksUntilSound = def.intermittentSoundInterval.RandomInRange;
 }
 public SubEffecter_DrifterEmote(SubEffecterDef def, Effecter parent)
     : base(def, parent)
 {
 }
Beispiel #23
0
        private DamageResult ApplyToPawn(DamageInfo dinfo, Pawn pawn)
        {
            DamageResult damageResult = new DamageResult();

            if (dinfo.Amount <= 0f)
            {
                return(damageResult);
            }
            if (!DebugSettings.enablePlayerDamage && pawn.Faction == Faction.OfPlayer)
            {
                return(damageResult);
            }
            Map  mapHeld = pawn.MapHeld;
            bool spawnedOrAnyParentSpawned = pawn.SpawnedOrAnyParentSpawned;

            if (dinfo.AllowDamagePropagation && dinfo.Amount >= (float)dinfo.Def.minDamageToFragment)
            {
                int num = Rand.RangeInclusive(2, 4);
                for (int i = 0; i < num; i++)
                {
                    DamageInfo dinfo2 = dinfo;
                    dinfo2.SetAmount(dinfo.Amount / (float)num);
                    ApplyDamageToPart(dinfo2, pawn, damageResult);
                }
            }
            else
            {
                ApplyDamageToPart(dinfo, pawn, damageResult);
                ApplySmallPawnDamagePropagation(dinfo, pawn, damageResult);
            }
            if (damageResult.wounded)
            {
                PlayWoundedVoiceSound(dinfo, pawn);
                pawn.Drawer.Notify_DamageApplied(dinfo);
                EffecterDef damageEffecter = pawn.RaceProps.FleshType.damageEffecter;
                if (damageEffecter != null)
                {
                    if (pawn.health.woundedEffecter != null && pawn.health.woundedEffecter.def != damageEffecter)
                    {
                        pawn.health.woundedEffecter.Cleanup();
                    }
                    pawn.health.woundedEffecter = damageEffecter.Spawn();
                    pawn.health.woundedEffecter.Trigger(pawn, dinfo.Instigator ?? pawn);
                }
                if (dinfo.Def.damageEffecter != null)
                {
                    Effecter effecter = dinfo.Def.damageEffecter.Spawn();
                    effecter.Trigger(pawn, pawn);
                    effecter.Cleanup();
                }
            }
            if (damageResult.headshot && pawn.Spawned)
            {
                MoteMaker.ThrowText(new Vector3((float)pawn.Position.x + 1f, pawn.Position.y, (float)pawn.Position.z + 1f), pawn.Map, "Headshot".Translate(), Color.white);
                if (dinfo.Instigator != null)
                {
                    (dinfo.Instigator as Pawn)?.records.Increment(RecordDefOf.Headshots);
                }
            }
            if ((damageResult.deflected || damageResult.diminished) && spawnedOrAnyParentSpawned)
            {
                EffecterDef effecterDef = (damageResult.deflected ? ((damageResult.deflectedByMetalArmor && dinfo.Def.canUseDeflectMetalEffect) ? ((dinfo.Def != DamageDefOf.Bullet) ? EffecterDefOf.Deflect_Metal : EffecterDefOf.Deflect_Metal_Bullet) : ((dinfo.Def != DamageDefOf.Bullet) ? EffecterDefOf.Deflect_General : EffecterDefOf.Deflect_General_Bullet)) : ((!damageResult.diminishedByMetalArmor) ? EffecterDefOf.DamageDiminished_General : EffecterDefOf.DamageDiminished_Metal));
                if (pawn.health.deflectionEffecter == null || pawn.health.deflectionEffecter.def != effecterDef)
                {
                    if (pawn.health.deflectionEffecter != null)
                    {
                        pawn.health.deflectionEffecter.Cleanup();
                        pawn.health.deflectionEffecter = null;
                    }
                    pawn.health.deflectionEffecter = effecterDef.Spawn();
                }
                pawn.health.deflectionEffecter.Trigger(pawn, dinfo.Instigator ?? pawn);
                if (damageResult.deflected)
                {
                    pawn.Drawer.Notify_DamageDeflected(dinfo);
                }
            }
            if (!damageResult.deflected && spawnedOrAnyParentSpawned)
            {
                ImpactSoundUtility.PlayImpactSound(pawn, dinfo.Def.impactSoundType, mapHeld);
            }
            return(damageResult);
        }