public static Mote ThrowCasingTurret(Thing caster, Map map, int weaponDamage, ThingDef moteDef)
        {
            if (!caster.Position.ShouldSpawnMotesAt(map) || map.moteCounter.Saturated)
            {
                return(null);
            }
            Building_TurretGun turret    = caster as Building_TurretGun;
            TurretTop          turrettop = Traverse.Create(turret).Field("top").GetValue <TurretTop>();

            float            angle      = Traverse.Create(turrettop).Field("curRotationInt").GetValue <float>();
            MoteThrownCasing moteThrown = (MoteThrownCasing)ThingMaker.MakeThing(moteDef, null);

            if (BulletCasingMoteSettings.uncapCasingSize)
            {
                moteThrown.Scale = GenMath.LerpDouble(5f, 50f, 0.2f, 0.5f, weaponDamage);
            }
            else
            {
                moteThrown.Scale = GenMath.LerpDoubleClamped(5f, 75f, 0.2f, 0.5f, weaponDamage);
            }
            moteThrown.exactPosition  = caster.TrueCenter();
            moteThrown.rotationRate   = Rand.Range(-360f, 360f);
            moteThrown.speed          = Rand.Range(BulletCasingMoteSettings.velocityFactor.min, BulletCasingMoteSettings.velocityFactor.max);
            moteThrown.rotation       = angle;
            moteThrown.velocityRandom = new Vector3(Rand.Range(-4f, 4f), 0f, Rand.Range(-4f, 4f));
            GenSpawn.Spawn(moteThrown, caster.Position, map, WipeMode.Vanish);
            return(moteThrown);
        }
        public static Mote ThrowCasing(Pawn caster, Map map, int weaponDamage, ThingDef moteDef)
        {
            if (!caster.Position.ShouldSpawnMotesAt(map) || map.moteCounter.Saturated)
            {
                return(null);
            }
            float            angle      = (caster.TargetCurrentlyAimingAt.CenterVector3 - caster.DrawPos).AngleFlat();
            MoteThrownCasing moteThrown = (MoteThrownCasing)ThingMaker.MakeThing(moteDef, null);

            if (BulletCasingMoteSettings.uncapCasingSize)
            {
                moteThrown.Scale = GenMath.LerpDouble(5f, 30f, 0.2f, 0.4f, weaponDamage);
            }
            else
            {
                moteThrown.Scale = GenMath.LerpDoubleClamped(5f, 30f, 0.2f, 0.4f, weaponDamage);
            }
            moteThrown.exactPosition  = caster.Position.ToVector3Shifted();
            moteThrown.exactPosition += Quaternion.AngleAxis(angle, Vector3.up) * new Vector3(0f, 0f, 0.3f); //puts the casing slightly infront of the pawn
            moteThrown.rotationRate   = Rand.Range(-360f, 360f);
            moteThrown.speed          = Rand.Range(BulletCasingMoteSettings.velocityFactor.min, BulletCasingMoteSettings.velocityFactor.max);
            moteThrown.rotation       = angle;
            moteThrown.velocityRandom = new Vector3(Rand.Range(-3f, 3f), 0f, Rand.Range(-3f, 3f));
            GenSpawn.Spawn(moteThrown, caster.Position, map, WipeMode.Vanish);
            return(moteThrown);
        }