public virtual void Hurt(HitInfo info) { Assert.IsTrue(base.isServer, "This should be called serverside only"); if (IsDead()) { return; } using (TimeWarning.New("Hurt( HitInfo )", 50)) { float num = health; ScaleDamage(info); if (info.PointStart != Vector3.zero) { for (int i = 0; i < propDirection.Length; i++) { if (!(propDirection[i].extraProtection == null) && !propDirection[i].IsWeakspot(base.transform, info)) { propDirection[i].extraProtection.Scale(info.damageTypes); } } } info.damageTypes.Scale(DamageType.Arrow, ConVar.Server.arrowdamage); info.damageTypes.Scale(DamageType.Bullet, ConVar.Server.bulletdamage); info.damageTypes.Scale(DamageType.Slash, ConVar.Server.meleedamage); info.damageTypes.Scale(DamageType.Blunt, ConVar.Server.meleedamage); info.damageTypes.Scale(DamageType.Stab, ConVar.Server.meleedamage); info.damageTypes.Scale(DamageType.Bleeding, ConVar.Server.bleedingdamage); if (!(this is BasePlayer)) { info.damageTypes.Scale(DamageType.Fun_Water, 0f); } if (Interface.CallHook("IOnBaseCombatEntityHurt", this, info) != null) { return; } DebugHurt(info); health = num - info.damageTypes.Total(); SendNetworkUpdate(); if (ConVar.Global.developer > 1) { Debug.Log(string.Concat("[Combat]".PadRight(10), base.gameObject.name, " hurt ", info.damageTypes.GetMajorityDamageType(), "/", info.damageTypes.Total(), " - ", health.ToString("0"), " health left")); } lastDamage = info.damageTypes.GetMajorityDamageType(); lastAttacker = info.Initiator; if (lastAttacker != null) { BaseCombatEntity baseCombatEntity = lastAttacker as BaseCombatEntity; if (baseCombatEntity != null) { baseCombatEntity.lastDealtDamageTime = UnityEngine.Time.time; baseCombatEntity.lastDealtDamageTo = this; } } BaseCombatEntity baseCombatEntity2 = lastAttacker as BaseCombatEntity; if (markAttackerHostile && baseCombatEntity2 != null && baseCombatEntity2 != this) { baseCombatEntity2.MarkHostileFor(); } if (DamageTypeEx.IsConsideredAnAttack(lastDamage)) { lastAttackedTime = UnityEngine.Time.time; if (lastAttacker != null) { LastAttackedDir = (lastAttacker.transform.position - base.transform.position).normalized; } } if (Health() <= 0f) { Die(info); } BasePlayer initiatorPlayer = info.InitiatorPlayer; if ((bool)initiatorPlayer) { if (IsDead()) { initiatorPlayer.stats.combat.Log(info, num, health, "killed"); } else { initiatorPlayer.stats.combat.Log(info, num, health); } } } }
public virtual void Hurt(HitInfo info) { Assert.IsTrue(base.isServer, "This should be called serverside only"); if (this.IsDead()) { return; } using (TimeWarning timeWarning = TimeWarning.New("Hurt( HitInfo )", (long)50)) { float single = this.health; this.ScaleDamage(info); if (info.PointStart != Vector3.zero) { for (int i = 0; i < (int)this.propDirection.Length; i++) { if (!(this.propDirection[i].extraProtection == null) && !this.propDirection[i].IsWeakspot(base.transform, info)) { this.propDirection[i].extraProtection.Scale(info.damageTypes, 1f); } } } info.damageTypes.Scale(DamageType.Arrow, ConVar.Server.arrowdamage); info.damageTypes.Scale(DamageType.Bullet, ConVar.Server.bulletdamage); info.damageTypes.Scale(DamageType.Slash, ConVar.Server.meleedamage); info.damageTypes.Scale(DamageType.Blunt, ConVar.Server.meleedamage); info.damageTypes.Scale(DamageType.Stab, ConVar.Server.meleedamage); info.damageTypes.Scale(DamageType.Bleeding, ConVar.Server.bleedingdamage); if (Interface.CallHook("IOnBaseCombatEntityHurt", this, info) != null) { return; } this.DebugHurt(info); this.health = single - info.damageTypes.Total(); base.SendNetworkUpdate(BasePlayer.NetworkQueue.Update); if (ConVar.Global.developer > 1) { object[] str = new object[] { "[Combat]".PadRight(10), base.gameObject.name, " hurt ", info.damageTypes.GetMajorityDamageType(), "/", info.damageTypes.Total(), " - ", null, null }; str[7] = this.health.ToString("0"); str[8] = " health left"; Debug.Log(string.Concat(str)); } this.lastDamage = info.damageTypes.GetMajorityDamageType(); this.lastAttacker = info.Initiator; if (this.lastAttacker != null) { BaseCombatEntity baseCombatEntity = this.lastAttacker as BaseCombatEntity; if (baseCombatEntity != null) { baseCombatEntity.lastDealtDamageTime = UnityEngine.Time.time; } } BaseCombatEntity baseCombatEntity1 = this.lastAttacker as BaseCombatEntity; if (this.markAttackerHostile && baseCombatEntity1 != null && baseCombatEntity1 != this) { baseCombatEntity1.MarkHostileFor(60f); } if (this.lastDamage != DamageType.Decay) { this.lastAttackedTime = UnityEngine.Time.time; if (this.lastAttacker != null) { Vector3 vector3 = this.lastAttacker.transform.position - base.transform.position; this.LastAttackedDir = vector3.normalized; } } if (this.health <= 0f) { this.Die(info); } BasePlayer initiatorPlayer = info.InitiatorPlayer; if (initiatorPlayer) { if (!this.IsDead()) { initiatorPlayer.stats.combat.Log(info, single, this.health, null); } else { initiatorPlayer.stats.combat.Log(info, single, this.health, "killed"); return; } } } }