Exemplo n.º 1
0
        private void GlobalEventManager_OnPlayerCharacterDeath(On.RoR2.GlobalEventManager.orig_OnPlayerCharacterDeath orig, GlobalEventManager self, DamageReport damageReport, NetworkUser netUser)
        {
            orig(self, damageReport, netUser);
            if (!netUser)
            {
                return;
            }

            var    attackerBody = damageReport.attackerBody;
            var    damageTaken  = damageReport.damageInfo.damage;
            var    healthLeft   = damageReport.combinedHealthBeforeDamage;
            bool   wasCrit      = damageReport.damageInfo.crit;
            var    dotType      = damageReport.dotType;
            bool   wasDot       = dotType != DotIndex.None;
            string prefixStr    = string.Empty;

            if (wasCrit || wasDot)
            {
                prefixStr = "<style=cDeath>";
                if (wasCrit)
                {
                    Color  critColor = DamageColor.FindColor(DamageColorIndex.WeakPoint);
                    string critStr   = Util.GenerateColoredString("Crit ", critColor);
                    prefixStr += critStr;
                }
                if (wasDot)
                {
                    string dotStr = DotIndexToString(dotType);
                    if (!string.IsNullOrWhiteSpace(dotStr))
                    {
                        Color dotColor = DamageColor.FindColor(damageReport.damageInfo.damageColorIndex);
                        dotStr     = Util.GenerateColoredString($"{dotStr} ", dotColor);
                        prefixStr += dotStr;
                    }
                }
                prefixStr += "from </style>";
            }

            string text = $"<style=cDeath>Killed by: <style=cIsDamage>{prefixStr}{(attackerBody ? attackerBody.GetDisplayName() : "Unknown causes")}</style> <style=cIsUtility>({damageTaken:F2} damage dealt to '{netUser.userName}' with {healthLeft:F2} health left)</style></style>";

            Chat.SendBroadcastChat(new Chat.SimpleChatMessage {
                baseToken = text
            });
        }
Exemplo n.º 2
0
 public static string GetDamageColorCode(DamageColorIndex damageColorIndex)
 {
     return("#" + ColorUtility.ToHtmlStringRGB(DamageColor.FindColor(damageColorIndex)));
 }