mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
asynch update and render (aka frameskip)
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,5 +2,6 @@ out/*
|
||||
bin/*
|
||||
hs_err_pid*
|
||||
Thumbs.db
|
||||
*.jar
|
||||
.DS_Store
|
||||
~$*
|
||||
|
||||
11
.idea/artifacts/TerrarumBuild.xml
generated
Normal file
11
.idea/artifacts/TerrarumBuild.xml
generated
Normal file
@@ -0,0 +1,11 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="TerrarumBuild">
|
||||
<output-path>$PROJECT_DIR$/</output-path>
|
||||
<root id="archive" name="TerrarumBuild.jar">
|
||||
<element id="directory" name="META-INF">
|
||||
<element id="file-copy" path="$PROJECT_DIR$/src/META-INF/MANIFEST.MF" />
|
||||
</element>
|
||||
<element id="module-output" name="Terrarum_renewed" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
||||
@@ -4,7 +4,6 @@
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/assets" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/core" />
|
||||
|
||||
Binary file not shown.
@@ -5,7 +5,7 @@
|
||||
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.itemproperties.Calculate
|
||||
@@ -60,27 +60,27 @@ class TestPick extends GameItem {
|
||||
int mouseTileY = TerrarumGdx.getMouseTileY()
|
||||
|
||||
def mousePoint = new Point2d(mouseTileX, mouseTileY)
|
||||
def actorvalue = TerrarumGDX.ingame.player.actorValue
|
||||
def actorvalue = Terrarum.ingame.player.actorValue
|
||||
|
||||
using = true
|
||||
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
TerrarumGDX.ingame.actorContainer.forEach({
|
||||
Terrarum.ingame.actorContainer.forEach({
|
||||
if (it instanceof ActorWithPhysics && it.tilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
})
|
||||
|
||||
// return false if here's no tile
|
||||
if (Block.AIR == TerrarumGDX.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY))
|
||||
if (Block.AIR == Terrarum.ingame.world.getTileFromTerrain(mouseTileX, mouseTileY))
|
||||
return false
|
||||
|
||||
// filter passed, do the job
|
||||
double swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)
|
||||
|
||||
TerrarumGDX.ingame.world.inflictTerrainDamage(
|
||||
Terrarum.ingame.world.inflictTerrainDamage(
|
||||
mouseTileX, mouseTileY,
|
||||
Calculate.pickaxePower(TerrarumGDX.ingame.player, material) * swingDmgToFrameDmg
|
||||
Calculate.pickaxePower(Terrarum.ingame.player, material) * swingDmgToFrameDmg
|
||||
)
|
||||
|
||||
return true
|
||||
@@ -90,7 +90,7 @@ class TestPick extends GameItem {
|
||||
boolean endPrimaryUse(float delta) {
|
||||
using = false
|
||||
// reset action timer to zero
|
||||
TerrarumGDX.ingame.player.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
|
||||
Terrarum.ingame.player.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
9
src/META-INF/MANIFEST.MF
Normal file
9
src/META-INF/MANIFEST.MF
Normal file
@@ -0,0 +1,9 @@
|
||||
Manifest-Version: 1.0
|
||||
Class-Path: lib/commons-codec-1.10.jar lib/commons-csv-1.2.jar lib/gdx
|
||||
.jar lib/gdx-backend-lwjgl.jar lib/gdx-backend-lwjgl3.jar lib/gdx-bac
|
||||
kend-lwjgl-natives.jar lib/gdx-natives.jar lib/groovy-all-2.4.10-indy
|
||||
.jar lib/gson-2.5.jar lib/jnlp.jar lib/jogg-0.0.7.jar lib/jopus.jar l
|
||||
ib/jorbis-0.0.17.jar lib/kotlin-reflect.jar lib/kotlin-stdlib.jar lib
|
||||
/luaj-jse-3.0.1.jar lib/Terrarum_Joise.jar lib/TerrarumSansBitmap.jar
|
||||
Main-Class: net.torvald.terrarum.TerrarumKt
|
||||
|
||||
@@ -13,12 +13,12 @@ object DefaultConfig {
|
||||
fun fetch(): JsonObject {
|
||||
val jsonObject = JsonObject()
|
||||
|
||||
jsonObject.addProperty("displayfps", 60)
|
||||
jsonObject.addProperty("usevsync", true)
|
||||
jsonObject.addProperty("displayfps", 0) // 0: no limit, non-zero: limit
|
||||
jsonObject.addProperty("usevsync", false)
|
||||
|
||||
|
||||
jsonObject.addProperty("imtooyoungtodie", false) // no perma-death
|
||||
jsonObject.addProperty("language", TerrarumGDX.sysLang)
|
||||
jsonObject.addProperty("language", Terrarum.sysLang)
|
||||
jsonObject.addProperty("notificationshowuptime", 6500)
|
||||
jsonObject.addProperty("multithread", true) // experimental!
|
||||
|
||||
@@ -48,7 +48,7 @@ object DefaultConfig {
|
||||
jsonObject.addProperty("keyup", Input.Keys.E)
|
||||
jsonObject.addProperty("keyleft", Input.Keys.S)
|
||||
jsonObject.addProperty("keydown", Input.Keys.D)
|
||||
jsonObject.addProperty("keyright", Input.Keys.F)
|
||||
jsonObject.addProperty("keyright", Input.Keys.F) // ESDF Masterrace
|
||||
|
||||
jsonObject.addProperty("keymovementaux", Input.Keys.A) // movement-auxiliary, or hookshot
|
||||
jsonObject.addProperty("keyinventory", Input.Keys.Q)
|
||||
|
||||
@@ -41,7 +41,7 @@ import net.torvald.terrarum.worldgenerator.WorldGenerator
|
||||
* Created by minjaesong on 2017-06-16.
|
||||
*/
|
||||
|
||||
class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
class Ingame(val batch: SpriteBatch) : Screen {
|
||||
|
||||
|
||||
private val ACTOR_UPDATE_RANGE = 4096
|
||||
@@ -53,7 +53,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
* list of Actors that is sorted by Actors' referenceID
|
||||
*/
|
||||
val ACTORCONTAINER_INITIAL_SIZE = 64
|
||||
val PARTICLES_MAX = TerrarumGDX.getConfigInt("maxparticles")
|
||||
val PARTICLES_MAX = Terrarum.getConfigInt("maxparticles")
|
||||
val actorContainer = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
val actorContainerInactive = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
val particlesContainer = CircularArray<ParticleBase>(PARTICLES_MAX)
|
||||
@@ -78,12 +78,12 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
}
|
||||
|
||||
|
||||
private val worldFBOformat = Pixmap.Format.RGBA4444 // just a future-proof for mobile
|
||||
private val worldFBOformat = if (Terrarum.environment == RunningEnvironment.MOBILE) Pixmap.Format.RGBA4444 else Pixmap.Format.RGBA8888
|
||||
private val lightFBOformat = Pixmap.Format.RGBA8888
|
||||
|
||||
var worldDrawFrameBuffer = FrameBuffer(worldFBOformat, TerrarumGDX.WIDTH, TerrarumGDX.HEIGHT, true)
|
||||
var lightmapFboA = FrameBuffer(lightFBOformat, TerrarumGDX.WIDTH.div(lightmapDownsample.toInt()), TerrarumGDX.HEIGHT.div(lightmapDownsample.toInt()), true)
|
||||
var lightmapFboB = FrameBuffer(lightFBOformat, TerrarumGDX.WIDTH.div(lightmapDownsample.toInt()), TerrarumGDX.HEIGHT.div(lightmapDownsample.toInt()), true)
|
||||
var worldDrawFrameBuffer = FrameBuffer(worldFBOformat, Terrarum.WIDTH, Terrarum.HEIGHT, true)
|
||||
var lightmapFboA = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), true)
|
||||
var lightmapFboB = FrameBuffer(lightFBOformat, Terrarum.WIDTH.div(lightmapDownsample.toInt()), Terrarum.HEIGHT.div(lightmapDownsample.toInt()), true)
|
||||
|
||||
|
||||
init {
|
||||
@@ -140,7 +140,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
// GDX code //
|
||||
//////////////
|
||||
|
||||
var camera = OrthographicCamera(TerrarumGDX.WIDTH.toFloat(), TerrarumGDX.HEIGHT.toFloat())
|
||||
var camera = OrthographicCamera(Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||
|
||||
// invert Y
|
||||
fun initViewPort(width: Int, height: Int) {
|
||||
@@ -160,7 +160,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
|
||||
override fun show() {
|
||||
// Set up viewport on first load
|
||||
initViewPort(TerrarumGDX.WIDTH, TerrarumGDX.HEIGHT)
|
||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
}
|
||||
|
||||
data class GameSaveData(
|
||||
@@ -225,7 +225,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
Gdx.input.inputProcessor = GameController
|
||||
|
||||
|
||||
initViewPort(TerrarumGDX.WIDTH, TerrarumGDX.HEIGHT)
|
||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
|
||||
|
||||
// init console window
|
||||
@@ -241,7 +241,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
notifier = UIHandler(Notification())
|
||||
notifier.UI.handler = notifier
|
||||
notifier.setPosition(
|
||||
(TerrarumGDX.WIDTH - notifier.UI.width) / 2, TerrarumGDX.HEIGHT - notifier.UI.height)
|
||||
(Terrarum.WIDTH - notifier.UI.width) / 2, Terrarum.HEIGHT - notifier.UI.height)
|
||||
|
||||
|
||||
|
||||
@@ -251,10 +251,10 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
uiInventoryPlayer = UIHandler(
|
||||
UIInventory(player,
|
||||
width = 840,
|
||||
height = TerrarumGDX.HEIGHT - 160,
|
||||
height = Terrarum.HEIGHT - 160,
|
||||
categoryWidth = 210
|
||||
),
|
||||
toggleKey = TerrarumGDX.getConfigInt("keyinventory")
|
||||
toggleKey = Terrarum.getConfigInt("keyinventory")
|
||||
)
|
||||
uiInventoryPlayer.setPosition(
|
||||
-uiInventoryPlayer.UI.width,
|
||||
@@ -269,7 +269,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
|
||||
// pie menu
|
||||
uiPieMenu = UIHandler(UIPieMenu())
|
||||
uiPieMenu.setPosition(TerrarumGDX.HALFW, TerrarumGDX.HALFH)
|
||||
uiPieMenu.setPosition(Terrarum.HALFW, Terrarum.HALFH)
|
||||
|
||||
// vital metre
|
||||
// fill in getter functions by
|
||||
@@ -284,11 +284,11 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
// basic watch-style notification bar (temperature, new mail)
|
||||
uiWatchBasic = UIHandler(UIBasicNotifier(player))
|
||||
uiWatchBasic.setAsAlwaysVisible()
|
||||
uiWatchBasic.setPosition(TerrarumGDX.WIDTH - uiWatchBasic.UI.width, 0)
|
||||
uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.UI.width, 0)
|
||||
|
||||
uiWatchTierOne = UIHandler(UITierOneWatch(player))
|
||||
uiWatchTierOne.setAsAlwaysVisible()
|
||||
uiWatchTierOne.setPosition(TerrarumGDX.WIDTH - uiWatchTierOne.UI.width, uiWatchBasic.UI.height - 2)
|
||||
uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.UI.width, uiWatchBasic.UI.height - 2)
|
||||
|
||||
|
||||
// batch-process uiAliases
|
||||
@@ -317,18 +317,36 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
}// END enter
|
||||
|
||||
|
||||
private var updateDeltaCounter = 0.0
|
||||
private val updateRate = 1.0 / Terrarum.TARGET_INTERNAL_FPS
|
||||
|
||||
///////////////
|
||||
// prod code //
|
||||
///////////////
|
||||
override fun render(delta: Float) {
|
||||
Gdx.graphics.setTitle(GAME_NAME +
|
||||
" — F: ${Gdx.graphics.framesPerSecond} (${TerrarumGDX.TARGET_INTERNAL_FPS})" +
|
||||
" — M: ${TerrarumGDX.memInUse}M / ${TerrarumGDX.memTotal}M / ${TerrarumGDX.memXmx}M"
|
||||
" — F: ${Gdx.graphics.framesPerSecond} (${Terrarum.TARGET_INTERNAL_FPS})" +
|
||||
" — M: ${Terrarum.memInUse}M / ${Terrarum.memTotal}M / ${Terrarum.memXmx}M"
|
||||
)
|
||||
|
||||
// ASYNCHRONOUS UPDATE AND RENDER //
|
||||
|
||||
|
||||
/** UPDATE CODE GOES HERE */
|
||||
updateDeltaCounter += delta
|
||||
|
||||
while (updateDeltaCounter >= updateRate) {
|
||||
updateGame(delta)
|
||||
updateDeltaCounter -= updateRate
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** RENDER CODE GOES HERE */
|
||||
renderGame(batch)
|
||||
}
|
||||
|
||||
private fun updateGame(delta: Float) {
|
||||
particlesActive = 0
|
||||
|
||||
|
||||
@@ -392,19 +410,8 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
AVTracker.update()
|
||||
ActorsList.update()
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////
|
||||
// app-related updates //
|
||||
/////////////////////////
|
||||
|
||||
|
||||
/** RENDER CODE GOES HERE */
|
||||
renderGame(batch)
|
||||
}
|
||||
|
||||
|
||||
private fun renderGame(batch: SpriteBatch) {
|
||||
Gdx.gl.glClearColor(.157f, .157f, .157f, 0f)
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||
@@ -418,7 +425,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
// Post-update; ones that needs everything is completed //
|
||||
FeaturesDrawer.render(batch) //
|
||||
// update lightmap on every other frames, OR full-frame if the option is true
|
||||
if (TerrarumGDX.getConfigBoolean("fullframelightupdate") or (TerrarumGDX.GLOBAL_RENDER_TIMER % 2 == 1)) { //
|
||||
if (Terrarum.getConfigBoolean("fullframelightupdate") or (Terrarum.GLOBAL_RENDER_TIMER % 2 == 1)) { //
|
||||
LightmapRenderer.fireRecalculateEvent() //
|
||||
} //
|
||||
// end of post-update /
|
||||
@@ -486,7 +493,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
texture.setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear)
|
||||
|
||||
|
||||
batch.shader = TerrarumGDX.shaderBlur
|
||||
batch.shader = Terrarum.shaderBlur
|
||||
batch.shader.setUniformf("iResolution",
|
||||
blurWriteBuffer.width.toFloat(), blurWriteBuffer.height.toFloat())
|
||||
batch.shader.setUniformf("flip", 1f)
|
||||
@@ -606,7 +613,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
/////////////////////////
|
||||
// draw to main screen //
|
||||
/////////////////////////
|
||||
camera.setToOrtho(true, TerrarumGDX.WIDTH.toFloat(), TerrarumGDX.HEIGHT.toFloat())
|
||||
camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||
batch.projectionMatrix = camera.combined
|
||||
batch.inUse {
|
||||
batch.shader = null
|
||||
@@ -647,7 +654,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
actorContainer.forEachIndexed { i, actor ->
|
||||
if (actor is ActorWithBody) {
|
||||
batch.color = Color.WHITE
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
actor.referenceID.toString(),
|
||||
actor.hitbox.startX.toFloat(),
|
||||
actor.hitbox.canonicalY.toFloat() + 4
|
||||
@@ -672,12 +679,12 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
|
||||
// velocity
|
||||
batch.color = Color.CHARTREUSE//GameFontBase.codeToCol["g"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
"${0x7F.toChar()}X ${actor.externalForce.x}",
|
||||
actor.hitbox.startX.toFloat(),
|
||||
actor.hitbox.canonicalY.toFloat() + 4 + 8
|
||||
)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
"${0x7F.toChar()}Y ${actor.externalForce.y}",
|
||||
actor.hitbox.startX.toFloat(),
|
||||
actor.hitbox.canonicalY.toFloat() + 4 + 8 * 2
|
||||
@@ -789,7 +796,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
actorContainer.forEachIndexed { i, actor ->
|
||||
if (actor is ActorWithBody) {
|
||||
batch.color = Color.WHITE
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
actor.referenceID.toString(),
|
||||
actor.hitbox.startX.toFloat(),
|
||||
actor.hitbox.canonicalY.toFloat() + 4
|
||||
@@ -814,12 +821,12 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
|
||||
// velocity
|
||||
batch.color = Color.CHARTREUSE//GameFontBase.codeToCol["g"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
"${0x7F.toChar()}X ${actor.externalForce.x}",
|
||||
actor.hitbox.startX.toFloat(),
|
||||
actor.hitbox.canonicalY.toFloat() + 4 + 8
|
||||
)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
"${0x7F.toChar()}Y ${actor.externalForce.y}",
|
||||
actor.hitbox.startX.toFloat(),
|
||||
actor.hitbox.canonicalY.toFloat() + 4 + 8 * 2
|
||||
@@ -869,8 +876,8 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
// centre marker
|
||||
/*gwin.color = Color(0x00FFFF)
|
||||
gwin.lineWidth = 1f
|
||||
gwin.drawLine(TerrarumGDX.WIDTH / 2f, 0f, TerrarumGDX.WIDTH / 2f, TerrarumGDX.HEIGHT.toFloat())
|
||||
gwin.drawLine(0f, TerrarumGDX.HEIGHT / 2f, TerrarumGDX.WIDTH.toFloat(), TerrarumGDX.HEIGHT / 2f)*/
|
||||
gwin.drawLine(Terrarum.WIDTH / 2f, 0f, Terrarum.WIDTH / 2f, Terrarum.HEIGHT.toFloat())
|
||||
gwin.drawLine(0f, Terrarum.HEIGHT / 2f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT / 2f)*/
|
||||
}
|
||||
|
||||
|
||||
@@ -966,15 +973,15 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
* NOTE: concurrency for actor updating is currently disabled because of it's poor performance
|
||||
*/
|
||||
fun updateActors(delta: Float) {
|
||||
if (false) { // don't multithread this for now, it's SLOWER //if (TerrarumGDX.MULTITHREAD && actorContainer.size > TerrarumGDX.THREADS) {
|
||||
if (false) { // don't multithread this for now, it's SLOWER //if (Terrarum.MULTITHREAD && actorContainer.size > Terrarum.THREADS) {
|
||||
val actors = actorContainer.size.toFloat()
|
||||
// set up indices
|
||||
for (i in 0..TerrarumGDX.THREADS - 1) {
|
||||
for (i in 0..Terrarum.THREADS - 1) {
|
||||
ThreadParallel.map(
|
||||
i,
|
||||
ThreadActorUpdate(
|
||||
actors.div(TerrarumGDX.THREADS).times(i).roundInt(),
|
||||
actors.div(TerrarumGDX.THREADS).times(i.plus(1)).roundInt() - 1
|
||||
actors.div(Terrarum.THREADS).times(i).roundInt(),
|
||||
actors.div(Terrarum.THREADS).times(i.plus(1)).roundInt() - 1
|
||||
),
|
||||
"ActorUpdate"
|
||||
)
|
||||
@@ -1033,10 +1040,10 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
/** whether the actor is within screen */
|
||||
private fun ActorWithBody.inScreen() =
|
||||
distToCameraSqr(this) <=
|
||||
(TerrarumGDX.WIDTH.plus(this.hitbox.width.div(2)).
|
||||
times(1 / TerrarumGDX.ingame!!.screenZoom).sqr() +
|
||||
TerrarumGDX.HEIGHT.plus(this.hitbox.height.div(2)).
|
||||
times(1 / TerrarumGDX.ingame!!.screenZoom).sqr())
|
||||
(Terrarum.WIDTH.plus(this.hitbox.width.div(2)).
|
||||
times(1 / Terrarum.ingame!!.screenZoom).sqr() +
|
||||
Terrarum.HEIGHT.plus(this.hitbox.height.div(2)).
|
||||
times(1 / Terrarum.ingame!!.screenZoom).sqr())
|
||||
|
||||
|
||||
/** whether the actor is within update range */
|
||||
@@ -1294,7 +1301,7 @@ class StateInGameGDX(val batch: SpriteBatch) : Screen {
|
||||
* Camera will be moved so that (newX, newY) would be sit on the top-left edge.
|
||||
*/
|
||||
fun setCameraPosition(newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + TerrarumGDX.HALFW).round(), (-newY + TerrarumGDX.HALFH).round(), 0f)
|
||||
camera.position.set((-newX + Terrarum.HALFW).round(), (-newY + Terrarum.HALFH).round(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}
|
||||
@@ -3,13 +3,10 @@ package net.torvald.terrarum
|
||||
import com.badlogic.gdx.ApplicationAdapter
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Screen
|
||||
import com.badlogic.gdx.assets.loaders.ShaderProgramLoader
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplication
|
||||
import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration
|
||||
import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.g2d.Batch
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont
|
||||
import com.badlogic.gdx.graphics.g2d.CpuSpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
||||
@@ -17,10 +14,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonPrimitive
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics.Companion.TILE_SIZE
|
||||
import net.torvald.terrarum.gameactors.floor
|
||||
import net.torvald.terrarum.Terrarum.RENDER_FPS
|
||||
import net.torvald.terrarum.gamecontroller.GameController
|
||||
import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -30,7 +24,6 @@ import net.torvald.terrarum.worlddrawer.RGB10
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.lwjgl.input.Controllers
|
||||
import org.lwjgl.opengl.GL11
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.*
|
||||
@@ -43,24 +36,27 @@ const val GAME_NAME = "Terrarum"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val config = LwjglApplicationConfiguration()
|
||||
config.foregroundFPS = TerrarumGDX.RENDER_FPS
|
||||
config.backgroundFPS = TerrarumGDX.RENDER_FPS
|
||||
//config.vSyncEnabled = true
|
||||
config.foregroundFPS = Terrarum.RENDER_FPS
|
||||
config.backgroundFPS = Terrarum.RENDER_FPS
|
||||
config.vSyncEnabled = Terrarum.USE_VSYNC
|
||||
config.resizable = true
|
||||
config.width = 1072
|
||||
config.height = 742
|
||||
config.backgroundFPS = 9999
|
||||
config.foregroundFPS = 9999
|
||||
config.backgroundFPS = RENDER_FPS
|
||||
config.foregroundFPS = RENDER_FPS
|
||||
config.title = GAME_NAME
|
||||
|
||||
LwjglApplication(TerrarumGDX, config)
|
||||
// the game must run on same speed regardless of the display FPS;
|
||||
// "Terrarum.TARGET_INTERNAL_FPS" denotes "execute as if FPS was set to this value"
|
||||
|
||||
LwjglApplication(Terrarum, config)
|
||||
}
|
||||
|
||||
|
||||
|
||||
typealias RGBA8888 = Int
|
||||
|
||||
object TerrarumGDX : ApplicationAdapter() {
|
||||
object Terrarum : ApplicationAdapter() {
|
||||
|
||||
lateinit var batch: SpriteBatch
|
||||
lateinit var shapeRender: ShapeRenderer // DO NOT USE!! for very limited applications e.g. WeatherMixer
|
||||
@@ -98,16 +94,13 @@ object TerrarumGDX : ApplicationAdapter() {
|
||||
/**
|
||||
* To be used with physics simulator
|
||||
*/
|
||||
val TARGET_FPS = 33.333333333333333333333
|
||||
val TARGET_FPS: Double = 33.33333333333333333333333 // higher value == faster gravity responce
|
||||
|
||||
/**
|
||||
* To be used with render, to achieve smooth frame drawing
|
||||
|
||||
* TARGET_INTERNAL_FPS > TARGET_FPS for smooth frame drawing
|
||||
|
||||
* Must choose a value so that (1000 / VAL) is still integer
|
||||
*/
|
||||
val TARGET_INTERNAL_FPS = 100
|
||||
val TARGET_INTERNAL_FPS: Double = 60.0
|
||||
|
||||
|
||||
/**
|
||||
@@ -131,7 +124,7 @@ object TerrarumGDX : ApplicationAdapter() {
|
||||
var previousScreen: Screen? = null // to be used with temporary states like StateMonitorCheck
|
||||
|
||||
|
||||
var ingame: StateInGameGDX? = null
|
||||
var ingame: Ingame? = null
|
||||
private val gameConfig = GameConfig()
|
||||
|
||||
val OSName = System.getProperty("os.name")
|
||||
@@ -318,7 +311,7 @@ object TerrarumGDX : ApplicationAdapter() {
|
||||
|
||||
|
||||
|
||||
ingame = StateInGameGDX(batch)
|
||||
ingame = Ingame(batch)
|
||||
currentScreen = ingame as Screen
|
||||
ingame!!.enter()
|
||||
|
||||
@@ -580,26 +573,26 @@ inline fun Color.toRGB10(): RGB10 {
|
||||
|
||||
fun blendMul() {
|
||||
// I must say: What the fuck is wrong with you, Slick2D? Your built-it blending is just fucking wrong.
|
||||
TerrarumGDX.batch.enableBlending()
|
||||
TerrarumGDX.batch.setBlendFunction(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
Terrarum.batch.enableBlending()
|
||||
Terrarum.batch.setBlendFunction(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD) // batch.flush does not touch blend equation
|
||||
}
|
||||
|
||||
fun blendNormal() {
|
||||
TerrarumGDX.batch.enableBlending()
|
||||
TerrarumGDX.batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
Terrarum.batch.enableBlending()
|
||||
Terrarum.batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD) // batch.flush does not touch blend equation
|
||||
}
|
||||
|
||||
fun blendLightenOnly() {
|
||||
TerrarumGDX.batch.enableBlending()
|
||||
TerrarumGDX.batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE)
|
||||
Terrarum.batch.enableBlending()
|
||||
Terrarum.batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE)
|
||||
Gdx.gl.glBlendEquation(GL30.GL_MAX) // batch.flush does not touch blend equation
|
||||
}
|
||||
|
||||
fun blendScreen() {
|
||||
TerrarumGDX.batch.enableBlending()
|
||||
TerrarumGDX.batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR)
|
||||
Terrarum.batch.enableBlending()
|
||||
Terrarum.batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_COLOR)
|
||||
Gdx.gl.glBlendEquation(GL20.GL_FUNC_ADD) // batch.flush does not touch blend equation
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
|
||||
|
||||
fun enter() {
|
||||
// init view port
|
||||
camera = OrthographicCamera(TerrarumGDX.WIDTH.toFloat(), TerrarumGDX.HEIGHT.toFloat())
|
||||
camera = OrthographicCamera(Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||
|
||||
|
||||
img = Texture("assets/test_texture.tga")
|
||||
@@ -55,14 +55,14 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
|
||||
blurFboA = FrameBuffer(Pixmap.Format.RGBA8888, img.width, img.height, false)
|
||||
blurFboB = FrameBuffer(Pixmap.Format.RGBA8888, img.width, img.height, false)
|
||||
|
||||
worldFbo = FrameBuffer(Pixmap.Format.RGBA8888, TerrarumGDX.WIDTH, TerrarumGDX.HEIGHT, false)
|
||||
worldFbo = FrameBuffer(Pixmap.Format.RGBA8888, Terrarum.WIDTH, Terrarum.HEIGHT, false)
|
||||
|
||||
//blurShader.begin()
|
||||
//blurShader.setUniformf("iResolution", img.width.toFloat(), img.height.toFloat(), 0f)
|
||||
//blurShader.end()
|
||||
|
||||
|
||||
initViewPort(TerrarumGDX.WIDTH, TerrarumGDX.HEIGHT)
|
||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
}
|
||||
|
||||
override fun render(delta: Float) {
|
||||
@@ -133,7 +133,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
|
||||
batch.inUse {
|
||||
batch.shader = null
|
||||
|
||||
camera.position.set(TerrarumGDX.WIDTH / 2f - 50f, TerrarumGDX.HEIGHT / 2f - 50f, 0f)
|
||||
camera.position.set(Terrarum.WIDTH / 2f - 50f, Terrarum.HEIGHT / 2f - 50f, 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
|
||||
@@ -145,11 +145,11 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
|
||||
}
|
||||
|
||||
|
||||
camera.setToOrtho(true, TerrarumGDX.WIDTH.toFloat(), TerrarumGDX.HEIGHT.toFloat())
|
||||
camera.setToOrtho(true, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||
batch.projectionMatrix = camera.combined
|
||||
batch.inUse {
|
||||
|
||||
camera.position.set(TerrarumGDX.WIDTH / 2f, TerrarumGDX.HEIGHT / 2f, 0f)
|
||||
camera.position.set(Terrarum.WIDTH / 2f, Terrarum.HEIGHT / 2f, 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
|
||||
@@ -166,7 +166,7 @@ class TestTestTest(val batch: SpriteBatch) : Screen {
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
initViewPort(TerrarumGDX.WIDTH, TerrarumGDX.HEIGHT)
|
||||
initViewPort(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
}
|
||||
|
||||
override fun pause() {
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.colourutil.CIELabUtil.darkerLab
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.ui.UIInventory
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
@@ -92,7 +91,7 @@ class UIItemInventoryElem(
|
||||
// if mouse is over, text lights up
|
||||
// this one-liner sets color
|
||||
batch.color = item!!.nameColour mul if (mouseUp) mouseOverTextCol else inactiveTextCol
|
||||
TerrarumGDX.fontGame.draw(batch,
|
||||
Terrarum.fontGame.draw(batch,
|
||||
//"$item" + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
|
||||
item!!.name + (if (amount > 0 && item!!.stackable) "$fwsp($amount)" else if (amount != 1) "$fwsp!!$amount!!" else "") +
|
||||
(if (equippedSlot != null) " ${0xE081.toChar()}\$$equippedSlot" else ""),
|
||||
@@ -117,8 +116,8 @@ class UIItemInventoryElem(
|
||||
|
||||
if (quickslot != null) {
|
||||
val label = quickslot!!.plus(0xE010).toChar()
|
||||
val labelW = TerrarumGDX.fontGame.getWidth("$label")
|
||||
TerrarumGDX.fontGame.draw(batch, "$label", barOffset + barFullLen - labelW, posY + textOffsetY)
|
||||
val labelW = Terrarum.fontGame.getWidth("$label")
|
||||
Terrarum.fontGame.draw(batch, "$label", barOffset + barFullLen - labelW, posY + textOffsetY)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -129,8 +128,8 @@ class UIItemInventoryElem(
|
||||
}
|
||||
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
if (item != null && TerrarumGDX.ingame != null && keycode in Input.Keys.NUM_1..Input.Keys.NUM_0) {
|
||||
val inventory = TerrarumGDX.ingame!!.player?.inventory
|
||||
if (item != null && Terrarum.ingame != null && keycode in Input.Keys.NUM_1..Input.Keys.NUM_0) {
|
||||
val inventory = Terrarum.ingame!!.player?.inventory
|
||||
val slot = if (keycode == Input.Keys.NUM_0) 9 else keycode - Input.Keys.NUM_1
|
||||
val currentSlotItem = inventory?.getQuickBar(slot)
|
||||
|
||||
@@ -169,11 +168,11 @@ class UIItemInventoryElem(
|
||||
|
||||
|
||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
if (item != null && TerrarumGDX.ingame != null) {
|
||||
if (item != null && Terrarum.ingame != null) {
|
||||
|
||||
// equip da shit
|
||||
val itemEquipSlot = item!!.equipPosition
|
||||
val player = TerrarumGDX.ingame!!.player
|
||||
val player = Terrarum.ingame!!.player
|
||||
|
||||
if (item != player?.inventory?.itemEquipped?.get(itemEquipSlot)) { // if this item is unequipped, equip it
|
||||
player?.equipItem(item!!)
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.blockproperties
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
@@ -95,7 +95,7 @@ object BlockPropUtil {
|
||||
fun getDynamicLumFunc(baseLum: Int, type: Int): Int {
|
||||
return when (type) {
|
||||
1 -> getTorchFlicker(baseLum)
|
||||
2 -> TerrarumGDX.ingame!!.world.globalLight // current global light
|
||||
2 -> Terrarum.ingame!!.world.globalLight // current global light
|
||||
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2).toRGB10() // daylight at noon
|
||||
4 -> getSlowBreath(baseLum)
|
||||
5 -> getPulsate(baseLum)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package net.torvald.terrarum.blockstats
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameworld.MapLayer
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import com.jme3.math.FastMath
|
||||
|
||||
import java.util.Arrays
|
||||
@@ -27,11 +26,11 @@ object BlockStats {
|
||||
|
||||
// Get stats on no-zoomed screen area. In other words, will behave as if screen zoom were 1.0
|
||||
// no matter how the screen is zoomed.
|
||||
val map = TerrarumGDX.ingame!!.world
|
||||
val player = TerrarumGDX.ingame!!.player
|
||||
val map = Terrarum.ingame!!.world
|
||||
val player = Terrarum.ingame!!.player
|
||||
|
||||
val renderWidth = FastMath.ceil(TerrarumGDX.WIDTH.toFloat())
|
||||
val renderHeight = FastMath.ceil(TerrarumGDX.HEIGHT.toFloat())
|
||||
val renderWidth = FastMath.ceil(Terrarum.WIDTH.toFloat())
|
||||
val renderHeight = FastMath.ceil(Terrarum.HEIGHT.toFloat())
|
||||
|
||||
val noZoomCameraX = Math.round(FastMath.clamp(
|
||||
(player?.hitbox?.centeredX?.toFloat() ?: 0f) - renderWidth / 2, TSIZE.toFloat(), map.width * TSIZE - renderWidth - TSIZE.toFloat()))
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.torvald.terrarum.concurrent
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-05-25.
|
||||
*/
|
||||
object ThreadParallel {
|
||||
private val pool: Array<Thread?> = Array(TerrarumGDX.THREADS, { null })
|
||||
private val pool: Array<Thread?> = Array(Terrarum.THREADS, { null })
|
||||
|
||||
/**
|
||||
* Map Runnable object to certain index of the thread pool.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.debuggerapp.ActorValueTracker
|
||||
import java.util.*
|
||||
|
||||
@@ -12,14 +12,14 @@ internal object AVTracker : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size < 2) {
|
||||
jPanelInstances.add(ActorValueTracker(TerrarumGDX.ingame!!.player))
|
||||
jPanelInstances.add(ActorValueTracker(Terrarum.ingame!!.player))
|
||||
}
|
||||
else {
|
||||
try {
|
||||
val actorID = args[1].toInt()
|
||||
|
||||
if (TerrarumGDX.ingame!!.theGameHasActor(actorID)) {
|
||||
jPanelInstances.add(ActorValueTracker(TerrarumGDX.ingame!!.getActorByID(actorID)))
|
||||
if (Terrarum.ingame!!.theGameHasActor(actorID)) {
|
||||
jPanelInstances.add(ActorValueTracker(Terrarum.ingame!!.getActorByID(actorID)))
|
||||
}
|
||||
else {
|
||||
throw IllegalArgumentException()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.debuggerapp.ActorsLister
|
||||
import java.util.*
|
||||
|
||||
@@ -12,8 +12,8 @@ internal object ActorsList : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
jPanelInstances.add(ActorsLister(
|
||||
TerrarumGDX.ingame!!.actorContainer,
|
||||
TerrarumGDX.ingame!!.actorContainerInactive)
|
||||
Terrarum.ingame!!.actorContainer,
|
||||
Terrarum.ingame!!.actorContainerInactive)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.ui.ConsoleWindow
|
||||
import org.apache.commons.codec.digest.DigestUtils
|
||||
|
||||
@@ -39,7 +39,7 @@ internal object Authenticator : ConsoleCommand {
|
||||
Echo(msg)
|
||||
println("[Authenticator] " + msg)
|
||||
a = !a
|
||||
(TerrarumGDX.ingame!!.consoleHandler.UI as ConsoleWindow).reset()
|
||||
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).reset()
|
||||
}
|
||||
else {
|
||||
printUsage() // thou shalt not pass!
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.ui.ConsoleWindow
|
||||
|
||||
/**
|
||||
@@ -16,13 +16,13 @@ internal object Echo : ConsoleCommand {
|
||||
val sb = StringBuilder()
|
||||
for (ch in single_line) {
|
||||
if (ch == '\n') {
|
||||
(TerrarumGDX.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
||||
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
||||
sb.delete(0, sb.length - 1)
|
||||
}
|
||||
else
|
||||
sb.append(ch)
|
||||
}
|
||||
(TerrarumGDX.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
||||
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(sb.toString())
|
||||
}
|
||||
|
||||
operator fun invoke(args: Array<String>) = execute(args)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.ui.ConsoleWindow
|
||||
|
||||
/**
|
||||
@@ -13,7 +13,7 @@ internal object EchoError : ConsoleCommand {
|
||||
}
|
||||
|
||||
fun execute(single_line: String) {
|
||||
(TerrarumGDX.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(single_line)
|
||||
(Terrarum.ingame!!.consoleHandler.UI as ConsoleWindow).sendMessage(single_line)
|
||||
}
|
||||
|
||||
operator fun invoke(args: Array<String>) = execute(args)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.utils.JsonWriter
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
@@ -13,8 +13,8 @@ internal object ExportAV : ConsoleCommand {
|
||||
if (args.size == 2) {
|
||||
try {
|
||||
JsonWriter.writeToFile(
|
||||
TerrarumGDX.ingame!!.player!!.actorValue,
|
||||
TerrarumGDX.defaultDir + "/Exports/" + args[1] + ".json")
|
||||
Terrarum.ingame!!.player!!.actorValue,
|
||||
Terrarum.defaultDir + "/Exports/" + args[1] + ".json")
|
||||
|
||||
Echo("ExportAV: exported to " + args[1] + ".json")
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.colourutil.Col4096
|
||||
import net.torvald.terrarum.utils.RasterWriter
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
|
||||
import java.io.*
|
||||
@@ -60,10 +60,10 @@ internal object ExportMap : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
|
||||
var mapData = ByteArray(TerrarumGDX.ingame!!.world.width * TerrarumGDX.ingame!!.world.height * 3)
|
||||
var mapData = ByteArray(Terrarum.ingame!!.world.width * Terrarum.ingame!!.world.height * 3)
|
||||
var mapDataPointer = 0
|
||||
|
||||
for (tile in TerrarumGDX.ingame!!.world.terrainIterator()) {
|
||||
for (tile in Terrarum.ingame!!.world.terrainIterator()) {
|
||||
val colArray = (colorTable as Map<Int, Col4096>)
|
||||
.getOrElse(tile, { Col4096(0xFFF) }).toByteArray()
|
||||
|
||||
@@ -74,7 +74,7 @@ internal object ExportMap : ConsoleCommand {
|
||||
mapDataPointer += 3
|
||||
}
|
||||
|
||||
val dir = TerrarumGDX.defaultDir + "/Exports/"
|
||||
val dir = Terrarum.defaultDir + "/Exports/"
|
||||
val dirAsFile = File(dir)
|
||||
if (!dirAsFile.exists()) {
|
||||
dirAsFile.mkdir()
|
||||
@@ -82,7 +82,7 @@ internal object ExportMap : ConsoleCommand {
|
||||
|
||||
try {
|
||||
RasterWriter.writePNG_RGB(
|
||||
TerrarumGDX.ingame!!.world.width, TerrarumGDX.ingame!!.world.height, mapData, dir + args[1] + ".png")
|
||||
Terrarum.ingame!!.world.width, Terrarum.ingame!!.world.height, mapData, dir + args[1] + ".png")
|
||||
Echo("ExportMap: exported to " + args[1] + ".png")
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-19.
|
||||
@@ -10,9 +10,9 @@ internal object GetAV : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
try {
|
||||
if (args.size == 1 && TerrarumGDX.ingame!!.player != null) {
|
||||
if (args.size == 1 && Terrarum.ingame!!.player != null) {
|
||||
// print all actorvalue of player
|
||||
val av = TerrarumGDX.ingame!!.player!!.actorValue
|
||||
val av = Terrarum.ingame!!.player!!.actorValue
|
||||
val keyset = av.keySet
|
||||
|
||||
Echo("$ccW== ActorValue list for ${ccY}player $ccW==")
|
||||
@@ -29,20 +29,20 @@ internal object GetAV : ConsoleCommand {
|
||||
// check if args[1] is number or not
|
||||
if (!args[1].isNum()) { // args[1] is ActorValue name
|
||||
Echo("${ccW}player.$ccM${args[1]} $ccW= " +
|
||||
ccG +
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[args[1]] +
|
||||
" $ccO" +
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[args[1]]!!.javaClass.simpleName
|
||||
ccG +
|
||||
Terrarum.ingame!!.player!!.actorValue[args[1]] +
|
||||
" $ccO" +
|
||||
Terrarum.ingame!!.player!!.actorValue[args[1]]!!.javaClass.simpleName
|
||||
)
|
||||
println("[GetAV] player.${args[1]} = " +
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[args[1]] +
|
||||
Terrarum.ingame!!.player!!.actorValue[args[1]] +
|
||||
" " +
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[args[1]]!!.javaClass.simpleName
|
||||
Terrarum.ingame!!.player!!.actorValue[args[1]]!!.javaClass.simpleName
|
||||
)
|
||||
}
|
||||
else {
|
||||
// args[1] is actor ID
|
||||
val actor = TerrarumGDX.ingame!!.getActorByID(args[1].toInt())
|
||||
val actor = Terrarum.ingame!!.getActorByID(args[1].toInt())
|
||||
val av = actor.actorValue
|
||||
val keyset = av.keySet
|
||||
|
||||
@@ -64,14 +64,14 @@ internal object GetAV : ConsoleCommand {
|
||||
val id = args[1].toInt()
|
||||
val av = args[2]
|
||||
Echo("$ccW$id.$ccM$av $ccW= $ccG" +
|
||||
TerrarumGDX.ingame!!.getActorByID(id).actorValue[av] +
|
||||
" $ccO" +
|
||||
TerrarumGDX.ingame!!.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||
Terrarum.ingame!!.getActorByID(id).actorValue[av] +
|
||||
" $ccO" +
|
||||
Terrarum.ingame!!.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||
)
|
||||
println("$id.$av = " +
|
||||
TerrarumGDX.ingame!!.getActorByID(id).actorValue[av] +
|
||||
Terrarum.ingame!!.getActorByID(id).actorValue[av] +
|
||||
" " +
|
||||
TerrarumGDX.ingame!!.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||
Terrarum.ingame!!.getActorByID(id).actorValue[av]!!.javaClass.simpleName
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Factionable
|
||||
import net.torvald.terrarum.gameactors.Player
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||
@@ -23,7 +23,7 @@ internal object GetFactioning : ConsoleCommand {
|
||||
val error = Error()
|
||||
|
||||
fun printOutFactioning(id: Int) {
|
||||
val a = TerrarumGDX.ingame!!.getActorByID(id)
|
||||
val a = Terrarum.ingame!!.getActorByID(id)
|
||||
if (a is Factionable) {
|
||||
Echo("$ccW== Faction assignment for $ccY${if (id == Player.PLAYER_REF_ID) "player" else id.toString()} $ccW==")
|
||||
println("[GetFactioning] == Faction assignment for '${if (id == Player.PLAYER_REF_ID) "player" else id.toString()}' ==")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-22.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-20.
|
||||
@@ -8,7 +8,7 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
internal object GetTime : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
|
||||
val worldTime = TerrarumGDX.ingame!!.world.time
|
||||
val worldTime = Terrarum.ingame!!.world.time
|
||||
Echo(worldTime.getFormattedTime())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.JsonElement
|
||||
|
||||
import java.io.BufferedWriter
|
||||
import java.io.FileWriter
|
||||
@@ -14,14 +13,14 @@ import java.io.IOException
|
||||
internal object GsonTest : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val avelem = Gson().toJsonTree(TerrarumGDX.ingame!!.player)
|
||||
val avelem = Gson().toJsonTree(Terrarum.ingame!!.player)
|
||||
|
||||
val jsonString = avelem.toString()
|
||||
|
||||
val bufferedWriter: BufferedWriter
|
||||
val writer: FileWriter
|
||||
try {
|
||||
writer = FileWriter(TerrarumGDX.defaultDir + "/Exports/" + args[1] + ".json")
|
||||
writer = FileWriter(Terrarum.defaultDir + "/Exports/" + args[1] + ".json")
|
||||
bufferedWriter = BufferedWriter(writer)
|
||||
|
||||
bufferedWriter.write(jsonString)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Player
|
||||
import net.torvald.terrarum.gameactors.Pocketed
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -11,7 +10,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
*/
|
||||
internal object Inventory : ConsoleCommand {
|
||||
|
||||
private var target: Pocketed? = TerrarumGDX.ingame!!.player
|
||||
private var target: Pocketed? = Terrarum.ingame!!.player
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 1) {
|
||||
@@ -46,7 +45,7 @@ internal object Inventory : ConsoleCommand {
|
||||
}
|
||||
|
||||
private fun setTarget(actorRefId: Int = Player.PLAYER_REF_ID) {
|
||||
val actor = TerrarumGDX.ingame!!.getActorByID(actorRefId)
|
||||
val actor = Terrarum.ingame!!.getActorByID(actorRefId)
|
||||
if (actor !is Pocketed) {
|
||||
EchoError("Cannot edit inventory of incompatible actor: $actor")
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,7 @@ internal object KillActor : ConsoleCommand {
|
||||
if (args.size == 2) {
|
||||
try {
|
||||
val actorid = args[1].toInt()
|
||||
TerrarumGDX.ingame!!.removeActor(actorid)
|
||||
Terrarum.ingame!!.removeActor(actorid)
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
EchoError("Wrong number input.")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-06-16.
|
||||
@@ -9,8 +9,8 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
internal object Seed : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
Echo("Map$ccW: $ccG${TerrarumGDX.ingame!!.world.generatorSeed}")
|
||||
println("[seed] Map$ccW: $ccG${TerrarumGDX.ingame!!.world.generatorSeed}")
|
||||
Echo("Map$ccW: $ccG${Terrarum.ingame!!.world.generatorSeed}")
|
||||
println("[seed] Map$ccW: $ccG${Terrarum.ingame!!.world.generatorSeed}")
|
||||
// TODO display randomiser seed
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-15.
|
||||
@@ -59,7 +59,7 @@ internal object SetAV : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[args[1]] = newValue
|
||||
Terrarum.ingame!!.player!!.actorValue[args[1]] = newValue
|
||||
Echo("${ccW}Set $ccM${args[1]} ${ccW}for ${ccY}player ${ccW}to $ccG$newValue")
|
||||
println("[SetAV] set ActorValue '${args[1]}' for player to '$newValue'.")
|
||||
}
|
||||
@@ -67,7 +67,7 @@ internal object SetAV : ConsoleCommand {
|
||||
try {
|
||||
val id = args[1].toInt()
|
||||
val newValue = parseAVInput(args[3])
|
||||
val actor = TerrarumGDX.ingame!!.getActorByID(id)
|
||||
val actor = Terrarum.ingame!!.getActorByID(id)
|
||||
|
||||
// check if av is number
|
||||
if (args[2].isNum()) {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.ui.Notification
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-23.
|
||||
@@ -25,7 +24,7 @@ internal object SetBulletin : ConsoleCommand {
|
||||
* @param message real message
|
||||
*/
|
||||
fun send(message: Array<String>) {
|
||||
TerrarumGDX.ingame!!.sendNotification(message)
|
||||
Terrarum.ingame!!.sendNotification(message)
|
||||
println("sent notifinator")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-17.
|
||||
@@ -20,7 +20,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
||||
val GL = LightmapRenderer.constructRGBFromInt(r, g, b)
|
||||
|
||||
lightOverride = true
|
||||
TerrarumGDX.ingame!!.world.globalLight = GL
|
||||
Terrarum.ingame!!.world.globalLight = GL
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
Echo("Wrong number input.")
|
||||
@@ -38,7 +38,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
||||
Echo("Range: 0-" + (LightmapRenderer.COLOUR_RANGE_SIZE - 1))
|
||||
}
|
||||
else {
|
||||
TerrarumGDX.ingame!!.world.globalLight = GL
|
||||
Terrarum.ingame!!.world.globalLight = GL
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
@@ -11,14 +11,14 @@ import java.io.IOException
|
||||
internal object SetLocale : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val prevLocale = TerrarumGDX.gameLocale
|
||||
TerrarumGDX.gameLocale = args[1]
|
||||
val prevLocale = Terrarum.gameLocale
|
||||
Terrarum.gameLocale = args[1]
|
||||
try {
|
||||
Echo("Set locale to '" + TerrarumGDX.gameLocale + "'.")
|
||||
Echo("Set locale to '" + Terrarum.gameLocale + "'.")
|
||||
}
|
||||
catch (e: IOException) {
|
||||
Echo("could not read lang file.")
|
||||
TerrarumGDX.gameLocale = prevLocale
|
||||
Terrarum.gameLocale = prevLocale
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
|
||||
/**
|
||||
@@ -10,10 +10,10 @@ internal object SetScale : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2 || args.size == 3) {
|
||||
try {
|
||||
val targetID = if (args.size == 3) args[1].toInt() else TerrarumGDX.ingame!!.player!!.referenceID
|
||||
val targetID = if (args.size == 3) args[1].toInt() else Terrarum.ingame!!.player!!.referenceID
|
||||
val scale = args[if (args.size == 3) 2 else 1].toDouble()
|
||||
|
||||
val target = TerrarumGDX.ingame!!.getActorByID(targetID)
|
||||
val target = Terrarum.ingame!!.getActorByID(targetID)
|
||||
|
||||
if (target !is ActorWithPhysics) {
|
||||
EchoError("Target is not ActorWithPhysics")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-20.
|
||||
@@ -11,10 +11,10 @@ internal object SetTime : ConsoleCommand {
|
||||
if (args.size == 2) {
|
||||
val timeToSet = WorldTime.parseTime(args[1])
|
||||
|
||||
TerrarumGDX.ingame!!.world.time.setTimeOfToday(timeToSet)
|
||||
Terrarum.ingame!!.world.time.setTimeOfToday(timeToSet)
|
||||
|
||||
Echo("Set time to ${TerrarumGDX.ingame!!.world.time.todaySeconds} " +
|
||||
"(${TerrarumGDX.ingame!!.world.time.hours}h${formatMin(TerrarumGDX.ingame!!.world.time.minutes)})")
|
||||
Echo("Set time to ${Terrarum.ingame!!.world.time.todaySeconds} " +
|
||||
"(${Terrarum.ingame!!.world.time.hours}h${formatMin(Terrarum.ingame!!.world.time.minutes)})")
|
||||
}
|
||||
else {
|
||||
printUsage()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-20.
|
||||
@@ -11,11 +11,11 @@ internal object SetTimeDelta : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
TerrarumGDX.ingame!!.world.time.timeDelta = args[1].toInt()
|
||||
if (TerrarumGDX.ingame!!.world.time.timeDelta == 0)
|
||||
Terrarum.ingame!!.world.time.timeDelta = args[1].toInt()
|
||||
if (Terrarum.ingame!!.world.time.timeDelta == 0)
|
||||
Echo("時間よ止まれ!ザ・ワルド!!")
|
||||
else
|
||||
Echo("Set time delta to ${TerrarumGDX.ingame!!.world.time.timeDelta}")
|
||||
Echo("Set time delta to ${Terrarum.ingame!!.world.time.timeDelta}")
|
||||
}
|
||||
else {
|
||||
printUsage()
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.gameactors.PhysTestBall
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
@@ -12,8 +11,8 @@ import org.dyn4j.geometry.Vector2
|
||||
internal object SpawnPhysTestBall : ConsoleCommand {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(args: Array<String>) {
|
||||
val mouseX = TerrarumGDX.mouseX
|
||||
val mouseY = TerrarumGDX.mouseY
|
||||
val mouseX = Terrarum.mouseX
|
||||
val mouseY = Terrarum.mouseY
|
||||
|
||||
if (args.size >= 3) {
|
||||
val elasticity = args[1].toDouble()
|
||||
@@ -29,7 +28,7 @@ internal object SpawnPhysTestBall : ConsoleCommand {
|
||||
ball.elasticity = elasticity
|
||||
ball.applyForce(Vector2(xvel, yvel))
|
||||
|
||||
TerrarumGDX.ingame!!.addNewActor(ball)
|
||||
Terrarum.ingame!!.addNewActor(ball)
|
||||
}
|
||||
else if (args.size == 2) {
|
||||
val elasticity = args[1].toDouble()
|
||||
@@ -41,7 +40,7 @@ internal object SpawnPhysTestBall : ConsoleCommand {
|
||||
)
|
||||
ball.elasticity = elasticity
|
||||
|
||||
TerrarumGDX.ingame!!.addNewActor(ball)
|
||||
Terrarum.ingame!!.addNewActor(ball)
|
||||
}
|
||||
else {
|
||||
printUsage()
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.DecodeTapestry
|
||||
import java.io.File
|
||||
import java.io.FileInputStream
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-01-14.
|
||||
@@ -16,7 +15,7 @@ internal object SpawnTapestry : ConsoleCommand {
|
||||
}
|
||||
|
||||
val tapestry = DecodeTapestry(File(args[1]))
|
||||
TerrarumGDX.ingame!!.addNewActor(tapestry)
|
||||
Terrarum.ingame!!.addNewActor(tapestry)
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.FixtureTikiTorch
|
||||
|
||||
/**
|
||||
@@ -9,9 +9,9 @@ import net.torvald.terrarum.gameactors.FixtureTikiTorch
|
||||
internal object SpawnTikiTorch : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val torch = FixtureTikiTorch()
|
||||
torch.setPosition(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
torch.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||
|
||||
TerrarumGDX.ingame!!.addNewActor(torch)
|
||||
Terrarum.ingame!!.addNewActor(torch)
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
|
||||
/**
|
||||
@@ -23,7 +23,7 @@ internal object Teleport : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
TerrarumGDX.ingame!!.player!!.setPosition(x.toDouble(), y.toDouble())
|
||||
Terrarum.ingame!!.player!!.setPosition(x.toDouble(), y.toDouble())
|
||||
}
|
||||
else if (args.size == 4) {
|
||||
if (args[2].toLowerCase() != "to") {
|
||||
@@ -35,20 +35,20 @@ internal object Teleport : ConsoleCommand {
|
||||
try {
|
||||
val fromActorID = args[1].toInt()
|
||||
val targetActorID = if (args[3].toLowerCase() == "player")
|
||||
TerrarumGDX.ingame!!.player!!.referenceID
|
||||
Terrarum.ingame!!.player!!.referenceID
|
||||
else
|
||||
args[3].toInt()
|
||||
|
||||
// if from == target, ignore the action
|
||||
if (fromActorID == targetActorID) return
|
||||
|
||||
if (TerrarumGDX.ingame!!.getActorByID(fromActorID) !is ActorWithPhysics ||
|
||||
TerrarumGDX.ingame!!.getActorByID(targetActorID) !is ActorWithPhysics) {
|
||||
if (Terrarum.ingame!!.getActorByID(fromActorID) !is ActorWithPhysics ||
|
||||
Terrarum.ingame!!.getActorByID(targetActorID) !is ActorWithPhysics) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
fromActor = TerrarumGDX.ingame!!.getActorByID(fromActorID) as ActorWithPhysics
|
||||
targetActor = TerrarumGDX.ingame!!.getActorByID(targetActorID) as ActorWithPhysics
|
||||
fromActor = Terrarum.ingame!!.getActorByID(fromActorID) as ActorWithPhysics
|
||||
targetActor = Terrarum.ingame!!.getActorByID(targetActorID) as ActorWithPhysics
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
@@ -79,11 +79,11 @@ internal object Teleport : ConsoleCommand {
|
||||
y = args[4].toInt() * FeaturesDrawer.TILE_SIZE + FeaturesDrawer.TILE_SIZE / 2
|
||||
val actorID = args[1].toInt()
|
||||
|
||||
if (TerrarumGDX.ingame!!.getActorByID(actorID) !is ActorWithPhysics) {
|
||||
if (Terrarum.ingame!!.getActorByID(actorID) !is ActorWithPhysics) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
actor = TerrarumGDX.ingame!!.getActorByID(actorID) as ActorWithPhysics
|
||||
actor = Terrarum.ingame!!.getActorByID(actorID) as ActorWithPhysics
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-19.
|
||||
*/
|
||||
internal object ToggleNoClip : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val status = TerrarumGDX.ingame!!.player!!.isNoClip()
|
||||
val status = Terrarum.ingame!!.player!!.isNoClip()
|
||||
|
||||
TerrarumGDX.ingame!!.player!!.setNoClip(!status)
|
||||
Terrarum.ingame!!.player!!.setNoClip(!status)
|
||||
Echo("Set no-clip status to " + (!status).toString())
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
|
||||
/**
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.langpack.Lang
|
||||
internal object Version : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
|
||||
Echo("${TerrarumGDX.NAME} ${TerrarumGDX.VERSION_STRING}")
|
||||
Echo("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||
Echo("Polyglot language pack version ${Lang.POLYGLOT_VERSION}")
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-25.
|
||||
@@ -18,14 +18,14 @@ internal object Zoom : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
if (zoom < TerrarumGDX.ingame!!.ZOOM_MINIMUM) {
|
||||
zoom = TerrarumGDX.ingame!!.ZOOM_MINIMUM
|
||||
if (zoom < Terrarum.ingame!!.ZOOM_MINIMUM) {
|
||||
zoom = Terrarum.ingame!!.ZOOM_MINIMUM
|
||||
}
|
||||
else if (zoom > TerrarumGDX.ingame!!.ZOOM_MAXIMUM) {
|
||||
zoom = TerrarumGDX.ingame!!.ZOOM_MAXIMUM
|
||||
else if (zoom > Terrarum.ingame!!.ZOOM_MAXIMUM) {
|
||||
zoom = Terrarum.ingame!!.ZOOM_MAXIMUM
|
||||
}
|
||||
|
||||
TerrarumGDX.ingame!!.screenZoom = zoom
|
||||
Terrarum.ingame!!.screenZoom = zoom
|
||||
|
||||
System.gc()
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.debuggerapp
|
||||
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.SetAV
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
@@ -83,11 +83,11 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
buttonChangeActor.addMouseListener(object : MouseAdapter() {
|
||||
override fun mousePressed(e: MouseEvent?) {
|
||||
if (actorIDField.text.toLowerCase() == "player") {
|
||||
actor = TerrarumGDX.ingame!!.player
|
||||
actor = Terrarum.ingame!!.player
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
else if (actorIDField.text.isNotBlank()) {
|
||||
actor = TerrarumGDX.ingame!!.getActorByID(actorIDField.text.toInt()) as ActorWithPhysics
|
||||
actor = Terrarum.ingame!!.getActorByID(actorIDField.text.toInt()) as ActorWithPhysics
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ACTORID_MIN
|
||||
|
||||
@@ -57,7 +57,7 @@ abstract class Actor(val renderOrder: RenderOrder) : Comparable<Actor>, Runnable
|
||||
fun generateUniqueReferenceID(): ActorID {
|
||||
fun hasCollision(value: ActorID) =
|
||||
try {
|
||||
TerrarumGDX.ingame!!.theGameHasActor(value) ||
|
||||
Terrarum.ingame!!.theGameHasActor(value) ||
|
||||
value < ItemCodex.ACTORID_MIN ||
|
||||
value !in when (renderOrder) {
|
||||
RenderOrder.BEHIND -> RANGE_BEHIND
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
@@ -134,7 +134,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
protected var isRightDown = false
|
||||
protected var isJumpDown = false
|
||||
protected inline val isGamer: Boolean
|
||||
get() = this == TerrarumGDX.ingame!!.player
|
||||
get() = this == Terrarum.ingame!!.player
|
||||
|
||||
|
||||
private val nullItem = object : GameItem() {
|
||||
@@ -195,32 +195,32 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
private fun updateGamerControlBox() {
|
||||
if (isGamer) {
|
||||
isUpDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyup"))
|
||||
isLeftDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyleft"))
|
||||
isDownDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keydown"))
|
||||
isRightDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyright"))
|
||||
isJumpDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyjump"))
|
||||
isUpDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyup"))
|
||||
isLeftDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyleft"))
|
||||
isDownDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keydown"))
|
||||
isRightDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyright"))
|
||||
isJumpDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyjump"))
|
||||
|
||||
if (TerrarumGDX.controller != null) {
|
||||
axisX = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadlstickx"))
|
||||
axisY = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadlsticky"))
|
||||
axisRX = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadrstickx"))
|
||||
axisRY = TerrarumGDX.controller!!.getAxisValue(TerrarumGDX.getConfigInt("joypadrsticky"))
|
||||
if (Terrarum.controller != null) {
|
||||
axisX = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadlstickx"))
|
||||
axisY = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadlsticky"))
|
||||
axisRX = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadrstickx"))
|
||||
axisRY = Terrarum.controller!!.getAxisValue(Terrarum.getConfigInt("joypadrsticky"))
|
||||
|
||||
// deadzonning
|
||||
if (Math.abs(axisX) < TerrarumGDX.CONTROLLER_DEADZONE) axisX = 0f
|
||||
if (Math.abs(axisY) < TerrarumGDX.CONTROLLER_DEADZONE) axisY = 0f
|
||||
if (Math.abs(axisRX) < TerrarumGDX.CONTROLLER_DEADZONE) axisRX = 0f
|
||||
if (Math.abs(axisRY) < TerrarumGDX.CONTROLLER_DEADZONE) axisRY = 0f
|
||||
if (Math.abs(axisX) < Terrarum.CONTROLLER_DEADZONE) axisX = 0f
|
||||
if (Math.abs(axisY) < Terrarum.CONTROLLER_DEADZONE) axisY = 0f
|
||||
if (Math.abs(axisRX) < Terrarum.CONTROLLER_DEADZONE) axisRX = 0f
|
||||
if (Math.abs(axisRY) < Terrarum.CONTROLLER_DEADZONE) axisRY = 0f
|
||||
|
||||
isJumpDown = Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyjump")) ||
|
||||
TerrarumGDX.controller!!.isButtonPressed(GAMEPAD_JUMP)
|
||||
isJumpDown = Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyjump")) ||
|
||||
Terrarum.controller!!.isButtonPressed(GAMEPAD_JUMP)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline val hasController: Boolean
|
||||
get() = if (isGamer) TerrarumGDX.controller != null
|
||||
get() = if (isGamer) Terrarum.controller != null
|
||||
else true
|
||||
|
||||
override fun processInput(delta: Float) {
|
||||
@@ -265,11 +265,11 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
// ↑F, ↓S
|
||||
if (isRightDown && !isLeftDown) {
|
||||
walkHorizontal(false, AXIS_KEYBOARD)
|
||||
prevHMoveKey = TerrarumGDX.getConfigInt("keyright")
|
||||
prevHMoveKey = Terrarum.getConfigInt("keyright")
|
||||
} // ↓F, ↑S
|
||||
else if (isLeftDown && !isRightDown) {
|
||||
walkHorizontal(true, AXIS_KEYBOARD)
|
||||
prevHMoveKey = TerrarumGDX.getConfigInt("keyleft")
|
||||
prevHMoveKey = Terrarum.getConfigInt("keyleft")
|
||||
} // ↓F, ↓S
|
||||
/*else if (isLeftDown && isRightDown) {
|
||||
if (prevHMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_LEFT)) {
|
||||
@@ -293,11 +293,11 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
// ↑E, ↓D
|
||||
if (isDownDown && !isUpDown) {
|
||||
walkVertical(false, AXIS_KEYBOARD)
|
||||
prevVMoveKey = TerrarumGDX.getConfigInt("keydown")
|
||||
prevVMoveKey = Terrarum.getConfigInt("keydown")
|
||||
} // ↓E, ↑D
|
||||
else if (isUpDown && !isDownDown) {
|
||||
walkVertical(true, AXIS_KEYBOARD)
|
||||
prevVMoveKey = TerrarumGDX.getConfigInt("keyup")
|
||||
prevVMoveKey = Terrarum.getConfigInt("keyup")
|
||||
} // ↓E, ↓D
|
||||
/*else if (isUpDown && isDownDown) {
|
||||
if (prevVMoveKey == KeyMap.getKeyCode(EnumKeyFunc.MOVE_UP)) {
|
||||
@@ -335,7 +335,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
// quickslot (quickbar)
|
||||
val quickbarKeys = TerrarumGDX.getConfigIntArray("keyquickbars")
|
||||
val quickbarKeys = Terrarum.getConfigIntArray("keyquickbars")
|
||||
if (keycode in quickbarKeys) {
|
||||
actorValue[AVKey.__PLAYER_QUICKSLOTSEL] = quickbarKeys.indexOf(keycode)
|
||||
}
|
||||
@@ -501,7 +501,7 @@ open class ActorHumanoid(birth: GameDate, death: GameDate? = null)
|
||||
|
||||
// force update inventory UI
|
||||
try {
|
||||
(TerrarumGDX.ingame!!.uiInventoryPlayer.UI as UIInventory).shutUpAndRebuild()
|
||||
(Terrarum.ingame!!.uiInventoryPlayer.UI as UIInventory).shutUpAndRebuild()
|
||||
}
|
||||
catch (LateInitMyArse: kotlin.UninitializedPropertyAccessException) { }
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -59,8 +59,8 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
"These commands are NOT INTERCHANGEABLE; they handle things differently according to the context.")
|
||||
if (item.originalID == Player.PLAYER_REF_ID || item.originalID == 0x51621D) // do not delete this magic
|
||||
throw IllegalArgumentException("Attempted to put human player into the inventory.")
|
||||
if (TerrarumGDX.ingame != null &&
|
||||
(item.originalID == TerrarumGDX.ingame?.player?.referenceID))
|
||||
if (Terrarum.ingame != null &&
|
||||
(item.originalID == Terrarum.ingame?.player?.referenceID))
|
||||
throw IllegalArgumentException("Attempted to put active player into the inventory.")
|
||||
if ((!item.stackable || item.dynamicID in ITEM_DYNAMIC) && count > 1)
|
||||
throw IllegalArgumentException("Attempting to adding stack of item but the item is not stackable; item: $item, count: $count")
|
||||
|
||||
@@ -44,7 +44,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
|
||||
var drawMode = BlendMode.NORMAL
|
||||
|
||||
@Transient private val world: GameWorld = TerrarumGDX.ingame!!.world
|
||||
@Transient private val world: GameWorld = Terrarum.ingame!!.world
|
||||
|
||||
var hitboxTranslateX: Int = 0// relative to spritePosX
|
||||
protected set
|
||||
@@ -492,7 +492,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
* weight; gravitational force in action
|
||||
* W = mass * G (9.8 [m/s^2])
|
||||
*/
|
||||
val W: Vector2 = gravitation * TerrarumGDX.TARGET_FPS.toDouble()
|
||||
val W: Vector2 = gravitation * Terrarum.TARGET_FPS.toDouble()
|
||||
/**
|
||||
* Area
|
||||
*/
|
||||
@@ -503,7 +503,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
*/
|
||||
val D: Vector2 = Vector2(externalForce.x.magnSqr(), externalForce.y.magnSqr()) * dragCoefficient * 0.5 * A// * tileDensityFluid.toDouble()
|
||||
|
||||
val V: Vector2 = (W - D) / TerrarumGDX.TARGET_FPS.toDouble() * SI_TO_GAME_ACC
|
||||
val V: Vector2 = (W - D) / Terrarum.TARGET_FPS.toDouble() * SI_TO_GAME_ACC
|
||||
|
||||
applyForce(V)
|
||||
//}
|
||||
@@ -767,7 +767,7 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
|
||||
// slam-into-whatever damage (such dirty; much hack; wow)
|
||||
// vvvv hack (supposed to be 1.0) vvv 50% hack
|
||||
val collisionDamage = mass * (vectorSum.magnitude / (10.0 / TerrarumGDX.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()
|
||||
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
|
||||
@@ -1358,16 +1358,16 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
/**
|
||||
* [m / s^2] * SI_TO_GAME_ACC -> [px / InternalFrame^2]
|
||||
*/
|
||||
@Transient val SI_TO_GAME_ACC = METER / (TerrarumGDX.TARGET_FPS * TerrarumGDX.TARGET_FPS)
|
||||
@Transient val SI_TO_GAME_ACC = METER / (Terrarum.TARGET_FPS * Terrarum.TARGET_FPS)
|
||||
/**
|
||||
* [m / s] * SI_TO_GAME_VEL -> [px / InternalFrame]
|
||||
*/
|
||||
@Transient val SI_TO_GAME_VEL = METER / TerrarumGDX.TARGET_FPS
|
||||
@Transient val SI_TO_GAME_VEL = METER / Terrarum.TARGET_FPS
|
||||
|
||||
/**
|
||||
* [px / InternalFrame^2] * GAME_TO_SI_ACC -> [m / s^2]
|
||||
*/
|
||||
@Transient val GAME_TO_SI_ACC = (TerrarumGDX.TARGET_FPS * TerrarumGDX.TARGET_FPS) / METER
|
||||
@Transient val GAME_TO_SI_ACC = (Terrarum.TARGET_FPS * Terrarum.TARGET_FPS) / METER
|
||||
|
||||
|
||||
/**
|
||||
@@ -1388,8 +1388,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
private fun div16TruncateToMapWidth(x: Int): Int {
|
||||
if (x < 0)
|
||||
return 0
|
||||
else if (x >= TerrarumGDX.ingame!!.world.width shl 4)
|
||||
return TerrarumGDX.ingame!!.world.width - 1
|
||||
else if (x >= Terrarum.ingame!!.world.width shl 4)
|
||||
return Terrarum.ingame!!.world.width - 1
|
||||
else
|
||||
return x and 0x7FFFFFFF shr 4
|
||||
}
|
||||
@@ -1397,8 +1397,8 @@ open class ActorWithPhysics(renderOrder: RenderOrder, val immobileBody: Boolean
|
||||
private fun div16TruncateToMapHeight(y: Int): Int {
|
||||
if (y < 0)
|
||||
return 0
|
||||
else if (y >= TerrarumGDX.ingame!!.world.height shl 4)
|
||||
return TerrarumGDX.ingame!!.world.height - 1
|
||||
else if (y >= Terrarum.ingame!!.world.height shl 4)
|
||||
return Terrarum.ingame!!.world.height - 1
|
||||
else
|
||||
return y and 0x7FFFFFFF shr 4
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
|
||||
typealias AnyPlayer = HistoricalFigure
|
||||
@@ -20,12 +20,13 @@ open class HistoricalFigure(
|
||||
realAirFriction: Boolean = false
|
||||
) : ActorWithPhysics(Actor.RenderOrder.MIDDLE, realAirFriction) {
|
||||
|
||||
val historicalFigureIdentifier: Int = generateHistoricalFigureIdentifier()
|
||||
var historicalFigureIdentifier: Int = generateHistoricalFigureIdentifier()
|
||||
internal set
|
||||
|
||||
private fun generateHistoricalFigureIdentifier(): Int {
|
||||
fun hasCollision(value: Int) =
|
||||
try {
|
||||
TerrarumGDX.ingame!!.historicalFigureIDBucket.contains(value)
|
||||
Terrarum.ingame!!.historicalFigureIDBucket.contains(value)
|
||||
}
|
||||
catch (gameNotInitialisedException: KotlinNullPointerException) {
|
||||
false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
import net.torvald.terrarum.gameactors.ai.LuaAIWrapper
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
@@ -51,8 +51,8 @@ open class HumanoidNPC(
|
||||
override fun secondaryUse(delta: Float): Boolean {
|
||||
try {
|
||||
// place the actor to the world
|
||||
this@HumanoidNPC.setPosition(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
TerrarumGDX.ingame!!.addNewActor(this@HumanoidNPC)
|
||||
this@HumanoidNPC.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||
Terrarum.ingame!!.addNewActor(this@HumanoidNPC)
|
||||
// successful
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.Sprite
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics.Companion.SI_TO_GAME_ACC
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
@@ -44,7 +43,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Second? = n
|
||||
lifetimeCounter += delta
|
||||
if (velocity.isZero || lifetimeCounter >= lifetimeMax ||
|
||||
// simple stuck check
|
||||
BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(
|
||||
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(
|
||||
hitbox.canonicalX.div(TILE_SIZE).floorInt(),
|
||||
hitbox.canonicalY.div(TILE_SIZE).floorInt()
|
||||
) ?: Block.STONE].isSolid) {
|
||||
@@ -53,7 +52,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, maxLifeTime: Second? = n
|
||||
|
||||
// gravity, winds, etc. (external forces)
|
||||
if (!isNoSubjectToGrav) {
|
||||
velocity += TerrarumGDX.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
velocity += Terrarum.ingame!!.world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.worldgenerator.RoguelikeRandomiser
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ class PhysTestBall : ActorWithPhysics(Actor.RenderOrder.MIDDLE, immobileBody = t
|
||||
}
|
||||
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
Terrarum.inShapeRenderer {
|
||||
it.color = color
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() - 1f,
|
||||
@@ -30,13 +30,13 @@ class PhysTestBall : ActorWithPhysics(Actor.RenderOrder.MIDDLE, immobileBody = t
|
||||
)
|
||||
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() + TerrarumGDX.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startX.toFloat() + Terrarum.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat()
|
||||
)
|
||||
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() - TerrarumGDX.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startX.toFloat() - Terrarum.ingame!!.world.width * TILE_SIZE - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat()
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-02-03.
|
||||
@@ -8,7 +8,7 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
object PlayerBuilder {
|
||||
|
||||
operator fun invoke(): Actor {
|
||||
val p: Actor = Player(TerrarumGDX.ingame!!.world.time.currentTimeAsGameDate)
|
||||
val p: Actor = Player(Terrarum.ingame!!.world.time.currentTimeAsGameDate)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -17,6 +17,7 @@ object PlayerBuilderSigrid {
|
||||
val p = Player(GameDate(-2147483648, 0)) // XD
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
p.historicalFigureIdentifier = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
|
||||
p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/test_player.tga"), 28, 51))
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gameactors
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -72,7 +72,7 @@ open class ProjectileSimple(
|
||||
lifetimeCounter += delta
|
||||
if (walledTop || walledBottom || walledRight || walledLeft || lifetimeCounter >= lifetimeMax ||
|
||||
// stuck check
|
||||
BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
) {
|
||||
flagDespawn()
|
||||
}
|
||||
@@ -90,15 +90,15 @@ open class ProjectileSimple(
|
||||
colourTail.a = 0.16f
|
||||
|
||||
/*batch.end()
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
Terrarum.inShapeRenderer {
|
||||
// draw trail of solid colour (Terraria style maybe?)
|
||||
it.lineWidth = 2f * TerrarumGDX.ingame!!.screenZoom
|
||||
it.lineWidth = 2f * Terrarum.ingame!!.screenZoom
|
||||
g.drawGradientLine(
|
||||
hitbox.centeredX.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
hitbox.centeredY.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
hitbox.centeredX.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
hitbox.centeredY.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
displayColour,
|
||||
posPre.x.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
posPre.y.toFloat() * TerrarumGDX.ingame!!.screenZoom,
|
||||
posPre.x.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
posPre.y.toFloat() * Terrarum.ingame!!.screenZoom,
|
||||
colourTail
|
||||
)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gameactors
|
||||
import com.badlogic.gdx.graphics.Pixmap
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ class TapestryObject(pixmap: Pixmap, val artName: String, val artAuthor: String)
|
||||
|
||||
makeNewSprite(texturePack)
|
||||
setHitboxDimension(texture.width, texture.height, 0, 0)
|
||||
setPosition(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||
// you CAN'T destroy the image
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-05-25.
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
class ThreadActorUpdate(val startIndex: Int, val endIndex: Int) : Runnable {
|
||||
override fun run() {
|
||||
for (i in startIndex..endIndex) {
|
||||
val it = TerrarumGDX.ingame!!.actorContainer[i]
|
||||
val it = Terrarum.ingame!!.actorContainer[i]
|
||||
it.update(Gdx.graphics.deltaTime)
|
||||
|
||||
if (it is Pocketed) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.ai
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AIControlled
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
@@ -240,7 +240,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
luatable[y - feetTilePos[1]] = LuaTable()
|
||||
|
||||
for (x in feetTilePos[0] - radius..feetTilePos[0] + radius) {
|
||||
val tile = BlockCodex[TerrarumGDX.ingame!!.world.getTileFromTerrain(x, y) ?: Block.NULL]
|
||||
val tile = BlockCodex[Terrarum.ingame!!.world.getTileFromTerrain(x, y) ?: Block.NULL]
|
||||
val solidity = tile.isSolid.toInt()
|
||||
val liquidity = tile.isFluid.toInt()
|
||||
val gravity = tile.isFallable.toInt()
|
||||
@@ -284,7 +284,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
// search down
|
||||
var searchDownCounter = 0
|
||||
while (true) {
|
||||
val tile = TerrarumGDX.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] + searchDownCounter) ?: Block.STONE
|
||||
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] + searchDownCounter) ?: Block.STONE
|
||||
if (BlockCodex[tile].isSolid || searchDownCounter >= searchDownLimit) {
|
||||
luatable[x - feetTilePos[0]] = searchDownCounter
|
||||
break
|
||||
@@ -327,7 +327,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
// search up
|
||||
var searchUpCounter = 0
|
||||
while (true) {
|
||||
val tile = TerrarumGDX.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
if (BlockCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
|
||||
luatable[x - feetTilePos[0]] = searchUpCounter
|
||||
break
|
||||
@@ -369,7 +369,7 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
// search up
|
||||
var searchUpCounter = 0
|
||||
while (true) {
|
||||
val tile = TerrarumGDX.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
val tile = Terrarum.ingame!!.world.getTileFromTerrain(x, feetTilePos[1] - searchUpCounter) ?: Block.STONE
|
||||
if (!BlockCodex[tile].isSolid || searchUpCounter >= searchUpLimit) {
|
||||
luatable[x - feetTilePos[0]] = searchUpCounter
|
||||
break
|
||||
@@ -388,13 +388,13 @@ internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
|
||||
class GameVersion : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return TerrarumGDX.VERSION_STRING.toLua()
|
||||
return Terrarum.VERSION_STRING.toLua()
|
||||
}
|
||||
}
|
||||
|
||||
class GameVersionRaw : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return TerrarumGDX.VERSION_RAW.toLua()
|
||||
return Terrarum.VERSION_RAW.toLua()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.faction
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import java.util.HashSet
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package net.torvald.terrarum.gameactors.faction
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors.physicssolver
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
import java.util.*
|
||||
|
||||
@@ -39,7 +38,7 @@ object CollisionSolver {
|
||||
collCandidateY.clear()
|
||||
|
||||
// mark list x
|
||||
TerrarumGDX.ingame!!.actorContainer.forEach { it ->
|
||||
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||
if (it is ActorWithPhysics) {
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
|
||||
@@ -72,7 +71,7 @@ object CollisionSolver {
|
||||
collCandidateStack.clear()
|
||||
|
||||
// mark list y
|
||||
TerrarumGDX.ingame!!.actorContainer.forEach { it ->
|
||||
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||
if (it is ActorWithPhysics) {
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))
|
||||
|
||||
@@ -3,10 +3,8 @@ package net.torvald.terrarum.gamecontroller
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.InputAdapter
|
||||
import com.badlogic.gdx.scenes.scene2d.InputEvent
|
||||
import com.badlogic.gdx.scenes.scene2d.InputListener
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
@@ -18,7 +16,7 @@ object GameController : InputAdapter() {
|
||||
|
||||
|
||||
|
||||
private val ingame = TerrarumGDX.ingame!!
|
||||
private val ingame = Terrarum.ingame!!
|
||||
|
||||
// these four values can also be accessed with GameContainer.<varname>
|
||||
// e.g. gc.mouseTileX
|
||||
@@ -69,14 +67,14 @@ object GameController : InputAdapter() {
|
||||
|
||||
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
||||
if (ingame.player != null && ingame.canPlayerControl) {
|
||||
if (Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mouseprimary")) || Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mousesecondary"))) {
|
||||
if (Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary")) || Gdx.input.isButtonPressed(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
val itemOnGrip = ingame.player!!.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||
|
||||
itemOnGrip?.let {
|
||||
if (Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mouseprimary"))) {
|
||||
if (Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary"))) {
|
||||
ingame.player!!.consumePrimary(it)
|
||||
}
|
||||
if (Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mousesecondary"))) {
|
||||
if (Gdx.input.isButtonPressed(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
ingame.player!!.consumeSecondary(it)
|
||||
}
|
||||
}
|
||||
@@ -95,8 +93,8 @@ object GameController : InputAdapter() {
|
||||
ingame.player?.keyDown(keycode)
|
||||
}
|
||||
|
||||
if (TerrarumGDX.getConfigIntArray("keyquickselalt").contains(keycode)
|
||||
|| keycode == TerrarumGDX.getConfigInt("keyquicksel")) {
|
||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(keycode)
|
||||
|| keycode == Terrarum.getConfigInt("keyquicksel")) {
|
||||
ingame.uiPieMenu.setAsOpen()
|
||||
ingame.uiQuickBar.setAsClose()
|
||||
}
|
||||
@@ -116,8 +114,8 @@ object GameController : InputAdapter() {
|
||||
}
|
||||
|
||||
override fun keyUp(keycode: Int): Boolean {
|
||||
if (TerrarumGDX.getConfigIntArray("keyquickselalt").contains(keycode)
|
||||
|| keycode == TerrarumGDX.getConfigInt("keyquicksel")) {
|
||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(keycode)
|
||||
|| keycode == Terrarum.getConfigInt("keyquicksel")) {
|
||||
ingame.uiPieMenu.setAsClose()
|
||||
ingame.uiQuickBar.setAsOpen()
|
||||
}
|
||||
@@ -139,17 +137,17 @@ object GameController : InputAdapter() {
|
||||
}
|
||||
|
||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
if (TerrarumGDX.ingame != null) {
|
||||
val ingame = TerrarumGDX.ingame!!
|
||||
if (Terrarum.ingame != null) {
|
||||
val ingame = Terrarum.ingame!!
|
||||
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
||||
if (ingame.player != null && ingame.canPlayerControl) {
|
||||
val itemOnGrip = ingame.player!!.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||
|
||||
if (itemOnGrip != null) {
|
||||
if (button == TerrarumGDX.getConfigInt("mousePrimary")) {
|
||||
if (button == Terrarum.getConfigInt("mousePrimary")) {
|
||||
itemOnGrip.endPrimaryUse(Gdx.graphics.deltaTime)
|
||||
}
|
||||
if (button == TerrarumGDX.getConfigInt("mouseSecondary")) {
|
||||
if (button == Terrarum.getConfigInt("mouseSecondary")) {
|
||||
itemOnGrip.endSecondaryUse(Gdx.graphics.deltaTime)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.gamecontroller
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import java.util.*
|
||||
|
||||
object KeyToggler {
|
||||
@@ -23,7 +23,7 @@ object KeyToggler {
|
||||
fun update(gameMode: Boolean = true) {
|
||||
for (it in 0..255) {
|
||||
if (gameMode && it in gameKeys &&
|
||||
(TerrarumGDX.ingame!!.consoleHandler.isOpening || TerrarumGDX.ingame!!.consoleHandler.isOpened)) {
|
||||
(Terrarum.ingame!!.consoleHandler.isOpening || Terrarum.ingame!!.consoleHandler.isOpened)) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.gameworld
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AnyPlayer
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
@@ -35,7 +35,7 @@ object WorldSimulator {
|
||||
val colourNone = Color(0x808080FF.toInt())
|
||||
val colourWater = Color(0x66BBFFFF.toInt())
|
||||
|
||||
private val world = TerrarumGDX.ingame!!.world
|
||||
private val world = Terrarum.ingame!!.world
|
||||
|
||||
operator fun invoke(p: AnyPlayer?, delta: Float) {
|
||||
if (p != null) {
|
||||
@@ -167,7 +167,7 @@ object WorldSimulator {
|
||||
else
|
||||
batch.color = colourWater
|
||||
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
data.toString(),
|
||||
updateXFrom.plus(x).times(FeaturesDrawer.TILE_SIZE).toFloat()
|
||||
+ if (data < 10) 4f else 0f,
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.KVHashMap
|
||||
import net.torvald.terrarum.gameactors.CanBeAnItem
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
@@ -62,11 +62,11 @@ object ItemCodex {
|
||||
}
|
||||
|
||||
override fun secondaryUse(delta: Float): Boolean {
|
||||
val mousePoint = Point2d(TerrarumGDX.mouseTileX.toDouble(), TerrarumGDX.mouseTileY.toDouble())
|
||||
val mousePoint = Point2d(Terrarum.mouseTileX.toDouble(), Terrarum.mouseTileY.toDouble())
|
||||
|
||||
// check for collision with actors (BLOCK only)
|
||||
if (this.inventoryCategory == Category.BLOCK) {
|
||||
TerrarumGDX.ingame!!.actorContainer.forEach {
|
||||
Terrarum.ingame!!.actorContainer.forEach {
|
||||
if (it is ActorWithPhysics && it.tilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
}
|
||||
@@ -74,27 +74,27 @@ object ItemCodex {
|
||||
|
||||
// return false if the tile is already there
|
||||
if (this.inventoryCategory == Category.BLOCK &&
|
||||
this.dynamicID == TerrarumGDX.ingame!!.world.getTileFromTerrain(TerrarumGDX.mouseTileX, TerrarumGDX.mouseTileY) ||
|
||||
this.dynamicID == Terrarum.ingame!!.world.getTileFromTerrain(Terrarum.mouseTileX, Terrarum.mouseTileY) ||
|
||||
this.inventoryCategory == Category.WALL &&
|
||||
this.dynamicID - ITEM_WALLS.start == TerrarumGDX.ingame!!.world.getTileFromWall(TerrarumGDX.mouseTileX, TerrarumGDX.mouseTileY) ||
|
||||
this.dynamicID - ITEM_WALLS.start == Terrarum.ingame!!.world.getTileFromWall(Terrarum.mouseTileX, Terrarum.mouseTileY) ||
|
||||
this.inventoryCategory == Category.WIRE &&
|
||||
this.dynamicID - ITEM_WIRES.start == TerrarumGDX.ingame!!.world.getTileFromWire(TerrarumGDX.mouseTileX, TerrarumGDX.mouseTileY)
|
||||
this.dynamicID - ITEM_WIRES.start == Terrarum.ingame!!.world.getTileFromWire(Terrarum.mouseTileX, Terrarum.mouseTileY)
|
||||
)
|
||||
return false
|
||||
|
||||
// filter passed, do the job
|
||||
// FIXME this is only useful for Player
|
||||
if (i in ITEM_TILES) {
|
||||
TerrarumGDX.ingame!!.world.setTileTerrain(
|
||||
TerrarumGDX.mouseTileX,
|
||||
TerrarumGDX.mouseTileY,
|
||||
Terrarum.ingame!!.world.setTileTerrain(
|
||||
Terrarum.mouseTileX,
|
||||
Terrarum.mouseTileY,
|
||||
i
|
||||
)
|
||||
}
|
||||
else {
|
||||
TerrarumGDX.ingame!!.world.setTileWall(
|
||||
TerrarumGDX.mouseTileX,
|
||||
TerrarumGDX.mouseTileY,
|
||||
Terrarum.ingame!!.world.setTileWall(
|
||||
Terrarum.mouseTileX,
|
||||
Terrarum.mouseTileY,
|
||||
i
|
||||
)
|
||||
}
|
||||
@@ -126,31 +126,31 @@ object ItemCodex {
|
||||
}
|
||||
|
||||
override fun primaryUse(delta: Float): Boolean {
|
||||
val mousePoint = Point2d(TerrarumGDX.mouseTileX.toDouble(), TerrarumGDX.mouseTileY.toDouble())
|
||||
val actorvalue = TerrarumGDX.ingame!!.player!!.actorValue
|
||||
val mousePoint = Point2d(Terrarum.mouseTileX.toDouble(), Terrarum.mouseTileY.toDouble())
|
||||
val actorvalue = Terrarum.ingame!!.player!!.actorValue
|
||||
|
||||
|
||||
using = true
|
||||
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
TerrarumGDX.ingame!!.actorContainer.forEach {
|
||||
Terrarum.ingame!!.actorContainer.forEach {
|
||||
if (it is ActorWithPhysics && it.tilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
}
|
||||
|
||||
// return false if there's no tile
|
||||
if (Block.AIR == TerrarumGDX.ingame!!.world.getTileFromTerrain(TerrarumGDX.mouseTileX, TerrarumGDX.mouseTileY))
|
||||
if (Block.AIR == Terrarum.ingame!!.world.getTileFromTerrain(Terrarum.mouseTileX, Terrarum.mouseTileY))
|
||||
return false
|
||||
|
||||
|
||||
// filter passed, do the job
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
|
||||
TerrarumGDX.ingame!!.world.inflictTerrainDamage(
|
||||
TerrarumGDX.mouseTileX,
|
||||
TerrarumGDX.mouseTileY,
|
||||
Calculate.pickaxePower(TerrarumGDX.ingame!!.player!!, material) * swingDmgToFrameDmg
|
||||
Terrarum.ingame!!.world.inflictTerrainDamage(
|
||||
Terrarum.mouseTileX,
|
||||
Terrarum.mouseTileY,
|
||||
Calculate.pickaxePower(Terrarum.ingame!!.player!!, material) * swingDmgToFrameDmg
|
||||
)
|
||||
return true
|
||||
}
|
||||
@@ -158,7 +158,7 @@ object ItemCodex {
|
||||
override fun endPrimaryUse(delta: Float): Boolean {
|
||||
using = false
|
||||
// reset action timer to zero
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[AVKey.__ACTION_TIMER] = 0.0
|
||||
Terrarum.ingame!!.player!!.actorValue[AVKey.__ACTION_TIMER] = 0.0
|
||||
return true
|
||||
}
|
||||
}*/
|
||||
@@ -177,7 +177,7 @@ object ItemCodex {
|
||||
TODO("read from dynamicitem description (JSON)")
|
||||
}
|
||||
else {
|
||||
val a = TerrarumGDX.ingame!!.getActorByID(code) // actor item
|
||||
val a = Terrarum.ingame!!.getActorByID(code) // actor item
|
||||
if (a is CanBeAnItem) return a.itemData
|
||||
|
||||
throw IllegalArgumentException("Attempted to get item data of actor that cannot be an item. ($a)")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.itemproperties
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ai.toLua
|
||||
import org.luaj.vm2.Globals
|
||||
import org.luaj.vm2.LuaTable
|
||||
@@ -32,24 +32,24 @@ class ItemEffectsLuaAPI(g: Globals) {
|
||||
|
||||
class GetMouseTile : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return LuaValue.tableOf(arrayOf(TerrarumGDX.mouseTileX.toLua(), TerrarumGDX.mouseTileY.toLua()))
|
||||
return LuaValue.tableOf(arrayOf(Terrarum.mouseTileX.toLua(), Terrarum.mouseTileY.toLua()))
|
||||
}
|
||||
}
|
||||
class GetMousePos : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return LuaValue.tableOf(arrayOf(TerrarumGDX.mouseX.toLua(), TerrarumGDX.mouseY.toLua()))
|
||||
return LuaValue.tableOf(arrayOf(Terrarum.mouseX.toLua(), Terrarum.mouseY.toLua()))
|
||||
}
|
||||
}
|
||||
|
||||
class StrikeEarth : ThreeArgFunction() {
|
||||
override fun call(x: LuaValue, y: LuaValue, power: LuaValue): LuaValue {
|
||||
TerrarumGDX.ingame!!.world.inflictTerrainDamage(x.checkint(), y.checkint(), power.checkdouble())
|
||||
Terrarum.ingame!!.world.inflictTerrainDamage(x.checkint(), y.checkint(), power.checkdouble())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
class StrikeWall : ThreeArgFunction() {
|
||||
override fun call(x: LuaValue, y: LuaValue, power: LuaValue): LuaValue {
|
||||
TerrarumGDX.ingame!!.world.inflictWallDamage(x.checkint(), y.checkint(), power.checkdouble())
|
||||
Terrarum.ingame!!.world.inflictWallDamage(x.checkint(), y.checkint(), power.checkdouble())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.langpack
|
||||
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import java.io.*
|
||||
import java.util.*
|
||||
|
||||
@@ -108,12 +108,12 @@ object Lang {
|
||||
fun fallback(): String = langpack["${key}_$FALLBACK_LANG_CODE"] ?: "$$key"
|
||||
|
||||
|
||||
val ret = langpack["${key}_${TerrarumGDX.gameLocale}"]
|
||||
val ret = langpack["${key}_${Terrarum.gameLocale}"]
|
||||
val ret2 = if (ret.isNullOrEmpty()) fallback() else ret!!
|
||||
|
||||
// special treatment
|
||||
if (key.startsWith("MENU_LABEL_PRESS_START_SYMBOL"))
|
||||
return ret2.replace('>', TerrarumGDX.joypadLabelStart).capitalize()
|
||||
return ret2.replace('>', Terrarum.joypadLabelStart).capitalize()
|
||||
|
||||
return ret2.capitalize()
|
||||
}
|
||||
@@ -125,7 +125,7 @@ object Lang {
|
||||
fun pluralise(word: String, count: Int): String {
|
||||
if (count < 2) return word
|
||||
|
||||
when (TerrarumGDX.gameLocale) {
|
||||
when (Terrarum.gameLocale) {
|
||||
"fr" -> {
|
||||
if (Arrays.binarySearch(FRENCH_WORD_NORMAL_PLURAL, word) >= 0) {
|
||||
return word + "s"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.realestate
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.faction.FactionCodex
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
|
||||
@@ -9,17 +9,17 @@ import net.torvald.terrarum.gameworld.BlockAddress
|
||||
*/
|
||||
object LandUtil {
|
||||
fun getBlockAddr(x: Int, y: Int): BlockAddress =
|
||||
(TerrarumGDX.ingame!!.world.width * y).toLong() + x
|
||||
(Terrarum.ingame!!.world.width * y).toLong() + x
|
||||
|
||||
fun resolveBlockAddr(t: BlockAddress): Pair<Int, Int> =
|
||||
Pair((t % TerrarumGDX.ingame!!.world.width).toInt(), (t / TerrarumGDX.ingame!!.world.width).toInt())
|
||||
Pair((t % Terrarum.ingame!!.world.width).toInt(), (t / Terrarum.ingame!!.world.width).toInt())
|
||||
|
||||
/**
|
||||
* Get owner ID as an Actor/Faction
|
||||
*/
|
||||
fun resolveOwner(id: Int): Any =
|
||||
if (id >= 0)
|
||||
TerrarumGDX.ingame!!.getActorByID(id)
|
||||
Terrarum.ingame!!.getActorByID(id)
|
||||
else
|
||||
FactionCodex.getFactionByID(id)
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.serialise
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import java.io.IOException
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Paths
|
||||
@@ -20,12 +20,12 @@ internal object WriteCSV {
|
||||
//val itemCSV = CSVFetcher.readCSVasString(ItemCodex.CSV_PATH)
|
||||
//val matCSV = CSVFetcher.readCSVasString(MaterialCodex.CSV_PATH)
|
||||
|
||||
val pathTile = Paths.get("${TerrarumGDX.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${META_FILENAME_TILE}")
|
||||
val pathItem = Paths.get("${TerrarumGDX.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${META_FILENAME_ITEM}")
|
||||
val pathMat = Paths.get("${TerrarumGDX.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${META_FILENAME_MAT}")
|
||||
val pathTile = Paths.get("${Terrarum.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${META_FILENAME_TILE}")
|
||||
val pathItem = Paths.get("${Terrarum.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${META_FILENAME_ITEM}")
|
||||
val pathMat = Paths.get("${Terrarum.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${META_FILENAME_MAT}")
|
||||
val tempPathTile = Files.createTempFile(pathTile.toString(), "_temp")
|
||||
val tempPathItem = Files.createTempFile(pathItem.toString(), "_temp")
|
||||
val tempPathMat = Files.createTempFile(pathMat.toString(), "_temp")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.serialise
|
||||
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import java.io.IOException
|
||||
import java.nio.charset.Charset
|
||||
import java.nio.file.Files
|
||||
@@ -22,10 +22,10 @@ internal object WriteGameMapData {
|
||||
|
||||
|
||||
internal fun write(saveDirectoryName: String): Boolean {
|
||||
val path = Paths.get("${TerrarumGDX.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${WriteMeta.META_FILENAME}")
|
||||
val path = Paths.get("${Terrarum.defaultSaveDir}" +
|
||||
"/$saveDirectoryName/${WriteMeta.META_FILENAME}")
|
||||
val tempPath = Files.createTempFile(path.toString(), "_temp")
|
||||
val map = TerrarumGDX.ingame!!.world
|
||||
val map = Terrarum.ingame!!.world
|
||||
|
||||
// TODO gzip
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.swingapp
|
||||
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.FlowLayout
|
||||
@@ -41,7 +41,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
|
||||
this.title = labelTitle
|
||||
defaultCloseOperation = JFrame.DISPOSE_ON_CLOSE
|
||||
|
||||
TerrarumGDX.pause()
|
||||
Terrarum.pause()
|
||||
|
||||
buttonOkay.addMouseListener(object : MouseListener {
|
||||
override fun mouseEntered(e: MouseEvent?) { }
|
||||
@@ -51,7 +51,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
|
||||
override fun mousePressed(e: MouseEvent?) {
|
||||
userInput = inputArea.text
|
||||
isVisible = false
|
||||
TerrarumGDX.resume()
|
||||
Terrarum.resume()
|
||||
|
||||
feedInput(userInput)
|
||||
|
||||
@@ -67,7 +67,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
|
||||
override fun mousePressed(e: MouseEvent?) {
|
||||
userInput = ""//null
|
||||
isVisible = false
|
||||
TerrarumGDX.resume()
|
||||
Terrarum.resume()
|
||||
|
||||
dispose()
|
||||
}
|
||||
@@ -79,7 +79,7 @@ class IMStringReader(feedInput: (String) -> Unit, message: String? = null) : JFr
|
||||
override fun keyPressed(e: KeyEvent?) {
|
||||
userInput = inputArea.text
|
||||
isVisible = false
|
||||
TerrarumGDX.resume()
|
||||
Terrarum.resume()
|
||||
|
||||
feedInput(userInput)
|
||||
|
||||
|
||||
@@ -1,25 +1,21 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseTileX
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseTileY
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseScreenX
|
||||
import net.torvald.terrarum.TerrarumGDX.mouseScreenY
|
||||
import net.torvald.terrarum.Terrarum.mouseTileX
|
||||
import net.torvald.terrarum.Terrarum.mouseTileY
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-03-14.
|
||||
*/
|
||||
class BasicDebugInfoWindow : UICanvas {
|
||||
|
||||
override var width: Int = TerrarumGDX.WIDTH
|
||||
override var height: Int = TerrarumGDX.HEIGHT
|
||||
override var width: Int = Terrarum.WIDTH
|
||||
override var height: Int = Terrarum.HEIGHT
|
||||
|
||||
override var openCloseTime: Float = 0f
|
||||
|
||||
@@ -34,7 +30,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
val player = TerrarumGDX.ingame!!.player!!
|
||||
val player = Terrarum.ingame!!.player!!
|
||||
val hitbox = player.hitbox
|
||||
|
||||
xdelta = hitbox.canonicalX - prevPlayerX
|
||||
@@ -49,7 +45,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
fun Int.rawG() = this % LightmapRenderer.MUL_2 / LightmapRenderer.MUL
|
||||
fun Int.rawB() = this % LightmapRenderer.MUL
|
||||
|
||||
val player = TerrarumGDX.ingame!!.player
|
||||
val player = Terrarum.ingame!!.player
|
||||
|
||||
batch.color = Color(0xFFEE88FF.toInt())
|
||||
|
||||
@@ -123,7 +119,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
rawB.toString() + ")"
|
||||
printLine(batch, 8, "light@cursor $ccG$lightVal")
|
||||
|
||||
val tileNum = TerrarumGDX.ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
||||
val tileNum = Terrarum.ingame!!.world.getTileFromTerrain(mouseTileX, mouseTileY) ?: -1
|
||||
|
||||
printLine(batch, 9, "tile@cursor $ccG$tileNum ($mtX, $mtY)")
|
||||
|
||||
@@ -134,25 +130,25 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
//printLineColumn(batch, 2, 1, "VSync $ccG" + Terrarum.appgc.isVSyncRequested)
|
||||
//printLineColumn(batch, 2, 2, "Env colour temp $ccG" + FeaturesDrawer.colTemp)
|
||||
|
||||
printLineColumn(batch, 2, 5, "Time $ccG${TerrarumGDX.ingame!!.world.time.todaySeconds.toString().padStart(5, '0')}" +
|
||||
" (${TerrarumGDX.ingame!!.world.time.getFormattedTime()})")
|
||||
printLineColumn(batch, 2, 5, "Time $ccG${Terrarum.ingame!!.world.time.todaySeconds.toString().padStart(5, '0')}" +
|
||||
" (${Terrarum.ingame!!.world.time.getFormattedTime()})")
|
||||
printLineColumn(batch, 2, 6, "Mass $ccG${player?.mass}")
|
||||
|
||||
printLineColumn(batch, 2, 7, "noClip $ccG${player?.noClip}")
|
||||
|
||||
|
||||
drawHistogram(batch, LightmapRenderer.histogram,
|
||||
TerrarumGDX.WIDTH - histogramW - 30,
|
||||
TerrarumGDX.HEIGHT - histogramH - 30
|
||||
Terrarum.WIDTH - histogramW - 30,
|
||||
Terrarum.HEIGHT - histogramH - 30
|
||||
)
|
||||
|
||||
batch.color = Color.WHITE
|
||||
|
||||
if (TerrarumGDX.controller != null) {
|
||||
if (Terrarum.controller != null) {
|
||||
drawGamepadAxis(batch,
|
||||
TerrarumGDX.controller!!.getAxisValue(3),
|
||||
TerrarumGDX.controller!!.getAxisValue(2),
|
||||
TerrarumGDX.WIDTH - 135,
|
||||
Terrarum.controller!!.getAxisValue(3),
|
||||
Terrarum.controller!!.getAxisValue(2),
|
||||
Terrarum.WIDTH - 135,
|
||||
40
|
||||
)
|
||||
}
|
||||
@@ -162,42 +158,42 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
*/
|
||||
|
||||
//g.color = GameFontBase.codeToCol["y"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}MEM ", (TerrarumGDX.WIDTH - 21 * 8 - 2).toFloat(), 2f)
|
||||
//g.draw(batch, "${ccY}FPS $ccG${Terrarum.appgc.fps}", (TerrarumGDX.WIDTH - 6 * 8 - 2).toFloat(), 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}CPUs ${if (TerrarumGDX.MULTITHREAD) ccG else ccR}${TerrarumGDX.THREADS}",
|
||||
(TerrarumGDX.WIDTH - 2 - 6*8).toFloat(), 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}MEM ", (Terrarum.WIDTH - 21 * 8 - 2).toFloat(), 2f)
|
||||
//g.draw(batch, "${ccY}FPS $ccG${Terrarum.appgc.fps}", (Terrarum.WIDTH - 6 * 8 - 2).toFloat(), 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}CPUs ${if (Terrarum.MULTITHREAD) ccG else ccR}${Terrarum.THREADS}",
|
||||
(Terrarum.WIDTH - 2 - 6 * 8).toFloat(), 10f)
|
||||
|
||||
//g.color = GameFontBase.codeToCol["g"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${TerrarumGDX.memInUse}M",
|
||||
(TerrarumGDX.WIDTH - 17 * 8 - 2).toFloat(), 2f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "/${TerrarumGDX.memTotal}M/",
|
||||
(TerrarumGDX.WIDTH - 12 * 8 - 2).toFloat(), 2f)
|
||||
//TerrarumGDX.fontSmallNumbers.color = GameFontBase.codeToCol["m"]
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${TerrarumGDX.memXmx}M",
|
||||
(TerrarumGDX.WIDTH - 5 * 8 - 2).toFloat(), 2f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${Terrarum.memInUse}M",
|
||||
(Terrarum.WIDTH - 17 * 8 - 2).toFloat(), 2f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "/${Terrarum.memTotal}M/",
|
||||
(Terrarum.WIDTH - 12 * 8 - 2).toFloat(), 2f)
|
||||
//Terrarum.fontSmallNumbers.color = GameFontBase.codeToCol["m"]
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${Terrarum.memXmx}M",
|
||||
(Terrarum.WIDTH - 5 * 8 - 2).toFloat(), 2f)
|
||||
|
||||
/**
|
||||
* Bottom left
|
||||
*/
|
||||
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${TerrarumGDX.ingame!!.actorContainer.size + TerrarumGDX.ingame!!.actorContainerInactive.size}",
|
||||
2f, TerrarumGDX.HEIGHT - 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${TerrarumGDX.ingame!!.actorContainer.size}",
|
||||
(2 + 17*8).toFloat(), TerrarumGDX.HEIGHT - 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${TerrarumGDX.ingame!!.actorContainerInactive.size}",
|
||||
(2 + 28*8).toFloat(), TerrarumGDX.HEIGHT - 10f)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${TerrarumGDX.ingame!!.particlesActive}",
|
||||
(2 + 41*8).toFloat(), TerrarumGDX.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Actors total $ccG${Terrarum.ingame!!.actorContainer.size + Terrarum.ingame!!.actorContainerInactive.size}",
|
||||
2f, Terrarum.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Active $ccG${Terrarum.ingame!!.actorContainer.size}",
|
||||
(2 + 17*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccY}Dormant $ccG${Terrarum.ingame!!.actorContainerInactive.size}",
|
||||
(2 + 28*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "${ccM}Particles $ccG${Terrarum.ingame!!.particlesActive}",
|
||||
(2 + 41*8).toFloat(), Terrarum.HEIGHT - 10f)
|
||||
}
|
||||
|
||||
private fun printLine(batch: SpriteBatch, l: Int, s: String) {
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
s, 10f, line(l)
|
||||
)
|
||||
}
|
||||
|
||||
private fun printLineColumn(batch: SpriteBatch, col: Int, row: Int, s: String) {
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch,
|
||||
Terrarum.fontSmallNumbers.draw(batch,
|
||||
s, (10 + column(col)), line(row)
|
||||
)
|
||||
}
|
||||
@@ -219,9 +215,9 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
batch.color = uiColour
|
||||
batch.fillRect(x.toFloat(), y.toFloat(), w.plus(1), h)
|
||||
batch.color = Color.GRAY
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8*3, y.toFloat() + h + 2)
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "0", x.toFloat(), y.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "255", x.toFloat() + w + 1 - 8 * 3, y.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, "Histogramme", x + w / 2 - 5.5f * 8, y.toFloat() + h + 2)
|
||||
|
||||
blendScreen()
|
||||
for (c in 0..2) {
|
||||
@@ -255,13 +251,13 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
val pointDX = axisX * halfW
|
||||
val pointDY = axisY * halfH
|
||||
|
||||
val padName = if (TerrarumGDX.controller!!.name.isEmpty()) "Gamepad"
|
||||
else TerrarumGDX.controller!!.name
|
||||
val padName = if (Terrarum.controller!!.name.isEmpty()) "Gamepad"
|
||||
else Terrarum.controller!!.name
|
||||
|
||||
blendNormal()
|
||||
|
||||
batch.end()
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
Terrarum.inShapeRenderer {
|
||||
it.color = uiColour
|
||||
it.rect(uiX.toFloat(), uiY.toFloat(), w, h)
|
||||
it.color = Color.WHITE
|
||||
@@ -270,7 +266,7 @@ class BasicDebugInfoWindow : UICanvas {
|
||||
}
|
||||
batch.begin()
|
||||
|
||||
TerrarumGDX.fontSmallNumbers.draw(batch, padName, uiX + w / 2 - (padName.length) * 4, uiY.toFloat() + h + 2)
|
||||
Terrarum.fontSmallNumbers.draw(batch, padName, uiX + w / 2 - (padName.length) * 4, uiY.toFloat() + h + 2)
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.dataclass.HistoryArray
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.Authenticator
|
||||
import net.torvald.terrarum.console.CommandInterpreter
|
||||
import net.torvald.terrarum.fillRect
|
||||
@@ -32,7 +31,7 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
private val LINE_HEIGHT = 20
|
||||
private val MESSAGES_DISPLAY_COUNT = 11
|
||||
|
||||
override var width: Int = TerrarumGDX.WIDTH
|
||||
override var width: Int = Terrarum.WIDTH
|
||||
override var height: Int = LINE_HEIGHT * (MESSAGES_DISPLAY_COUNT + 1)
|
||||
|
||||
override var openCloseTime = 0f
|
||||
@@ -59,12 +58,12 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
batch.fillRect(drawOffX, drawOffY, width.toFloat(), LINE_HEIGHT.toFloat())
|
||||
|
||||
val input = commandInputPool!!.toString()
|
||||
val inputDrawWidth = TerrarumGDX.fontGame.getWidth(input)
|
||||
val inputDrawHeight = TerrarumGDX.fontGame.lineHeight
|
||||
val inputDrawWidth = Terrarum.fontGame.getWidth(input)
|
||||
val inputDrawHeight = Terrarum.fontGame.lineHeight
|
||||
|
||||
// text and cursor
|
||||
batch.color = Color.WHITE
|
||||
TerrarumGDX.fontGame.draw(batch, input, 1f + drawOffX, drawOffY)
|
||||
Terrarum.fontGame.draw(batch, input, 1f + drawOffX, drawOffY)
|
||||
|
||||
batch.color = Color(0x7f7f7f_ff)
|
||||
batch.fillRect(inputDrawWidth.toFloat() + drawOffX + 1, drawOffY, 2f, inputDrawHeight)
|
||||
@@ -75,7 +74,7 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
// messages
|
||||
for (i in 0..MESSAGES_DISPLAY_COUNT - 1) {
|
||||
val message = messages[messageDisplayPos + i]
|
||||
TerrarumGDX.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY)
|
||||
Terrarum.fontGame.draw(batch, message, 1f + drawOffX, (LINE_HEIGHT * (i + 1)).toFloat() + drawOffY)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +181,7 @@ class ConsoleWindow : UICanvas, KeyControlled {
|
||||
commandInputPool = StringBuilder()
|
||||
|
||||
if (Authenticator.b()) {
|
||||
sendMessage("${TerrarumGDX.NAME} ${TerrarumGDX.VERSION_STRING}")
|
||||
sendMessage("${Terrarum.NAME} ${Terrarum.VERSION_STRING}")
|
||||
sendMessage(Lang["DEV_MESSAGE_CONSOLE_CODEX"])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
|
||||
/**
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.TerrarumGDX
|
||||
object DrawUtil {
|
||||
fun drawCentered(batch: SpriteBatch, image: Texture, screenPosY: Int, ui: UICanvas? = null) {
|
||||
val imageW = image.width
|
||||
val targetW = if (ui == null) TerrarumGDX.WIDTH else ui.width
|
||||
val targetW = if (ui == null) Terrarum.WIDTH else ui.width
|
||||
|
||||
batch.draw(image, targetW.minus(imageW).ushr(1).toFloat(), screenPosY.toFloat())
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -19,7 +19,7 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
||||
override var height: Int = 0
|
||||
|
||||
private var fontCol: Color = if (!isBlackVariant) Color.BLACK else Color.WHITE
|
||||
private val GLYPH_HEIGHT = TerrarumGDX.fontGame.lineHeight
|
||||
private val GLYPH_HEIGHT = Terrarum.fontGame.lineHeight
|
||||
|
||||
override var openCloseTime: Second = OPEN_CLOSE_TIME
|
||||
|
||||
@@ -38,7 +38,7 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
||||
override fun render(batch: SpriteBatch) {
|
||||
blendNormal()
|
||||
|
||||
val textWidth = messagesList.map { TerrarumGDX.fontGame.getWidth(it) }.sorted()[1]
|
||||
val textWidth = messagesList.map { Terrarum.fontGame.getWidth(it) }.sorted()[1]
|
||||
|
||||
batch.color = Color.WHITE
|
||||
|
||||
@@ -47,7 +47,7 @@ class MessageWindow(override var width: Int, isBlackVariant: Boolean) : UICanvas
|
||||
batch.draw(segment.get(2, 0), 2 * LRmargin + textWidth, 0f)
|
||||
|
||||
messagesList.forEachIndexed { index, s ->
|
||||
TerrarumGDX.fontGame.draw(batch, s, segment.tileW + LRmargin, (segment.tileH - TerrarumGDX.fontGame.lineHeight) / 2f)
|
||||
Terrarum.fontGame.draw(batch, s, segment.tileW + LRmargin, (segment.tileH - Terrarum.fontGame.lineHeight) / 2f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
|
||||
/**
|
||||
@@ -17,7 +17,7 @@ class Notification : UICanvas {
|
||||
|
||||
override var height: Int = msgUI.height
|
||||
private val visibleTime = Math.min(
|
||||
TerrarumGDX.getConfigInt("notificationshowuptime"),
|
||||
Terrarum.getConfigInt("notificationshowuptime"),
|
||||
SHOWUP_MAX
|
||||
)
|
||||
private var displayTimer = 0f
|
||||
|
||||
@@ -34,7 +34,7 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas {
|
||||
ELuptimer += delta
|
||||
}
|
||||
|
||||
if (mouseUp || Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyinteract"))) {
|
||||
if (mouseUp || Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyinteract"))) {
|
||||
ELuptimer = 0f
|
||||
ELon = true
|
||||
}
|
||||
@@ -94,11 +94,11 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas {
|
||||
if (player != null) {
|
||||
val playerPos = player.tilewiseHitbox
|
||||
lightLevel = (LightmapRenderer.getLight(playerPos.centeredX.toInt(), playerPos.centeredY.toInt()) ?:
|
||||
TerrarumGDX.ingame!!.world.globalLight
|
||||
Terrarum.ingame!!.world.globalLight
|
||||
).normaliseToColour()
|
||||
}
|
||||
else {
|
||||
lightLevel = TerrarumGDX.ingame!!.world.globalLight.normaliseToColour()
|
||||
lightLevel = Terrarum.ingame!!.world.globalLight.normaliseToColour()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
|
||||
@@ -29,16 +29,16 @@ interface UICanvas {
|
||||
|
||||
|
||||
val relativeMouseX: Int
|
||||
get() = (TerrarumGDX.mouseScreenX - (handler?.posX ?: 0))
|
||||
get() = (Terrarum.mouseScreenX - (handler?.posX ?: 0))
|
||||
val relativeMouseY: Int
|
||||
get() = (TerrarumGDX.mouseScreenY - (handler?.posY ?: 0))
|
||||
get() = (Terrarum.mouseScreenY - (handler?.posY ?: 0))
|
||||
|
||||
/** If mouse is hovering over it */
|
||||
val mouseUp: Boolean
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
val mousePushed: Boolean
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mouseprimary"))
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary"))
|
||||
|
||||
|
||||
fun update(delta: Float)
|
||||
@@ -98,13 +98,13 @@ interface UICanvas {
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.WIDTH.toFloat(),
|
||||
TerrarumGDX.WIDTH - handler.UI.width.toFloat()
|
||||
Terrarum.WIDTH.toFloat(),
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.HEIGHT.toFloat(),
|
||||
TerrarumGDX.HEIGHT - handler.UI.height.toFloat()
|
||||
Terrarum.HEIGHT.toFloat(),
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
@@ -122,13 +122,13 @@ interface UICanvas {
|
||||
).roundInt()
|
||||
Position.RIGHT -> handler!!.posX = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.WIDTH - handler.UI.width.toFloat(),
|
||||
TerrarumGDX.WIDTH.toFloat()
|
||||
Terrarum.WIDTH - handler.UI.width.toFloat(),
|
||||
Terrarum.WIDTH.toFloat()
|
||||
).roundInt()
|
||||
Position.BOTTOM -> handler!!.posY = Movement.fastPullOut(
|
||||
handler.openCloseCounter / openCloseTime,
|
||||
TerrarumGDX.HEIGHT - handler.UI.height.toFloat(),
|
||||
TerrarumGDX.HEIGHT.toFloat()
|
||||
Terrarum.HEIGHT - handler.UI.height.toFloat(),
|
||||
Terrarum.HEIGHT.toFloat()
|
||||
).roundInt()
|
||||
}
|
||||
}
|
||||
@@ -136,16 +136,16 @@ interface UICanvas {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = 0
|
||||
Position.TOP -> handler!!.posY = 0
|
||||
Position.RIGHT -> handler!!.posX = TerrarumGDX.WIDTH - handler.UI.width
|
||||
Position.BOTTOM -> handler!!.posY = TerrarumGDX.HEIGHT - handler.UI.height
|
||||
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH - handler.UI.width
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT - handler.UI.height
|
||||
}
|
||||
}
|
||||
fun endClosingPopOut(handler: UIHandler?, position: Position) {
|
||||
when (position) {
|
||||
Position.LEFT -> handler!!.posX = -handler.UI.width
|
||||
Position.TOP -> handler!!.posY = -handler.UI.height
|
||||
Position.RIGHT -> handler!!.posX = TerrarumGDX.WIDTH
|
||||
Position.BOTTOM -> handler!!.posY = TerrarumGDX.HEIGHT
|
||||
Position.RIGHT -> handler!!.posX = Terrarum.WIDTH
|
||||
Position.BOTTOM -> handler!!.posY = Terrarum.HEIGHT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
|
||||
/**
|
||||
@@ -134,12 +133,12 @@ class UIHandler(val UI: UICanvas,
|
||||
//batch.projectionMatrix = Matrix4()
|
||||
//
|
||||
//if (!customPositioning)
|
||||
// TerrarumGDX.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work?
|
||||
// Terrarum.ingame?.camera?.position?.set(posX.toFloat(), posY.toFloat(), 0f) // does it work?
|
||||
|
||||
|
||||
|
||||
if (!customPositioning)
|
||||
TerrarumGDX.ingame?.setCameraPosition(posX.toFloat(), posY.toFloat())
|
||||
Terrarum.ingame?.setCameraPosition(posX.toFloat(), posY.toFloat())
|
||||
batch.color = Color.WHITE
|
||||
|
||||
UI.render(batch)
|
||||
|
||||
@@ -2,10 +2,9 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumGDX.joypadLabelNinA
|
||||
import net.torvald.terrarum.TerrarumGDX.joypadLabelNinY
|
||||
import net.torvald.terrarum.Terrarum.joypadLabelNinA
|
||||
import net.torvald.terrarum.Terrarum.joypadLabelNinY
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.ActorInventory.Companion.CAPACITY_MODE_NO_ENCUMBER
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
@@ -57,7 +56,7 @@ class UIInventory(
|
||||
val itemStripGutterH = 8
|
||||
val itemInterColGutter = 8
|
||||
|
||||
val controlHelpHeight = TerrarumGDX.fontGame.lineHeight.toInt()
|
||||
val controlHelpHeight = Terrarum.fontGame.lineHeight.toInt()
|
||||
|
||||
val catButtons = UIItemTextButtonList(
|
||||
this,
|
||||
@@ -116,7 +115,7 @@ class UIInventory(
|
||||
|
||||
private val SP = "${0x3000.toChar()}${0x3000.toChar()}${0x3000.toChar()}"
|
||||
val listControlHelp: String
|
||||
get() = if (TerrarumGDX.environment == RunningEnvironment.PC)
|
||||
get() = if (Terrarum.environment == RunningEnvironment.PC)
|
||||
"${0xe006.toChar()} ${Lang["GAME_INVENTORY_USE"]}$SP" +
|
||||
"${0xe011.toChar()}..${0xe010.toChar()} ${Lang["GAME_INVENTORY_REGISTER"]}$SP" +
|
||||
"${0xe034.toChar()} ${Lang["GAME_INVENTORY_DROP"]}"
|
||||
@@ -125,7 +124,7 @@ class UIInventory(
|
||||
"${0xe011.toChar()}${0xe010.toChar()} ${Lang["GAME_INVENTORY_REGISTER"]}$SP" +
|
||||
"$joypadLabelNinA ${Lang["GAME_INVENTORY_DROP"]}"
|
||||
val listControlClose: String
|
||||
get() = if (TerrarumGDX.environment == RunningEnvironment.PC)
|
||||
get() = if (Terrarum.environment == RunningEnvironment.PC)
|
||||
"${0xe037.toChar()} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||
else
|
||||
"${0xe069.toChar()} ${Lang["GAME_ACTION_CLOSE"]}"
|
||||
@@ -181,16 +180,16 @@ class UIInventory(
|
||||
blendNormal()
|
||||
batch.color = defaultTextColour
|
||||
// W - close
|
||||
TerrarumGDX.fontGame.draw(batch, listControlClose, 4f, height - controlHelpHeight.toFloat())
|
||||
Terrarum.fontGame.draw(batch, listControlClose, 4f, height - controlHelpHeight.toFloat())
|
||||
// MouseL - Use ; 1.9 - Register ; T - Drop
|
||||
TerrarumGDX.fontGame.draw(batch, listControlHelp, catButtons.width + 4f, height - controlHelpHeight.toFloat())
|
||||
Terrarum.fontGame.draw(batch, listControlHelp, catButtons.width + 4f, height - controlHelpHeight.toFloat())
|
||||
// encumbrance
|
||||
if (inventory != null) {
|
||||
val encumbranceText = Lang["GAME_INVENTORY_ENCUMBRANCE"]
|
||||
|
||||
TerrarumGDX.fontGame.draw(batch,
|
||||
Terrarum.fontGame.draw(batch,
|
||||
encumbranceText,
|
||||
width - 9 - TerrarumGDX.fontGame.getWidth(encumbranceText) - weightBarWidth,
|
||||
width - 9 - Terrarum.fontGame.getWidth(encumbranceText) - weightBarWidth,
|
||||
height - controlHelpHeight.toFloat()
|
||||
)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,16 +17,16 @@ abstract class UIItem(var parentUI: UICanvas) { // do not replace parentUI to UI
|
||||
abstract val height: Int
|
||||
|
||||
protected val relativeMouseX: Int
|
||||
get() = (TerrarumGDX.mouseScreenX - (parentUI.handler?.posX ?: 0) - this.posX)
|
||||
get() = (Terrarum.mouseScreenX - (parentUI.handler?.posX ?: 0) - this.posX)
|
||||
protected val relativeMouseY: Int
|
||||
get() = (TerrarumGDX.mouseScreenY - (parentUI.handler?.posY ?: 0) - this.posY)
|
||||
get() = (Terrarum.mouseScreenY - (parentUI.handler?.posY ?: 0) - this.posY)
|
||||
|
||||
/** If mouse is hovering over it */
|
||||
open val mouseUp: Boolean
|
||||
get() = relativeMouseX in 0..width - 1 && relativeMouseY in 0..height - 1
|
||||
/** If mouse is hovering over it and mouse is down */
|
||||
open val mousePushed: Boolean
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(TerrarumGDX.getConfigInt("mouseprimary")!!)
|
||||
get() = mouseUp && Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary")!!)
|
||||
|
||||
abstract fun update(delta: Float)
|
||||
abstract fun render(batch: SpriteBatch)
|
||||
|
||||
@@ -30,7 +30,7 @@ class UIItemTextButton(
|
||||
) : UIItem(parentUI) {
|
||||
|
||||
companion object {
|
||||
val font = TerrarumGDX.fontGame
|
||||
val font = Terrarum.fontGame
|
||||
val height = font.lineHeight.toInt() * 2
|
||||
val defaultInactiveCol: Color = Color(0xc8c8c8_ff.toInt())
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.ui
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -35,9 +35,9 @@ class UIPieMenu : UICanvas {
|
||||
var selection: Int = -1
|
||||
|
||||
override fun update(delta: Float) {
|
||||
if (TerrarumGDX.ingame!!.player != null) {
|
||||
if (Terrarum.ingame!!.player != null) {
|
||||
if (selection >= 0)
|
||||
TerrarumGDX.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
Terrarum.ingame!!.player!!.actorValue[AVKey.__PLAYER_QUICKSLOTSEL] =
|
||||
selection % slotCount
|
||||
}
|
||||
}
|
||||
@@ -57,8 +57,8 @@ class UIPieMenu : UICanvas {
|
||||
|
||||
val slotSize = image.width
|
||||
|
||||
val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2) + TerrarumGDX.HALFW
|
||||
val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2) + TerrarumGDX.HALFH
|
||||
val slotX = slotCentrePoint.x.toFloat() - (slotSize / 2) + Terrarum.HALFW
|
||||
val slotY = slotCentrePoint.y.toFloat() - (slotSize / 2) + Terrarum.HALFH
|
||||
|
||||
batch.color = Color(1f, 1f, 1f, handler!!.opacity * UIQuickBar.finalOpacity)
|
||||
batch.draw(
|
||||
@@ -69,7 +69,7 @@ class UIPieMenu : UICanvas {
|
||||
|
||||
|
||||
// draw item
|
||||
val itemPair = TerrarumGDX.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
val itemPair = Terrarum.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
|
||||
if (itemPair != null) {
|
||||
val itemImage = ItemCodex.getItemImage(itemPair.item)
|
||||
@@ -88,8 +88,8 @@ class UIPieMenu : UICanvas {
|
||||
|
||||
override fun processInput(delta: Float) {
|
||||
if (handler!!.isOpened || handler!!.isOpening) {
|
||||
val cursorPos = Vector2(TerrarumGDX.mouseX, TerrarumGDX.mouseY)
|
||||
val centre = Vector2(TerrarumGDX.HALFW.toDouble(), TerrarumGDX.HALFH.toDouble())
|
||||
val cursorPos = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
||||
val centre = Vector2(Terrarum.HALFW.toDouble(), Terrarum.HALFH.toDouble())
|
||||
val deg = -(centre - cursorPos).direction.toFloat()
|
||||
|
||||
selection = Math.round(deg * slotCount / FastMath.TWO_PI)
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
@@ -14,7 +14,7 @@ import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
class UIQuickBar : UICanvas, MouseControlled {
|
||||
private val gutter = 8
|
||||
override var width: Int = (ItemSlotImageBuilder.slotImage.width + gutter) * SLOT_COUNT
|
||||
override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + TerrarumGDX.fontGame.lineHeight.toInt()
|
||||
override var height: Int = ItemSlotImageBuilder.slotImage.height + 4 + Terrarum.fontGame.lineHeight.toInt()
|
||||
/**
|
||||
* In milliseconds
|
||||
*/
|
||||
@@ -26,8 +26,8 @@ class UIQuickBar : UICanvas, MouseControlled {
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var selection: Int
|
||||
get() = TerrarumGDX.ingame!!.player?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
set(value) { TerrarumGDX.ingame!!.player?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
|
||||
get() = Terrarum.ingame!!.player?.actorValue?.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL) ?: 0
|
||||
set(value) { Terrarum.ingame!!.player?.actorValue?.set(AVKey.__PLAYER_QUICKSLOTSEL, value.fmod(SLOT_COUNT)) }
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
@@ -53,7 +53,7 @@ class UIQuickBar : UICanvas, MouseControlled {
|
||||
)
|
||||
|
||||
// draw item
|
||||
val itemPair = TerrarumGDX.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
val itemPair = Terrarum.ingame!!.player!!.inventory.getQuickBar(i)
|
||||
|
||||
if (itemPair != null) {
|
||||
val itemImage = ItemCodex.getItemImage(itemPair.item)
|
||||
|
||||
@@ -39,7 +39,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
||||
private val lcdLitCol = Color(0x141414_ff)
|
||||
|
||||
private val worldTime: WorldTime
|
||||
get() = TerrarumGDX.ingame!!.world.time
|
||||
get() = Terrarum.ingame!!.world.time
|
||||
|
||||
|
||||
override fun update(delta: Float) {
|
||||
@@ -47,7 +47,7 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
||||
ELuptimer += delta
|
||||
}
|
||||
|
||||
if (mouseUp || Gdx.input.isKeyPressed(TerrarumGDX.getConfigInt("keyinteract"))) {
|
||||
if (mouseUp || Gdx.input.isKeyPressed(Terrarum.getConfigInt("keyinteract"))) {
|
||||
ELuptimer = 0f
|
||||
ELon = true
|
||||
}
|
||||
@@ -69,11 +69,11 @@ class UITierOneWatch(private val player: ActorHumanoid?) : UICanvas {
|
||||
if (player != null) {
|
||||
val playerPos = player.tilewiseHitbox
|
||||
lightLevel = (LightmapRenderer.getLight(playerPos.centeredX.toInt(), playerPos.centeredY.toInt()) ?:
|
||||
TerrarumGDX.ingame!!.world.globalLight
|
||||
Terrarum.ingame!!.world.globalLight
|
||||
).normaliseToColour()
|
||||
}
|
||||
else {
|
||||
lightLevel = TerrarumGDX.ingame!!.world.globalLight.normaliseToColour()
|
||||
lightLevel = Terrarum.ingame!!.world.globalLight.normaliseToColour()
|
||||
}
|
||||
|
||||
// backplate
|
||||
|
||||
@@ -4,10 +4,9 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.colourutil.CIELabUtil.darkerLab
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
|
||||
/**
|
||||
* Created by SKYHi14 on 2017-03-03.
|
||||
@@ -56,8 +55,8 @@ class UIVitalMetre(
|
||||
|
||||
override fun update(delta: Float) {
|
||||
handler!!.setPosition(
|
||||
TerrarumGDX.HALFW,
|
||||
TerrarumGDX.HALFH
|
||||
Terrarum.HALFW,
|
||||
Terrarum.HALFH
|
||||
)
|
||||
}
|
||||
|
||||
@@ -69,8 +68,8 @@ class UIVitalMetre(
|
||||
|
||||
/*if (vitalGetterVal() != null && vitalGetterMax() != null && player != null) {
|
||||
g.translate(
|
||||
TerrarumGDX.ingame!!.screenZoom * (player!!.centrePosPoint.x.toFloat() - (WorldCamera.x)),
|
||||
TerrarumGDX.ingame!!.screenZoom * (player!!.centrePosPoint.y.toFloat() - (WorldCamera.y))
|
||||
Terrarum.ingame!!.screenZoom * (player!!.centrePosPoint.x.toFloat() - (WorldCamera.x)),
|
||||
Terrarum.ingame!!.screenZoom * (player!!.centrePosPoint.y.toFloat() - (WorldCamera.y))
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -8,10 +8,9 @@ import org.luaj.vm2.lib.TwoArgFunction
|
||||
import org.luaj.vm2.lib.ZeroArgFunction
|
||||
import org.luaj.vm2.lib.jse.JsePlatform
|
||||
import net.torvald.terrarum.KVHashMap
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.Second
|
||||
import net.torvald.terrarum.gameactors.ceilInt
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.virtualcomputer.luaapi.*
|
||||
import net.torvald.terrarum.virtualcomputer.peripheral.*
|
||||
import net.torvald.terrarum.virtualcomputer.terminal.*
|
||||
@@ -19,7 +18,6 @@ import net.torvald.terrarum.virtualcomputer.tvd.VDUtil
|
||||
import net.torvald.terrarum.virtualcomputer.tvd.VirtualDisk
|
||||
import net.torvald.terrarum.virtualcomputer.worldobject.ComputerPartsCodex
|
||||
import org.lwjgl.BufferUtils
|
||||
import org.lwjgl.openal.AL
|
||||
import org.lwjgl.openal.AL10
|
||||
import java.io.*
|
||||
import java.nio.ByteBuffer
|
||||
@@ -100,7 +98,7 @@ class TerrarumComputer(peripheralSlots: Int) {
|
||||
// put disk in diskRack
|
||||
if (filename.isNotEmpty() && filename.isNotBlank()) {
|
||||
diskRack[slot] = VDUtil.readDiskArchive(
|
||||
File(TerrarumGDX.currentSaveDir.path + "/computers/$filename").absoluteFile,
|
||||
File(Terrarum.currentSaveDir.path + "/computers/$filename").absoluteFile,
|
||||
Level.WARNING,
|
||||
{ },
|
||||
Filesystem.sysCharset
|
||||
|
||||
@@ -4,8 +4,7 @@ import org.luaj.vm2.*
|
||||
import org.luaj.vm2.lib.OneArgFunction
|
||||
import org.luaj.vm2.lib.TwoArgFunction
|
||||
import org.luaj.vm2.lib.ZeroArgFunction
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.toHex
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import net.torvald.terrarum.virtualcomputer.luaapi.Term.Companion.checkIBM437
|
||||
import java.io.*
|
||||
@@ -63,8 +62,8 @@ internal class FilesystemDir(globals: Globals, computer: TerrarumComputer) {
|
||||
init {
|
||||
try {
|
||||
val uuid = UUID.randomUUID().toString()
|
||||
val lowerCase = File(TerrarumGDX.currentSaveDir, uuid + "oc_rox")
|
||||
val upperCase = File(TerrarumGDX.currentSaveDir, uuid + "OC_ROX")
|
||||
val lowerCase = File(Terrarum.currentSaveDir, uuid + "oc_rox")
|
||||
val upperCase = File(Terrarum.currentSaveDir, uuid + "OC_ROX")
|
||||
// This should NEVER happen but could also lead to VERY weird bugs, so we
|
||||
// make sure the files don't exist.
|
||||
if (lowerCase.exists()) lowerCase.delete()
|
||||
@@ -105,7 +104,7 @@ internal class FilesystemDir(globals: Globals, computer: TerrarumComputer) {
|
||||
*/
|
||||
fun TerrarumComputer.getRealPath(luapath: LuaValue) : String {
|
||||
// direct mounted paths to real path
|
||||
val computerDir = TerrarumGDX.currentSaveDir.absolutePath + "/computers/"
|
||||
val computerDir = Terrarum.currentSaveDir.absolutePath + "/computers/"
|
||||
/* if not begins with "(/?)media/", direct to boot
|
||||
* else, to corresponding drives
|
||||
*
|
||||
|
||||
@@ -2,12 +2,10 @@ package net.torvald.terrarum.virtualcomputer.luaapi
|
||||
|
||||
import org.luaj.vm2.Globals
|
||||
import org.luaj.vm2.LuaFunction
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameworld.WorldTime
|
||||
import org.luaj.vm2.LuaTable
|
||||
import org.luaj.vm2.LuaValue
|
||||
import org.luaj.vm2.lib.ZeroArgFunction
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Implementation of lua's os.date, to return world info of the game world.
|
||||
@@ -24,7 +22,7 @@ class WorldInformationProvider(globals: Globals) {
|
||||
companion object {
|
||||
fun getWorldTimeInLuaFormat() : LuaTable {
|
||||
val t = LuaTable()
|
||||
val time = if (TerrarumGDX.ingame != null) TerrarumGDX.ingame!!.world.time else WorldTime()
|
||||
val time = if (Terrarum.ingame != null) Terrarum.ingame!!.world.time else WorldTime()
|
||||
|
||||
// int Terrarum World Time format
|
||||
t["hour"] = time.hours
|
||||
@@ -43,7 +41,7 @@ class WorldInformationProvider(globals: Globals) {
|
||||
|
||||
/** evaluate single C date format */
|
||||
fun String.evalAsDate(): String {
|
||||
val time = if (TerrarumGDX.ingame != null) TerrarumGDX.ingame!!.world.time else WorldTime()
|
||||
val time = if (Terrarum.ingame != null) Terrarum.ingame!!.world.time else WorldTime()
|
||||
return when (this) {
|
||||
"%a" -> time.getDayNameShort()
|
||||
"%A" -> time.getDayNameFull()
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
package net.torvald.terrarum.virtualcomputer.peripheral
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.DecodeTapestry
|
||||
import net.torvald.terrarum.gameactors.ai.toLua
|
||||
import net.torvald.terrarum.virtualcomputer.computer.TerrarumComputer
|
||||
import net.torvald.terrarum.virtualcomputer.terminal.Terminal
|
||||
import org.luaj.vm2.*
|
||||
import org.luaj.vm2.lib.*
|
||||
import org.luaj.vm2.lib.ThreeArgFunction
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Resolution: 640 x 200, non-square pixels
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package net.torvald.terrarum.weather
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import net.torvald.colourutil.*
|
||||
import net.torvald.random.HQRNG
|
||||
@@ -35,7 +33,7 @@ object WeatherMixer {
|
||||
lateinit var mixedWeather: BaseModularWeather
|
||||
|
||||
val globalLightNow = Color(0)
|
||||
private val world = TerrarumGDX.ingame!!.world
|
||||
private val world = Terrarum.ingame!!.world
|
||||
|
||||
// Weather indices
|
||||
const val WEATHER_GENERIC = "generic"
|
||||
@@ -76,17 +74,17 @@ object WeatherMixer {
|
||||
currentWeather = weatherList[WEATHER_GENERIC]!![0]
|
||||
|
||||
|
||||
if (TerrarumGDX.ingame!!.player != null) {
|
||||
if (Terrarum.ingame!!.player != null) {
|
||||
// test rain toggled by F2
|
||||
if (KeyToggler.isOn(Input.Keys.F2)) {
|
||||
val playerPos = TerrarumGDX.ingame!!.player!!.centrePosPoint
|
||||
val playerPos = Terrarum.ingame!!.player!!.centrePosPoint
|
||||
kotlin.repeat(4) {
|
||||
// 4 seems good
|
||||
val rainParticle = ParticleTestRain(
|
||||
playerPos.x + HQRNG().nextInt(TerrarumGDX.WIDTH) - TerrarumGDX.HALFW,
|
||||
playerPos.y - TerrarumGDX.HALFH
|
||||
playerPos.x + HQRNG().nextInt(Terrarum.WIDTH) - Terrarum.HALFW,
|
||||
playerPos.y - Terrarum.HALFH
|
||||
)
|
||||
TerrarumGDX.ingame!!.addParticle(rainParticle)
|
||||
Terrarum.ingame!!.addParticle(rainParticle)
|
||||
}
|
||||
globalLightNow.set(getGlobalLightOfTime(world.time.todaySeconds).mul(0.3f, 0.3f, 0.3f, 1f))
|
||||
}
|
||||
@@ -106,7 +104,7 @@ object WeatherMixer {
|
||||
fun render(batch: SpriteBatch) {
|
||||
|
||||
// we will not care for nextSkybox for now
|
||||
val timeNow = TerrarumGDX.ingame!!.world.time.todaySeconds
|
||||
val timeNow = Terrarum.ingame!!.world.time.todaySeconds
|
||||
val skyboxColourMap = currentWeather.skyboxGradColourMap
|
||||
val lightColourMap = currentWeather.globalLightColourMap
|
||||
|
||||
@@ -118,11 +116,11 @@ object WeatherMixer {
|
||||
|
||||
// draw skybox to provided graphics instance
|
||||
batch.end()
|
||||
TerrarumGDX.inShapeRenderer {
|
||||
Terrarum.inShapeRenderer {
|
||||
it.rect(
|
||||
0f, 0f,
|
||||
TerrarumGDX.WIDTH.toFloat(),
|
||||
TerrarumGDX.HEIGHT.toFloat(),
|
||||
Terrarum.WIDTH.toFloat(),
|
||||
Terrarum.HEIGHT.toFloat(),
|
||||
getGradientColour(skyboxColourMap, 1, timeNow),
|
||||
getGradientColour(skyboxColourMap, 1, timeNow),
|
||||
getGradientColour(skyboxColourMap, 0, timeNow),
|
||||
|
||||
@@ -17,7 +17,6 @@ import net.torvald.terrarum.worlddrawer.WorldCamera.y
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera.height
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera.width
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.lwjgl.opengl.GL11
|
||||
import java.io.BufferedOutputStream
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
@@ -28,7 +27,7 @@ import java.util.zip.GZIPInputStream
|
||||
* Created by minjaesong on 16-01-19.
|
||||
*/
|
||||
object BlocksDrawer {
|
||||
private val world: GameWorld = TerrarumGDX.ingame!!.world
|
||||
private val world: GameWorld = Terrarum.ingame!!.world
|
||||
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
||||
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
|
||||
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockstats.BlockStats
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.colourutil.ColourTemp
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendMul
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarum.inUse
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 15-12-31.
|
||||
@@ -47,7 +44,7 @@ object FeaturesDrawer {
|
||||
* usually targeted for the environmental temperature (desert/winterland), hence the name.
|
||||
*/
|
||||
fun drawEnvOverlay(batch: SpriteBatch) {
|
||||
val onscreen_tiles_max = FastMath.ceil(TerrarumGDX.HEIGHT * TerrarumGDX.WIDTH / FastMath.sqr (TILE_SIZE.toFloat())) * 2
|
||||
val onscreen_tiles_max = FastMath.ceil(Terrarum.HEIGHT * Terrarum.WIDTH / FastMath.sqr (TILE_SIZE.toFloat())) * 2
|
||||
val onscreen_tiles_cap = onscreen_tiles_max / 4f
|
||||
val onscreen_cold_tiles = BlockStats.getCount(*TILES_COLD).toFloat()
|
||||
val onscreen_warm_tiles = BlockStats.getCount(*TILES_WARM).toFloat()
|
||||
@@ -55,15 +52,15 @@ object FeaturesDrawer {
|
||||
val colTemp_cold = colTempLinearFunc(onscreen_cold_tiles / onscreen_tiles_cap)
|
||||
val colTemp_warm = colTempLinearFunc(-(onscreen_warm_tiles / onscreen_tiles_cap))
|
||||
colTemp = colTemp_warm + colTemp_cold - ENV_COLTEMP_NOON
|
||||
val zoom = TerrarumGDX.ingame!!.screenZoom
|
||||
val zoom = Terrarum.ingame!!.screenZoom
|
||||
|
||||
blendMul()
|
||||
|
||||
batch.color = ColourTemp(colTemp)
|
||||
batch.fillRect(WorldCamera.x * zoom,
|
||||
WorldCamera.y * zoom,
|
||||
TerrarumGDX.WIDTH * if (zoom < 1) 1f / zoom else zoom,
|
||||
TerrarumGDX.HEIGHT * if (zoom < 1) 1f / zoom else zoom
|
||||
Terrarum.WIDTH * if (zoom < 1) 1f / zoom else zoom,
|
||||
Terrarum.HEIGHT * if (zoom < 1) 1f / zoom else zoom
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.StateInGameGDX
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Ingame
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.inUse
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Warning: you are not going to store float value to the lightmap -- see RGB_HDR_LUT (beziér)
|
||||
*
|
||||
* Created by minjaesong on 16-01-25.
|
||||
*/
|
||||
|
||||
typealias RGB10 = Int
|
||||
|
||||
object LightmapRenderer {
|
||||
private val world: GameWorld = TerrarumGDX.ingame!!.world
|
||||
private val world: GameWorld = Terrarum.ingame!!.world
|
||||
|
||||
|
||||
// TODO if (VBO works on BlocksDrawer) THEN overscan of 256, utilise same technique in here
|
||||
@@ -32,18 +31,22 @@ object LightmapRenderer {
|
||||
val overscan_open: Int = Math.min(32, 256f.div(BlockCodex[Block.AIR].opacity and 0xFF).ceil())
|
||||
val overscan_opaque: Int = Math.min(8, 256f.div(BlockCodex[Block.STONE].opacity and 0xFF).ceil())
|
||||
|
||||
init {
|
||||
println("[LightmapRenderer] Overscan open: $overscan_open; opaque: $overscan_opaque")
|
||||
}
|
||||
|
||||
// TODO resize(int, int) -aware
|
||||
|
||||
val LIGHTMAP_WIDTH = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(TerrarumGDX.WIDTH)
|
||||
val LIGHTMAP_WIDTH = Terrarum.ingame!!.ZOOM_MINIMUM.inv().times(Terrarum.WIDTH)
|
||||
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
val LIGHTMAP_HEIGHT = TerrarumGDX.ingame!!.ZOOM_MINIMUM.inv().times(TerrarumGDX.HEIGHT)
|
||||
val LIGHTMAP_HEIGHT = Terrarum.ingame!!.ZOOM_MINIMUM.inv().times(Terrarum.HEIGHT)
|
||||
.div(FeaturesDrawer.TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
|
||||
/**
|
||||
* 8-Bit RGB values
|
||||
*/
|
||||
private val lightmap: Array<IntArray> = Array(LIGHTMAP_HEIGHT) { IntArray(LIGHTMAP_WIDTH) } // TODO framebuffer?
|
||||
private val lanternMap = ArrayList<Lantern>(TerrarumGDX.ingame!!.ACTORCONTAINER_INITIAL_SIZE * 4)
|
||||
private val lanternMap = ArrayList<Lantern>(Terrarum.ingame!!.ACTORCONTAINER_INITIAL_SIZE * 4)
|
||||
|
||||
private val AIR = Block.AIR
|
||||
|
||||
@@ -52,7 +55,7 @@ object LightmapRenderer {
|
||||
private val OFFSET_B = 0
|
||||
|
||||
private const val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
||||
private val DRAW_TILE_SIZE: Float = FeaturesDrawer.TILE_SIZE / StateInGameGDX.lightmapDownsample
|
||||
private val DRAW_TILE_SIZE: Float = FeaturesDrawer.TILE_SIZE / Ingame.lightmapDownsample
|
||||
|
||||
// color model related constants
|
||||
const val MUL = 1024 // modify this to 1024 to implement 30-bit RGB
|
||||
@@ -161,7 +164,7 @@ object LightmapRenderer {
|
||||
// build noop map
|
||||
for (i in 0..rect_size) {
|
||||
val point = edgeToMaskNum(i)
|
||||
val tile = TerrarumGDX.ingame!!.world.getTileFromTerrain(point.first, point.second) ?: Block.NULL
|
||||
val tile = Terrarum.ingame!!.world.getTileFromTerrain(point.first, point.second) ?: Block.NULL
|
||||
val isSolid = BlockCodex[tile].isSolid
|
||||
|
||||
noop_mask.set(i, isSolid)
|
||||
@@ -218,7 +221,7 @@ object LightmapRenderer {
|
||||
|
||||
private fun buildLanternmap() {
|
||||
lanternMap.clear()
|
||||
TerrarumGDX.ingame!!.actorContainer.forEach { it ->
|
||||
Terrarum.ingame!!.actorContainer.forEach { it ->
|
||||
if (it is Luminous && it is ActorWithPhysics) {
|
||||
// put lanterns to the area the luminantBox is occupying
|
||||
for (lightBox in it.lightBoxList) {
|
||||
@@ -250,11 +253,11 @@ object LightmapRenderer {
|
||||
var ambientAccumulator = 0
|
||||
|
||||
var lightLevelThis: Int = 0
|
||||
val thisTerrain = TerrarumGDX.ingame!!.world.getTileFromTerrain(x, y)
|
||||
val thisWall = TerrarumGDX.ingame!!.world.getTileFromWall(x, y)
|
||||
val thisTerrain = Terrarum.ingame!!.world.getTileFromTerrain(x, y)
|
||||
val thisWall = Terrarum.ingame!!.world.getTileFromWall(x, y)
|
||||
val thisTileLuminosity = BlockCodex[thisTerrain].luminosity
|
||||
val thisTileOpacity = BlockCodex[thisTerrain].opacity
|
||||
val sunLight = TerrarumGDX.ingame!!.world.globalLight
|
||||
val sunLight = Terrarum.ingame!!.world.globalLight
|
||||
|
||||
// MIX TILE
|
||||
// open air
|
||||
@@ -350,8 +353,8 @@ object LightmapRenderer {
|
||||
batch.fillRect(
|
||||
(x * DRAW_TILE_SIZE).round().toFloat(),
|
||||
(y * DRAW_TILE_SIZE).round().toFloat(),
|
||||
(DRAW_TILE_SIZE.ceil() * sameLevelCounter).toFloat(),
|
||||
DRAW_TILE_SIZE.ceil().toFloat() + 1f
|
||||
DRAW_TILE_SIZE.ceil() * sameLevelCounter + 1f,
|
||||
DRAW_TILE_SIZE.ceil() + 1f
|
||||
)
|
||||
|
||||
x += sameLevelCounter - 1
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.gameactors.ceilInt
|
||||
import net.torvald.terrarum.gameactors.floor
|
||||
import net.torvald.terrarum.gameactors.floorInt
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.round
|
||||
@@ -14,7 +10,7 @@ import net.torvald.terrarum.round
|
||||
* Created by minjaesong on 2016-12-30.
|
||||
*/
|
||||
object WorldCamera {
|
||||
private val world: GameWorld? = TerrarumGDX.ingame?.world
|
||||
private val world: GameWorld? = Terrarum.ingame?.world
|
||||
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
|
||||
|
||||
var x: Int = 0
|
||||
@@ -35,12 +31,12 @@ object WorldCamera {
|
||||
get() = y + height.ushr(1)
|
||||
|
||||
fun update() {
|
||||
if (TerrarumGDX.ingame != null) {
|
||||
if (Terrarum.ingame != null) {
|
||||
|
||||
val player = TerrarumGDX.ingame!!.player
|
||||
val player = Terrarum.ingame!!.player
|
||||
|
||||
width = FastMath.ceil(TerrarumGDX.WIDTH / TerrarumGDX.ingame!!.screenZoom) // div, not mul
|
||||
height = FastMath.ceil(TerrarumGDX.HEIGHT / TerrarumGDX.ingame!!.screenZoom)
|
||||
width = FastMath.ceil(Terrarum.WIDTH / Terrarum.ingame!!.screenZoom) // div, not mul
|
||||
height = FastMath.ceil(Terrarum.HEIGHT / Terrarum.ingame!!.screenZoom)
|
||||
|
||||
// position - (WH / 2)
|
||||
x = (// X only: ROUNDWORLD implementation
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.torvald.terrarum.blockproperties.Block
|
||||
import com.jme3.math.FastMath
|
||||
import com.sudoplay.joise.Joise
|
||||
import com.sudoplay.joise.module.*
|
||||
import net.torvald.terrarum.TerrarumGDX
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.concurrent.ThreadParallel
|
||||
import net.torvald.terrarum.gameactors.roundInt
|
||||
import java.util.*
|
||||
@@ -748,14 +748,14 @@ object WorldGenerator {
|
||||
}
|
||||
|
||||
private fun processNoiseLayers(noiseRecords: Array<TaggedJoise>) {
|
||||
if (TerrarumGDX.MULTITHREAD) {
|
||||
if (Terrarum.MULTITHREAD) {
|
||||
// set up indices
|
||||
for (i in 0..TerrarumGDX.THREADS - 1) {
|
||||
for (i in 0..Terrarum.THREADS - 1) {
|
||||
ThreadParallel.map(
|
||||
i,
|
||||
ThreadProcessNoiseLayers(
|
||||
HEIGHT.toFloat().div(TerrarumGDX.THREADS).times(i).roundInt(),
|
||||
HEIGHT.toFloat().div(TerrarumGDX.THREADS).times(i.plus(1)).roundInt() - 1,
|
||||
HEIGHT.toFloat().div(Terrarum.THREADS).times(i).roundInt(),
|
||||
HEIGHT.toFloat().div(Terrarum.THREADS).times(i.plus(1)).roundInt() - 1,
|
||||
noiseRecords
|
||||
),
|
||||
"SampleJoiseMap"
|
||||
|
||||
@@ -34,14 +34,10 @@ bb bb bb bb bb bb bb bb // 64 bits make one tick
|
||||
|Note Note
|
||||
|(C6) (C1)
|
||||
3 bits are program notes, which are:
|
||||
- 000 : NOP
|
||||
- 001 : (unused)
|
||||
- 010 : Halve the speed (applied to next tick)
|
||||
- 011 : Double the speed (applied to next tick)
|
||||
- 100 : Quarter the speed (applied to next tick)
|
||||
- 101 : Quadruple the speed (applied to next tick)
|
||||
- 110 : (unused)
|
||||
- 111 : Play current tick and halt
|
||||
- 000 : NOP, turns off all effects
|
||||
- 001 : Engage down-arpeggiator
|
||||
- 010 : Engage up-arpeggiator
|
||||
- 100 : Engage triggering repeat on that single row (can be combined with arpeggio)
|
||||
|
||||
================================================================================
|
||||
Computer tape format
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user