Esempio n. 1
0
 static bool Decay(BaseCombatEntity entity, float amount)
 {
     entity.health -= amount;
     entity.SendNetworkUpdate();
     if (!(entity.health <= 0f))
     {
         return(true);
     }
     entity.GetComponent <BaseEntity>().KillMessage();
     return(false);
 }
Esempio n. 2
0
 // Decays an entity, returns false if destroyed
 static bool decay(BaseCombatEntity entity, float amount)
 {
     entity.health -= amount;
     entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
     if (entity.health <= 0f)
     {
         entity.Die();
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
        private void OnEntityBuilt(Planner plan, GameObject go)
        {
            if (plan == null || go == null)
            {
                return;
            }

            string name = go.name;

            if (name == null || (name.Length != HighStoneWallName.Length && name.Length != HighWoodWallName.Length))
            {
                return;
            }
            else if (name != HighStoneWallName && name != HighWoodWallName)
            {
                return;
            }

            BasePlayer ownerPlayer = plan.GetOwnerPlayer();

            if (ownerPlayer == null)
            {
                return;
            }
            if (ownerPlayer.IsBuildingAuthed())
            {
                return;
            }

            BaseCombatEntity entity = go.GetComponent <BaseCombatEntity>();

            if (entity == null)
            {
                return;
            }

            float barricadeHealth = entity.MaxHealth() * barricadeHealthPercentage;

            entity.health = barricadeHealth;
            entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);

            InvokeHandler.Invoke(entity, delegate
            {
                if (entity.health > barricadeHealth)
                {
                    return;
                }

                entity.Kill();
            }, decayTime);
        }
Esempio n. 4
0
 /// <summary>
 /// Use this to change the health.
 /// Updates health of all child entities and saves the new value to save data.
 /// </summary>
 /// <param name="newhealth"></param>
 public void SetHealth(float newhealth)
 {
     data.health = newhealth;
     if (MainParent != null)
     {
         MainParent.health = newhealth;
         MainParent.SendNetworkUpdate(BasePlayer.NetworkQueue.UpdateDistance);
     }
     foreach (BaseCombatEntity e in ChildEntities)
     {
         e.health = newhealth;
         e.SendNetworkUpdate(BasePlayer.NetworkQueue.UpdateDistance);
     }
 }
Esempio n. 5
0
        private object OnStructureRepair(BaseCombatEntity entity, BasePlayer player)
        {
            if (!entity.repair.enabled)
            {
                return(false);
            }

            if (entity.SecondsSinceAttacked <= 30)
            {
                return(null);
            }

            var healthMissing         = entity.MaxHealth() - entity.Health();
            var healthMissingFraction = 1 - entity.healthFraction;

            if (healthMissingFraction <= 0)
            {
                return(null);
            }

            if (entity.BuildCost() == null)
            {
                return(null);
            }

            var repairAmount = Math.Max(entity.MaxHealth() * RepairFraction, MinRepairAmount);

            repairAmount = Math.Min(repairAmount, healthMissing);

            entity.health += repairAmount;
            entity.SendNetworkUpdate();

            if (entity.Health() >= entity.MaxHealth())
            {
                entity.OnRepairFinished();
            }
            else
            {
                entity.OnRepair();
            }

            return(false);
        }
        void OnEntityBuilt(Planner plan, GameObject go)
        {
            BaseCombatEntity entity = go.ToBaseEntity() as BaseCombatEntity;

            if (entity == null)
            {
                return;
            }

            if (Settings.EntityUpgradeTime.ContainsKey(entity.ShortPrefabName) == false)
            {
                return;
            }

            var data = GetEntityData(entity);

            entity.healthFraction = (float)data.TimerRate / Settings.EntityUpgradeTime[entity.ShortPrefabName];
            entity.SendNetworkUpdate();
            data.StartTimer();

            return;

            Timer _timer = null;

            entity.healthFraction   = 0;
            entity.lastAttackedTime = Time.time;
            _timer = timer.Repeat(1f, Settings.UpgradeDelay, () =>
            {
                if (entity == null || entity.IsDestroyed || _timer == null)
                {
                    _timer?.Destroy();
                    return;
                }
                entity.lastAttackedTime = Time.time;
                entity.healthFraction   = 1f / Settings.UpgradeDelay * (Settings.UpgradeDelay - _timer.Repetitions);
                if (_timer.Repetitions == 0)
                {
                    entity.lastAttackedTime = 0;
                    //timers.Remove(entity);
                }
            });
            //timers.Add(entity, _timer);
        }
Esempio n. 7
0
        // Decays an entity, returns false if destroyed
        private bool decay(BaseCombatEntity entity, float amount)
        {
            var decay = entity as DecayEntity;

            if (!ignoreDecayTimer && decay != null && (float)decayTimer.GetValue(decay) < (float)decayDelayTime.GetValue(decay))
            {
                return(true);
            }
            if (entity.OwnerID == 0 || ignoreAlivePlayers && activePlayers.Contains(entity.OwnerID))
            {
                return(true);
            }
            //if (decay != null && !decay.enabled) return true;
            entity.health -= amount;
            if (entity.health <= 0f)
            {
                return(false);
            }
            entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            return(true);
        }
            private void TimerLoop()
            {
                if (Entity == null)
                {
                    return;
                }
                NextRepairTime = Mathf.Max(UnityEngine.Time.time + TimerRate + 4, NextRepairTime);
                float rate = 0;

                if (Entity is BuildingBlock)
                {
                    switch (((BuildingBlock)Entity).grade)
                    {
                    case BuildingGrade.Enum.Wood: { rate = Settings.WoodUpgradeDelay; break; }

                    case BuildingGrade.Enum.Stone: { rate = Settings.StoneUpgradeDelay; break; }

                    case BuildingGrade.Enum.Metal: { rate = Settings.MetalUpgradeDelay; break; }

                    case BuildingGrade.Enum.TopTier: { rate = Settings.ArmouredUpgradeDelay; break; }

                    default: { return; }
                    }
                }
                int amount;

                if (Settings.EntityUpgradeTime.TryGetValue(Entity.ShortPrefabName, out amount))
                {
                    rate = amount;
                }
                Entity.healthFraction = Mathf.Min(1f, Entity.healthFraction + (TimerRate / rate));
                if (Entity.healthFraction >= 1f)
                {
                    Destroy();
                }
                if (!(Entity is BuildingBlock))
                {
                    Entity.SendNetworkUpdate();
                }
            }
Esempio n. 9
0
        /// <summary>
        /// Called from <c>BaseCombatEntity.Hurt(HitInfo)</c> .
        /// </summary>
        public static void On_CombatEntityHurt(BaseCombatEntity combatEntity, HitInfo info)
        {
            try {
                Assert.Test(combatEntity.isServer, "This should be called serverside only");

                if (combatEntity.IsDead())
                    return;

                using (TimeWarning.New("Hurt", 50)) {
                    BaseNPC baseNPC = combatEntity.GetComponent<BaseNPC>();
                    BaseCorpse baseCorpse = combatEntity.GetComponent<BaseCorpse>();
                    BasePlayer basePlayer = combatEntity.GetComponent<BasePlayer>();

                    combatEntity.ScaleDamage(info);

                    if (basePlayer != null) {
                        Player player = Server.GetPlayer(basePlayer);

                        if (player.Teleporting) {
                            for (int i = 0; i < info.damageTypes.types.Length; i++) {
                                info.damageTypes.types[i] = 0f;
                            }
                        }

                        HurtEvent he = new PlayerHurtEvent(player, info);
                        OnNext("On_PlayerHurt", he);
                    } else if (baseNPC != null) {
                            HurtEvent he = new NPCHurtEvent(new NPC(baseNPC), info);
                            OnNext("On_NPCHurt", he);
                        } else if (baseCorpse != null) {
                                HurtEvent he = new CorpseHurtEvent(baseCorpse, info);
                                OnNext("On_CorpseHurt", he);
                            } else {
                                HurtEvent he = new CombatEntityHurtEvent(combatEntity, info);
                                OnNext("On_CombatEntityHurt", he);
                            }

                    if (info.PointStart != Vector3.zero) {
                        DirectionProperties[] directionProperties = (DirectionProperties[])combatEntity.GetFieldValue("propDirection");

                        for (int i = 0; i < directionProperties.Length; i++) {
                            if (!(directionProperties[i].extraProtection == null)) {
                                if (directionProperties[i].IsWeakspot(combatEntity.transform, info)) {
                                    directionProperties[i].extraProtection.Scale(info.damageTypes);
                                }
                            }
                        }
                    }

                    // the DebugHurt() method
                    if (ConVar.Vis.attack) {
                        if (info.PointStart != info.PointEnd) {
                            ConsoleNetwork.BroadcastToAllClients("ddraw.arrow", new object[] {
                                60, UnityEngine.Color.cyan, info.PointStart, info.PointEnd, 0.1
                            });

                            ConsoleNetwork.BroadcastToAllClients("ddraw.sphere", new object[] {
                                60, UnityEngine.Color.cyan, info.HitPositionWorld, 0.05
                            });
                        }

                        string text = String.Empty;

                        for (int i = 0; i < info.damageTypes.types.Length; i++) {
                            float num = info.damageTypes.types[i];

                            if (num != 0) {
                                string text2 = text;
                                text = String.Concat(new string[] {
                                    text2, " ", ((global::Rust.DamageType)i).ToString().PadRight(10), num.ToString("0.00"), "\r\n"
                                });
                            }
                        }

                        string text3 = String.Concat(new object[] {
                            "<color=lightblue>Damage:</color>".PadRight(10),
                            info.damageTypes.Total().ToString("0.00"),
                            "\r\n<color=lightblue>Health:</color>".PadRight(10),
                            combatEntity.health.ToString("0.00"), " / ",
                            (combatEntity.health - info.damageTypes.Total() > 0) ? "<color=green>" : "<color=red>",
                            (combatEntity.health - info.damageTypes.Total()).ToString("0.00"), "</color>",
                            "\r\n<color=lightblue>Hit Ent:</color>".PadRight(10), combatEntity,
                            "\r\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator,
                            "\r\n<color=lightblue>Weapon:</color>".PadRight(10), info.Weapon,
                            "\r\n<color=lightblue>Damages:</color>\r\n", text
                        });

                        ConsoleNetwork.BroadcastToAllClients("ddraw.text", new object[] {
                            60, UnityEngine.Color.white, info.HitPositionWorld, text3
                        });
                    }

                    combatEntity.health -= info.damageTypes.Total();
                    combatEntity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);

                    if (ConVar.Global.developer > 1) {
                        Debug.Log(string.Concat(new object[] {
                            "[Combat]".PadRight(10),
                            combatEntity.gameObject.name,
                            " hurt ",
                            info.damageTypes.GetMajorityDamageType(),
                            "/",
                            info.damageTypes.Total(),
                            " - ",
                            combatEntity.health.ToString("0"),
                            " health left"
                        }));
                    }

                    combatEntity.lastDamage = info.damageTypes.GetMajorityDamageType();
                    combatEntity.lastAttacker = info.Initiator;

                    BaseCombatEntity baseCombatEntity = combatEntity.lastAttacker as BaseCombatEntity;

                    if (baseCombatEntity != null)
                        baseCombatEntity.MarkHostileTime();

                    combatEntity.SetFieldValue("_lastAttackedTime", Time.time);

                    if (combatEntity.health <= 0f) {
                        combatEntity.Die(info);

                        BuildingBlock bb = combatEntity.GetComponent<BuildingBlock>();

                        if (bb != null) {
                            OnNext("On_BuildingPartDestroyed", new BuildingPartDestroyedEvent(bb, info));
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.LogError("[Hooks] Error in CombatEntityHurt hook.");
                Logger.LogException(ex);
            }
        }
Esempio n. 10
0
        private void DoRepair(BasePlayer player, BaseCombatEntity entity, PlayerRepairStats stats, bool noCost)
        {
            if (!entity.repair.enabled || entity.health == entity.MaxHealth())
            {
                return;
            }

            if (Interface.CallHook("OnStructureRepair", this, player) != null)
            {
                return;
            }

            if (entity.SecondsSinceAttacked <= 30f)
            {
                entity.OnRepairFailed(null, string.Empty);
                stats.RecentlyDamaged++;
                return;
            }

            float missingHealth    = entity.MaxHealth() - entity.health;
            float healthPercentage = missingHealth / entity.MaxHealth();

            if (missingHealth <= 0f || healthPercentage <= 0f)
            {
                entity.OnRepairFailed(null, string.Empty);
                return;
            }

            if (!noCost)
            {
                List <ItemAmount> itemAmounts = entity.RepairCost(healthPercentage);
                if (itemAmounts.Sum(x => x.amount) <= 0f)
                {
                    entity.health += missingHealth;
                    entity.SendNetworkUpdate();
                    entity.OnRepairFinished();
                    return;
                }

                if (_pluginConfig.RepairCostMultiplier != 1f)
                {
                    foreach (ItemAmount amount in itemAmounts)
                    {
                        amount.amount *= _pluginConfig.RepairCostMultiplier;
                    }
                }

                if (itemAmounts.Any(ia => player.inventory.GetAmount(ia.itemid) < (int)ia.amount))
                {
                    entity.OnRepairFailed(null, string.Empty);

                    foreach (ItemAmount amount in itemAmounts)
                    {
                        stats.MissingAmounts[amount.itemid] += (int)amount.amount;
                    }

                    stats.TotalCantAfford++;
                    return;
                }

                foreach (ItemAmount amount in itemAmounts)
                {
                    player.inventory.Take(null, amount.itemid, (int)amount.amount);
                    stats.AmountTaken[amount.itemid] += (int)amount.amount;
                }
            }

            entity.health += missingHealth;
            entity.SendNetworkUpdate();

            if (entity.health < entity.MaxHealth())
            {
                entity.OnRepair();
            }
            else
            {
                entity.OnRepairFinished();
            }

            stats.TotalSuccess++;
        }
Esempio n. 11
0
        // BaseCombatEntity
        public bool DoRepair(BaseCombatEntity entity, BasePlayer player)
        {
            if (!entity.repair.enabled)
            {
                return(false);
            }
            if (Interface.CallHook("OnStructureRepair", new object[]
            {
                entity,
                player
            }) != null)
            {
                return(false);
            }
            if (entity.SecondsSinceAttacked <= lastAttackLimit)
            {
                entity.OnRepairFailed();
                return(false);
            }
            float num  = entity.MaxHealth() - entity.Health();
            float num2 = num / entity.MaxHealth();

            if (num <= 0f || num2 <= 0f)
            {
                entity.OnRepairFailed();
                return(false);
            }
            var list = entity.RepairCost(num2);

            if (list == null || list.Count == 0)
            {
                return(false);
            }
            foreach (var ia in list)
            {
                ia.amount *= repairMulti;
            }
            float num3 = list.Sum(x => x.amount);

            if (num3 > 0f)
            {
                float num4 = list.Min(x => Mathf.Clamp01((float)player.inventory.GetAmount(x.itemid) / x.amount));
                num4 = Mathf.Min(num4, 50f / num);
                if (num4 <= 0f)
                {
                    entity.OnRepairFailed();
                    return(false);
                }
                int num5 = 0;
                foreach (var current in list)
                {
                    int amount = Mathf.CeilToInt(num4 * current.amount);
                    num5 += player.inventory.Take(null, current.itemid, amount);
                }

                float num7 = (float)num5 / num3;
                entity.health += num * num7;
                entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            }
            else
            {
                entity.health += num;
                entity.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
            }
            if (entity.health >= entity.MaxHealth())
            {
                entity.OnRepairFinished();
            }
            else
            {
                entity.OnRepair();
            }

            return(true);
        }
Esempio n. 12
0
        public static void CombatEntityHurt(BaseCombatEntity combatEnt, HitInfo info)
        {
            try {
                Assert.Test(combatEnt.isServer, "This should be called serverside only");
                if (combatEnt.IsDead()) {
                    return;
                }

                BaseNPC npc = combatEnt.GetComponent<BaseNPC>();
                BaseCorpse corpse = combatEnt.GetComponent<BaseCorpse>();
                BasePlayer player = combatEnt.GetComponent<BasePlayer>();

                if (!SkinnedMeshCollider.ScaleDamage(info)) {
                    if (combatEnt.baseProtection != null) {
                        combatEnt.baseProtection.Scale(info.damageTypes);
                        if (ConVar.Global.developer > 1) {
                            Debug.Log("BaseProtection Scaling for entity :" + combatEnt.name);
                        }
                    }
                }
                else if (ConVar.Global.developer > 1) {
                    Debug.Log("SMC scaling damage for entity :" + combatEnt.name);
                }
                HurtEvent he;
                if (player != null) {
                    Player p = Server.GetPlayer(player);
                    if (p.Teleporting) {
                        for (int i = 0; i < info.damageTypes.types.Length; i++) {
                            info.damageTypes.types[i] = 0f;
                        }
                    }

                    he = new PlayerHurtEvent(p, info);
                    OnPlayerHurt.OnNext(he as PlayerHurtEvent);
                } else if (npc != null) {
                    he = new NPCHurtEvent(new NPC(npc), info);
                    OnNPCHurt.OnNext(he as NPCHurtEvent);
                } else if (corpse != null) {
                    he = new CorpseHurtEvent(corpse, info);
                    OnCorpseHurt.OnNext(he as CorpseHurtEvent);
                } else {
                    he = new CombatEntityHurtEvent(combatEnt, info);
                    OnCombatEntityHurt.OnNext(he as CombatEntityHurtEvent);
                }

                // the DebugHurt() method
                if (ConVar.Vis.attack) {
                    if (info.PointStart != info.PointEnd) {
                        ConsoleSystem.Broadcast("ddraw.arrow", new object[] {
                            60, Color.cyan, info.PointStart, info.PointEnd, 0.1
                        });
                        ConsoleSystem.Broadcast("ddraw.sphere", new object[] {
                            60, Color.cyan, info.HitPositionWorld, 0.05
                        });
                    }
                    string text = String.Empty;
                    for (int i = 0; i < info.damageTypes.types.Length; i++) {
                        float num = info.damageTypes.types[i];
                        if (num != 0) {
                            string text2 = text;
                            text = String.Concat(new string[] {
                                text2, " ", ((Rust.DamageType)i).ToString().PadRight(10), num.ToString("0.00"), "\r\n"
                            });
                        }
                    }
                    string text3 = String.Concat(new object[] {
                        "<color=lightblue>Damage:</color>".PadRight(10),
                        info.damageTypes.Total().ToString("0.00"),
                        "\r\n<color=lightblue>Health:</color>".PadRight(10),
                        combatEnt.health.ToString("0.00"), " / ",
                        (combatEnt.health - info.damageTypes.Total() > 0) ? "<color=green>" : "<color=red>",
                        (combatEnt.health - info.damageTypes.Total()).ToString("0.00"), "</color>",
                        "\r\n<color=lightblue>Hit Ent:</color>".PadRight(10), combatEnt,
                        "\r\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator,
                        "\r\n<color=lightblue>Weapon:</color>".PadRight(10), info.Weapon,
                        "\r\n<color=lightblue>Damages:</color>\r\n", text
                    });
                    ConsoleSystem.Broadcast("ddraw.text", new object[] {
                        60, Color.white, info.HitPositionWorld, text3
                    });
                }
                if (combatEnt.skeletonProperties) {
                    combatEnt.skeletonProperties.ScaleDamage(info);
                }
                if (info.PointStart != Vector3.zero) {
                    DirectionProperties[] directionProperties = (DirectionProperties[])combatEnt.GetFieldValue("propDirection");
                    for (int i = 0; i < directionProperties.Length; i++) {
                        if (!(directionProperties[i].extraProtection == null)) {
                            if (directionProperties[i].IsPointWithinRadius(combatEnt.transform, info.PointStart)) {
                                directionProperties[i].extraProtection.Scale(info.damageTypes);
                            }
                        }
                    }
                }
                combatEnt.health -= info.damageTypes.Total();
                combatEnt.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
                if (ConVar.Global.developer > 1) {
                    Debug.Log(string.Concat(new object[]
                    {
                        "[Combat]".PadRight(10),
                        combatEnt.gameObject.name,
                        " hurt ",
                        info.damageTypes.GetMajorityDamageType(),
                        "/",
                        info.damageTypes.Total(),
                        " - ",
                        combatEnt.health.ToString("0"),
                        " health left"
                    }));
                }
                combatEnt.lastDamage = info.damageTypes.GetMajorityDamageType();
                combatEnt.lastAttacker = info.Initiator;
                if (combatEnt.health <= 0f) {
                    combatEnt.Die(info);
                    BuildingBlock bb = combatEnt.GetComponent<BuildingBlock>();
                    if (bb != null)
                    {
                        OnBuildingPartDestroyed.OnNext(new BuildingPartDestroyedEvent(bb, info));
                    }
                }
            } catch (Exception ex) {
                Logger.LogError("[Hooks] Error in CombatEntityHurt hook.");
                Logger.LogException(ex);
            }
        }
Esempio n. 13
0
        public static void On_CombatEntityHurt(BaseCombatEntity combatEnt, HitInfo info, bool useProtection = true)
        {
            try {
                Assert.Test(combatEnt.isServer, "This should be called serverside only");
                if (combatEnt.IsDead())
                {
                    return;
                }
                using (TimeWarning.New("Hurt", 50)) {
                    BaseNPC    npc    = combatEnt.GetComponent <BaseNPC>();
                    BaseCorpse corpse = combatEnt.GetComponent <BaseCorpse>();
                    BasePlayer player = combatEnt.GetComponent <BasePlayer>();

                    combatEnt.ScaleDamage(info, useProtection);

                    HurtEvent he;
                    if (player != null)
                    {
                        Player p = Server.GetPlayer(player);
                        if (p.Teleporting)
                        {
                            for (int i = 0; i < info.damageTypes.types.Length; i++)
                            {
                                info.damageTypes.types[i] = 0f;
                            }
                        }

                        he = new PlayerHurtEvent(p, info);
                        OnNext("On_PlayerHurt", he);
                    }
                    else if (npc != null)
                    {
                        he = new NPCHurtEvent(new NPC(npc), info);
                        OnNext("On_NPCHurt", he);
                    }
                    else if (corpse != null)
                    {
                        he = new CorpseHurtEvent(corpse, info);
                        OnNext("On_CorpseHurt", he);
                    }
                    else
                    {
                        he = new CombatEntityHurtEvent(combatEnt, info);
                        OnNext("On_CombatEntityHurt", he);
                    }

                    if (info.PointStart != Vector3.zero)
                    {
                        DirectionProperties[] directionProperties = (DirectionProperties[])combatEnt.GetFieldValue("propDirection");
                        for (int i = 0; i < directionProperties.Length; i++)
                        {
                            if (!(directionProperties[i].extraProtection == null))
                            {
                                if (directionProperties[i].IsPointWithinRadius(combatEnt.transform, info.PointStart))
                                {
                                    directionProperties[i].extraProtection.Scale(info.damageTypes);
                                }
                            }
                        }
                    }

                    // the DebugHurt() method
                    if (ConVar.Vis.attack)
                    {
                        if (info.PointStart != info.PointEnd)
                        {
                            ConsoleSystem.Broadcast("ddraw.arrow", new object[] {
                                60, Color.cyan, info.PointStart, info.PointEnd, 0.1
                            });
                            ConsoleSystem.Broadcast("ddraw.sphere", new object[] {
                                60, Color.cyan, info.HitPositionWorld, 0.05
                            });
                        }
                        string text = String.Empty;
                        for (int i = 0; i < info.damageTypes.types.Length; i++)
                        {
                            float num = info.damageTypes.types[i];
                            if (num != 0)
                            {
                                string text2 = text;
                                text = String.Concat(new string[] {
                                    text2, " ", ((Rust.DamageType)i).ToString().PadRight(10), num.ToString("0.00"), "\r\n"
                                });
                            }
                        }
                        string text3 = String.Concat(new object[] {
                            "<color=lightblue>Damage:</color>".PadRight(10),
                            info.damageTypes.Total().ToString("0.00"),
                            "\r\n<color=lightblue>Health:</color>".PadRight(10),
                            combatEnt.health.ToString("0.00"), " / ",
                            (combatEnt.health - info.damageTypes.Total() > 0) ? "<color=green>" : "<color=red>",
                            (combatEnt.health - info.damageTypes.Total()).ToString("0.00"), "</color>",
                            "\r\n<color=lightblue>Hit Ent:</color>".PadRight(10), combatEnt,
                            "\r\n<color=lightblue>Attacker:</color>".PadRight(10), info.Initiator,
                            "\r\n<color=lightblue>Weapon:</color>".PadRight(10), info.Weapon,
                            "\r\n<color=lightblue>Damages:</color>\r\n", text
                        });
                        ConsoleSystem.Broadcast("ddraw.text", new object[] {
                            60, Color.white, info.HitPositionWorld, text3
                        });
                    }

                    combatEnt.health -= info.damageTypes.Total();
                    combatEnt.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
                    if (ConVar.Global.developer > 1)
                    {
                        Debug.Log(string.Concat(new object[]
                        {
                            "[Combat]".PadRight(10),
                            combatEnt.gameObject.name,
                            " hurt ",
                            info.damageTypes.GetMajorityDamageType(),
                            "/",
                            info.damageTypes.Total(),
                            " - ",
                            combatEnt.health.ToString("0"),
                            " health left"
                        }));
                    }
                    combatEnt.lastDamage   = info.damageTypes.GetMajorityDamageType();
                    combatEnt.lastAttacker = info.Initiator;
                    combatEnt.SetFieldValue("_lastAttackedTime", Time.time);
                    if (combatEnt.health <= 0f)
                    {
                        combatEnt.Die(info);
                        BuildingBlock bb = combatEnt.GetComponent <BuildingBlock>();
                        if (bb != null)
                        {
                            OnNext("On_BuildingPartDestroyed", new BuildingPartDestroyedEvent(bb, info));
                        }
                    }
                }
            } catch (Exception ex) {
                Logger.LogError("[Hooks] Error in CombatEntityHurt hook.");
                Logger.LogException(ex);
            }
        }