private void instruct_apply_force(Body body, MessageNode message) {
Vector2 dir = new Vector2(), pos = body.getPosition();
boolean is_wake = true;
int strength = -1;
MessageNode temp = message;
//skip the head node (which is processed in the upper structure )
while (temp.has_next) {
temp = temp.next;
boolean end_while = false;
if (temp.stringMessage != null) {
switch (temp.stringMessage) {
case MESSAGE_DIRECTION_X: {
dir.x = message.intMessage;
break;
}
case MESSAGE_DIRECTION_Y: {
dir.y = message.intMessage;
break;
}
case MESSAGE_STRENGTH:{
strength=message.intMessage;
break;
}
case MESSAGE_END: {
end_while = true;
// if this part of message ends while there are still another message left,
// go ahead and process them in the decoder
if (temp.has_next) {
message_decoder(body, temp.next);
}
break;
}
}
}
if (end_while) {
break;
}
}
if (strength != -1) {
dir = PhysicsTool.standard_strength(dir, strength);
}
body.applyForce(dir,
pos, is_wake);
}