Ejemplo n.º 1
0
        public static void PostGenerateCode(Behaviac.Design.MethodDef.Param param, StringWriter stream, string indent, string typename, string var, string caller, object parent, string setValue)
        {
            Behaviac.Design.ParInfo par = param.Value as Behaviac.Design.ParInfo;

            if (par != null)
            {
                ParInfoCsExporter.PostGenerateCode(par, null, stream, indent, typename, var, caller);
                return;
            }

            Behaviac.Design.VariableDef v = param.Value as Behaviac.Design.VariableDef;

            if (v != null)
            {
                VariableCsExporter.PostGenerateCode(v, stream, indent, typename, var, caller, parent, param.Name, setValue);
                return;
            }

            Type type = param.Value.GetType();

            if (Plugin.IsCustomClassType(type) && !DesignerStruct.IsPureConstDatum(param.Value, parent, param.Name))
            {
                StructCsExporter.PostGenerateCode(param.Value, stream, indent, var, parent, param.Name);
            }
        }
Ejemplo n.º 2
0
        public static void PostGenerateCode(Behaviac.Design.PropertyDef property, MethodDef.Param arrayIndexElement, StreamWriter stream, string indent, string typename, string var, string caller, string setValue = null)
        {
            if (property.IsPar || property.IsCustomized)
            {
                ParInfoCsExporter.PostGenerateCode(property, arrayIndexElement, stream, indent, typename, var, caller);
                return;
            }

            if (!property.IsReadonly)
            {
                string agentName = GetGenerateAgentName(property, var, caller);
                string prop      = setValue;

                if (property.Owner != Behaviac.Design.VariableDef.kSelf)
                {
                    stream.WriteLine("{0}behaviac.Agent {1} = behaviac.Agent.GetInstance(\"{2}\", pAgent.GetContextId());", indent, agentName, property.Owner.Replace("::", "."));
                    stream.WriteLine("{0}Debug.Check({1} != null);", indent, agentName);
                }

                string propBasicName = property.BasicName.Replace("[]", "");

                if (setValue != null)
                {
                    stream.WriteLine("{0}AgentExtra_Generated.SetProperty({1}, \"{2}\", {3});", indent, agentName, propBasicName, prop);
                }
                else
                {
                    prop = getProperty(property, arrayIndexElement, agentName, stream, indent);
                }

                uint id = Behaviac.Design.CRC32.CalcCRC(propBasicName);
                stream.WriteLine("{0}Debug.Check(behaviac.Utils.MakeVariableId(\"{1}\") == {2}u);", indent, propBasicName, id);

                if (string.IsNullOrEmpty(typename))
                {
                    typename = property.NativeType;
                }
                typename = DataCsExporter.GetGeneratedNativeType(typename);

                stream.WriteLine("{0}{1}.SetVariable<{2}>(\"{3}\", {4}, {5}u);", indent, agentName, typename, property.BasicName, prop, id);
            }
        }
Ejemplo n.º 3
0
 public static void PostGenerateCode(Behaviac.Design.VariableDef variable, StreamWriter stream, string indent, string typename, string var, string caller, object parent = null, string paramName = "", string setValue = null)
 {
     if (variable.ValueClass == Behaviac.Design.VariableDef.kConst)
     {
         Type type = variable.Value.GetType();
         if (Plugin.IsCustomClassType(type) && !DesignerStruct.IsPureConstDatum(variable.Value, parent, paramName))
         {
             StructCsExporter.PostGenerateCode(variable.Value, stream, indent, var, parent, paramName);
         }
     }
     else if (variable.ValueClass == Behaviac.Design.VariableDef.kPar)
     {
         Behaviac.Design.ParInfo par = variable.Value as Behaviac.Design.ParInfo;
         if (par != null)
         {
             ParInfoCsExporter.PostGenerateCode(par, stream, indent, typename, var, caller);
         }
     }
     else if (variable.Property != null)
     {
         PropertyCsExporter.PostGenerateCode(variable.Property, stream, indent, typename, var, caller, setValue);
     }
 }