private Ja2Data.JsdStruct DownloadJsdStructure(JsdStructure aStructRecrod, bool aIsHiDefenition) { Ja2Data.JsdStruct _struct = new Ja2Data.JsdStruct(aIsHiDefenition); uint _flags = 0; foreach (JsdStructureStructureFlag _flag in aStructRecrod.JsdStructureStructureFlag) { _flags |= (uint)_flag.JsdStructureFlags.Mask.Value; } _struct.Flags = (Ja2Data.JsdStruct.JsdStructureFlags)_flags; _struct.Armour = aStructRecrod.Armour; _struct.Density = aStructRecrod.Density; _struct.DestructionPartner = (sbyte)aStructRecrod.DestructionPartner; _struct.HitPoints = aStructRecrod.HitPoints; _struct.PartnerDelta = (sbyte)aStructRecrod.PartnerDelta; _struct.StructureNumber = (ushort)aStructRecrod.StructureNumber; _struct.Unused = aStructRecrod.Unused; _struct.WallOrientation = aStructRecrod.WallOrientation; _struct.ZTileOffsetX = (sbyte)aStructRecrod.ZTileOffsetX; _struct.ZTileOffsetY = (sbyte)aStructRecrod.ZTileOffsetY; _struct.NumberOfTiles = aStructRecrod.NumberOfTiles; int i = 0; foreach (JsdTile _tileRec in aStructRecrod.JsdTile) { _struct.Tiles[i] = this.DownloadJsdTile(_tileRec, aIsHiDefenition); i++; } return(_struct); }
private SlfRecordJsd LoadJsd(Stream aInput) { SlfRecordJsd _jsdRecord = new SlfRecordJsd(); Ja2Data.JsdFile _jsdFile = Ja2Data.JsdFile.Load(aInput); this.FJsdFileIsHiDefinition = _jsdFile.IsHighDefenition; this.FProfileXSize = Ja2Data.JsdTile.GetProfileXSize(this.FJsdFileIsHiDefinition); this.FProfileYSize = Ja2Data.JsdTile.GetProfileYSize(this.FJsdFileIsHiDefinition); this.FJsdTileCell = new List <JsdTileCell>(this.FStrCount * FProfileXSize * FProfileYSize); _jsdRecord.ID = _jsdFile.FormatId; _jsdRecord.NumberOfImageTileLocsStored = _jsdFile.NumberOfImageTileLocsStored; _jsdRecord.NumberOfStructuresStored = _jsdFile.NumberOfStructuresStored; _jsdRecord.NumberOfStructuresAndOrImages = _jsdFile.NumberOfElements; _jsdRecord.StructureDataSize = _jsdFile.StructureDataSize; _jsdRecord.Unused = _jsdFile.Unused; _jsdRecord.UserId = this.FUserId; _jsdRecord.DateCreated = DateTime.Now; var _flags = this.FJsdFlags.Where(x => (x.Mask & (byte)_jsdFile.Flags) != 0); foreach (Flag _flag in _flags) { JsdRecordHeaderFlag _recFlag = new JsdRecordHeaderFlag(); _recFlag.FlagId = (byte)_flag.Id; _recFlag.SlfRecordJsd = _jsdRecord; this.FJsdHeaderFlags.Add(_recFlag); } if (_jsdFile.Auxilarity.Length > 0) { JsdAuxData _auxData = this.LoadJsdAux(_jsdFile.Auxilarity, _jsdFile.TileLocData); _auxData.SlfRecordJsd = _jsdRecord; this.FJsdAuxData.Add(_auxData); } if (_jsdFile.Structs.Length > 0) { foreach (Ja2Data.JsdStruct _struct in _jsdFile.Structs) { JsdStructure _structRec = this.LoadStructure(_struct); _structRec.SlfRecordJsd = _jsdRecord; this.FJsdStructures.Add(_structRec); } } return(_jsdRecord); }
private JsdStructure LoadStructure(Ja2Data.JsdStruct aStruct) { JsdStructure _structRec = new JsdStructure(); _structRec.Armour = aStruct.Armour; _structRec.Density = aStruct.Density; _structRec.DestructionPartner = aStruct.DestructionPartner; _structRec.HitPoints = aStruct.HitPoints; _structRec.NumberOfTiles = aStruct.NumberOfTiles; _structRec.PartnerDelta = aStruct.PartnerDelta; _structRec.StructureNumber = aStruct.StructureNumber; _structRec.Unused = aStruct.Unused; _structRec.WallOrientation = aStruct.WallOrientation; _structRec.ZTileOffsetX = aStruct.ZTileOffsetX; _structRec.ZTileOffsetY = aStruct.ZTileOffsetY; _structRec.DateCreated = DateTime.Now; _structRec.UserId = this.FUserId; var _flags = this.FStructureFlags.Where(x => (x.Mask & (uint)aStruct.Flags) != 0); foreach (Flag _flag in _flags) { JsdStructureStructureFlag _structToFlag = new JsdStructureStructureFlag(); _structToFlag.JsdStructure = _structRec; _structToFlag.FlagId = (byte)_flag.Id; this.FStructureStructuresFlags.Add(_structToFlag); } foreach (Ja2Data.JsdTile _tile in aStruct.Tiles) { JsdTile _tileRec = this.LoadJsdTile(_tile); _tileRec.JsdStructure = _structRec; this.FJsdTile.Add(_tileRec); } return(_structRec); }