using Oxide.Core.Libraries.Covalence; using System; using System.Collections.Generic; using System.Linq; using System.Text; using UnityEngine; namespace Oxide.Plugins { [Info("Debug Info", "Billy Joe", "1.0.1")] [Description("A plugin that gives debug information for developers.")] public class DebugInfo : CovalencePlugin { private void GetInfo(BasePlayer player, BaseEntity ent) { player.ConsoleMessage("--------------------| Object Info |--------------------"); GetObjectInfo(player, ent); GetComponents(player, ent); } private void GetObjectInfo(BasePlayer player, BaseEntity ent) { var message = $" >> Prefab Shortname: {ent.ShortPrefabName}\n" + $" >> Prefab Location: {ent.name}\n" + $" >> Prefab ID: {ent.prefabID}\n" + $"\n >> Position:\n" + $" X: {ent.transform.position.x}\n" + $" Y: {ent.transform.position.y}\n" + $" Z: {ent.transform.position.z}\n" + $" Local: {ent.transform.localPosition}\n" + $" Normalized: {ent.transform.position.normalized}\n" + $" Magnitude: {ent.transform.position.magnitude}\n" + $"\n >> Rotation: \n" + $" X: {ent.transform.rotation.x}\n" + $" Y: {ent.transform.rotation.y}\n" + $" Z: {ent.transform.rotation.z}\n" + $" Local: {ent.transform.localRotation}\n" + $" Euler: {ent.transform.rotation.eulerAngles}\n" + $"\n >> Bounds:\n" + $" Center: {ent.bounds.center}\n" + $" Extents: {ent.bounds.extents}\n" + $" Size: {ent.bounds.size}\n" + $"\n >> Network ID: {ent.net.ID}\n" + $" >> Layer: {LayerMask.LayerToName(ent.gameObject.layer)} ({ent.gameObject.layer})\n" + $" >> Distance: {player.Distance(ent)}\n" + $" >> Category: {ent.GetType()}\n" + $" >> Health: {Math.Round(ent.Health())}/{ent.MaxHealth()}\n" + $" >> Local Scale: {ent.transform.localScale}\n"; player.ConsoleMessage(message); } private string GetInherantance(Component comp) { List temp = new List(); StringBuilder sb = new StringBuilder(); sb.Append("("); for (var current = comp.GetType(); current != null; current = current.BaseType) { if (current.Name.Contains("Mono") || current.Name.Contains("Component")) break; temp.Add(current.Name); } foreach (var current in temp) { if (temp.LastOrDefault() == current) sb.Append(" " + current + " "); else sb.Append(" " + current + " -> "); } sb.Append(")"); temp.Clear(); return sb.ToString(); } private void GetComponents(BasePlayer player, BaseEntity ent) { player.ConsoleMessage("
"); player.ConsoleMessage("--------------------| Components |--------------------"); foreach (var comp in ent.GetComponents(typeof(Component))) { player.ConsoleMessage($" >> {comp.GetType().Name} -------- {GetInherantance(comp)}"); } } #region Commands [Command("getinfo")] void GetInfoCMD(IPlayer iPlayer, string command, string[] args) { BasePlayer player = iPlayer.Object as BasePlayer; if (player == null || !player.IsAdmin) return; RaycastHit hit; if (Physics.Raycast(player.eyes.HeadRay(), out hit, 10f)) { BaseEntity entity = hit.GetEntity(); if (entity == null) return; GetInfo(player, entity); } } #endregion } }