added distance to network message

This commit is contained in:
2023-03-28 00:54:18 +02:00
parent 409c4fb411
commit f7c320c123
5 changed files with 25 additions and 20 deletions

View File

@@ -60,7 +60,7 @@ class Net {
}
private function setupInterf(interf: INetworkInterface) {
interf.onMessage.handle(pack -> handle(pack,interf));
interf.onMessage.handle(e -> handle(e.pack,interf,e.dist));
interf.listen(networkID);
interf.listen(BRODCAST_PORT);
}
@@ -68,7 +68,7 @@ class Net {
/**
Called when a new package comes in.
**/
private function handle(pack:Package,interf: INetworkInterface) {
private function handle(pack:Package,interf: INetworkInterface, ?dist: Float) {
if (pack.toID == this.networkID || pack.toID == Net.BRODCAST_PORT){
switch pack.type {
case Data(_) | DataNoResponse(_):