using System;using System.IO;using System.Reflection;using System.Runtime.Serialization;using Newtonsoft.Json;using Newtonsoft.Json.Linq;using Microsoft.Xna.Framework;
public static class AvatarRules {
 public static void Capture(string group,string tag,Color color){Console.WriteLine(group+"\t"+tag+"\t"+color.PackedValue);}
 public static void Main(string[] args){string game=args[0];AppDomain.CurrentDomain.AssemblyResolve+=(s,e)=>Assembly.LoadFrom(Path.Combine(game,new AssemblyName(e.Name).Name+".dll"));var a=Assembly.LoadFile(Path.GetFullPath(args[1]));var easm=Assembly.LoadFrom(Path.Combine(game,"Amorous.Engine.dll"));var ptype=easm.ManifestModule.ResolveType(0x02000032);var input=JObject.Parse(File.ReadAllText(args[2]));var colors=new System.Collections.Generic.Dictionary<string,JObject>();foreach(var property in ptype.GetProperties()){var at=(JsonPropertyAttribute)Attribute.GetCustomAttribute(property,typeof(JsonPropertyAttribute));if(at!=null && property.PropertyType==typeof(Color) && input[at.PropertyName] is JObject){colors[at.PropertyName]=(JObject)input[at.PropertyName];input.Remove(at.PropertyName);}}var p=JsonConvert.DeserializeObject(input.ToString(),ptype);foreach(var property in ptype.GetProperties()){var at=(JsonPropertyAttribute)Attribute.GetCustomAttribute(property,typeof(JsonPropertyAttribute));JObject col;if(at!=null && colors.TryGetValue(at.PropertyName,out col))property.SetValue(p,new Color((int)col["R"],(int)col["G"],(int)col["B"],(int)col["A"]),null);}var t=a.ManifestModule.ResolveType(0x02000030);var o=FormatterServices.GetUninitializedObject(t);a.ManifestModule.ResolveMethod(0x060002ff).Invoke(o,new[]{p});}
}

