mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-09 18:14:06 +09:00
abolished a need to pass world as parametre
+ simply changing the single variable (ingame.world) will update all the renderer's behaviour + somehow my git changelogs are exploding
This commit is contained in:
@@ -139,7 +139,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
cameraPlayer = object : HumanoidNPC(demoWorld, cameraAI, born = 0, usePhysics = false, forceAssignRefID = Terrarum.PLAYER_REF_ID) {
|
cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false, forceAssignRefID = Terrarum.PLAYER_REF_ID) {
|
||||||
init {
|
init {
|
||||||
setHitboxDimension(2, 2, 0, 0)
|
setHitboxDimension(2, 2, 0, 0)
|
||||||
hitbox.setPosition(
|
hitbox.setPosition(
|
||||||
@@ -224,7 +224,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
|||||||
|
|
||||||
demoWorld.globalLight = WeatherMixer.globalLightNow
|
demoWorld.globalLight = WeatherMixer.globalLightNow
|
||||||
demoWorld.updateWorldTime(delta)
|
demoWorld.updateWorldTime(delta)
|
||||||
WeatherMixer.update(delta, cameraPlayer)
|
WeatherMixer.update(delta, cameraPlayer, demoWorld)
|
||||||
cameraPlayer.update(delta)
|
cameraPlayer.update(delta)
|
||||||
|
|
||||||
// worldcamera update AFTER cameraplayer in this case; the other way is just an exception for actual ingame SFX
|
// worldcamera update AFTER cameraplayer in this case; the other way is just an exception for actual ingame SFX
|
||||||
|
|||||||
@@ -4,15 +4,13 @@ import com.badlogic.gdx.graphics.Color
|
|||||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
|
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-02-17.
|
* Created by minjaesong on 2016-02-17.
|
||||||
*/
|
*/
|
||||||
internal object SetGlobalLightOverride : ConsoleCommand {
|
internal object SetGlobalLightOverride : ConsoleCommand {
|
||||||
|
|
||||||
var lightOverride = false
|
|
||||||
private set
|
|
||||||
|
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
if (args.size == 5) {
|
if (args.size == 5) {
|
||||||
try {
|
try {
|
||||||
@@ -22,7 +20,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
|||||||
val a = args[4].toFloat()
|
val a = args[4].toFloat()
|
||||||
val GL = Color(r, g, b, a)
|
val GL = Color(r, g, b, a)
|
||||||
|
|
||||||
lightOverride = true
|
WeatherMixer.globalLightOverridden = true
|
||||||
(Terrarum.ingame!!.world).globalLight = GL
|
(Terrarum.ingame!!.world).globalLight = GL
|
||||||
}
|
}
|
||||||
catch (e: NumberFormatException) {
|
catch (e: NumberFormatException) {
|
||||||
@@ -33,6 +31,9 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else if (args.size == 2 && args[1].trim().toLowerCase() == "none") {
|
||||||
|
WeatherMixer.globalLightOverridden = false
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
printUsage()
|
printUsage()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,13 +31,19 @@ import java.util.*
|
|||||||
*
|
*
|
||||||
* Created by minjaesong on 2016-01-13.
|
* Created by minjaesong on 2016-01-13.
|
||||||
*/
|
*/
|
||||||
open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val immobileBody: Boolean = false, var usePhysics: Boolean = true) :
|
open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean = false, var usePhysics: Boolean = true) :
|
||||||
ActorWithBody(renderOrder) {
|
ActorWithBody(renderOrder) {
|
||||||
|
|
||||||
|
|
||||||
val COLLISION_TEST_MODE = false
|
val COLLISION_TEST_MODE = false
|
||||||
|
|
||||||
/** !! ActorValue macros are on the very bottom of the source !! **/
|
/* !! ActorValue macros are on the very bottom of the source !! */
|
||||||
|
|
||||||
|
/** This is GameWorld? only because the title screen also uses this thing as its camera;
|
||||||
|
* titlescreen does not use instance of Ingame.
|
||||||
|
*/
|
||||||
|
private val world: GameWorld?
|
||||||
|
get() = Terrarum.ingame?.world
|
||||||
|
|
||||||
|
|
||||||
@Transient internal var sprite: SpriteAnimation? = null
|
@Transient internal var sprite: SpriteAnimation? = null
|
||||||
@@ -165,9 +171,11 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
private inline val grounded: Boolean
|
private inline val grounded: Boolean
|
||||||
get() = isNoClip ||
|
get() = if (world == null) true else {
|
||||||
(world.gravitation.y > 0 && isWalled(hitbox, COLLIDING_BOTTOM) ||
|
isNoClip ||
|
||||||
world.gravitation.y < 0 && isWalled(hitbox, COLLIDING_TOP))
|
(world!!.gravitation.y > 0 && isWalled(hitbox, COLLIDING_BOTTOM) ||
|
||||||
|
world!!.gravitation.y < 0 && isWalled(hitbox, COLLIDING_TOP))
|
||||||
|
}
|
||||||
/** Default to 'true' */
|
/** Default to 'true' */
|
||||||
var isVisible = true
|
var isVisible = true
|
||||||
/** Default to 'true' */
|
/** Default to 'true' */
|
||||||
@@ -190,7 +198,8 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
* s^2 = 1/FPS = 1/60 if FPS is targeted to 60
|
* s^2 = 1/FPS = 1/60 if FPS is targeted to 60
|
||||||
* meter to pixel : 24/FPS
|
* meter to pixel : 24/FPS
|
||||||
*/
|
*/
|
||||||
@Transient private val gravitation: Vector2 = world.gravitation
|
private val gravitation: Vector2
|
||||||
|
get() = world?.gravitation ?: Vector2(0.0, 9.8)
|
||||||
@Transient val DRAG_COEFF_DEFAULT = 1.2
|
@Transient val DRAG_COEFF_DEFAULT = 1.2
|
||||||
/** Drag coefficient. Parachutes have much higher value than bare body (1.2) */
|
/** Drag coefficient. Parachutes have much higher value than bare body (1.2) */
|
||||||
var dragCoefficient: Double
|
var dragCoefficient: Double
|
||||||
@@ -565,257 +574,281 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
|
|
||||||
private fun displaceHitbox() {
|
private fun displaceHitbox() {
|
||||||
|
|
||||||
fun debug1(wut: Any?) {
|
if (world != null) {
|
||||||
// vvvvv set it true to make debug print work
|
|
||||||
if (true) println(wut)
|
fun debug1(wut: Any?) {
|
||||||
}
|
// vvvvv set it true to make debug print work
|
||||||
fun debug2(wut: Any?) {
|
if (true) println(wut)
|
||||||
// vvvvv set it true to make debug print work
|
}
|
||||||
if (false) println(wut)
|
|
||||||
}
|
fun debug2(wut: Any?) {
|
||||||
fun debug3(wut: Any?) {
|
// vvvvv set it true to make debug print work
|
||||||
// vvvvv set it true to make debug print work
|
if (false) println(wut)
|
||||||
if (false) println(wut)
|
}
|
||||||
}
|
|
||||||
fun debug4(wut: Any?) {
|
fun debug3(wut: Any?) {
|
||||||
// vvvvv set it true to make debug print work
|
// vvvvv set it true to make debug print work
|
||||||
if (false) println(wut)
|
if (false) println(wut)
|
||||||
}
|
}
|
||||||
fun Double.modTile() = this.toInt().div(TILE_SIZE).times(TILE_SIZE)
|
|
||||||
fun Double.modTileDelta() = this - this.modTile()
|
fun debug4(wut: Any?) {
|
||||||
|
// vvvvv set it true to make debug print work
|
||||||
|
if (false) println(wut)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Double.modTile() = this.toInt().div(TILE_SIZE).times(TILE_SIZE)
|
||||||
|
fun Double.modTileDelta() = this - this.modTile()
|
||||||
|
|
||||||
|
|
||||||
val vectorSum = externalForce + controllerMoveDelta
|
val vectorSum = externalForce + controllerMoveDelta
|
||||||
val ccdSteps = minOf(16, (vectorSum.magnitudeSquared / TILE_SIZE.sqr()).floorInt() + 1) // adaptive
|
val ccdSteps = minOf(16, (vectorSum.magnitudeSquared / TILE_SIZE.sqr()).floorInt() + 1) // adaptive
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// * NEW idea: wall pushes the actors (ref. SM64 explained by dutch pancake) *
|
// * NEW idea: wall pushes the actors (ref. SM64 explained by dutch pancake) *
|
||||||
// direction to push is determined by the velocity
|
// direction to push is determined by the velocity
|
||||||
// proc:
|
// proc:
|
||||||
// 10 I detect being walled and displace myself
|
// 10 I detect being walled and displace myself
|
||||||
// 11 There's 16 possible case so work all 16 (some can be merged obviously)
|
// 11 There's 16 possible case so work all 16 (some can be merged obviously)
|
||||||
// 12 Amount of displacement can be obtained with modTileDelta()
|
// 12 Amount of displacement can be obtained with modTileDelta()
|
||||||
// 13 isWalled() is confirmed to be working
|
// 13 isWalled() is confirmed to be working
|
||||||
// 20 sixteenStep may be optional, I think, but it'd be good to have
|
// 20 sixteenStep may be optional, I think, but it'd be good to have
|
||||||
|
|
||||||
// ignore MOST of the codes below (it might be possible to recycle the structure??)
|
// ignore MOST of the codes below (it might be possible to recycle the structure??)
|
||||||
|
|
||||||
val sixteenStep = (0..ccdSteps).map { hitbox.clone().translate(vectorSum * (it / ccdSteps.toDouble())) } // zeroth step is for special condition
|
val sixteenStep = (0..ccdSteps).map { hitbox.clone().translate(vectorSum * (it / ccdSteps.toDouble())) } // zeroth step is for special condition
|
||||||
|
|
||||||
val affectingTiles = ArrayList<BlockAddress>()
|
val affectingTiles = ArrayList<BlockAddress>()
|
||||||
var collidingStep: Int? = null
|
var collidingStep: Int? = null
|
||||||
|
|
||||||
for (step in 1..ccdSteps) {
|
for (step in 1..ccdSteps) {
|
||||||
|
|
||||||
val stepBox = sixteenStep[step]
|
val stepBox = sixteenStep[step]
|
||||||
|
|
||||||
forEachOccupyingTilePos(stepBox) {
|
forEachOccupyingTilePos(stepBox) {
|
||||||
val tileCoord = LandUtil.resolveBlockAddr(this.world, it)
|
val tileCoord = LandUtil.resolveBlockAddr(world!!, it)
|
||||||
val tileProp = BlockCodex.getOrNull(world.getTileFromTerrain(tileCoord.first, tileCoord.second))
|
val tileProp = BlockCodex.getOrNull(world!!.getTileFromTerrain(tileCoord.first, tileCoord.second))
|
||||||
|
|
||||||
if (tileProp == null || tileProp.isSolid) {
|
if (tileProp == null || tileProp.isSolid) {
|
||||||
affectingTiles.add(it)
|
affectingTiles.add(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (affectingTiles.isNotEmpty()) {
|
||||||
|
collidingStep = step
|
||||||
|
break // collision found on this step, break and proceed to next step
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (affectingTiles.isNotEmpty()) {
|
|
||||||
collidingStep = step
|
val COLL_LEFTSIDE = 1
|
||||||
break // collision found on this step, break and proceed to next step
|
val COLL_BOTTOMSIDE = 2
|
||||||
|
val COLL_RIGHTSIDE = 4
|
||||||
|
val COLL_TOPSIDE = 8
|
||||||
|
|
||||||
|
var bounceX = false
|
||||||
|
var bounceY = false
|
||||||
|
var zeroX = false
|
||||||
|
var zeroY = false
|
||||||
|
// collision NOT detected
|
||||||
|
if (collidingStep == null) {
|
||||||
|
hitbox.translate(vectorSum)
|
||||||
|
// grounded = false
|
||||||
}
|
}
|
||||||
}
|
// collision detected
|
||||||
|
else {
|
||||||
|
debug1("== Collision step: $collidingStep / $ccdSteps")
|
||||||
|
|
||||||
|
|
||||||
val COLL_LEFTSIDE = 1
|
val newHitbox = hitbox.reassign(sixteenStep[collidingStep])
|
||||||
val COLL_BOTTOMSIDE = 2
|
|
||||||
val COLL_RIGHTSIDE = 4
|
|
||||||
val COLL_TOPSIDE = 8
|
|
||||||
|
|
||||||
var bounceX = false
|
var selfCollisionStatus = 0
|
||||||
var bounceY = false
|
if (isWalled(newHitbox, COLLIDING_LEFT)) selfCollisionStatus += COLL_LEFTSIDE // 1
|
||||||
var zeroX = false
|
if (isWalled(newHitbox, COLLIDING_RIGHT)) selfCollisionStatus += COLL_RIGHTSIDE // 4
|
||||||
var zeroY = false
|
if (isWalled(newHitbox, COLLIDING_TOP)) selfCollisionStatus += COLL_TOPSIDE // 8
|
||||||
// collision NOT detected
|
if (isWalled(newHitbox, COLLIDING_BOTTOM)) selfCollisionStatus += COLL_BOTTOMSIDE // 2
|
||||||
if (collidingStep == null) {
|
|
||||||
hitbox.translate(vectorSum)
|
|
||||||
// grounded = false
|
|
||||||
}
|
|
||||||
// collision detected
|
|
||||||
else {
|
|
||||||
debug1("== Collision step: $collidingStep / $ccdSteps")
|
|
||||||
|
|
||||||
|
// fixme UP and RIGHT && LEFT and DOWN bug
|
||||||
|
|
||||||
val newHitbox = hitbox.reassign(sixteenStep[collidingStep])
|
debug1("Collision type: $selfCollisionStatus")
|
||||||
|
affectingTiles.forEach {
|
||||||
|
val tileCoord = LandUtil.resolveBlockAddr(world!!, it)
|
||||||
|
debug2("affectign tile: ${tileCoord.first}, ${tileCoord.second}")
|
||||||
|
}
|
||||||
|
|
||||||
var selfCollisionStatus = 0
|
when (selfCollisionStatus) {
|
||||||
if (isWalled(newHitbox, COLLIDING_LEFT)) selfCollisionStatus += COLL_LEFTSIDE // 1
|
0 -> {
|
||||||
if (isWalled(newHitbox, COLLIDING_RIGHT)) selfCollisionStatus += COLL_RIGHTSIDE // 4
|
debug1("[ActorWBMovable] Contradiction -- collision detected by CCD, but isWalled() says otherwise")
|
||||||
if (isWalled(newHitbox, COLLIDING_TOP)) selfCollisionStatus += COLL_TOPSIDE // 8
|
}
|
||||||
if (isWalled(newHitbox, COLLIDING_BOTTOM)) selfCollisionStatus += COLL_BOTTOMSIDE // 2
|
5 -> {
|
||||||
|
zeroX = true
|
||||||
// fixme UP and RIGHT && LEFT and DOWN bug
|
}
|
||||||
|
10 -> {
|
||||||
debug1("Collision type: $selfCollisionStatus")
|
zeroY = true
|
||||||
affectingTiles.forEach {
|
}
|
||||||
val tileCoord = LandUtil.resolveBlockAddr(this.world, it)
|
15 -> {
|
||||||
debug2("affectign tile: ${tileCoord.first}, ${tileCoord.second}")
|
newHitbox.reassign(sixteenStep[0]); zeroX = true; zeroY = true
|
||||||
}
|
}
|
||||||
|
|
||||||
when (selfCollisionStatus) {
|
|
||||||
0 -> { debug1("[ActorWBMovable] Contradiction -- collision detected by CCD, but isWalled() says otherwise") }
|
|
||||||
5 -> { zeroX = true }
|
|
||||||
10 -> { zeroY = true }
|
|
||||||
15 -> { newHitbox.reassign(sixteenStep[0]); zeroX = true; zeroY = true }
|
|
||||||
// one-side collision
|
// one-side collision
|
||||||
1, 11 -> { newHitbox.translatePosX(TILE_SIZE - newHitbox.startX.modTileDelta()); bounceX = true }
|
1, 11 -> {
|
||||||
4, 14 -> { newHitbox.translatePosX( - newHitbox.endX.modTileDelta()) ; bounceX = true }
|
newHitbox.translatePosX(TILE_SIZE - newHitbox.startX.modTileDelta()); bounceX = true
|
||||||
8, 13 -> { newHitbox.translatePosY(TILE_SIZE - newHitbox.startY.modTileDelta()); bounceY = true }
|
}
|
||||||
2, 7 -> { newHitbox.translatePosY( - newHitbox.endY.modTileDelta()) ; bounceY = true }
|
4, 14 -> {
|
||||||
}
|
newHitbox.translatePosX(-newHitbox.endX.modTileDelta()); bounceX = true
|
||||||
|
}
|
||||||
|
8, 13 -> {
|
||||||
|
newHitbox.translatePosY(TILE_SIZE - newHitbox.startY.modTileDelta()); bounceY = true
|
||||||
|
}
|
||||||
|
2, 7 -> {
|
||||||
|
newHitbox.translatePosY(-newHitbox.endY.modTileDelta()); bounceY = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// fire Collision Event with one/two/three-side collision
|
// fire Collision Event with one/two/three-side collision
|
||||||
// for the ease of writing, this jumptable is separated from above.
|
// for the ease of writing, this jumptable is separated from above.
|
||||||
when (selfCollisionStatus) {
|
when (selfCollisionStatus) {
|
||||||
// TODO compose CollisionInfo and fire collided()
|
// TODO compose CollisionInfo and fire collided()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// two-side collision
|
// two-side collision
|
||||||
if (selfCollisionStatus in listOf(3,6,9,12)) {
|
if (selfCollisionStatus in listOf(3, 6, 9, 12)) {
|
||||||
debug1("twoside collision $selfCollisionStatus")
|
debug1("twoside collision $selfCollisionStatus")
|
||||||
|
|
||||||
// !! this code is based on Dyn4j Vector's coord system; V(1,0) -> 0, V(0,1) -> pi, V(0,-1) -> -pi !! //
|
// !! this code is based on Dyn4j Vector's coord system; V(1,0) -> 0, V(0,1) -> pi, V(0,-1) -> -pi !! //
|
||||||
|
|
||||||
// we can use selfCollisionStatus to tell which of those four side we care
|
// we can use selfCollisionStatus to tell which of those four side we care
|
||||||
|
|
||||||
// points to the EDGE of the tile in world dimension (don't use this directly to get tilewise coord!!)
|
// points to the EDGE of the tile in world dimension (don't use this directly to get tilewise coord!!)
|
||||||
val offendingTileWorldX = if (selfCollisionStatus in listOf(6, 12))
|
val offendingTileWorldX = if (selfCollisionStatus in listOf(6, 12))
|
||||||
newHitbox.endX.div(TILE_SIZE).floor() * TILE_SIZE - 0.00001
|
newHitbox.endX.div(TILE_SIZE).floor() * TILE_SIZE - 0.00001
|
||||||
else
|
else
|
||||||
newHitbox.startX.div(TILE_SIZE).ceil() * TILE_SIZE
|
newHitbox.startX.div(TILE_SIZE).ceil() * TILE_SIZE
|
||||||
|
|
||||||
// points to the EDGE of the tile in world dimension (don't use this directly to get tilewise coord!!)
|
// points to the EDGE of the tile in world dimension (don't use this directly to get tilewise coord!!)
|
||||||
val offendingTileWorldY = if (selfCollisionStatus in listOf(3, 6))
|
val offendingTileWorldY = if (selfCollisionStatus in listOf(3, 6))
|
||||||
newHitbox.endY.div(TILE_SIZE).floor() * TILE_SIZE - 0.00001
|
newHitbox.endY.div(TILE_SIZE).floor() * TILE_SIZE - 0.00001
|
||||||
else
|
else
|
||||||
newHitbox.startY.div(TILE_SIZE).ceil() * TILE_SIZE
|
newHitbox.startY.div(TILE_SIZE).ceil() * TILE_SIZE
|
||||||
|
|
||||||
val offendingHitboxPointX = if (selfCollisionStatus in listOf(6, 12))
|
val offendingHitboxPointX = if (selfCollisionStatus in listOf(6, 12))
|
||||||
newHitbox.endX
|
newHitbox.endX
|
||||||
else
|
else
|
||||||
newHitbox.startX
|
newHitbox.startX
|
||||||
|
|
||||||
val offendingHitboxPointY = if (selfCollisionStatus in listOf(3, 6))
|
val offendingHitboxPointY = if (selfCollisionStatus in listOf(3, 6))
|
||||||
newHitbox.endY
|
newHitbox.endY
|
||||||
else
|
else
|
||||||
newHitbox.startY
|
newHitbox.startY
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val angleOfIncidence =
|
val angleOfIncidence =
|
||||||
if (selfCollisionStatus in listOf(3, 9))
|
if (selfCollisionStatus in listOf(3, 9))
|
||||||
vectorSum.direction.toPositiveRad()
|
vectorSum.direction.toPositiveRad()
|
||||||
else
|
else
|
||||||
vectorSum.direction
|
vectorSum.direction
|
||||||
|
|
||||||
val angleThreshold =
|
val angleThreshold =
|
||||||
if (selfCollisionStatus in listOf(3, 9))
|
if (selfCollisionStatus in listOf(3, 9))
|
||||||
(Vector2(offendingHitboxPointX, offendingHitboxPointY) -
|
(Vector2(offendingHitboxPointX, offendingHitboxPointY) -
|
||||||
Vector2(offendingTileWorldX, offendingTileWorldY)).direction.toPositiveRad()
|
Vector2(offendingTileWorldX, offendingTileWorldY)).direction.toPositiveRad()
|
||||||
else
|
else
|
||||||
(Vector2(offendingHitboxPointX, offendingHitboxPointY) -
|
(Vector2(offendingHitboxPointX, offendingHitboxPointY) -
|
||||||
Vector2(offendingTileWorldX, offendingTileWorldY)).direction
|
Vector2(offendingTileWorldX, offendingTileWorldY)).direction
|
||||||
|
|
||||||
|
|
||||||
debug1("vectorSum: $vectorSum, vectorDirRaw: ${vectorSum.direction / Math.PI}pi")
|
debug1("vectorSum: $vectorSum, vectorDirRaw: ${vectorSum.direction / Math.PI}pi")
|
||||||
debug1("incidentAngle: ${angleOfIncidence / Math.PI}pi, threshold: ${angleThreshold / Math.PI}pi")
|
debug1("incidentAngle: ${angleOfIncidence / Math.PI}pi, threshold: ${angleThreshold / Math.PI}pi")
|
||||||
|
|
||||||
|
|
||||||
val displacementAbs = Vector2(
|
val displacementAbs = Vector2(
|
||||||
(offendingTileWorldX - offendingHitboxPointX).abs(),
|
(offendingTileWorldX - offendingHitboxPointX).abs(),
|
||||||
(offendingTileWorldY - offendingHitboxPointY).abs()
|
(offendingTileWorldY - offendingHitboxPointY).abs()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
// FIXME jump-thru-ceil bug on 1px-wide (the edge), case-9 collision (does not occur on case-12 coll.)
|
// FIXME jump-thru-ceil bug on 1px-wide (the edge), case-9 collision (does not occur on case-12 coll.)
|
||||||
|
|
||||||
|
|
||||||
val displacementUnitVector =
|
val displacementUnitVector =
|
||||||
if (angleOfIncidence == angleThreshold)
|
if (angleOfIncidence == angleThreshold)
|
||||||
-vectorSum
|
-vectorSum
|
||||||
else {
|
else {
|
||||||
when (selfCollisionStatus) {
|
when (selfCollisionStatus) {
|
||||||
3 -> if (angleOfIncidence > angleThreshold) Vector2(1.0, 0.0) else Vector2(0.0, -1.0)
|
3 -> if (angleOfIncidence > angleThreshold) Vector2(1.0, 0.0) else Vector2(0.0, -1.0)
|
||||||
6 -> if (angleOfIncidence > angleThreshold) Vector2(0.0, -1.0) else Vector2(-1.0, 0.0)
|
6 -> if (angleOfIncidence > angleThreshold) Vector2(0.0, -1.0) else Vector2(-1.0, 0.0)
|
||||||
9 -> if (angleOfIncidence > angleThreshold) Vector2(0.0, 1.0) else Vector2(1.0, 0.0)
|
9 -> if (angleOfIncidence > angleThreshold) Vector2(0.0, 1.0) else Vector2(1.0, 0.0)
|
||||||
12 -> if (angleOfIncidence > angleThreshold) Vector2(-1.0, 0.0) else Vector2(0.0, 1.0)
|
12 -> if (angleOfIncidence > angleThreshold) Vector2(-1.0, 0.0) else Vector2(0.0, 1.0)
|
||||||
else -> throw InternalError("Blame hardware or universe")
|
else -> throw InternalError("Blame hardware or universe")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
val finalDisplacement =
|
val finalDisplacement =
|
||||||
if (angleOfIncidence == angleThreshold)
|
if (angleOfIncidence == angleThreshold)
|
||||||
displacementUnitVector
|
displacementUnitVector
|
||||||
else
|
else
|
||||||
Vector2(
|
Vector2(
|
||||||
displacementAbs.x * displacementUnitVector.x,
|
displacementAbs.x * displacementUnitVector.x,
|
||||||
displacementAbs.y * displacementUnitVector.y
|
displacementAbs.y * displacementUnitVector.y
|
||||||
)
|
)
|
||||||
|
|
||||||
newHitbox.translate(finalDisplacement)
|
newHitbox.translate(finalDisplacement)
|
||||||
|
|
||||||
|
|
||||||
debug1("displacement: $finalDisplacement")
|
debug1("displacement: $finalDisplacement")
|
||||||
|
|
||||||
|
|
||||||
// TODO: translate other axis proportionally to the incident vector
|
// TODO: translate other axis proportionally to the incident vector
|
||||||
|
|
||||||
bounceX = angleOfIncidence == angleThreshold || displacementUnitVector.x != 0.0
|
bounceX = angleOfIncidence == angleThreshold || displacementUnitVector.x != 0.0
|
||||||
bounceY = angleOfIncidence == angleThreshold || displacementUnitVector.y != 0.0
|
bounceY = angleOfIncidence == angleThreshold || displacementUnitVector.y != 0.0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// bounce X/Y
|
// bounce X/Y
|
||||||
if (bounceX) {
|
if (bounceX) {
|
||||||
externalForce.x *= elasticity
|
externalForce.x *= elasticity
|
||||||
controllerMoveDelta?.let { controllerMoveDelta!!.x *= elasticity }
|
controllerMoveDelta?.let { controllerMoveDelta!!.x *= elasticity }
|
||||||
}
|
}
|
||||||
if (bounceY) {
|
if (bounceY) {
|
||||||
externalForce.y *= elasticity
|
externalForce.y *= elasticity
|
||||||
controllerMoveDelta?.let { controllerMoveDelta!!.y *= elasticity }
|
controllerMoveDelta?.let { controllerMoveDelta!!.y *= elasticity }
|
||||||
}
|
}
|
||||||
if (zeroX) {
|
if (zeroX) {
|
||||||
externalForce.x = 0.0
|
externalForce.x = 0.0
|
||||||
controllerMoveDelta?.let { controllerMoveDelta!!.x = 0.0 }
|
controllerMoveDelta?.let { controllerMoveDelta!!.x = 0.0 }
|
||||||
}
|
}
|
||||||
if (zeroY) {
|
if (zeroY) {
|
||||||
externalForce.y = 0.0
|
externalForce.y = 0.0
|
||||||
controllerMoveDelta?.let { controllerMoveDelta!!.y = 0.0 }
|
controllerMoveDelta?.let { controllerMoveDelta!!.y = 0.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hitbox.reassign(newHitbox)
|
hitbox.reassign(newHitbox)
|
||||||
|
|
||||||
|
|
||||||
// slam-into-whatever damage (such dirty; much hack; wow)
|
// slam-into-whatever damage (such dirty; much hack; wow)
|
||||||
// vvvv hack (supposed to be 1.0) vvv 50% hack
|
// vvvv hack (supposed to be 1.0) vvv 50% hack
|
||||||
val collisionDamage = mass * (vectorSum.magnitude / (10.0 / Terrarum.TARGET_FPS).sqr()) / fallDamageDampening.sqr() * GAME_TO_SI_ACC
|
val collisionDamage = mass * (vectorSum.magnitude / (10.0 / Terrarum.TARGET_FPS).sqr()) / fallDamageDampening.sqr() * GAME_TO_SI_ACC
|
||||||
// kg * m / s^2 (mass * acceleration), acceleration -> (vectorMagn / (0.01)^2).gameToSI()
|
// kg * m / s^2 (mass * acceleration), acceleration -> (vectorMagn / (0.01)^2).gameToSI()
|
||||||
if (collisionDamage != 0.0) debug1("Collision damage: $collisionDamage N")
|
if (collisionDamage != 0.0) debug1("Collision damage: $collisionDamage N")
|
||||||
// FIXME instead of 0.5mv^2, we can model after "change of velocity (aka accel)", just as in real-life; big change of accel on given unit time is what kills
|
// FIXME instead of 0.5mv^2, we can model after "change of velocity (aka accel)", just as in real-life; big change of accel on given unit time is what kills
|
||||||
|
|
||||||
|
|
||||||
// grounded = true
|
// grounded = true
|
||||||
}// end of collision not detected
|
}// end of collision not detected
|
||||||
|
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// if collision not detected, just don't care; it's not your job to apply moveDelta
|
// if collision not detected, just don't care; it's not your job to apply moveDelta
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -909,9 +942,11 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun isCollidingInternal(txStart: Int, tyStart: Int, txEnd: Int, tyEnd: Int): Boolean {
|
private fun isCollidingInternal(txStart: Int, tyStart: Int, txEnd: Int, tyEnd: Int): Boolean {
|
||||||
|
if (world == null) return false
|
||||||
|
|
||||||
for (y in tyStart..tyEnd) {
|
for (y in tyStart..tyEnd) {
|
||||||
for (x in txStart..txEnd) {
|
for (x in txStart..txEnd) {
|
||||||
val tile = world.getTileFromTerrain(x, y)
|
val tile = world!!.getTileFromTerrain(x, y)
|
||||||
if (BlockCodex[tile].isSolid)
|
if (BlockCodex[tile].isSolid)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@@ -921,6 +956,8 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
||||||
|
if (world == null) return 0
|
||||||
|
|
||||||
var contactAreaCounter = 0
|
var contactAreaCounter = 0
|
||||||
for (i in 0..(if (side % 2 == 0) hitbox.width else hitbox.height).roundInt() - 1) {
|
for (i in 0..(if (side % 2 == 0) hitbox.width else hitbox.height).roundInt() - 1) {
|
||||||
// set tile positions
|
// set tile positions
|
||||||
@@ -951,7 +988,7 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
// evaluate
|
// evaluate
|
||||||
if (BlockCodex[world.getTileFromTerrain(tileX, tileY)].isFluid) {
|
if (BlockCodex[world!!.getTileFromTerrain(tileX, tileY)].isFluid) {
|
||||||
contactAreaCounter += 1
|
contactAreaCounter += 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1166,7 +1203,10 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun clampHitbox() {
|
private fun clampHitbox() {
|
||||||
val worldsizePxl = world.width.times(TILE_SIZE)
|
if (world == null) return
|
||||||
|
|
||||||
|
|
||||||
|
val worldsizePxl = world!!.width.times(TILE_SIZE)
|
||||||
|
|
||||||
// DEAR FUTURE ME,
|
// DEAR FUTURE ME,
|
||||||
//
|
//
|
||||||
@@ -1223,7 +1263,10 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun drawSpriteInGoodPosition(sprite: SpriteAnimation, batch: SpriteBatch) {
|
private fun drawSpriteInGoodPosition(sprite: SpriteAnimation, batch: SpriteBatch) {
|
||||||
val leftsidePadding = world.width.times(TILE_SIZE) - WorldCamera.width.ushr(1)
|
if (world == null) return
|
||||||
|
|
||||||
|
|
||||||
|
val leftsidePadding = world!!.width.times(TILE_SIZE) - WorldCamera.width.ushr(1)
|
||||||
val rightsidePadding = WorldCamera.width.ushr(1)
|
val rightsidePadding = WorldCamera.width.ushr(1)
|
||||||
|
|
||||||
val offsetX = hitboxTranslateX * scale
|
val offsetX = hitboxTranslateX * scale
|
||||||
@@ -1233,7 +1276,7 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
if (WorldCamera.xCentre > leftsidePadding && centrePosPoint.x <= rightsidePadding) {
|
if (WorldCamera.xCentre > leftsidePadding && centrePosPoint.x <= rightsidePadding) {
|
||||||
// camera center neg, actor center pos
|
// camera center neg, actor center pos
|
||||||
sprite.render(batch,
|
sprite.render(batch,
|
||||||
(hitbox.startX - offsetX).toFloat() + world.width * TILE_SIZE,
|
(hitbox.startX - offsetX).toFloat() + world!!.width * TILE_SIZE,
|
||||||
(hitbox.startY - offsetY).toFloat(),
|
(hitbox.startY - offsetY).toFloat(),
|
||||||
(scale).toFloat()
|
(scale).toFloat()
|
||||||
)
|
)
|
||||||
@@ -1241,7 +1284,7 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
else if (WorldCamera.xCentre < rightsidePadding && centrePosPoint.x >= leftsidePadding) {
|
else if (WorldCamera.xCentre < rightsidePadding && centrePosPoint.x >= leftsidePadding) {
|
||||||
// camera center pos, actor center neg
|
// camera center pos, actor center neg
|
||||||
sprite.render(batch,
|
sprite.render(batch,
|
||||||
(hitbox.startX - offsetX).toFloat() - world.width * TILE_SIZE,
|
(hitbox.startX - offsetX).toFloat() - world!!.width * TILE_SIZE,
|
||||||
(hitbox.startY - offsetY).toFloat(),
|
(hitbox.startY - offsetY).toFloat(),
|
||||||
(scale).toFloat()
|
(scale).toFloat()
|
||||||
)
|
)
|
||||||
@@ -1263,32 +1306,34 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
|
|
||||||
|
|
||||||
private fun clampW(x: Double): Double =
|
private fun clampW(x: Double): Double =
|
||||||
if (x < TILE_SIZE + hitbox.width / 2) {
|
if (world == null) x
|
||||||
|
else if (x < TILE_SIZE + hitbox.width / 2) {
|
||||||
TILE_SIZE + hitbox.width / 2
|
TILE_SIZE + hitbox.width / 2
|
||||||
}
|
}
|
||||||
else if (x >= (world.width * TILE_SIZE).toDouble() - TILE_SIZE.toDouble() - hitbox.width / 2) {
|
else if (x >= (world!!.width * TILE_SIZE).toDouble() - TILE_SIZE.toDouble() - hitbox.width / 2) {
|
||||||
(world.width * TILE_SIZE).toDouble() - 1.0 - TILE_SIZE.toDouble() - hitbox.width / 2
|
(world!!.width * TILE_SIZE).toDouble() - 1.0 - TILE_SIZE.toDouble() - hitbox.width / 2
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
x
|
x
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clampH(y: Double): Double =
|
private fun clampH(y: Double): Double =
|
||||||
if (y < TILE_SIZE + hitbox.height) {
|
if (world == null) y
|
||||||
|
else if (y < TILE_SIZE + hitbox.height) {
|
||||||
TILE_SIZE + hitbox.height
|
TILE_SIZE + hitbox.height
|
||||||
}
|
}
|
||||||
else if (y >= (world.height * TILE_SIZE).toDouble() - TILE_SIZE.toDouble() - hitbox.height) {
|
else if (y >= (world!!.height * TILE_SIZE).toDouble() - TILE_SIZE.toDouble() - hitbox.height) {
|
||||||
(world.height * TILE_SIZE).toDouble() - 1.0 - TILE_SIZE.toDouble() - hitbox.height
|
(world!!.height * TILE_SIZE).toDouble() - 1.0 - TILE_SIZE.toDouble() - hitbox.height
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
y
|
y
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clampWtile(x: Int): Int =
|
private fun clampWtile(x: Int): Int =
|
||||||
if (x < 0) 0 else if (x >= world.width) world.width - 1 else x
|
if (x < 0) 0 else if (x >= world?.width ?: 0) (world?.width ?: 0) - 1 else x
|
||||||
|
|
||||||
private fun clampHtile(x: Int): Int =
|
private fun clampHtile(x: Int): Int =
|
||||||
if (x < 0) 0 else if (x >= world.height) world.height - 1 else x
|
if (x < 0) 0 else if (x >= world?.height ?: 0) (world?.height ?: 0) - 1 else x
|
||||||
|
|
||||||
|
|
||||||
var isNoClip: Boolean = false
|
var isNoClip: Boolean = false
|
||||||
@@ -1324,10 +1369,13 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
|
|
||||||
|
|
||||||
private fun forEachOccupyingTileNum(consumer: (Int?) -> Unit) {
|
private fun forEachOccupyingTileNum(consumer: (Int?) -> Unit) {
|
||||||
|
if (world == null) return
|
||||||
|
|
||||||
|
|
||||||
val tiles = ArrayList<Int?>()
|
val tiles = ArrayList<Int?>()
|
||||||
for (y in hIntTilewiseHitbox.startY.toInt()..hIntTilewiseHitbox.endY.toInt()) {
|
for (y in hIntTilewiseHitbox.startY.toInt()..hIntTilewiseHitbox.endY.toInt()) {
|
||||||
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
||||||
tiles.add(world.getTileFromTerrain(x, y))
|
tiles.add(world!!.getTileFromTerrain(x, y))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1335,10 +1383,13 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun forEachOccupyingTile(consumer: (BlockProp?) -> Unit) {
|
private fun forEachOccupyingTile(consumer: (BlockProp?) -> Unit) {
|
||||||
|
if (world == null) return
|
||||||
|
|
||||||
|
|
||||||
val tileProps = ArrayList<BlockProp?>()
|
val tileProps = ArrayList<BlockProp?>()
|
||||||
for (y in hIntTilewiseHitbox.startY.toInt()..hIntTilewiseHitbox.endY.toInt()) {
|
for (y in hIntTilewiseHitbox.startY.toInt()..hIntTilewiseHitbox.endY.toInt()) {
|
||||||
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
||||||
tileProps.add(BlockCodex[world.getTileFromTerrain(x, y)])
|
tileProps.add(BlockCodex[world!!.getTileFromTerrain(x, y)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1346,6 +1397,9 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun forEachOccupyingTilePos(hitbox: Hitbox, consumer: (BlockAddress) -> Unit) {
|
private fun forEachOccupyingTilePos(hitbox: Hitbox, consumer: (BlockAddress) -> Unit) {
|
||||||
|
if (world == null) return
|
||||||
|
|
||||||
|
|
||||||
val newTilewiseHitbox = Hitbox.fromTwoPoints(
|
val newTilewiseHitbox = Hitbox.fromTwoPoints(
|
||||||
hitbox.startX.div(TILE_SIZE).floor(),
|
hitbox.startX.div(TILE_SIZE).floor(),
|
||||||
hitbox.startY.div(TILE_SIZE).floor(),
|
hitbox.startY.div(TILE_SIZE).floor(),
|
||||||
@@ -1356,7 +1410,7 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
val tilePosList = ArrayList<BlockAddress>()
|
val tilePosList = ArrayList<BlockAddress>()
|
||||||
for (y in newTilewiseHitbox.startY.toInt()..newTilewiseHitbox.endY.toInt()) {
|
for (y in newTilewiseHitbox.startY.toInt()..newTilewiseHitbox.endY.toInt()) {
|
||||||
for (x in newTilewiseHitbox.startX.toInt()..newTilewiseHitbox.endX.toInt()) {
|
for (x in newTilewiseHitbox.startX.toInt()..newTilewiseHitbox.endX.toInt()) {
|
||||||
tilePosList.add(LandUtil.getBlockAddr(this.world, x, y))
|
tilePosList.add(LandUtil.getBlockAddr(world!!, x, y))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1364,26 +1418,32 @@ open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val im
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun forEachFeetTileNum(consumer: (Int?) -> Unit) {
|
private fun forEachFeetTileNum(consumer: (Int?) -> Unit) {
|
||||||
|
if (world == null) return
|
||||||
|
|
||||||
|
|
||||||
val tiles = ArrayList<Int?>()
|
val tiles = ArrayList<Int?>()
|
||||||
|
|
||||||
// offset 1 pixel to the down so that friction would work
|
// offset 1 pixel to the down so that friction would work
|
||||||
val y = hitbox.endY.plus(1.0).div(TILE_SIZE).floorInt()
|
val y = hitbox.endY.plus(1.0).div(TILE_SIZE).floorInt()
|
||||||
|
|
||||||
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
||||||
tiles.add(world.getTileFromTerrain(x, y))
|
tiles.add(world!!.getTileFromTerrain(x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
return tiles.forEach(consumer)
|
return tiles.forEach(consumer)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun forEachFeetTile(consumer: (BlockProp?) -> Unit) {
|
private fun forEachFeetTile(consumer: (BlockProp?) -> Unit) {
|
||||||
|
if (world == null) return
|
||||||
|
|
||||||
|
|
||||||
val tileProps = ArrayList<BlockProp?>()
|
val tileProps = ArrayList<BlockProp?>()
|
||||||
|
|
||||||
// offset 1 pixel to the down so that friction would work
|
// offset 1 pixel to the down so that friction would work
|
||||||
val y = hitbox.endY.plus(1.0).div(TILE_SIZE).floorInt()
|
val y = hitbox.endY.plus(1.0).div(TILE_SIZE).floorInt()
|
||||||
|
|
||||||
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
for (x in hIntTilewiseHitbox.startX.toInt()..hIntTilewiseHitbox.endX.toInt()) {
|
||||||
tileProps.add(BlockCodex[world.getTileFromTerrain(x, y)])
|
tileProps.add(BlockCodex[world!!.getTileFromTerrain(x, y)])
|
||||||
}
|
}
|
||||||
|
|
||||||
return tileProps.forEach(consumer)
|
return tileProps.forEach(consumer)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ open class GameWorld {
|
|||||||
//public World physWorld = new World( new Vec2(0, -Terrarum.game.gravitationalAccel) );
|
//public World physWorld = new World( new Vec2(0, -Terrarum.game.gravitationalAccel) );
|
||||||
//physics
|
//physics
|
||||||
/** Meter per second squared. Currently only the downward gravity is supported. No reverse gravity :p */
|
/** Meter per second squared. Currently only the downward gravity is supported. No reverse gravity :p */
|
||||||
var gravitation: Vector2 = Vector2(0.0, 9.8)
|
var gravitation: Vector2 = Vector2(0.0, 9.80665)
|
||||||
/** 0.0..1.0+ */
|
/** 0.0..1.0+ */
|
||||||
var globalLight = Color(0f,0f,0f,0f)
|
var globalLight = Color(0f,0f,0f,0f)
|
||||||
var averageTemperature = 288f // 15 deg celsius; simulates global warming
|
var averageTemperature = 288f // 15 deg celsius; simulates global warming
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import net.torvald.terrarum.IngameInstance
|
|||||||
import net.torvald.terrarum.Terrarum
|
import net.torvald.terrarum.Terrarum
|
||||||
import net.torvald.terrarum.blockproperties.Block
|
import net.torvald.terrarum.blockproperties.Block
|
||||||
import net.torvald.terrarum.gameactors.*
|
import net.torvald.terrarum.gameactors.*
|
||||||
import net.torvald.terrarum.gameworld.GameWorld
|
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
import net.torvald.terrarum.modulebasegame.ui.Notification
|
import net.torvald.terrarum.modulebasegame.ui.Notification
|
||||||
@@ -46,7 +45,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override var actorNowPlaying: ActorHumanoid? = MovableWorldCamera(world)
|
override var actorNowPlaying: ActorHumanoid? = MovableWorldCamera()
|
||||||
|
|
||||||
val uiToolbox = UIBuildingMakerToolbox()
|
val uiToolbox = UIBuildingMakerToolbox()
|
||||||
val notifier = Notification()
|
val notifier = Notification()
|
||||||
@@ -170,7 +169,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class MovableWorldCamera(world: GameWorld) : ActorHumanoid(world, 0, usePhysics = false) {
|
class MovableWorldCamera : ActorHumanoid(0, usePhysics = false) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
referenceID = Terrarum.PLAYER_REF_ID
|
referenceID = Terrarum.PLAYER_REF_ID
|
||||||
|
|||||||
@@ -523,10 +523,9 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
|||||||
BlockPropUtil.dynamicLumFuncTickClock()
|
BlockPropUtil.dynamicLumFuncTickClock()
|
||||||
world.updateWorldTime(delta)
|
world.updateWorldTime(delta)
|
||||||
//WorldSimulator(player, delta)
|
//WorldSimulator(player, delta)
|
||||||
WeatherMixer.update(delta, actorNowPlaying)
|
WeatherMixer.update(delta, actorNowPlaying, world)
|
||||||
BlockStats.update()
|
BlockStats.update()
|
||||||
if (!(CommandDict["setgl"] as SetGlobalLightOverride).lightOverride)
|
|
||||||
gameworld.globalLight = WeatherMixer.globalLightNow
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////
|
////////////////////////////
|
||||||
|
|||||||
@@ -74,7 +74,12 @@ object IngameRenderer {
|
|||||||
uiListToDraw = uisToDraw
|
uiListToDraw = uisToDraw
|
||||||
}
|
}
|
||||||
|
|
||||||
init(world)
|
init()
|
||||||
|
|
||||||
|
BlocksDrawer.world = world
|
||||||
|
LightmapRenderer.setWorld(world)
|
||||||
|
FeaturesDrawer.world = world
|
||||||
|
|
||||||
this.player = player
|
this.player = player
|
||||||
|
|
||||||
|
|
||||||
@@ -389,7 +394,7 @@ object IngameRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun init(world: GameWorldExtension) {
|
private fun init() {
|
||||||
if (!initDone) {
|
if (!initDone) {
|
||||||
batch = SpriteBatch()
|
batch = SpriteBatch()
|
||||||
camera = OrthographicCamera(widthf, heightf)
|
camera = OrthographicCamera(widthf, heightf)
|
||||||
@@ -402,11 +407,6 @@ object IngameRenderer {
|
|||||||
|
|
||||||
initDone = true
|
initDone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BlocksDrawer.world = world
|
|
||||||
LightmapRenderer.setWorld(world)
|
|
||||||
FeaturesDrawer.world = world
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun clearBuffer() {
|
private fun clearBuffer() {
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ object ImportLayerData : ConsoleCommand {
|
|||||||
(Terrarum.ingame!!.world).spawnX * FeaturesDrawer.TILE_SIZE.toDouble()
|
(Terrarum.ingame!!.world).spawnX * FeaturesDrawer.TILE_SIZE.toDouble()
|
||||||
)
|
)
|
||||||
|
|
||||||
IngameRenderer.
|
|
||||||
|
|
||||||
Echo("Successfully loaded ${args[1]}")
|
Echo("Successfully loaded ${args[1]}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,9 +13,6 @@ import org.dyn4j.geometry.Vector2
|
|||||||
internal object SpawnPhysTestBall : ConsoleCommand {
|
internal object SpawnPhysTestBall : ConsoleCommand {
|
||||||
@Throws(Exception::class)
|
@Throws(Exception::class)
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val world = (Terrarum.ingame!!.world)
|
|
||||||
|
|
||||||
|
|
||||||
val mouseX = Terrarum.mouseX
|
val mouseX = Terrarum.mouseX
|
||||||
val mouseY = Terrarum.mouseY
|
val mouseY = Terrarum.mouseY
|
||||||
|
|
||||||
@@ -25,7 +22,7 @@ internal object SpawnPhysTestBall : ConsoleCommand {
|
|||||||
val xvel = args[2].toDouble()
|
val xvel = args[2].toDouble()
|
||||||
val yvel = if (args.size >= 4) args[3].toDouble() else 0.0
|
val yvel = if (args.size >= 4) args[3].toDouble() else 0.0
|
||||||
|
|
||||||
val ball = PhysTestBall(world)
|
val ball = PhysTestBall()
|
||||||
ball.setPosition(mouseX, mouseY)
|
ball.setPosition(mouseX, mouseY)
|
||||||
ball.elasticity = elasticity
|
ball.elasticity = elasticity
|
||||||
ball.applyForce(Vector2(xvel, yvel))
|
ball.applyForce(Vector2(xvel, yvel))
|
||||||
@@ -35,7 +32,7 @@ internal object SpawnPhysTestBall : ConsoleCommand {
|
|||||||
else if (args.size == 2) {
|
else if (args.size == 2) {
|
||||||
val elasticity = args[1].toDouble()
|
val elasticity = args[1].toDouble()
|
||||||
|
|
||||||
val ball = PhysTestBall(world)
|
val ball = PhysTestBall()
|
||||||
ball.setPosition(mouseX, mouseY)
|
ball.setPosition(mouseX, mouseY)
|
||||||
ball.elasticity = elasticity
|
ball.elasticity = elasticity
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ internal object SpawnPhysTestLunarLander : ConsoleCommand {
|
|||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val mouseX = Terrarum.mouseX
|
val mouseX = Terrarum.mouseX
|
||||||
val mouseY = Terrarum.mouseY
|
val mouseY = Terrarum.mouseY
|
||||||
val lander = PhysTestLuarLander((Terrarum.ingame!!.world))
|
val lander = PhysTestLuarLander()
|
||||||
|
|
||||||
lander.setPosition(mouseX, mouseY)
|
lander.setPosition(mouseX, mouseY)
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
|||||||
*/
|
*/
|
||||||
internal object SpawnTikiTorch : ConsoleCommand {
|
internal object SpawnTikiTorch : ConsoleCommand {
|
||||||
override fun execute(args: Array<String>) {
|
override fun execute(args: Array<String>) {
|
||||||
val torch = FixtureTikiTorch((Terrarum.ingame!!.world))
|
val torch = FixtureTikiTorch()
|
||||||
torch.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
torch.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||||
|
|
||||||
Terrarum.ingame!!.addNewActor(torch)
|
Terrarum.ingame!!.addNewActor(torch)
|
||||||
|
|||||||
@@ -25,12 +25,13 @@ import java.util.*
|
|||||||
* Created by minjaesong on 2016-10-24.
|
* Created by minjaesong on 2016-10-24.
|
||||||
*/
|
*/
|
||||||
open class ActorHumanoid(
|
open class ActorHumanoid(
|
||||||
world: GameWorld,
|
|
||||||
birth: time_t,
|
birth: time_t,
|
||||||
death: time_t? = null,
|
death: time_t? = null,
|
||||||
usePhysics: Boolean = true
|
usePhysics: Boolean = true
|
||||||
) : ActorWBMovable(world, RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
) : ActorWBMovable(RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
||||||
|
|
||||||
|
private val world: GameWorld?
|
||||||
|
get() = Terrarum.ingame?.world
|
||||||
|
|
||||||
|
|
||||||
var vehicleRiding: Controllable? = null // usually player only
|
var vehicleRiding: Controllable? = null // usually player only
|
||||||
@@ -50,11 +51,11 @@ open class ActorHumanoid(
|
|||||||
override var houseDesignation: ArrayList<Long>? = ArrayList()
|
override var houseDesignation: ArrayList<Long>? = ArrayList()
|
||||||
|
|
||||||
override fun addHouseTile(x: Int, y: Int) {
|
override fun addHouseTile(x: Int, y: Int) {
|
||||||
if (houseDesignation != null) houseDesignation!!.add(LandUtil.getBlockAddr(world, x, y))
|
if (houseDesignation != null) houseDesignation!!.add(LandUtil.getBlockAddr(world!!, x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun removeHouseTile(x: Int, y: Int) {
|
override fun removeHouseTile(x: Int, y: Int) {
|
||||||
if (houseDesignation != null) houseDesignation!!.remove(LandUtil.getBlockAddr(world, x, y))
|
if (houseDesignation != null) houseDesignation!!.remove(LandUtil.getBlockAddr(world!!, x, y))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun clearHouseDesignation() {
|
override fun clearHouseDesignation() {
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ object CreatureBuilder {
|
|||||||
/**
|
/**
|
||||||
* @Param jsonFileName with extension
|
* @Param jsonFileName with extension
|
||||||
*/
|
*/
|
||||||
operator fun invoke(world: GameWorld, module: String, jsonFileName: String): ActorWBMovable {
|
operator fun invoke(module: String, jsonFileName: String): ActorWBMovable {
|
||||||
val actor = ActorWBMovable(world, Actor.RenderOrder.MIDDLE)
|
val actor = ActorWBMovable(Actor.RenderOrder.MIDDLE)
|
||||||
InjectCreatureRaw(actor.actorValue, module, jsonFileName)
|
InjectCreatureRaw(actor.actorValue, module, jsonFileName)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -173,6 +173,6 @@ object DecodeTapestry {
|
|||||||
readCounter++
|
readCounter++
|
||||||
}
|
}
|
||||||
|
|
||||||
return TapestryObject((Terrarum.ingame!!.world), outImageData, artName, authorName)
|
return TapestryObject(outImageData, artName, authorName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-03-15.
|
* Created by minjaesong on 2016-03-15.
|
||||||
*/
|
*/
|
||||||
open class DroppedItem(world: GameWorld, private val item: GameItem) : ActorWBMovable(world, RenderOrder.MIDTOP) {
|
open class DroppedItem(private val item: GameItem) : ActorWBMovable(RenderOrder.MIDTOP) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
if (item.dynamicID >= ItemCodex.ACTORID_MIN)
|
if (item.dynamicID >= ItemCodex.ACTORID_MIN)
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-06-17.
|
* Created by minjaesong on 2016-06-17.
|
||||||
*/
|
*/
|
||||||
open class FixtureBase(world: GameWorld, physics: Boolean = true) :
|
open class FixtureBase(physics: Boolean = true) :
|
||||||
ActorWBMovable(world, RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
|
ActorWBMovable(RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
|
||||||
/**
|
/**
|
||||||
* 0: Open
|
* 0: Open
|
||||||
* 1: Blocked
|
* 1: Blocked
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import java.util.*
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-06-17.
|
* Created by minjaesong on 2016-06-17.
|
||||||
*/
|
*/
|
||||||
internal class FixtureTikiTorch(world: GameWorld) : FixtureBase(world), Luminous {
|
internal class FixtureTikiTorch : FixtureBase(), Luminous {
|
||||||
|
|
||||||
override var color: Color
|
override var color: Color
|
||||||
get() = BlockCodex[Block.TORCH].luminosity
|
get() = BlockCodex[Block.TORCH].luminosity
|
||||||
|
|||||||
@@ -15,12 +15,11 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
|||||||
* Created by minjaesong on 2016-01-31.
|
* Created by minjaesong on 2016-01-31.
|
||||||
*/
|
*/
|
||||||
open class HumanoidNPC(
|
open class HumanoidNPC(
|
||||||
world: GameWorld,
|
|
||||||
override val ai: ActorAI, // it's there for written-in-Kotlin, "hard-wired" AIs
|
override val ai: ActorAI, // it's there for written-in-Kotlin, "hard-wired" AIs
|
||||||
born: time_t,
|
born: time_t,
|
||||||
usePhysics: Boolean = true,
|
usePhysics: Boolean = true,
|
||||||
forceAssignRefID: Int? = null
|
forceAssignRefID: Int? = null
|
||||||
) : ActorHumanoid(world, born, usePhysics = usePhysics), AIControlled, CanBeAnItem {
|
) : ActorHumanoid(born, usePhysics = usePhysics), AIControlled, CanBeAnItem {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val DEFAULT_COLLISION_TYPE = COLLISION_DYNAMIC
|
val DEFAULT_COLLISION_TYPE = COLLISION_DYNAMIC
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
|||||||
* Created by minjaesong on 2015-12-31.
|
* Created by minjaesong on 2015-12-31.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class IngamePlayer(world: GameWorldExtension, born: time_t) : ActorHumanoid(world, born) {
|
class IngamePlayer(born: time_t) : ActorHumanoid(born) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-03-05.
|
* Created by minjaesong on 2016-03-05.
|
||||||
*/
|
*/
|
||||||
class PhysTestBall(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDDLE, immobileBody = true) {
|
class PhysTestBall : ActorWBMovable(RenderOrder.MIDDLE, immobileBody = true) {
|
||||||
|
|
||||||
private var color = Color.GOLD
|
private var color = Color.GOLD
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2018-01-17.
|
* Created by minjaesong on 2018-01-17.
|
||||||
*/
|
*/
|
||||||
class PhysTestLuarLander(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDTOP), Controllable {
|
class PhysTestLuarLander : ActorWBMovable(RenderOrder.MIDTOP), Controllable {
|
||||||
|
|
||||||
private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))
|
private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ object PlayerBuilder {
|
|||||||
operator fun invoke(): Actor {
|
operator fun invoke(): Actor {
|
||||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||||
|
|
||||||
val p: Actor = IngamePlayer(world, world.time.TIME_T)
|
val p: Actor = IngamePlayer(world.time.TIME_T)
|
||||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||||
|
|
||||||
// attach sprite
|
// attach sprite
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ object PlayerBuilderCynthia {
|
|||||||
operator fun invoke(): ActorWBMovable {
|
operator fun invoke(): ActorWBMovable {
|
||||||
//val p: IngamePlayer = IngamePlayer(GameDate(100, 143)) // random value thrown
|
//val p: IngamePlayer = IngamePlayer(GameDate(100, 143)) // random value thrown
|
||||||
val p: HumanoidNPC = HumanoidNPC(
|
val p: HumanoidNPC = HumanoidNPC(
|
||||||
(Terrarum.ingame!!.world),
|
|
||||||
NullAI(),
|
NullAI(),
|
||||||
-589141658L) // random value thrown
|
-589141658L) // random value thrown
|
||||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
object PlayerBuilderSigrid {
|
object PlayerBuilderSigrid {
|
||||||
|
|
||||||
operator fun invoke(): IngamePlayer {
|
operator fun invoke(): IngamePlayer {
|
||||||
val p = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -9223372036854775807L) // XD
|
val p = IngamePlayer(-9223372036854775807L) // XD
|
||||||
|
|
||||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
*/
|
*/
|
||||||
object PlayerBuilderTestSubject1 {
|
object PlayerBuilderTestSubject1 {
|
||||||
operator fun invoke(): IngamePlayer {
|
operator fun invoke(): IngamePlayer {
|
||||||
val p: IngamePlayer = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -589141658L) // random value thrown
|
val p: IngamePlayer = IngamePlayer(-589141658L) // random value thrown
|
||||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -7,11 +7,10 @@ import org.dyn4j.geometry.Vector2
|
|||||||
* Created by minjaesong on 2016-08-29.
|
* Created by minjaesong on 2016-08-29.
|
||||||
*/
|
*/
|
||||||
class ProjectileHoming(
|
class ProjectileHoming(
|
||||||
world: GameWorld,
|
|
||||||
type: Int,
|
type: Int,
|
||||||
fromPoint: Vector2, // projected coord
|
fromPoint: Vector2, // projected coord
|
||||||
toPoint: Vector2 // arriving coord
|
toPoint: Vector2 // arriving coord
|
||||||
) : ProjectileSimple(world, type, fromPoint, toPoint) {
|
) : ProjectileSimple(type, fromPoint, toPoint) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,10 @@ import java.util.*
|
|||||||
|
|
||||||
// TODO simplified, lightweight physics (does not call PhysicsSolver)
|
// TODO simplified, lightweight physics (does not call PhysicsSolver)
|
||||||
open class ProjectileSimple(
|
open class ProjectileSimple(
|
||||||
world: GameWorld,
|
|
||||||
private val type: Int,
|
private val type: Int,
|
||||||
fromPoint: Vector2, // projected coord
|
fromPoint: Vector2, // projected coord
|
||||||
toPoint: Vector2 // arriving coord
|
toPoint: Vector2 // arriving coord
|
||||||
) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous, Projectile {
|
) : ActorWBMovable(RenderOrder.MIDTOP), Luminous, Projectile {
|
||||||
|
|
||||||
val damage: Int
|
val damage: Int
|
||||||
val displayColour: Color
|
val displayColour: Color
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2017-01-07.
|
* Created by minjaesong on 2017-01-07.
|
||||||
*/
|
*/
|
||||||
class TapestryObject(world: GameWorld, pixmap: Pixmap, val artName: String, val artAuthor: String) : FixtureBase(world, physics = false) {
|
class TapestryObject(pixmap: Pixmap, val artName: String, val artAuthor: String) : FixtureBase(physics = false) {
|
||||||
|
|
||||||
// physics = false only speeds up for ~2 frames with 50 tapestries
|
// physics = false only speeds up for ~2 frames with 50 tapestries
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-04-26.
|
* Created by minjaesong on 2016-04-26.
|
||||||
*/
|
*/
|
||||||
class WeaponSwung(world: GameWorld, val itemID: Int) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous {
|
class WeaponSwung(val itemID: Int) : ActorWBMovable(RenderOrder.MIDTOP), Luminous {
|
||||||
// just let the solver use AABB; it's cheap but works just enough
|
// just let the solver use AABB; it's cheap but works just enough
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -3,13 +3,17 @@ package net.torvald.terrarum.modulebasegame.weather
|
|||||||
import com.badlogic.gdx.Gdx
|
import com.badlogic.gdx.Gdx
|
||||||
import com.badlogic.gdx.Input
|
import com.badlogic.gdx.Input
|
||||||
import com.badlogic.gdx.graphics.*
|
import com.badlogic.gdx.graphics.*
|
||||||
|
import com.badlogic.gdx.utils.GdxRuntimeException
|
||||||
import net.torvald.terrarum.utils.JsonFetcher
|
import net.torvald.terrarum.utils.JsonFetcher
|
||||||
import net.torvald.colourutil.*
|
import net.torvald.colourutil.*
|
||||||
import net.torvald.random.HQRNG
|
import net.torvald.random.HQRNG
|
||||||
import net.torvald.terrarum.*
|
import net.torvald.terrarum.*
|
||||||
|
import net.torvald.terrarum.console.CommandDict
|
||||||
|
import net.torvald.terrarum.console.SetGlobalLightOverride
|
||||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||||
import net.torvald.terrarum.modulebasegame.gameactors.ParticleMegaRain
|
import net.torvald.terrarum.modulebasegame.gameactors.ParticleMegaRain
|
||||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||||
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.RNGConsumer
|
import net.torvald.terrarum.modulebasegame.RNGConsumer
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
@@ -36,6 +40,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
|
|
||||||
override val RNG = HQRNG()
|
override val RNG = HQRNG()
|
||||||
|
|
||||||
|
var globalLightOverridden = false
|
||||||
|
|
||||||
var weatherList: HashMap<String, ArrayList<BaseModularWeather>>
|
var weatherList: HashMap<String, ArrayList<BaseModularWeather>>
|
||||||
|
|
||||||
@@ -84,7 +89,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
/**
|
/**
|
||||||
* Part of Ingame update
|
* Part of Ingame update
|
||||||
*/
|
*/
|
||||||
fun update(delta: Float, player: ActorWithBody?) {
|
fun update(delta: Float, player: ActorWithBody?, world: GameWorldExtension) {
|
||||||
if (player == null) return
|
if (player == null) return
|
||||||
|
|
||||||
currentWeather = weatherList[WEATHER_GENERIC]!![0]
|
currentWeather = weatherList[WEATHER_GENERIC]!![0]
|
||||||
@@ -104,6 +109,10 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
//globalLightNow.set(getGlobalLightOfTime((Terrarum.ingame!!.world).time.todaySeconds).mul(0.3f, 0.3f, 0.3f, 0.58f))
|
//globalLightNow.set(getGlobalLightOfTime((Terrarum.ingame!!.world).time.todaySeconds).mul(0.3f, 0.3f, 0.3f, 0.58f))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (!globalLightOverridden) {
|
||||||
|
world.globalLight = WeatherMixer.globalLightNow
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//private val parallaxZeroPos = WorldGenerator.TERRAIN_AVERAGE_HEIGHT * 0.75f // just an arb multiplier (266.66666 -> 200)
|
//private val parallaxZeroPos = WorldGenerator.TERRAIN_AVERAGE_HEIGHT * 0.75f // just an arb multiplier (266.66666 -> 200)
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-09-08.
|
* Created by minjaesong on 2016-09-08.
|
||||||
*/
|
*/
|
||||||
class FixtureBasicTerminal(world: GameWorld, phosphor: Color) : FixtureBase(world) {
|
class FixtureBasicTerminal(phosphor: Color) : FixtureBase() {
|
||||||
|
|
||||||
/*val computer = TerrarumComputer(8)
|
/*val computer = TerrarumComputer(8)
|
||||||
val vt: Terminal = SimpleTextTerminal(phosphor, 80, 25, computer)
|
val vt: Terminal = SimpleTextTerminal(phosphor, 80, 25, computer)
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 2016-09-08.
|
* Created by minjaesong on 2016-09-08.
|
||||||
*/
|
*/
|
||||||
open class FixtureComputerBase(world: GameWorld) : FixtureBase(world) {
|
open class FixtureComputerBase : FixtureBase() {
|
||||||
|
|
||||||
/** Connected terminal */
|
/** Connected terminal */
|
||||||
var terminal: FixtureBasicTerminal? = null
|
var terminal: FixtureBasicTerminal? = null
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
|||||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||||
import net.torvald.terrarum.Terrarum.mouseTileX
|
import net.torvald.terrarum.Terrarum.mouseTileX
|
||||||
import net.torvald.terrarum.Terrarum.mouseTileY
|
import net.torvald.terrarum.Terrarum.mouseTileY
|
||||||
|
import net.torvald.terrarum.gameworld.GameWorld
|
||||||
import net.torvald.terrarum.modulebasegame.Ingame
|
import net.torvald.terrarum.modulebasegame.Ingame
|
||||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||||
|
|
||||||
@@ -29,7 +30,10 @@ class BasicDebugInfoWindow : UICanvas() {
|
|||||||
private var ydelta = 0.0
|
private var ydelta = 0.0
|
||||||
|
|
||||||
private val ingame = Terrarum.ingame!! as Ingame
|
private val ingame = Terrarum.ingame!! as Ingame
|
||||||
private val world = ingame.world as GameWorldExtension
|
|
||||||
|
private val world: GameWorldExtension
|
||||||
|
get() = Terrarum.ingame!!.world as GameWorldExtension
|
||||||
|
|
||||||
|
|
||||||
override fun updateUI(delta: Float) {
|
override fun updateUI(delta: Float) {
|
||||||
val player = ingame.actorNowPlaying
|
val player = ingame.actorNowPlaying
|
||||||
|
|||||||
@@ -30,12 +30,18 @@ import kotlin.system.measureNanoTime
|
|||||||
|
|
||||||
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
||||||
|
|
||||||
internal object LightmapRenderer {
|
/** This object should not be called by yourself; must be only being used and manipulated by your
|
||||||
|
* own ingame renderer
|
||||||
|
*/
|
||||||
|
object LightmapRenderer {
|
||||||
private lateinit var world: GameWorld
|
private lateinit var world: GameWorld
|
||||||
|
|
||||||
|
/** do not call this yourself! Let your game renderer handle this! */
|
||||||
fun setWorld(world: GameWorld) {
|
fun setWorld(world: GameWorld) {
|
||||||
try {
|
try {
|
||||||
if (this.world != world) {
|
if (this.world != world) {
|
||||||
|
println("World change detected -- old world: ${this.world.hashCode()}, new world: ${world.hashCode()}")
|
||||||
|
|
||||||
for (y in 0 until LIGHTMAP_HEIGHT) {
|
for (y in 0 until LIGHTMAP_HEIGHT) {
|
||||||
for (x in 0 until LIGHTMAP_WIDTH) {
|
for (x in 0 until LIGHTMAP_WIDTH) {
|
||||||
lightmap[y][x] = Color(0)
|
lightmap[y][x] = Color(0)
|
||||||
|
|||||||
BIN
work_files/graphics/fonts/latinExtA_variable.psd
LFS
Normal file
BIN
work_files/graphics/fonts/latinExtA_variable.psd
LFS
Normal file
Binary file not shown.
BIN
work_files/graphics/fonts/latinExtB_variable.psd
LFS
Normal file
BIN
work_files/graphics/fonts/latinExtB_variable.psd
LFS
Normal file
Binary file not shown.
Reference in New Issue
Block a user