// ReSharper disable once UnusedMethodReturnValue.Local private STUInstance ReadInstance(long offset, BinaryReader reader) { if (_instances.ContainsKey(offset)) { return(_instances[offset]); } _instances[offset] = null; long position = reader.BaseStream.Position; reader.BaseStream.Position = offset + Start; uint checksum = reader.ReadUInt32(); reader.BaseStream.Position = offset + Start; if (_InstanceTypes.ContainsKey(checksum)) { Type type = _InstanceTypes[checksum]; object instance = Activator.CreateInstance(type); _instances[offset] = InitializeObject(instance, type, reader, false, false) as STUInstance; } else { // STUInstance instance = new STUInstance(); // instances[offset] = InitializeObject(instance, typeof(STUInstance), reader) as STUInstance; Debugger.Log(0, "STU", $"[Version1]: Unhandled instance type: {checksum:X} (offset={offset})\n"); } TypeHashes.Add(checksum); reader.BaseStream.Position = position; return(_instances[offset]); }
public static int AddType(JObject jo) { var hash = "t_" + jo.ToString().GetHashCode(); lock (TypeHashes) { var idx = 0; if (TypeHashes.Contains(hash) == false) { TypeHashes.Add(hash); idx = TypeHashes.IndexOf(hash); Types.Add(idx, jo); } } return(TypeHashes.IndexOf(hash)); }
public static int AddType(JObject jo) { var hash = string.Format("t_{0}", jo.ToString().GetHashCode()); lock (TypeHashes) { if (TypeHashes.Contains(hash)) { return(TypeHashes.IndexOf(hash)); } TypeHashes.Add(hash); var idx = TypeHashes.IndexOf(hash); Types.Add(idx, jo); } return(TypeHashes.IndexOf(hash)); }