-
-
Notifications
You must be signed in to change notification settings - Fork 591
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow sending spawnData when spawning entities using the Multip…
…layerService
- Loading branch information
1 parent
59d580e
commit a3f3ba6
Showing
3 changed files
with
49 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
fxgl/src/main/kotlin/com/almasb/fxgl/multiplayer/NetworkSpawnData.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* FXGL - JavaFX Game Library. The MIT License (MIT). | ||
* Copyright (c) AlmasB ([email protected]). | ||
* See LICENSE for details. | ||
*/ | ||
|
||
package com.almasb.fxgl.multiplayer | ||
|
||
import com.almasb.fxgl.core.serialization.Bundle | ||
import com.almasb.fxgl.entity.SpawnData | ||
import java.io.Serializable | ||
|
||
/** | ||
* Wrapper around SpawnData to be sent over network. | ||
* | ||
* @author Jonas Andersen ([email protected]) | ||
*/ | ||
class NetworkSpawnData(spawnData: SpawnData) : Serializable { | ||
|
||
val bundle = Bundle("NetworkSpawnData") | ||
var x: Double = 0.0 | ||
var y: Double = 0.0 | ||
var z: Double = 0.0 | ||
|
||
init { | ||
x = spawnData.x | ||
y = spawnData.y | ||
z = spawnData.z | ||
|
||
spawnData.data.forEach { (key, value) -> | ||
if (value is Serializable) { | ||
bundle.put(key, value) | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters