public static void ThrowMuzzleFlash(IntVec3 cell, Map map, ThingDef moteDef, float scale, Verb verb) { if (verb.EquipmentSource != null) { if (verb.verbProps.range > 1.48f) { ThingDef mote = moteDef; Vector3 origin = verb.CasterIsPawn ? verb.CasterPawn.Drawer.DrawPos : verb.Caster.DrawPos; CompEquippable equippable = verb.EquipmentSource.TryGetComp <CompEquippable>(); float aimAngle = (verb.CurrentTarget.CenterVector3 - origin).AngleFlat(); if (Oversized) { OversizedWeapon(verb.EquipmentSource, aimAngle, verb, ref origin); } if (verb.EquipmentSource.def.HasModExtension <BarrelOffsetExtension>()) { BarrelOffsetExtension ext = verb.EquipmentSource.def.GetModExtension <BarrelOffsetExtension>(); EffectProjectileExtension ext2 = verb.GetProjectile().HasModExtension <EffectProjectileExtension>() ? verb.GetProjectile().GetModExtension <EffectProjectileExtension>() : null; float offset = ext.barrellength; origin += (verb.CurrentTarget.CenterVector3 - origin).normalized * (verb.EquipmentSource.def.graphic.drawSize.magnitude * (offset)); if (ext2 != null && ext2.muzzleFlare) { ThingDef muzzleFlaremote = DefDatabase <ThingDef> .GetNamed(!ext2.muzzleSmokeDef.NullOrEmpty()?ext2.muzzleFlareDef : "Mote_SparkFlash"); MoteMaker.MakeStaticMote(origin, map, muzzleFlaremote, ext2.muzzleFlareSize); } else if (ext.muzzleFlare) { ThingDef muzzleFlaremote = DefDatabase <ThingDef> .GetNamed(!ext.muzzleSmokeDef.NullOrEmpty()?ext.muzzleFlareDef : "Mote_SparkFlash"); MoteMaker.MakeStaticMote(origin, map, muzzleFlaremote, ext.muzzleFlareSize); } if (ext2 != null && ext2.muzzleSmoke) { string muzzleSmokemote = !ext2.muzzleSmokeDef.NullOrEmpty() ? ext2.muzzleSmokeDef : "OG_Mote_SmokeTrail"; TrailThrower.ThrowSmoke(origin, ext2.muzzleSmokeSize, map, muzzleSmokemote); } else if (ext.muzzleSmoke) { string muzzleSmokemote = !ext.muzzleSmokeDef.NullOrEmpty() ? ext.muzzleSmokeDef : "OG_Mote_SmokeTrail"; TrailThrower.ThrowSmoke(origin, ext.muzzleSmokeSize, map, muzzleSmokemote); } } MoteMaker.MakeStaticMote(origin, map, mote, scale); return; } } { MoteMaker.MakeStaticMote(cell.ToVector3Shifted(), map, moteDef, scale); } }
public override void Tick() { base.Tick(); if (landed) { return; } LastPos = ExactPosition; ticksToImpact--; if (!ExactPosition.InBounds(Map)) { Position = LastPos.ToIntVec3(); Destroy(); return; } if (CheckForCollisionBetween()) { return; } Position = ExactPosition.ToIntVec3(); if (ticksToImpact == 60 && Find.TickManager.CurTimeSpeed == TimeSpeed.Normal && def.projectile.soundImpactAnticipate != null) { def.projectile.soundImpactAnticipate.PlayOneShot(this); } //TODO : It appears that the final steps in the arc (past ticksToImpact == 0) don't CheckForCollisionBetween. if (ticksToImpact <= 0) { ImpactSomething(); return; } if (ambientSustainer != null) { ambientSustainer.Maintain(); } if (def.HasModExtension <TrailerProjectileExtension>()) { var trailer = def.GetModExtension <TrailerProjectileExtension>(); if (trailer != null) { if (ticksToImpact % trailer.trailerMoteInterval == 0) { for (int i = 0; i < trailer.motesThrown; i++) { TrailThrower.ThrowSmoke(DrawPos, trailer.trailMoteSize, Map, trailer.trailMoteDef); } } } } }
public static void Postfix(Projectile __instance, int ___ticksToImpact) { if (__instance != null) { if (__instance.def.HasModExtension <TrailerProjectileExtension>()) { TrailerProjectileExtension trailer = __instance.def.GetModExtension <TrailerProjectileExtension>(); if (trailer != null) { if (___ticksToImpact % trailer.trailerMoteInterval == 0) { for (int i = 0; i < trailer.motesThrown; i++) { // TrailThrower.ThrowSmokeTrail(__instance.Position.ToVector3Shifted(), trailer.trailMoteSize, __instance.Map, trailer.trailMoteDef); TrailThrower.ThrowSmoke(__instance.DrawPos, trailer.trailMoteSize, __instance.Map, trailer.trailMoteDef); } } } } } }