Exemplo n.º 1
0
        public static void TestSerializeComponent(int id, string typeName)
        {
            var dict = EntityController.GetEntityComponentDict(id);

            if (dict == null)
            {
                Debug.LogFormat("{0} has no components", id);
                return;
            }
            System.Type type     = null;
            IComponent  instance = null;

            foreach (var cRef in dict)
            {
                if (cRef.Key.Name == typeName)
                {
                    type     = cRef.Key;
                    instance = cRef.Value.Get() as IComponent;
                }
            }
            if (type == null || instance == null)
            {
                Debug.LogFormat("{0} doesn't have component {1}", id, typeName);
                return;
            }
            TestSerializeComponent(instance);
        }
Exemplo n.º 2
0
        public static void ListEntityContainer(int id, string typeName)
        {
            var dict = EntityController.GetEntityComponentDict(id);

            if (dict == null)
            {
                Debug.LogFormat("{0} has no components", id);
                return;
            }
            System.Type     type     = null;
            EntityContainer instance = null;

            foreach (var cRef in dict)
            {
                if (cRef.Key.Name == typeName)
                {
                    type     = cRef.Key;
                    instance = cRef.Value.Get() as EntityContainer;
                }
            }
            if (type == null || instance == null)
            {
                Debug.LogFormat("{0} doesn't have component {1}", id, typeName);
                return;
            }
            Debug.LogFormat("Container has {0}", instance.Count);
            for (int i = 0; i < instance.Count; i++)
            {
                Debug.LogFormat("{0}: {1}", i, instance[i].Get <LabelComponent>()?.Text ?? instance[i].Id.ToString());
            }
        }
Exemplo n.º 3
0
        public static void DebugComponent(int id, string typeName)
        {
            var dict = EntityController.GetEntityComponentDict(id);

            if (dict == null)
            {
                Debug.LogFormat("{0} has no components", id);
                return;
            }
            System.Type   type     = null;
            System.Object instance = null;
            foreach (var cRef in dict)
            {
                if (cRef.Key.Name == typeName)
                {
                    type     = cRef.Key;
                    instance = cRef.Value.Get();
                }
            }
            if (type == null)
            {
                Debug.LogFormat("{0} doesn't have component {1}", id, typeName);
                return;
            }
            var           bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
            var           fieldValues  = type.GetFields(bindingFlags).Select(field => field.GetValue(instance)).ToList();
            StringBuilder sb           = new StringBuilder();

            for (int i = 0; i < fieldValues.Count; i++)
            {
                sb.AppendNewLine(fieldValues[i].ToString());
            }
            Debug.LogFormat("{0} {1}: {2}", id, typeName, sb.ToString());
        }
Exemplo n.º 4
0
        public static void ListComponents(int id)
        {
            var dict = EntityController.GetEntityComponentDict(id);

            if (dict == null)
            {
                Debug.LogFormat("{0} has no components", id);
                return;
            }
            StringBuilder sb = new StringBuilder();

            sb.Append(EntityController.GetEntity(id).Name);
            sb.AppendNewLine(" Components");
            foreach (var cRef in dict)
            {
                sb.AppendNewLine(string.Format("Type {0} Index {1}", cRef.Key, cRef.Value.Index));
            }

            Debug.Log(sb.ToString());
        }