summaryrefslogtreecommitdiff
path: root/_Debug/REPL.cs
blob: 29209efa8e651eeeb30e860f5b13d3327e34f9ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
using System.Collections.Generic;
using System.Drawing;
using UnityEngine;

class REPL
{
    public static void StartREPL()
    {
        AddCamera();
        AddRigidbodyDebug();
        AddCubes();
    }

    public static void AddCamera()
	{
        GameObject camera = GameObject.Find("WanderCamera");
        if (camera != null)
        {
            GameObject.DestroyImmediate(camera);
        }

        camera = new GameObject();
        camera.name = "WanderCamera";
        camera.AddComponent<Camera>();
        camera.AddComponent<SimpleMoveCamera>();

        GameObject wanderCam = GameObject.Find("WanderCamera");

        GameObject player = GameObject.Find("Player");
        if (player != null)
        {
            wanderCam.transform.position = player.transform.position;
        }

        wanderCam.transform.position = new Vector3(1.21f, 33.92f, -10.4f);
        wanderCam.transform.rotation = Quaternion.Euler(25.95f, 75, 0);
    }

    public static void AddRigidbodyDebug()
    {
        string[] targets = { 
            "Head",
            "Neck",
            "Torso",
            "Arm_Right",
            "Arm_Left",
            "Hand_Right",
            "Hand_Left",
            "Hip",
            "Leg_Left",
            "Leg_Right",
            "Foot_Left",
            "Foot_Right",
            "Knee_Left",
            "Knee_Right",
        };

        for(int i = 0; i < targets.Length; ++i)
        {
            string target = targets[i];
            GameObject go = GameObject.Find(target);
            if(go != null)
            {
                var comps = go.gameObject.GetComponents<MonoBehaviour>();
                if (comps != null)
                {
                    for (int j = 0; j < comps.Length; j++)
                    {
                        if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2")
                        {
                            UnityEngine.Object.DestroyImmediate(comps[j]);
                        }
                    }
                }
                Debug.Log(go.name);
                var drb = go.AddComponent<DebugRigidBody>();
                //drb.mode = DebugRigidBody.EMode.Cube;
                //drb.color = Color.green;
            }
        }
    }

    public struct CubeParams
    {
        public UnityEngine.Color color;
        public float size;
        public DebugRigidBody.EMode mode;
    }

    public static void AddCubes()
    {
        Dictionary<string, CubeParams> targets = new Dictionary<string, CubeParams>{
            {"CameraPos",  new CubeParams(){ color = UnityEngine.Color.red, size = 0.2f, mode = DebugRigidBody.EMode.Cube } },
            {"Main Camera",  new CubeParams(){ color = UnityEngine.Color.white, size = 0.05f, mode = DebugRigidBody.EMode.Axis_Cube } },
            {"RotationTarget",  new CubeParams(){ color = UnityEngine.Color.green, size = 0.05f, mode = DebugRigidBody.EMode.Axis_Cube } },
            //{"AvaragePosition",  new CubeParams(){ color = UnityEngine.Color.blue, size = 0.2f, mode = DebugRigidBody.EMode.Axis_Cube } },
        };

        foreach(var target in targets)
        {
            string name = target.Key;
            GameObject go = GameObject.Find(name);
            if (go != null)
            {
                var comps = go.gameObject.GetComponents<MonoBehaviour>();
                if (comps != null)
                {
                    for (int j = 0; j < comps.Length; j++)
                    {
                        if (comps[j].GetType().Name == "DebugRigidBody" || comps[j].GetType().Name == "DebugRigidBody2")
                        {
                            UnityEngine.Object.DestroyImmediate(comps[j]);
                        }
                    }
                }
                Debug.Log(go.name);
                var drb = go.AddComponent<DebugRigidBody>();
                drb.mode = target.Value.mode;
                drb.color = target.Value.color;
                drb.cubeLen = target.Value.size;
            }
        }
    }
}