protected override bool TryCastShot() { //Reduce ammunition if (compAmmo != null) { if (!compAmmo.TryReduceAmmoCount()) { if (compAmmo.hasMagazine) { compAmmo.TryStartReload(); } return(false); } } if (base.TryCastShot()) { //Drop casings if (verbPropsCE.ejectsCasings && projectilePropsCE.dropsCasings) { CE_Utility.ThrowEmptyCasing(this.caster.DrawPos, caster.Map, ThingDef.Named(this.projectilePropsCE.casingMoteDefname)); } return(true); } return(false); }
protected override bool TryCastShot() { //Reduce ammunition if (CompAmmo != null) { if (!CompAmmo.TryReduceAmmoCount()) { if (CompAmmo.HasMagazine) { CompAmmo.TryStartReload(); } return(false); } } if (base.TryCastShot()) { //Required since Verb_Shoot does this but Verb_LaunchProjectileCE doesn't when calling base.TryCastShot() because Shoot isn't its base if (ShooterPawn != null) { ShooterPawn.records.Increment(RecordDefOf.ShotsFired); } //Drop casings if (VerbPropsCE.ejectsCasings && projectilePropsCE.dropsCasings) { CE_Utility.ThrowEmptyCasing(caster.DrawPos, caster.Map, ThingDef.Named(projectilePropsCE.casingMoteDefname)); } // This needs to here for weapons without magazine to ensure their last shot plays sounds if (CompAmmo != null && !CompAmmo.HasMagazine && CompAmmo.UseAmmo) { if (!CompAmmo.Notify_ShotFired()) { if (VerbPropsCE.muzzleFlashScale > 0.01f) { MoteMaker.MakeStaticMote(caster.Position, caster.Map, ThingDefOf.Mote_ShotFlash, VerbPropsCE.muzzleFlashScale); } if (VerbPropsCE.soundCast != null) { VerbPropsCE.soundCast.PlayOneShot(new TargetInfo(caster.Position, caster.Map)); } if (VerbPropsCE.soundCastTail != null) { VerbPropsCE.soundCastTail.PlayOneShotOnCamera(); } if (ShooterPawn != null) { if (ShooterPawn.thinker != null) { ShooterPawn.mindState.lastEngageTargetTick = Find.TickManager.TicksGame; } } } return(CompAmmo.Notify_PostShotFired()); } return(true); } return(false); }