public static void DumpSTUFields <T>(T instance, string padding = "\t") // eww? { Type t = typeof(T); foreach (FieldInfo info in t.GetFields()) { object got = info.GetValue(instance); if (got == null) { Console.Out.WriteLine("{0}{1}: {2:X8}", padding, info.Name, info.GetValue(instance)); } else { if (got.GetType().Name == "STUGUID" && got.GetType().Namespace == "STULib.Types.Generic") { ulong key = (ulong)GetInstanceField(got.GetType(), got, "Key"); Console.Out.WriteLine($"{padding}{info.Name}: {GUID.AsString(key)}"); } else { Console.Out.WriteLine("{0}{1}: {2:X8}", padding, info.Name, info.GetValue(instance).ToString()); } } } }
public static Stream OpenFile(PackageRecord record, CASCHandler handler) { long offset = 0; EncodingEntry enc; if (record.Flags.HasFlag(ContentFlags.Bundle)) { offset = record.Offset; } if (!handler.Encoding.GetEntry(record.Hash, out enc)) { return(null); } MemoryStream ms = new MemoryStream((int)record.Size); try { Stream fstream = handler.OpenFile(enc.Key); fstream.Position = offset; CopyBytes(fstream, ms, (int)record.Size); ms.Position = 0; } catch (Exception ex) { Console.Out.WriteLine("Error {0} with file {2} ({1})", ex.Message, TypeAlias(GUID.Type(record.GUID)), GUID.AsString(record.GUID)); return(null); } if (System.Diagnostics.Debugger.IsAttached) { System.Diagnostics.Debugger.Log(0, "CASC:IO", $"[CASC:IO] Opened file {GUID.AsString(record.GUID)}\n"); } return(ms); }
public static string ToStringA(this OWRecord i) { return(GUID.AsString(i.key)); }