Beispiel #1
0
    public override void Execute(List <string> _params, global::CommandSenderInfo _senderInfo)
    {
        int id;

        if (int.TryParse(_params[0], out id))
        {
            global::Entity entity = null;
            for (int i = global::GameManager.Instance.World.Entities.list.Count - 1; i >= 0; i--)
            {
                global::Entity curEntity = global::GameManager.Instance.World.Entities.list[i];
                if (curEntity.entityId == id)
                {
                    entity = curEntity;
                    break;
                }
            }
            if (entity == null)
            {
                global::SingletonMonoBehaviour <global::SdtdConsole> .Instance.Output("Not a valid entity");

                return;
            }
            global::EntityAlive entityAlive = null;
            if (entity is global::EntityAlive)
            {
                entityAlive = (global::EntityAlive)entity;
            }

            string output = "Entity infos:\n";
            output += (entity.ToString() + "\n");
            output += ("pos = " + entity.GetPosition().ToString() + "\n");
            output += ("rot = " + entity.rotation.ToString() + "\n");
            output += ("lifetime = " + ((entity.lifetime != float.MaxValue) ? entity.lifetime.ToCultureInvariantString("0.0").ToString() : "float.Max".ToString()));
            output += ("remote = " + entity.isEntityRemote.ToString() + "\n");
            output += ("dead = " + entity.IsDead().ToString() + "\n");

            if (entityAlive != null)
            {
                output += ("health = " + entityAlive.Health.ToString() + " / " + entityAlive.classMaxHealth.ToString() + "\n");
                output += ("stamina = " + entityAlive.Stamina.ToString() + " / " + entityAlive.classMaxStamina.ToString() + "\n");
                output += ("food = " + entityAlive.Stats.Food.ToString() + " / " + entityAlive.classMaxFood.ToString() + "\n");
                output += ("water = " + entityAlive.Stats.Water.ToString() + " / " + entityAlive.classMaxWater.ToString() + "\n");
                output += ("sickness = " + entityAlive.Stats.Sickness.ToString() + " / " + entityAlive.classMaxSickness.ToString() + "\n");

                Animation[] animation = entityAlive.gameObject.GetComponentsInChildren <Animation>();
                if (animation != null && animation.Length > 0)
                {
                    output += ("Animations:\n");
                    foreach (AnimationState state in animation[0])
                    {
                        output += ("state: " + state.name + " / clip: " + state.clip.name + " / enabled = " + state.enabled.ToString() + " / length: " + state.clip.length.ToString() + "\n");
                    }
                }

                Animator[] animator = entityAlive.gameObject.GetComponentsInChildren <Animator>();
                if (animator != null && animator.Length > 0)
                {
                    AnimatorClipInfo[] animatorClipInfo = animator[0].GetCurrentAnimatorClipInfo(0);
                    if (animatorClipInfo != null && animatorClipInfo.Length > 0)
                    {
                        output += ("AnimatorClipInfo: " + animatorClipInfo[0].clip.name + " / length = " + animatorClipInfo[0].clip.length.ToString() + "\n");
                    }

                    AnimatorStateInfo animatorStateInfo = animator[0].GetCurrentAnimatorStateInfo(0);
                    output += ("AnimatorStateInfo: length = " + animatorStateInfo.length.ToString() + " / speed = " + animatorStateInfo.speed.ToString() + "\n");
                }

                Renderer[] renderers = entityAlive.GetComponentsInChildren <Renderer>();
                output += "Renderers:\n";
                foreach (Renderer rend in renderers)
                {
                    output += ("object " + rend.gameObject.name + " material = " + rend.material.shader.name + "\n");
                }
            }

            global::SingletonMonoBehaviour <global::SdtdConsole> .Instance.Output(output);
        }
        else
        {
            global::SingletonMonoBehaviour <global::SdtdConsole> .Instance.Output("Entity '" + _params[0] + "' not found");
        }
    }
Beispiel #2
0
    public override void Execute(List <string> _params, global::CommandSenderInfo _senderInfo)
    {
        int id;

        if (int.TryParse(_params[0], out id))
        {
            global::Entity entity = null;
            for (int i = global::GameManager.Instance.World.Entities.list.Count - 1; i >= 0; i--)
            {
                global::Entity curEntity = global::GameManager.Instance.World.Entities.list[i];
                if (curEntity.entityId == id)
                {
                    entity = curEntity;
                    break;
                }
            }
            if (entity == null)
            {
                global::SingletonMonoBehaviour <global::SdtdConsole> .Instance.Output("Not a valid entity");

                return;
            }

            string output = "------------------------------------------------------------\n";
            output += ("------------------------------------------------------------\n");
            output += "ENTITY PREFAB INFOS:\n";
            output += (entity.ToString() + "\n");
            output += ("------------------------------------------------------------\n");
            output += ("------------------------------------------------------------\n");
            Transform        root                = GetRootTransform(entity.transform, entity.name.ToLower());
            List <Transform> childrenList        = new List <Transform>();
            List <int>       childrenInstanceIds = new List <int>();
            if (root != null && root.gameObject != null)
            {
                output += ("Root = " + root.gameObject.name + " | " + root.gameObject.GetInstanceID().ToString());
            }
            else
            {
                root = entity.transform;
            }
            childrenList.Add(root);
            childrenInstanceIds.Add(root.GetInstanceID());
            GetAllChildTransforms(root, ref childrenList, ref childrenInstanceIds);

            output += ("CHILDREN:\n");
            output += ("------------------------------------------------------------\n");
            output += ("------------------------------------------------------------\n");
            foreach (Transform child in childrenList)
            {
                output += (child.name + " | parent: " + child.parent.name + ":\n");
            }
            output += ("------------------------------------------------------------\n");
            output += ("------------------------------------------------------------\n");
            output += ("DETAILED INFOS:\n");
            output += ("------------------------------------------------------------\n");
            foreach (Transform child in childrenList)
            {
                output += ("------------------------------------------------------------\n");
                output += ("name: " + child.name + "\n");
                output += ("\tparent: " + child.parent.name + "\n");
                output += ("\ttag: " + child.tag.ToString() + "\n");
                output += ("\tinstance id: " + child.GetInstanceID().ToString() + "\n");
                output += ("components:\n");
                Component[] components = child.GetComponents <Component>();
                foreach (Component comp in components)
                {
                    output += ("\t" + comp.ToString() + "\n");
                }
            }
            output += ("------------------------------------------------------------\n");

            global::SingletonMonoBehaviour <global::SdtdConsole> .Instance.Output(output);

            string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "7D2D");
            Directory.CreateDirectory(dir);
            string path = Path.Combine(dir, "GetEntityPrefabInfos.txt");
            if (!File.Exists(path))
            {
                File.Create(path).Dispose();
            }
            File.WriteAllText(path, output);
        }
        else
        {
            global::SingletonMonoBehaviour <global::SdtdConsole> .Instance.Output("Entity '" + _params[0] + "' not found");
        }
    }