예제 #1
0
        static void GenerateVariableRelatedCode(StreamWriter writer, EditorComponent component)
        {
            int code_variable_count = 0;
            int attribute_count     = 0;

            for (int i = 0; i < component.m_variables.Count; ++i)
            {
                EditorVariable variable = component.m_variables[i];
                if (variable.m_code_name == null)
                {
                    continue;
                }
                if (variable.NeedDeclareVariable())
                {
                    ++code_variable_count;
                    writer.Write("\r\n        public const int ");
                    writer.Write(variable.m_code_name);
                    writer.Write(" = ");
                    writer.Write(((int)CRC.Calculate(variable.m_config_name)).ToString());
                    writer.Write(";");
                }
                if (variable.NeedCSAttribute())
                {
                    ++attribute_count;
                }
            }

            bool generate = code_variable_count > 0 || component.Need_InitializeVariable();

            if (m_logic == false && generate)
            {
                writer.Write("\r\n\r\n#if COMBAT_CLIENT");
            }

            if (code_variable_count > 0)
            {
                Generate_StaticConstructor(writer, component);
            }
            if (component.Need_InitializeVariable())
            {
                Generate_InitializeVariable(writer, component);
            }
            if (code_variable_count > 0 && component.Need_GetVariable())
            {
                Generate_GetVariable(writer, component);
            }
            if (code_variable_count > 0 && component.Need_SetVariable())
            {
                Generate_SetVariable(writer, component);
            }
            if (attribute_count > 0 && component.Need_CSharpAttribute())
            {
                Generate_CSharpAttribute(writer, component);
            }

            if (m_logic == false && generate)
            {
                writer.Write("\r\n#endif");
            }
        }
예제 #2
0
 static void Generate_StaticConstructor(StreamWriter writer, EditorComponent component)
 {
     writer.Write("\r\n\r\n        static ");
     writer.Write(component.m_name);
     writer.Write("()\r\n        {");
     for (int i = 0; i < component.m_variables.Count; ++i)
     {
         EditorVariable variable = component.m_variables[i];
         if (variable.m_code_name == null || !variable.NeedDeclareVariable())
         {
             continue;
         }
         writer.Write("\r\n            ComponentTypeRegistry.RegisterVariable(");
         writer.Write(variable.m_code_name);
         writer.Write(", ID);");
     }
     writer.Write("\r\n        }");
 }