blob: 384c859a49b6d90a825b16d4e858eb1d16477282 (
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
|
package cat.freya.khs.world
import cat.freya.khs.Khs
import cat.freya.khs.player.Player
data class Location(
var x: Double = 0.0,
var y: Double = 0.0,
var z: Double = 0.0,
var worldName: String = "world",
) {
/// Returns the position from this location
var position: Position
get() = Position(this.x, this.y, this.z)
set(new: Position) {
this.x = new.x
this.y = new.y
this.z = new.z
}
/// Returns the world associated with this location
fun getWorld(khs: Khs): World? {
return khs.shim.getWorld(this.worldName)
}
fun distance(other: Location): Double {
if (this.worldName != other.worldName) return Double.POSITIVE_INFINITY
return position.distance(other.position)
}
fun teleport(player: Player) {
player.teleport(this)
}
}
|