private static object ReadLoadAssets(MappingReadArgs args) { var reader = args.Reader; var itemCount = reader.ReadInt16(); var unk02 = reader.ReadInt16(); var unk04 = reader.ReadInt16(); var unk06 = reader.ReadInt16(); var loadSet = new List <IEventEntry>(); for (var i = 0; i < itemCount; i++) { var startPosition = reader.BaseStream.Position; var typeId = reader.ReadInt16(); var length = reader.ReadInt16(); var entryType = _idType[typeId]; loadSet.Add(Mapping.ReadObject(reader.BaseStream, (IEventEntry)Activator.CreateInstance(entryType))); reader.BaseStream.Position = startPosition + length; } return(new ReadAssets { FrameStart = unk02, FrameEnd = unk04, Unk06 = unk06, Set = loadSet }); }
private unsafe static object ReadFloat(MappingReadArgs arg) { var data = (arg.Reader.ReadByte() << 24) | (arg.Reader.ReadByte() << 16) | (arg.Reader.ReadByte() << 8) | arg.Reader.ReadByte(); return(*(float *)&data); }
private static object IfReader(MappingReadArgs args) { var item = new If { Value = args.Reader.ReadInt32(), Commands = ParseScript(args.Reader.BaseStream.ReadBytes()).ToList() }; return(item); }
private static object SetInventoryReader(MappingReadArgs args) { var count = args.Reader.ReadInt16(); return(new SetInventory { Items = Enumerable .Range(0, count) .Select(_ => args.Reader.ReadInt32()) .ToList() }); }
private static object ScriptMultipleStringReader(MappingReadArgs args) { var list = new List <string>(); args.Count = 4; while (args.Reader.BaseStream.Position + 3 < args.Reader.BaseStream.Length) { list.Add(ScriptStringReader(args) as string); } return(list); }
private static object ReadString(MappingReadArgs arg) { var dstPosition = arg.Reader.BaseStream.Position + arg.Count * 2; var count = arg.Count; var sb = new StringBuilder(count); for (var i = 0; i < count; i++) { var ch = arg.Reader.ReadByte(); if (ch == 0) { break; } if (ch >= '0' && ch <= '9') { sb.Append((char)ch); } else if (ch >= 'A' && ch <= 'Z') { sb.Append((char)ch); } else if (ch >= 'a' && ch <= 'z') { sb.Append((char)ch); } else if (ch == 0x80) { ch = arg.Reader.ReadByte(); if (ch >= 0xc1 && ch <= 0xc1 + ('z' - 'a')) { sb.Append((char)(ch - 0xc1 + 'a')); } else if (ch >= 0xa1 && ch <= 0xa1 + ('Z' - 'A')) { sb.Append((char)(ch - 0xa1 + 'A')); } else { throw new NotImplementedException($"Read P5 string: second char {ch:X02}"); } } else { throw new NotImplementedException($"Read P5 string: first char {ch:X02}"); } } arg.Reader.BaseStream.Position = dstPosition; return(sb.ToString()); }
private static object AreaSettingsReader(MappingReadArgs args) { var reader = args.Reader; var settings = new AreaSettings { Unk00 = reader.ReadInt16(), Unk02 = reader.ReadInt16(), Settings = new List <IAreaDataSetting>() }; while (reader.BaseStream.Position < args.Reader.BaseStream.Length) { var opcode = reader.ReadInt16(); var instance = Activator.CreateInstance(_idSetType[opcode]); instance = Mapping.ReadObject(reader.BaseStream, instance); settings.Settings.Add(instance as IAreaDataSetting); } return(settings); }
private static object ReadUnk1E(MappingReadArgs args) { var id = args.Reader.ReadInt16(); var count = args.Reader.ReadInt16(); var unk04 = args.Reader.ReadInt16(); var unk06 = args.Reader.ReadInt16(); var entries = Enumerable .Range(0, count) .Select(x => Mapping.ReadObject <Unk1E.Entry>(args.Reader.BaseStream)) .ToList(); var unkG = args.Reader.ReadInt16(); var unkH = args.Reader.ReadInt16(); return(new Unk1E { Id = id, UnkG = unkG, UnkH = unkH, Entries = entries }); }
private static object ReadSetCameraData(MappingReadArgs args) { List <SetCameraData.CameraKeys> AssignValues(SetCameraDataHeader header, IList <SetCameraData.CameraKeys> values) => Enumerable.Range(0, header.Count).Select(i => values[header.Index + i]).ToList(); var cameraId = args.Reader.ReadInt16(); var headers = Enumerable .Range(0, 8) .Select(x => BinaryMapping.ReadObject <SetCameraDataHeader>(args.Reader.BaseStream)) .ToList(); args.Reader.BaseStream.AlignPosition(4); var valueCount = headers.Max(x => x.Index + x.Count); var values = Enumerable .Range(0, valueCount) .Select(x => BinaryMapping.ReadObject <CameraValueInternal>(args.Reader.BaseStream)) .Select(x => new SetCameraData.CameraKeys { Interpolation = (Motion.Interpolation)(x.FlagData >> 29), KeyFrame = (int)((x.FlagData & 0x1FFFFFFF ^ 0x10000000) - 0x10000000), Value = x.Value, TangentEaseIn = x.TangentEaseIn, TangentEaseOut = x.TangentEaseOut }) .ToList(); return(new SetCameraData { CameraId = cameraId, PositionX = AssignValues(headers[0], values), PositionY = AssignValues(headers[1], values), PositionZ = AssignValues(headers[2], values), LookAtX = AssignValues(headers[3], values), LookAtY = AssignValues(headers[4], values), LookAtZ = AssignValues(headers[5], values), Roll = AssignValues(headers[6], values), FieldOfView = AssignValues(headers[7], values), }); }
private static object ReadVoices(MappingReadArgs args) { var voiceCount = args.Reader.ReadInt32(); var voices = new List <SeqVoices.Voice>(voiceCount); for (var i = 0; i < voiceCount; i++) { var voice = new SeqVoices.Voice(); var startPos = args.Reader.BaseStream.Position; args.Reader.ReadInt32(); // It always supposed to be 0 voice.FrameStart = args.Reader.ReadInt16(); args.Reader.ReadByte(); voice.Name = ReadCStyleString(args.Reader.BaseStream); voices.Add(voice); args.Reader.BaseStream.Position = startPos + 0x20; } return(new SeqVoices { Voices = voices }); }
private static object CStringReader(MappingReadArgs args) => ReadCStyleString(args.Reader.BaseStream);