public static bool OnPreDamage(MeleeImpactArea __instance, MechBodyPart bodyPart) { //TODO: this doesn't include spidertron ("MortarWalker") grenade fragments ("BulletProjectile"s) //Observations: //Spear comes up as sword //Fire doesn't come up at all //Player-fired arrows have no owner return(EventBus.Instance.Post(new CharacterPreDamageEvent(__instance, bodyPart))); }
public CharacterPreDamageEvent(MeleeImpactArea mia, MechBodyPart part) { Damager = mia.Owner; Damagee = part.GetOwner(); BodyPart = part; switch (mia) { case ArrowCutArea _: DamageType = Type.BOW; break; case NonMovingHammerMeleeArea _: //Includes MovingLaserImpactArea DamageType = Type.ENVIRONMENT_EXPLOSION; break; case HammerImpactMeleeArea _: DamageType = Type.HAMMER; break; case SwordHitArea _: DamageType = Type.SWORD; break; case BladeCutArea _: //Both Arrow and Sword are subclasses of blade, so if we're here it's a saw blade DamageType = Type.ENVIRONMENT_BLADE; break; default: new Logger("DamageSource").Debug($"Unknown damage source - {mia} from {Damager} to {Damagee}"); DamageType = Type.OTHER; break; } //new Logger("DamageSource").Debug($"{DamageType} damage being dealt from {Damager} to {Damagee}"); }