mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-14 12:34:05 +09:00
loading player from json file
This commit is contained in:
@@ -12,7 +12,20 @@ typealias ActorID = Int
|
||||
*
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
*/
|
||||
abstract class Actor(var renderOrder: RenderOrder, id: ActorID?) : Comparable<Actor>, Runnable {
|
||||
abstract class Actor() : Comparable<Actor>, Runnable {
|
||||
|
||||
/**
|
||||
* Valid RefID is equal to or greater than 16777216.
|
||||
* @return Reference ID. (16777216-0x7FFF_FFFF)
|
||||
*/
|
||||
open var referenceID: ActorID = 0 // in old time this was nullable without initialiser. If you're going to revert to that, add the reason why this should be nullable.
|
||||
var renderOrder = RenderOrder.MIDDLE
|
||||
|
||||
// needs zero-arg constructor for serialiser to work
|
||||
constructor(renderOrder: RenderOrder, id: ActorID?) : this() {
|
||||
referenceID = id ?: Terrarum.generateUniqueReferenceID(renderOrder)
|
||||
}
|
||||
|
||||
|
||||
enum class RenderOrder {
|
||||
BEHIND, // tapestries, some particles (obstructed by terrain)
|
||||
@@ -32,11 +45,6 @@ abstract class Actor(var renderOrder: RenderOrder, id: ActorID?) : Comparable<Ac
|
||||
|
||||
abstract fun update(delta: Float)
|
||||
|
||||
/**
|
||||
* Valid RefID is equal to or greater than 16777216.
|
||||
* @return Reference ID. (16777216-0x7FFF_FFFF)
|
||||
*/
|
||||
open var referenceID: ActorID = id ?: Terrarum.generateUniqueReferenceID(renderOrder) // in old time this was nullable without initialiser. If you're going to revert to that, add the reason why this should be nullable.
|
||||
var actorValue = ActorValue(this) // FIXME cyclic reference on GSON
|
||||
@Volatile var flagDespawn = false
|
||||
|
||||
|
||||
@@ -5,17 +5,23 @@ import net.torvald.terrarum.KVHashMap
|
||||
/**
|
||||
* Created by minjaesong on 2017-04-28.
|
||||
*/
|
||||
class ActorValue(@Transient val actor: Actor) : KVHashMap() {
|
||||
class ActorValue : KVHashMap {
|
||||
|
||||
private constructor(actor: Actor, newMap: HashMap<String, Any>): this(actor) {
|
||||
@Transient lateinit var actor: Actor
|
||||
internal set
|
||||
|
||||
private constructor()
|
||||
|
||||
constructor(actor: Actor) : this() {
|
||||
this.actor = actor
|
||||
}
|
||||
|
||||
private constructor(actor: Actor, newMap: HashMap<String, Any>): this() {
|
||||
this.actor = actor
|
||||
hashMap = newMap
|
||||
}
|
||||
|
||||
override fun set(key: String, value: Any) {
|
||||
/*if (key == AVKey.__PLAYER_QUICKSLOTSEL) {
|
||||
printStackTrace(this)
|
||||
}*/
|
||||
|
||||
super.set(key, value)
|
||||
actor.onActorValueChange(key, value) // fire the event handler
|
||||
}
|
||||
|
||||
@@ -36,9 +36,15 @@ import kotlin.math.roundToInt
|
||||
*
|
||||
* Created by minjaesong on 2016-01-13.
|
||||
*/
|
||||
open class ActorWithBody(renderOrder: RenderOrder, val physProp: PhysProperties, id: ActorID? = null) :
|
||||
Actor(renderOrder, id) {
|
||||
open class ActorWithBody() : Actor() {
|
||||
|
||||
var physProp = PhysProperties.HUMANOID_DEFAULT
|
||||
|
||||
constructor(renderOrder: RenderOrder, physProp: PhysProperties, id: ActorID? = null) : this() {
|
||||
this.physProp = physProp
|
||||
this.renderOrder = renderOrder
|
||||
id?.let { this.referenceID = id }
|
||||
}
|
||||
|
||||
@Transient val COLLISION_TEST_MODE = false
|
||||
|
||||
|
||||
@@ -11,18 +11,15 @@ import org.dyn4j.geometry.Vector2
|
||||
*
|
||||
* Created by minjaesong on 2016-01-15.
|
||||
*/
|
||||
class Hitbox (x1: Double, y1: Double, width: Double, height: Double, var suppressWarning: Boolean = true) {
|
||||
class Hitbox {
|
||||
|
||||
@Volatile var hitboxStart: Point2d
|
||||
private set
|
||||
inline val hitboxEnd: Point2d
|
||||
get() = Point2d(hitboxStart.x + width, hitboxStart.y + height)
|
||||
var width: Double = 0.0
|
||||
private set
|
||||
var height: Double = 0.0
|
||||
private set
|
||||
var suppressWarning = true
|
||||
|
||||
private constructor()
|
||||
|
||||
constructor(x1: Double, y1: Double, width: Double, height: Double, suppressWarning: Boolean = true) : this() {
|
||||
this.suppressWarning = suppressWarning
|
||||
|
||||
init {
|
||||
hitboxStart = Point2d(x1, y1)
|
||||
this.width = width
|
||||
this.height = height
|
||||
@@ -33,6 +30,15 @@ class Hitbox (x1: Double, y1: Double, width: Double, height: Double, var suppres
|
||||
}
|
||||
}
|
||||
|
||||
@Volatile var hitboxStart: Point2d = Point2d(-1.0, -1.0)
|
||||
private set
|
||||
inline val hitboxEnd: Point2d
|
||||
get() = Point2d(hitboxStart.x + width, hitboxStart.y + height)
|
||||
var width: Double = 0.0
|
||||
private set
|
||||
var height: Double = 0.0
|
||||
private set
|
||||
|
||||
|
||||
val startX: Double
|
||||
get() = hitboxStart.x
|
||||
|
||||
Reference in New Issue
Block a user