protected override void Read(BinaryReader reader, teMAP_PLACEABLE_TYPE type) { Header = reader.Read <PlaceableDataHeader>(); if (Header.PlaceableOffset > 0) { reader.BaseStream.Position = Header.PlaceableOffset; CommonStructures = new CommonStructure[Header.PlaceableCount]; Placeables = new IMapPlaceable[Header.PlaceableCount]; for (int i = 0; i < Header.PlaceableCount; i++) { long beforePos = reader.BaseStream.Position; CommonStructure commonStructure = reader.Read <CommonStructure>(); CommonStructures[i] = commonStructure; Placeables[i] = Manager.CreateType(commonStructure, type, reader); reader.BaseStream.Position = beforePos + CommonStructures[i].Size; } if (CommonStructures.Length > 0 && type == teMAP_PLACEABLE_TYPE.ENTITY && Header.InstanceDataOffset > 0) { int execCount = 0; reader.BaseStream.Position = Header.InstanceDataOffset + 16; foreach (IMapPlaceable placeable in Placeables) { if (!(placeable is teMapPlaceableEntity entity)) { continue; } entity.InstanceData = new STUComponentInstanceData[entity.Header.InstanceDataCount]; for (int i = 0; i < entity.Header.InstanceDataCount; i++) { reader.BaseStream.Position = entity.m_instanceDataOffsets[i]; try { teStructuredData structuredData = new teStructuredData(reader); entity.InstanceData[i] = structuredData.GetInstance <STUComponentInstanceData>(); } catch { execCount++; } } } if (execCount > 0) { Debugger.Log(0, "teMapChunk", $"Threw {execCount} exceptions when trying to parse entity instance data\r\n"); } } } }
public teMapPlaceableData(BinaryReader reader, teMAP_PLACEABLE_TYPE type) : base(reader, type) { }
public teMapPlaceableData(Stream stream, teMAP_PLACEABLE_TYPE type) : base(stream, type) { }
public IMapPlaceable CreateType(teMapPlaceableData.CommonStructure commonStructure, teMAP_PLACEABLE_TYPE type, BinaryReader reader) { IMapPlaceable value = new teMapPlaceableDummy((int)commonStructure.Size); if (Types.TryGetValue(type, out Type placeableType)) { value = (IMapPlaceable)Activator.CreateInstance(placeableType); } else if (_misingTypes.Add(type)) { Debugger.Log(0, "teMapPlaceableManager", $"Unhandled placeable type: {type}\r\n"); } value.Read(reader); return(value); }
protected teMapChunk(BinaryReader reader, teMAP_PLACEABLE_TYPE type) { Read(reader, type); }
protected teMapChunk(Stream stream, teMAP_PLACEABLE_TYPE type) { using (BinaryReader reader = new BinaryReader(stream)) { Read(reader, type); } }
protected abstract void Read(BinaryReader reader, teMAP_PLACEABLE_TYPE type);