Exemplo n.º 1
0
        public static string GetStackTraceRaw(StackTrace stack, int skipCount = 0)
        {
            MBStringBuilder mbStringBuilder = new MBStringBuilder();

            mbStringBuilder.Initialize(callerMemberName: nameof(GetStackTraceRaw));
            for (int index = 0; index < stack.FrameCount; ++index)
            {
                if (index >= skipCount)
                {
                    string str = "unknown_module.dll";
                    try
                    {
                        StackFrame frame  = stack.GetFrame(index);
                        MethodBase method = frame.GetMethod();
                        str = method.Module.Assembly.Location;
                        int ilOffset      = frame.GetILOffset();
                        int metadataToken = method.MetadataToken;
                        mbStringBuilder.AppendLine <string>(str + "@" + (object)metadataToken + "@" + (object)ilOffset);
                    }
                    catch
                    {
                        mbStringBuilder.AppendLine <string>(str + "@-1@-1");
                    }
                }
            }
            return(mbStringBuilder.ToStringAndRelease());
        }
        public static void PrintDebugLogForInfo(
            Agent attackerAgent,
            Agent victimAgent,
            DamageTypes damageType,
            int speedBonus,
            int armorAmount,
            int inflictedDamage,
            int absorbedByArmor,
            sbyte collisionBone,
            float lostHpPercentage)
        {
            TextObject     message  = TextObject.Empty;
            CombatLogColor logColor = CombatLogColor.White;
            bool           isMine   = attackerAgent.IsMine;
            int            num      = victimAgent.IsMine ? 1 : 0;

            GameTexts.SetVariable("AMOUNT", inflictedDamage);
            GameTexts.SetVariable("DAMAGE_TYPE", damageType.ToString().ToLower());
            GameTexts.SetVariable("LOST_HP_PERCENTAGE", lostHpPercentage);
            if (num != 0)
            {
                GameTexts.SetVariable("ATTACKER_NAME", attackerAgent.Name);
                message  = GameTexts.FindText("combat_log_player_attacked");
                logColor = CombatLogColor.Red;
            }
            else if (isMine)
            {
                GameTexts.SetVariable("VICTIM_NAME", victimAgent.Name);
                message  = GameTexts.FindText("combat_log_player_attacker");
                logColor = CombatLogColor.Green;
            }
            CombatLogManager.Print(message, logColor);
            MBStringBuilder mbStringBuilder = new MBStringBuilder();

            mbStringBuilder.Initialize(callerMemberName: nameof(PrintDebugLogForInfo));
            if (armorAmount > 0)
            {
                GameTexts.SetVariable("ABSORBED_AMOUNT", absorbedByArmor);
                GameTexts.SetVariable("ARMOR_AMOUNT", armorAmount);
                mbStringBuilder.AppendLine <string>(GameTexts.FindText("combat_log_damage_absorbed").ToString());
            }
            if (victimAgent.IsHuman)
            {
                Agent.AgentBoneMapArray boneMappingArray = victimAgent.BoneMappingArray;
                for (int index = 0; index < boneMappingArray.Length; ++index)
                {
                    HumanBone i = (HumanBone)index;
                    if ((int)collisionBone == (int)boneMappingArray[i])
                    {
                        GameTexts.SetVariable("BONE", i.ToString());
                        mbStringBuilder.AppendLine <string>(GameTexts.FindText("combat_log_hit_bone").ToString());
                        break;
                    }
                }
            }
            if (speedBonus != 0)
            {
                GameTexts.SetVariable("SPEED_BONUS", speedBonus);
                mbStringBuilder.AppendLine <string>(GameTexts.FindText("combat_log_speed_bonus").ToString());
            }
            CombatLogManager.Print(new TextObject(mbStringBuilder.ToStringAndRelease()));
        }