public bool Write(DAIIO io, bool skiplength = false) { try { if (!skiplength) { io.WriteBits(Length, LengthBits); } io.WriteInt32(Id); io.WriteInt32(DestroyedPartsCount); io.WriteBoolean(KeepInfoOnUnregister); if (PartIds == null) { PartIds = new int[PartIdsCount]; } io.WriteInt16((short)PartIds.Length); foreach (int t in PartIds) { io.WriteInt32(t); } io.WriteInt32(BitCount); if (BitArray == null) { BitArray = new byte[BitCount.NumberOfSetBits() << 2]; } io.Write(BitArray, 0, BitArray.Length); return(true); } catch (Exception) { return(false); } }
public CallBackData Read(DAIIO io) { xLength = io.ReadBit2(LengthBits); Id = io.ReadInt32(); DestroyedPartsCount = io.ReadInt32(); KeepInfoOnUnregister = io.ReadBoolean(); PartIdsCount = io.ReadInt16(); PartIds = new int[PartIdsCount]; for (int i = 0; i < PartIdsCount; i++) { PartIds[i] = io.ReadInt32(); } BitCount = io.ReadInt32(); int x = BitCount.NumberOfSetBits() << 2; BitArray = new byte[x]; io.Read(BitArray, 0, x); return(this); }