public void Save(Serializer serializer) { this.FHeader.ubNumberOfTiles = this.NumberOfTiles; serializer.Serialize(this.FHeader); if (this.FTiles == null || this.FTiles.Length == 0) { return; } // Базовый тайл должен быть первым. if (this.FTiles[0].XPosRelToBase != 0 || this.FTiles[0].YPosRelToBase != 0) { JsdTile _temp = this.FTiles[0]; for (int i = 0; i < this.FTiles.Length; i++) { if (this.FTiles[i].XPosRelToBase == 0 && this.FTiles[i].YPosRelToBase == 0) { this.FTiles[0] = this.FTiles[i]; this.FTiles[i] = _temp; break; } } } foreach (JsdTile jsdTile in this.FTiles) { jsdTile.Save(serializer); } }
public void AddTile(JsdTile aJsdTile) { JsdTile[] _tiles = new JsdTile[this.NumberOfTiles + 1]; if (this.FTiles != null) { Array.Copy(this.FTiles, _tiles, this.NumberOfTiles); } _tiles[this.NumberOfTiles] = aJsdTile; this.FTiles = _tiles; }
public void Load(Deserializer deserializer) { this.FHeader = (Header)deserializer.Deserialize(typeof(Header)); this.FTiles = new JsdTile[this.FHeader.ubNumberOfTiles]; for (int i = 0; i < this.FHeader.ubNumberOfTiles; i++) { JsdTile _tile = new JsdTile(this.FIsHighDefenition); _tile.Load(deserializer); this.FTiles[i] = _tile; } }
public void RemoveTile(JsdTile aTile) { List <JsdTile> _tiles = new List <JsdTile>(this.NumberOfTiles - 1); for (int i = 0; i < this.NumberOfTiles; i++) { if (this.FTiles[i] == aTile) { continue; } _tiles.Add(this.FTiles[i]); } this.FTiles = _tiles.ToArray(); }
// Базовый тайл должен быть первым. public int CompareTo(object obj) { JsdTile _tile = obj as JsdTile; int _result = 0; if (_tile != null) { if (_tile.XPosRelToBase == 0 && _tile.YPosRelToBase == 0) { _result = -1; } } return(_result); }
public JsdTile Clone() { JsdTile _newTile = new JsdTile(this.IsHighDefenition); Data _data = new Data(); _data.bUnused = this.FData.bUnused; _data.bXPosRelToBase = this.FData.bXPosRelToBase; _data.bYPosRelToBase = this.FData.bYPosRelToBase; _data.fFlags = this.FData.fFlags; _data.shape = new byte[this.FData.shape.Length]; Array.Copy(this.FData.shape, _data.shape, _data.shape.Length); _data.sPosRelToBase = this.FData.sPosRelToBase; _data.ubVehicleHitLocation = this.FData.ubVehicleHitLocation; _newTile.FData = _data; return(_newTile); }