blob: a084555fa32e1b1aa3e8c023848c77af53cb49fe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package kz.ilotterytea.frogartha.events;
import com.badlogic.gdx.math.Vector3;
import com.github.czyzby.websocket.serialization.SerializationException;
import com.github.czyzby.websocket.serialization.Transferable;
import com.github.czyzby.websocket.serialization.impl.Deserializer;
import com.github.czyzby.websocket.serialization.impl.Serializer;
public class PlayerJumpEvent extends Event implements Transferable<PlayerJumpEvent> {
private Vector3 startPosition, endPosition;
private float jumpStrength;
public PlayerJumpEvent() {
super();
}
public PlayerJumpEvent(Integer playerId, Vector3 startPosition, Vector3 endPosition, Float jumpStrength) {
super(playerId);
this.startPosition = startPosition;
this.endPosition = endPosition;
this.jumpStrength = jumpStrength;
}
public Vector3 getStartPosition() {
return startPosition;
}
public Vector3 getEndPosition() {
return endPosition;
}
public float getJumpStrength() {
return jumpStrength;
}
@Override
public void serialize(Serializer serializer) throws SerializationException {
serializer
// id
.serializeInt(playerId)
// start position
.serializeFloatArray(new float[]{startPosition.x, startPosition.y, startPosition.z})
// end position
.serializeFloatArray(new float[]{endPosition.x, endPosition.y, endPosition.z})
// jump strength
.serializeFloat(jumpStrength);
}
@Override
public PlayerJumpEvent deserialize(Deserializer deserializer) throws SerializationException {
return new PlayerJumpEvent(
deserializer.deserializeInt(),
new Vector3(deserializer.deserializeFloatArray()),
new Vector3(deserializer.deserializeFloatArray()),
deserializer.deserializeFloat()
);
}
}
|