private static int GetComponentLines(MyComponentBase component, bool countAll = true)
 {
     int n = 1;
     if (component is IMyComponentAggregate)
     {
         int count = (component as IMyComponentAggregate).ChildList.Reader.Count;
         int i = 0;
         foreach (var childComponent in (component as IMyComponentAggregate).ChildList.Reader)
         {
             i++;
             if (i < count || countAll)
                 n += GetComponentLines(childComponent);
             else
                 n += 1;
         }
     }
     return n;
 }
Пример #2
0
 void Components_ComponentAdded(Type arg1, MyComponentBase arg2)
 {
     if (arg1 == typeof(MyGameLogicComponent))
         m_logic = arg2 as MyMeteorGameLogic;
 }
        private static void DebugDrawComponent(MyComponentBase component, Vector3D origin, Vector3D rightVector, Vector3D upVector, double lineSize, float textSize)
        {
            Vector3D offset = rightVector * 0.025f;
            Vector3D offsetOrigin = origin + offset * 3.5f;
            Vector3D textOrigin = origin + 2.0f * offset + rightVector * 0.015f;

            MyRenderProxy.DebugDrawLine3D(origin, origin + 2.0f * offset, Color.White, Color.White, false);
            MyRenderProxy.DebugDrawText3D(textOrigin, component.ToString(), Color.White, textSize, false, MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_CENTER);

            if (component is IMyComponentAggregate && (component as IMyComponentAggregate).ChildList.Reader.Count != 0)
            {
                int lines = GetComponentLines(component, false) - 1;
                MyRenderProxy.DebugDrawLine3D(offsetOrigin - 0.5f * lineSize * upVector, offsetOrigin - lines * lineSize * upVector, Color.White, Color.White, false);

                offsetOrigin -= 1 * lineSize * upVector;
                foreach (var childComponent in (component as IMyComponentAggregate).ChildList.Reader)
                {
                    int n = GetComponentLines(childComponent);
                    DebugDrawComponent(childComponent, offsetOrigin, rightVector, upVector, lineSize, textSize);
                    offsetOrigin -= n * lineSize * upVector;
                }
            }
        }