public void SaveToStream(BinaryWriter stream, FileVersion version) { try { int count = fGoals.Count; int num = fGoals.Count; for (int i = 0; i < num; i++) { ISerializable item = (ISerializable)fGoals[i]; if (item.SerializeKind <= 0) { count--; } } StreamUtils.WriteInt(stream, count); for (int i = 0; i < num; i++) { ISerializable item = (ISerializable)fGoals[i]; byte kind = item.SerializeKind; if (kind > 0) { StreamUtils.WriteByte(stream, kind); item.SaveToStream(stream, version); } } } catch (Exception ex) { Logger.Write("NWBrainEntity.saveToStream(): " + ex.Message); throw ex; } }