public void SetThings(YodaReader yodesk_reader, int[] zoneOffsets) { this.yodesk = yodesk_reader; this.zoneOffsets = zoneOffsets; Func<int, byte[]> attrs = delegate(int i) { byte[] header = new byte[20]; yodesk.Seek(zoneOffsets[i], 0); yodesk.Read(header, 0, 20); //return header[12].ToString("X02") + " " + header[18].ToString("X02"); return new byte[] { header[12], header[18] }; }; var zone_list = Enumerable.Range(0, zoneOffsets.Length) .Select(i => new { index = i, attr = attrs(i) }) .Select(o => new ZoneListEntry { index = o.index, offset = zoneOffsets[o.index], planet = o.attr[1], type = o.attr[0] }) ;//.OrderBy(o => o.type).OrderBy(o => o.planet); ZonesForm.entries = zone_list.ToArray(); cbZoneTypeFilter.Items.Clear(); cbZoneTypeFilter.Items.AddRange(Zone.ZONE_TYPE); lbZoneIndex.Items.Clear(); lbZoneIndex.Items.AddRange(ZonesForm.entries); }
public ItemCollection(YodaReader stream) { stream.Seek(TNAM_OFFSET, SeekOrigin.Begin); Items = new GameItem[ITEM_COUNT]; stream.Seek(4, SeekOrigin.Current); // skip "TNAM" stream.Seek(4, SeekOrigin.Current); // skip 4-byte header for (int i = 0; i < ITEM_COUNT; i++) { byte[] buf = new byte[26]; stream.Read(buf, 0, 26); Items[i].Index = i; Items[i].Sprite = buf[0] + buf[1] * 0x100; /*StringBuilder builder = new StringBuilder(); for (int k = 2; k < 26; k++) { if (buf[k] == 0) break; builder.Append((char)buf[k]); }*/ Items[i].Name = Encoding.ASCII.GetString(buf, 2, 24); Items[i].Name = Items[i].Name.Substring(0, Items[i].Name.IndexOf('\0')); } }
private void ReadHeader(YodaReader stream) { byte[] header = new byte[20]; Header = header; stream.Read(header, 0, 20); Width = header[8]; Height = header[10]; this.Planet = header[18] >= PLANET.Length ? "UNK" : PLANET[header[18]]; this.ZoneType = header[12] >= ZONE_TYPE.Length ? "UNK" : ZONE_TYPE[header[12]]; }
private void ReadCells(YodaReader stream) { Cells = new Cell[Width, Height]; byte[] buf = new Byte[6]; for (int i = 0; i < Width; i++) { for (int j = 0; j < Height; j++) { Cells[i, j].Bytes = new byte[6]; stream.Read(Cells[i, j].Bytes, 0, 6); } } }