internal static void Run() { PrimitiveType.Register <float>("DT_ACCEL", "Acceleration", "(Value * 3600.0f).ToString(\"0.00\") + \" ft/s^2\";"); PrimitiveType.Register <float>("DT_ANGLE", "Angle", "(Value * RadianToDegree).ToString(\"0.00\") + \"-|\";", "public const float RadianToDegree = 180f / (float)Math.PI; //57.295776f;"); PrimitiveType.Register <float>("DT_ANGULARVELOCITY", "AngularVelocity", "((Value * RadianToDegree) * 60.0f).ToString(\"0.00\") + \"-|/s\";", "public const float RadianToDegree = 180f / (float)Math.PI; //57.295776f;"); PrimitiveType.Register <int>("DT_ATTRIBUTEPARAM", "AttributeParameter"); PrimitiveType.Register <int>("DT_DATAID", "DataId", "\"0x\" + Value.ToString(\"X8\");"); PrimitiveType.Register <int>("DT_GBID", "GBID"); PrimitiveType.Register <float>("DT_HIGHPRECISIONPERCENT", "HighPrecisionPercent", "(Value * 100.0f).ToString(\"0.0000\") + \"%\";"); PrimitiveType.Register <float>("DT_IMPULSE", "Impulse", "(Value * 60.0f).ToString(\"0.00\") + \" lb-sec\";"); PrimitiveType.Register <float>("DT_MASS", "Mass", "(Value * 32.2f).ToString(\"0.00\") + \" lb\";"); PrimitiveType.Register <byte>("DT_PERCENT", "Percent", "(((float)Value / 255.0f) * 100.0f).ToString(\"0.00\") + \"%\";"); PrimitiveType.Register <int>("DT_SNO", "SNO"); PrimitiveType.Register <int>("DT_SNO_GROUP", "SNOGroup", "((Enigma.D3.Enums.SNOType)Value).ToString().ToUpper() + \"_SNO\";"); PrimitiveType.Register <int>("DT_SNONAME_HANDLE", "SNONameHandle"); PrimitiveType.Register <float>("DT_TIME", "Time", "(Value / 60f).ToString(\"0.00 sec\");"); PrimitiveType.Register <int>("DT_TRANSLATEABLE", "Translateable"); PrimitiveType.Register <float>("DT_VELOCITY", "Velocity", "(Value * 60f).ToString(\"0.00\") + \" ft/s\";"); NativeTypes.Register <bool>("DT_FLAG"); NativeTypes.Register <byte>("DT_BYTE"); NativeTypes.Register <short>("DT_WORD"); NativeTypes.Register <int>("DT_INT"); NativeTypes.Register <long>("DT_INT64"); NativeTypes.Register <float>("DT_FLOAT"); NativeTypes.Register <int>("DT_ENUM"); NativeTypes.Register <Vector3>("DT_VECTOR3D"); NativeTypes.Register <Vector2>("DT_VECTOR2D"); NativeTypes.Register <Vector2I>("DT_IVECTOR2D"); NativeTypes.Register <Quaternion>("Quaternion"); NativeTypes.Register <QuaternionI>("Quaternion16"); NativeTypes.Register <AABB>("AABB"); NativeTypes.Register <Sphere>("Sphere"); NativeTypes.Register <Vector3>("dmFloat3"); NativeTypes.Register <Plane>("dmPlane"); NativeTypes.Register <Matrix4x4>("Matrix4x4"); NativeTypes.Register <SNOName>("SNOName"); var groups = MemoryContext.Current.DataSegment.SNOGroupStorage .Select(p => p.Cast <SNOGroupStorage <MemoryObject> >().Dereference()).Where(a => a != null).ToList(); var project = new SharedProject("966c65df-1054-4d67-91ee-31c155f0c8f8", "Enigma.D3.Assets"); var outDir = Directory.CreateDirectory("enigma-d3-assets-" + MemoryContext.Current.MainModuleVersion); foreach (var group in groups.OrderBy(a => a.Name)) { Console.WriteLine(ConsoleTitleBase + " - " + group.Name); var knownTypes = new List <KnownType>(); knownTypes.AddRange(PrimitiveType.GetRawNames().Select(a => (KnownType)a)); knownTypes.AddRange(NativeTypes.GetRawNames().Select(a => (KnownType)a)); knownTypes.Add(group.PtrDataType.Dereference()); knownTypes.Add("DT_VARIABLEARRAY"); knownTypes.Add("DT_CHARARRAY"); knownTypes.Add("DT_TAGMAP"); knownTypes.Add("DT_CSTRING"); knownTypes.Add("DT_FORMULA"); knownTypes.Add("SerializeData"); string filePath = Path.Combine(outDir.FullName, group.PtrDataType.Dereference().GetName() + ".cs"); using (var output = File.CreateText(filePath)) { var baseType = group.PtrDataType.Dereference().ContainsSerializedData() ? "SerializeMemoryObject" : "MemoryObject"; AttachPrinterStream(output); PrintLine("using System.Runtime.CompilerServices;"); PrintLine("using Enigma.D3.DataTypes;"); PrintLine("using Enigma.Memory;"); PrintLine(); PrintLine("namespace Enigma.D3.Assets"); PrintLine("{"); IndentLevel++; PrintLine("[CompilerGenerated]"); PrintLine("public {2}class {0} : {1}", group.Name, baseType, DeclarePartial ? "partial " : ""); PrintLine("{"); IndentLevel++; PrintLine("public const int SizeOf = 0x{0:X}; // {0}", group.PtrDataType.Dereference().GetSizeOf()); PrintLine(); PrintLine("public SNOHeader x{0}_Header {{ get {{ return Read<SNOHeader>(0x{0}); }} }}", 0.ToString("X" + Math.Max(2, group.PtrDataType.Dereference().GetSizeOf().ToString("X").Length))); Examine(knownTypes.Select(a => (KnownType)a).ToList(), group.PtrDataType.Dereference()); IndentLevel--; PrintLine("}"); IndentLevel--; PrintLine("}"); DetachPrinterStream(output); project.AddCompileFile(filePath); } } Console.Title = ConsoleTitleBase + " - Creating shared project..."; project.Save(Path.Combine(outDir.FullName, "Enigma.D3.Assets.Generated.*")); if (Program.DeployGeneratedCode) { Console.Title = ConsoleTitleBase + " - Deploying shared project..."; project.Deploy( outDir, Program.SolutionDirectory.CreateSubdirectory(project.RootNamespace + ".Generated")); } }