void PackSystemBytes(ref BitPack pack) { pack.PackBitsFromUInt(CRC); pack.PackBitsFromUInt(PartFlags); pack.PackBitsFromByte((byte)Pattern); pack.PackFixed(MaxAge, false, 8, 8); pack.PackFixed(StartAge, false, 8, 8); pack.PackFixed(InnerAngle, false, 3, 5); pack.PackFixed(OuterAngle, false, 3, 5); pack.PackFixed(BurstRate, false, 8, 8); pack.PackFixed(BurstRadius, false, 8, 8); pack.PackFixed(BurstSpeedMin, false, 8, 8); pack.PackFixed(BurstSpeedMax, false, 8, 8); pack.PackBitsFromByte(BurstPartCount); pack.PackFixed(AngularVelocity.X, true, 8, 7); pack.PackFixed(AngularVelocity.Y, true, 8, 7); pack.PackFixed(AngularVelocity.Z, true, 8, 7); pack.PackFixed(PartAcceleration.X, true, 8, 7); pack.PackFixed(PartAcceleration.Y, true, 8, 7); pack.PackFixed(PartAcceleration.Z, true, 8, 7); pack.PackUUID(Texture); pack.PackUUID(Target); }
/// <summary> /// Generate byte[] array from particle data /// </summary> /// <returns>Byte array</returns> public byte[] GetBytes() { int size = LegacyDataBlockSize; if (!IsLegacyCompatible()) { size += 8; // two new ints for size } if (HasGlow()) { size += 2; // two bytes for start and end glow } if (HasBlendFunc()) { size += 2; // two bytes for start end end blend function } byte[] bytes = new byte[size]; BitPack pack = new BitPack(bytes, 0); if (IsLegacyCompatible()) { PackSystemBytes(ref pack); PackLegacyData(ref pack); } else { if (HasGlow()) { PartDataFlags |= ParticleDataFlags.DataGlow; } if (HasBlendFunc()) { PartDataFlags |= ParticleDataFlags.DataBlend; } pack.PackBitsFromUInt((uint)SysDataSize); PackSystemBytes(ref pack); int partSize = PartDataSize; if (HasGlow()) { partSize += 2; // two bytes for start and end glow } if (HasBlendFunc()) { partSize += 2; // two bytes for start end end blend function } pack.PackBitsFromUInt((uint)partSize); PackLegacyData(ref pack); if (HasGlow()) { pack.PackBitsFromByte((byte)(PartStartGlow * 255f)); pack.PackBitsFromByte((byte)(PartEndGlow * 255f)); } if (HasBlendFunc()) { pack.PackBitsFromByte(BlendFuncSource); pack.PackBitsFromByte(BlendFuncDest); } } return(bytes); }