public void Notify_TerrainDestroyed(IntVec3 c) { TerrainDef terrainDef = this.TerrainAt(c); this.RemoveTopLayer(c, false); if (terrainDef.destroyBuildingsOnDestroyed) { Building firstBuilding = c.GetFirstBuilding(this.map); if (firstBuilding != null) { firstBuilding.Kill(null, null); } } if (terrainDef.destroyEffectWater != null && this.TerrainAt(c) != null && this.TerrainAt(c).IsWater) { Effecter effecter = terrainDef.destroyEffectWater.Spawn(); effecter.Trigger(new TargetInfo(c, this.map, false), new TargetInfo(c, this.map, false)); effecter.Cleanup(); } else if (terrainDef.destroyEffect != null) { Effecter effecter2 = terrainDef.destroyEffect.Spawn(); effecter2.Trigger(new TargetInfo(c, this.map, false), new TargetInfo(c, this.map, false)); effecter2.Cleanup(); } }
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 = this.def.projectile.DamageAmount; float armorPenetration = this.def.projectile.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); }
public Stance_Warmup(int ticks, LocalTargetInfo focusTarg, Verb verb) : base(ticks, focusTarg, verb) { if (focusTarg.HasThing && focusTarg.Thing is Pawn) { Pawn pawn = (Pawn)focusTarg.Thing; targetStartedDowned = pawn.Downed; if (pawn.apparel != null) { for (int i = 0; i < pawn.apparel.WornApparelCount; i++) { (pawn.apparel.WornApparel[i] as ShieldBelt)?.KeepDisplaying(); } } } if (verb != null) { if (verb.verbProps.soundAiming != null) { SoundInfo info = SoundInfo.InMap(verb.caster, MaintenanceType.PerTick); if (verb.CasterIsPawn) { info.pitchFactor = 1f / verb.CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor); } sustainer = verb.verbProps.soundAiming.TrySpawnSustainer(info); } if (verb.verbProps.warmupEffecter != null && verb.Caster != null) { effecter = verb.verbProps.warmupEffecter.Spawn(verb.Caster, verb.Caster.Map); effecter.Trigger(verb.Caster, focusTarg.ToTargetInfo(verb.Caster.Map)); } } drawAimPie = verb?.verbProps.drawAimPie ?? false; }
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); } } }
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); } }
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)); }
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); }