public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 a = origin + Velocity(this.ExactRotation.eulerAngles.y); Vector3 b = ExactPosition; a.y = b.y = def.Altitude; SpawnBeam(a, b, hitThing); /* * if (this.def.impactReflection > 0) * { * Vector3 dir = (this.ExactRotation.eulerAngles - origin).normalized; * Rand.PushState(); * for (int i = 0; i < this.def.impactReflection; i++) * { * Vector3 c = ExactPosition - dir.RotatedBy(Rand.Range(-35.5f, 35.5f)) * Rand.Range(-1.5f, 1.5f);// 0.8f; * SpawnBeam(b, c); * } * Rand.PopState(); * } */ base.DeSpawn(mode); }
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 a = Origin + ShotLine.direction * (defWeapon == null ? 0.9f : defWeapon.barrelLength); Vector3 b = ExactPosition; a.y = b.y = def.Altitude; SpawnBeam(a, b); base.DeSpawn(mode); }
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 a = origin + Velocity(this.ExactRotation.eulerAngles.y) * (defWeapon == null ? 0.9f : defWeapon.barrelLength); Vector3 b = ExactPosition; a.y = b.y = def.Altitude; SpawnBeam(a, b); if (this.def.impactReflection > 0) { Vector3 dir = (destination - origin).normalized; Rand.PushState(); Vector3 c = ExactPosition - dir.RotatedBy(Rand.Range(-22.5f, 22.5f)) * 0.8f; Rand.PopState(); SpawnBeamReflections(b, c, this.def.impactReflection); } base.DeSpawn(mode); }
public override void DeSpawn(DestroyMode mode = DestroyMode.Vanish) { LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 a = Origin + ShotLine.direction * (defWeapon == null ? 0.9f : defWeapon.barrelLength); Vector3 b = ExactPosition; a.y = b.y = def.Altitude; SpawnBeam(a, b, hitThing); if (this.def.impactReflection > 0) { Vector3 dir = (this.ExactRotation.eulerAngles - Origin).normalized; Rand.PushState(); for (int i = 0; i < this.def.impactReflection; i++) { Vector3 c = ExactPosition - dir.RotatedBy(Rand.Range(-35.5f, 35.5f)) * Rand.Range(-1.5f, 1.5f);// 0.8f; SpawnBeam(b, c); } Rand.PopState(); } base.DeSpawn(mode); }
protected override void Impact(Thing hitThing) { this.hitThing = hitThing; bool shielded = hitThing.IsShielded() && def.IsWeakToShields; LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 dir = (destination - origin).normalized; dir.y = 0; Vector3 a = origin + dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength); Vector3 b; if (hitThing == null) { b = destination; } else if (shielded) { b = hitThing.TrueCenter() - dir.RotatedBy(Rand.Range(-22.5f, 22.5f)) * 0.8f; } else if ((destination - hitThing.TrueCenter()).magnitude < 1) { b = destination; } else { b = hitThing.TrueCenter(); b.x += Rand.Range(-0.5f, 0.5f); b.z += Rand.Range(-0.5f, 0.5f); } a.y = b.y = def.Altitude; // SpawnBeam(a, b); if (this.def.projectile.explosionRadius > 0f) { this.Explode(hitThing, false); GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(this, this.def.projectile.damageDef, this.launcher.Faction); } Pawn pawn = launcher as Pawn; IDrawnWeaponWithRotation weapon = null; if (pawn != null && pawn.equipment != null) { weapon = pawn.equipment.Primary as IDrawnWeaponWithRotation; } if (weapon == null) { Building_LaserGun turret = launcher as Building_LaserGun; if (turret != null) { weapon = turret.gun as IDrawnWeaponWithRotation; } } if (weapon != null) { float angle = (b - a).AngleFlat() - (intendedTarget.CenterVector3 - a).AngleFlat(); weapon.RotationOffset = (angle + 180) % 360 - 180; } if (hitThing == null) { Rand.PushState(); bool flag2 = this.def.causefireChance > 0f && Rand.Chance(this.def.causefireChance); Rand.PopState(); if (flag2) { FireUtility.TryStartFireIn(b.ToIntVec3(), pawn.Map, 0.01f); } } else { if (hitThing is Pawn && shielded) { weaponDamageMultiplier *= def.shieldDamageMultiplier; SpawnBeamReflections(a, b, 5); } Rand.PushState(); bool flag2 = this.def.causefireChance > 0f && Rand.Chance(this.def.causefireChance); Rand.PopState(); if (flag2) { hitThing.TryAttachFire(0.01f); } AddeEffects(hitThing); } // TriggerEffect(def.explosionEffect, b, hitThing); Map map = base.Map; IntVec3 position = base.Position; GenClamor.DoClamor(this, 2.1f, ClamorDefOf.Impact); this.Destroy(DestroyMode.Vanish); BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef); Find.BattleLog.Add(battleLogEntry_RangedImpact); this.NotifyImpact(hitThing, map, position); if (hitThing != null) { DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, (float)this.DamageAmount, this.ArmorPenetration, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing); hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact); if (pawn != null && pawn.stances != null && pawn.BodySize <= this.def.projectile.StoppingPower + 0.001f) { pawn.stances.StaggerFor(95); } if (this.def.projectile.extraDamages == null) { return; } using (List <ExtraDamage> .Enumerator enumerator = this.def.projectile.extraDamages.GetEnumerator()) { while (enumerator.MoveNext()) { ExtraDamage extraDamage = enumerator.Current; if (Rand.Chance(extraDamage.chance)) { DamageInfo dinfo2 = new DamageInfo(extraDamage.def, extraDamage.amount, extraDamage.AdjustedArmorPenetration(), this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing); hitThing.TakeDamage(dinfo2).AssociateWithLog(battleLogEntry_RangedImpact); } } return; } } SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false)); if (base.Position.GetTerrain(map).takeSplashes) { MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)base.DamageAmount) * 1f, 4f); return; } // MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); }
protected override void Impact(Thing hitThing) { bool shielded = hitThing.IsShielded() && def.IsWeakToShields; LaserGunDef defWeapon = equipmentDef as LaserGunDef; Vector3 dir = ShotLine.direction; dir.y = 0; Vector3 a = Origin + dir * (defWeapon == null ? 0.9f : defWeapon.barrelLength); Vector3 b; if (hitThing == null) { b = ExactPosition; } else if (shielded) { Rand.PushState(); b = ExactPosition - dir.RotatedBy(Rand.Range(-22.5f, 22.5f)) * 0.8f; Rand.PopState(); } else if ((destination - ExactPosition).magnitude < 1) { b = ExactPosition; } else { b = ExactPosition; Rand.PushState(); b.x += Rand.Range(-0.5f, 0.5f); b.z += Rand.Range(-0.5f, 0.5f); Rand.PopState(); } a.y = b.y = def.Altitude; // SpawnBeam(a, b); /* * bool createsExplosion = this.def.projectile.explosionRadius>0f; * if (createsExplosion) * { * this.Explode(hitThing, false); * GenExplosion.NotifyNearbyPawnsOfDangerousExplosive(this, this.def.projectile.damageDef, this.launcher.Faction); * } */ Pawn pawn = launcher as Pawn; IDrawnWeaponWithRotation weapon = null; if (pawn != null && pawn.equipment != null) { weapon = pawn.equipment.Primary as IDrawnWeaponWithRotation; } if (weapon == null) { Building_LaserGunCE turret = launcher as Building_LaserGunCE; if (turret != null) { weapon = turret.Gun as IDrawnWeaponWithRotation; } } if (weapon != null) { float angle = (b - a).AngleFlat() - (destination - a).AngleFlat(); weapon.RotationOffset = (angle + 180) % 360 - 180; } if (hitThing == null) { TriggerEffect(def.explosionEffect, b); Rand.PushState(); bool flag2 = this.def.causefireChance > 0f && Rand.Chance(this.def.causefireChance); Rand.PopState(); if (flag2) { FireUtility.TryStartFireIn(b.ToIntVec3(), pawn.Map, 0.01f); } } else { if (hitThing is Pawn && shielded) { // weaponDamageMultiplier *= def.shieldDamageMultiplier; SpawnBeamReflections(a, b, 5); } Rand.PushState(); bool flag2 = this.def.causefireChance > 0f && Rand.Chance(this.def.causefireChance); Rand.PopState(); if (flag2) { hitThing.TryAttachFire(0.01f); } TriggerEffect(def.explosionEffect, b, hitThing); } if (def.HediffToAdd != null) { AddedEffect(hitThing); } Map map = base.Map; base.Impact(hitThing); /* * if (this.equipmentDef==null) * { * this.equipmentDef = this.launcher.def; * } * BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget, this.equipmentDef, this.def, null); * Find.BattleLog.Add(battleLogEntry_RangedImpact); * if (hitThing != null) * { * DamageDef damageDef = this.def.projectile.damageDef; * float amount = DamageAmount; * float armorPenetration = ArmorPenetration; * float y = this.ExactRotation.eulerAngles.y; * Thing launcher = this.launcher; * ThingDef equipmentDef = this.equipmentDef; * DamageInfo dinfo = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget); * hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact); * Pawn hitPawn = hitThing as Pawn; * if (hitPawn != null && hitPawn.stances != null && hitPawn.BodySize <= this.def.projectile.StoppingPower + 0.001f) * { * hitPawn.stances.StaggerFor(95); * } * } * else * { * SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false)); * MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f); * if (base.Position.GetTerrain(map).takeSplashes) * { * MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)this.def.projectile.GetDamageAmount(1f, null)) * 1f, 4f); * } * } */ }