new actor type "HistoricalFigure" that has date of birth and death

Former-commit-id: ec7ca90f29e0c56b3553e87b5a95fd023d9c55e1
Former-commit-id: 685958754f78542843913731880eb73f90e8e4c9
This commit is contained in:
Song Minjae
2016-10-10 18:25:29 +09:00
parent b0736aa722
commit c1d72c29af
12 changed files with 79 additions and 27 deletions

View File

@@ -130,8 +130,8 @@ open class ActorWithBody : Actor(), Visible {
*/
var grounded = false
override var flagDespawn = false
@Volatile var grounded = false
override @Volatile var flagDespawn = false
/** Default to 'false' */
var isVisible = false
/** Default to 'true' */
@@ -146,7 +146,7 @@ open class ActorWithBody : Actor(), Visible {
* think of a grass cutting on the Zelda games. It would also make a great puzzle to solve.
* --minjaesong)
*/
var isChronostasis = false
@Volatile var isChronostasis = false
/**
* Constants
@@ -213,8 +213,8 @@ open class ActorWithBody : Actor(), Visible {
@Transient private var assertPrinted = false
// to use with Controller (incl. player)
internal var walledLeft = false
internal var walledRight = false
internal @Volatile var walledLeft = false
internal @Volatile var walledRight = false
/**
* true: This actor had just made collision

View File

@@ -0,0 +1,49 @@
package net.torvald.terrarum.gameactors
import net.torvald.terrarum.gameworld.WorldTime
/**
* An actor (NPC) which has life and death,
* though death might not exist if it has achieved immortality :)
*
* Created by minjaesong on 16-10-10.
*/
open class HistoricalFigure(born: GameDate, dead: GameDate? = null) : ActorWithBody() {
init {
this.actorValue["_bornyear"] = born.year
this.actorValue["_borndays"] = born.yearlyDay
if (dead != null) {
this.actorValue["_deadyear"] = dead.year
this.actorValue["_deaddays"] = dead.yearlyDay
}
}
}
data class GameDate(val year: Int, val yearlyDay: Int) {
operator fun plus(other: GameDate): GameDate {
var newyd = this.yearlyDay + other.yearlyDay
var newy = this.year + other.year
if (newyd > WorldTime.YEAR_DAYS) {
newyd -= WorldTime.YEAR_DAYS
newy += 1
}
return GameDate(newy, newyd)
}
operator fun minus(other: GameDate): GameDate {
var newyd = this.yearlyDay - other.yearlyDay
var newy = this.year - other.year
if (newyd < 0) {
newyd += WorldTime.YEAR_DAYS
newy -= 1
}
return GameDate(newy, newyd)
}
}

View File

@@ -10,7 +10,7 @@ import java.util.*
/**
* Created by minjaesong on 16-03-14.
*/
open class NPCIntelligentBase : ActorWithBody()
open class NPCIntelligentBase(born: GameDate) : HistoricalFigure(born)
, AIControlled, Pocketed, CanBeAnItem, Factionable, LandHolder {
override var actorAI: ActorAI = object : ActorAI {

View File

@@ -9,7 +9,7 @@ import net.torvald.terrarum.mapdrawer.MapDrawer
object PBCynthia {
fun create(): Player {
val p: Player = Player()
val p: Player = Player(GameDate(100, 143)) // random value thrown
CreatureRawInjector.inject(p.actorValue, "CreatureHuman.json")
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0

View File

@@ -16,7 +16,7 @@ import java.io.IOException
object PBSigrid {
fun create(): Player {
val p = Player()
val p = Player(GameDate(-2147483648, 0)) // XD
p.sprite = SpriteAnimation()
p.sprite!!.setDimension(28, 51)

View File

@@ -19,7 +19,7 @@ import java.util.*
* Created by minjaesong on 16-03-14.
*/
class Player : ActorWithBody(), Controllable, Pocketed, Factionable, Luminous, LandHolder {
class Player(born: GameDate) : HistoricalFigure(born), Controllable, Pocketed, Factionable, Luminous, LandHolder {
/**
* empirical value.