package com.ezardlabs.dethsquare.multiplayer;

import java.nio.ByteBuffer;

public class NetworkAnimator extends NetworkBehaviour {

	@Override
	public void start() {
		super.start();
		assert gameObject.animator != null;
		gameObject.animator.shouldUpdate = getPlayerId() == Network.getPlayerId();
	}

	@Override
	protected ByteBuffer onSend() {
		data.position(0);
		data.putInt(0, gameObject.animator.getCurrentAnimationId()); // 0 - 3
		data.putInt(4, gameObject.animator.getCurrentAnimationFrame()); // 4 - 7
		return data;
	}

	@Override
	protected void onReceive(ByteBuffer data, int index) {
		gameObject.animator.setCurrentAnimationId(data.getInt(index));
		gameObject.animator.setCurrentAnimationFrame(data.getInt(index + 4));
	}

	@Override
	public short getSize() {
		return 8;
	}
}

@@ -374,14 +374,24 @@
 .put
-Int(0,
+Short(0, (short)
  gam
@@ -444,9 +444,9 @@
 0 - 
-3
+1
 %0A%09%09d
@@ -456,14 +456,24 @@
 .put
-Int(4,
+Short(2, (short)
  gam
@@ -525,13 +525,13 @@
  // 
-4 - 7
+2 - 3
 %0A%09%09r
@@ -661,26 +661,28 @@
 nId(data.get
-In
+Shor
 t(index));%0A%09
@@ -739,10 +739,12 @@
 .get
-In
+Shor
 t(in
@@ -753,9 +753,9 @@
 x + 
-4
+2
 ));%0A
@@ -808,9 +808,9 @@
 urn 
-8
+4
 ;%0A%09%7D

Send animation data across the network as shorts instead of ints, to save some bytes