Archived
1
0
Fork 0

Entity changes

This commit is contained in:
Moritz Ruth 2021-06-14 15:24:59 +02:00
parent 71cd8bf486
commit 0414f83541
No known key found for this signature in database
GPG key ID: AFD57E23E753841B
2 changed files with 12 additions and 3 deletions

View file

@ -23,10 +23,17 @@ interface Entity {
*/ */
val numericID: Int val numericID: Int
/**
* If players should be added to [visibleTo] when they join.
*
* Defaults to true.
*/
var visibleToNewPlayers: Boolean
/** /**
* Players that can see this entity if it is in their view distance. * Players that can see this entity if it is in their view distance.
*/ */
val viewers: MutableSet<Player> val visibleTo: MutableSet<Player>
fun belongsToChunk(key: Chunk.Key): Boolean fun belongsToChunk(key: Chunk.Key): Boolean
@ -34,9 +41,9 @@ interface Entity {
suspend fun setWorld(world: World?) suspend fun setWorld(world: World?)
/** /**
* If players should be added to [viewers] when they enter [world]. * Players who currently have this entity loaded (= it is in their viewing distance).
*/ */
var visibleToNewPlayers: Boolean val viewers: Set<Player>
var glowing: Boolean // It seems like every entity can glow var glowing: Boolean // It seems like every entity can glow

View file

@ -31,6 +31,8 @@ sealed class UranosEntity(server: UranosServer) : Entity {
override var visibleToNewPlayers: Boolean = true override var visibleToNewPlayers: Boolean = true
override val visibleTo = mutableSetOf<Player>()
private val worldMutex = Mutex() private val worldMutex = Mutex()
final override var world: World? = null; private set final override var world: World? = null; private set