public void fromBytes(byte[] buf) { prop_id = BitConverter.ToUInt32(buf, 0); layer_id = BitConverter.ToUInt32(buf, 4); loc = new PacketVec2(); loc.fromBytes(buf, 8); scl = new PacketVec2(); scl.fromBytes(buf, 16); index = BitConverter.ToInt32(buf, 24); tiledeck_id = BitConverter.ToUInt32(buf, 28); grid_id = BitConverter.ToUInt32(buf, 32); debug = BitConverter.ToInt32(buf, 36); rot = BitConverter.ToSingle(buf, 40); xflip = BitConverter.ToUInt32(buf, 44); yflip = BitConverter.ToUInt32(buf, 48); color = new PacketColor(); color.fromBytes(buf, 52); }
public byte[] BuildPacket(LEDColor[] colors, PacketColor packetColor) { byte[] buf = new byte[264]; buf[0] = 0x07; buf[1] = 0x16; buf[2] = (byte)packetColor; buf[3] = 0xA0; int ptr = 0; for (int ct = 0; ct < colors.Length; ct++) { ptr = ct; int rindex = (int)OrderOfKeys[ptr]; var ledColor = colors[ct]; buf[keys[ct]] = packetColor == PacketColor.Red ? (byte)ledColor.Red : packetColor == PacketColor.Green ? (byte)ledColor.Green : (byte)ledColor.Blue; } return(buf); }
public void fromBytes( byte[] buf ) { prop_id = BitConverter.ToUInt32(buf,0); layer_id = BitConverter.ToUInt32(buf,4); loc = new PacketVec2(); loc.fromBytes(buf,8); scl = new PacketVec2(); scl.fromBytes(buf,16); index = BitConverter.ToInt32(buf,24); tiledeck_id = BitConverter.ToUInt32(buf,28); grid_id = BitConverter.ToUInt32(buf,32); debug = BitConverter.ToInt32(buf,36); rot = BitConverter.ToSingle(buf,40); xflip = BitConverter.ToUInt32(buf,44); yflip = BitConverter.ToUInt32(buf,48); color = new PacketColor(); color.fromBytes(buf,52); }