private void VisitGroupCore(BethesdaGroup group) { this.OnEnterGroup(group); BethesdaGroupReader reader = new BethesdaGroupReader(group); BethesdaGroupReaderState state; while ((state = reader.Read()) != BethesdaGroupReaderState.EndOfContent) { switch (state) { case BethesdaGroupReaderState.Record: this.OnRecord(reader.CurrentRecord); break; case BethesdaGroupReaderState.Subgroup: this.VisitGroupCore(reader.CurrentSubgroup); break; } } this.OnExitGroup(group); }
private static BethesdaGroup Write(Group group, ref MArrayPosition <byte> pos) { MBitConverter.Set(pos, GRUP); BethesdaGroup grp = new BethesdaGroup(pos) { DataSize = unchecked ((uint)(CalculateSize(group) - 24)), Label = group.Label, GroupType = group.GroupType, Stamp = group.Stamp, UNKNOWN_18 = group.UNKNOWN_18, Version = group.Version, UNKNOWN_22 = group.UNKNOWN_22 }; pos += 24; foreach (var rec in group.Records) { Write(rec, ref pos); } return(grp); }
protected virtual void OnExitGroup(BethesdaGroup group) { }
protected virtual void OnEnterGroup(BethesdaGroup group) { }
public Group(BethesdaGroup copyFrom) { this.GroupType = copyFrom.GroupType; this.Label = copyFrom.Label; this.Stamp = copyFrom.Stamp; this.UNKNOWN_18 = copyFrom.UNKNOWN_18; this.Version = copyFrom.Version; this.UNKNOWN_22 = copyFrom.UNKNOWN_22; Record record = null; Record dummyRecord = null; BethesdaGroupReader reader = new BethesdaGroupReader(copyFrom); BethesdaGroupReaderState state; while ((state = reader.Read()) != BethesdaGroupReaderState.EndOfContent) { switch (state) { case BethesdaGroupReaderState.Record: this.Records.Add(record = new Record(reader.CurrentRecord) { Parent = this }); break; case BethesdaGroupReaderState.Subgroup: var currSubgroup = reader.CurrentSubgroup; switch (currSubgroup.GroupType) { case BethesdaGroupType.CellChildren: case BethesdaGroupType.CellPersistentChildren: case BethesdaGroupType.CellTemporaryChildren: case BethesdaGroupType.CellVisibleDistantChildren: case BethesdaGroupType.WorldChildren: case BethesdaGroupType.TopicChildren: break; default: record = null; break; } if (record == null) { if (dummyRecord == null) { this.Records.Add(dummyRecord = new Record { Parent = this }); } record = dummyRecord; } record.Subgroups.Add(new Group(currSubgroup) { Parent = record }); break; } } }