mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
dump (another useless message)
This commit is contained in:
5
.idea/compiler.xml
generated
5
.idea/compiler.xml
generated
@@ -4,6 +4,9 @@
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="true" />
|
||||
</annotationProcessing>
|
||||
<bytecodeTargetLevel target="1.8" />
|
||||
<bytecodeTargetLevel target="8" />
|
||||
</component>
|
||||
<component name="JavacSettings">
|
||||
<option name="PREFER_TARGET_JDK_COMPILER" value="false" />
|
||||
</component>
|
||||
</project>
|
||||
2
.idea/misc.xml
generated
2
.idea/misc.xml
generated
@@ -38,7 +38,7 @@
|
||||
<property name="caretWidth" class="java.lang.Integer" />
|
||||
</properties>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="true" project-jdk-name="OpenJDK 10" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
BIN
assets/graphics/circle_512.tga
LFS
Normal file
BIN
assets/graphics/circle_512.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
assets/graphics/fonts/terrarum-sans-bitmap/tsalagi_variable.tga
LFS
Normal file
BIN
assets/graphics/fonts/terrarum-sans-bitmap/tsalagi_variable.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
BIN
assets/mods/basegame/gui/building_maker_toolbox.tga
LFS
Normal file
BIN
assets/mods/basegame/gui/building_maker_toolbox.tga
LFS
Normal file
Binary file not shown.
@@ -4,10 +4,10 @@
|
||||
*/
|
||||
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.itemproperties.Calculate
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
@@ -60,7 +60,7 @@ class TestPick extends GameItem {
|
||||
int mouseTileY = Terrarum.getMouseTileY()
|
||||
|
||||
def mousePoint = new Point2d(mouseTileX, mouseTileY)
|
||||
def actorvalue = Terrarum.ingame.player.actorValue
|
||||
def actorvalue = Terrarum.ingame.playableActor.actorValue
|
||||
|
||||
using = true
|
||||
|
||||
@@ -80,7 +80,7 @@ class TestPick extends GameItem {
|
||||
|
||||
Terrarum.ingame.world.inflictTerrainDamage(
|
||||
mouseTileX, mouseTileY,
|
||||
Calculate.pickaxePower(Terrarum.ingame.player, material) * swingDmgToFrameDmg
|
||||
Calculate.pickaxePower(Terrarum.ingame.playableActor, material) * swingDmgToFrameDmg
|
||||
)
|
||||
|
||||
return true
|
||||
@@ -90,7 +90,7 @@ class TestPick extends GameItem {
|
||||
boolean endPrimaryUse(float delta) {
|
||||
using = false
|
||||
// reset action timer to zero
|
||||
Terrarum.ingame.player.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
|
||||
Terrarum.ingame.playableActor.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,7 +1,7 @@
|
||||
package net.torvald.aa
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.sqr
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ class KDHeapifiedTree() {
|
||||
|
||||
private val dimension = 2
|
||||
private val initialSize = 128
|
||||
private val nodes = Array<ActorWithPhysics?>(initialSize, { null })
|
||||
private val nodes = Array<ActorWBMovable?>(initialSize, { null })
|
||||
|
||||
private val root: Int = 0
|
||||
|
||||
@@ -32,13 +32,13 @@ class KDHeapifiedTree() {
|
||||
private fun Int.getActor() = nodes[this]
|
||||
private fun Int.getLeft() = this * 2 + 1
|
||||
private fun Int.getRight() = this * 2 + 2
|
||||
private fun Int.set(value: ActorWithPhysics?) { nodes[this] = value }
|
||||
private fun Int.setLeftChild(value: ActorWithPhysics?) { nodes[this.getLeft()] = value }
|
||||
private fun Int.setRightChild(value: ActorWithPhysics?) { nodes[this.getRight()] = value }
|
||||
private fun Int.set(value: ActorWBMovable?) { nodes[this] = value }
|
||||
private fun Int.setLeftChild(value: ActorWBMovable?) { nodes[this.getLeft()] = value }
|
||||
private fun Int.setRightChild(value: ActorWBMovable?) { nodes[this.getRight()] = value }
|
||||
|
||||
private val zeroPoint = Point2d(0.0, 0.0)
|
||||
|
||||
private fun create(points: List<ActorWithPhysics?>, depth: Int, index: Int): ActorWithPhysics? {
|
||||
private fun create(points: List<ActorWBMovable?>, depth: Int, index: Int): ActorWBMovable? {
|
||||
if (points.isEmpty()) {
|
||||
index.set(null)
|
||||
|
||||
@@ -89,7 +89,7 @@ class KDHeapifiedTree() {
|
||||
|
||||
private fun expandArray() {
|
||||
val prevNodes = nodes.copyOf()
|
||||
Array<ActorWithPhysics?>(prevNodes.size * 2, { null })
|
||||
Array<ActorWBMovable?>(prevNodes.size * 2, { null })
|
||||
create(prevNodes.toList(), 0, 0)
|
||||
}
|
||||
|
||||
|
||||
@@ -143,18 +143,35 @@ object CIEXYZUtil {
|
||||
}
|
||||
|
||||
fun CIEXYZ.toRGB(): RGB {
|
||||
val r = 3.2404542f * X - 1.5371385f * Y - 0.4985314f * Z
|
||||
val r = 3.2404542f * X - 1.5371385f * Y - 0.4985314f * Z
|
||||
val g = -0.9692660f * X + 1.8760108f * Y + 0.0415560f * Z
|
||||
val b = 0.0556434f * X - 0.2040259f * Y + 1.0572252f * Z
|
||||
val b = 0.0556434f * X - 0.2040259f * Y + 1.0572252f * Z
|
||||
|
||||
return RGB(r, g, b, alpha).unLinearise()
|
||||
}
|
||||
|
||||
fun CIEXYZ.toRGBRaw(): RGB {
|
||||
val r = 3.2404542f * X - 1.5371385f * Y - 0.4985314f * Z
|
||||
val g = -0.9692660f * X + 1.8760108f * Y + 0.0415560f * Z
|
||||
val b = 0.0556434f * X - 0.2040259f * Y + 1.0572252f * Z
|
||||
|
||||
return RGB(r, g, b, alpha)
|
||||
}
|
||||
|
||||
fun CIEXYZ.toColor(): Color {
|
||||
val rgb = this.toRGB()
|
||||
return Color(rgb.r, rgb.g, rgb.b, rgb.alpha)
|
||||
}
|
||||
|
||||
fun CIEXYZ.toColorRaw(): Color {
|
||||
val rgb = this.toRGBRaw()
|
||||
return Color(rgb.r, rgb.g, rgb.b, rgb.alpha)
|
||||
}
|
||||
|
||||
fun CIEYXY.toXYZ(): CIEXYZ {
|
||||
return CIEXYZ(x * yy / y, yy, (1f - x - y) * yy / y)
|
||||
}
|
||||
|
||||
fun colourTempToXYZ(temp: Float, Y: Float): CIEXYZ {
|
||||
val x = if (temp < 7000)
|
||||
-4607000000f / FastMath.pow(temp, 3f) + 2967800f / FastMath.pow(temp, 2f) + 99.11f / temp + 0.244063f
|
||||
@@ -187,11 +204,18 @@ object CIEXYZUtil {
|
||||
/** Range: X, Y, Z: 0 - 1.0+ (One-based-plus) */
|
||||
data class CIEXYZ(var X: Float = 0f, var Y: Float = 0f, var Z: Float = 0f, var alpha: Float = 1f) {
|
||||
init {
|
||||
if (X > 2f || Y > 2f || Z > 2f)
|
||||
if (X !in -5f..5f || Y!in -5f..5f || Z !in -5f..5f)
|
||||
throw IllegalArgumentException("Value range error - this version of CIEXYZ is one-based (0.0 - 1.0+): ($X, $Y, $Z)")
|
||||
}
|
||||
}
|
||||
|
||||
data class CIEYXY(val yy: Float = 0f, var x: Float = 0f, var y: Float = 0f, var alpha: Float = 1f) {
|
||||
init {
|
||||
if (yy < 0f || x < 0f || y < 0f)
|
||||
throw IllegalArgumentException("Value range error - parametres of YXY cannot be negative: ($yy, $x, $y)")
|
||||
}
|
||||
}
|
||||
|
||||
/** Range: r, g, b: 0 - 1.0 (One-based) */
|
||||
data class RGB(var r: Float = 0f, var g: Float = 0f, var b: Float = 0f, var alpha: Float = 1f) {
|
||||
constructor(color: Color) : this() {
|
||||
|
||||
134
src/net/torvald/dataclass/ArrayListMap.kt
Normal file
134
src/net/torvald/dataclass/ArrayListMap.kt
Normal file
@@ -0,0 +1,134 @@
|
||||
package net.torvald.dataclass
|
||||
|
||||
import java.util.function.BiConsumer
|
||||
import java.util.function.BiFunction
|
||||
import java.util.function.Function
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2018-07-15.
|
||||
*/
|
||||
class ArrayListMap<K, V> : MutableMap<K, V> {
|
||||
|
||||
private val keysArray = ArrayList<K>()
|
||||
private val valuesArray = ArrayList<V>()
|
||||
|
||||
override val entries: MutableSet<MutableMap.MutableEntry<K, V>>
|
||||
get() = TODO("not implemented") //To change initializer of created properties use File | Settings | File Templates.
|
||||
|
||||
override val size: Int
|
||||
get() = keysArray.size
|
||||
|
||||
override val values: MutableCollection<V>
|
||||
get() = valuesArray.toMutableSet()
|
||||
|
||||
override val keys: MutableSet<K>
|
||||
get() = keysArray.toMutableSet()
|
||||
|
||||
|
||||
|
||||
override fun containsKey(key: K): Boolean {
|
||||
return keysArray.contains(key)
|
||||
}
|
||||
|
||||
override fun containsValue(value: V): Boolean {
|
||||
return valuesArray.contains(value)
|
||||
}
|
||||
|
||||
override fun forEach(action: BiConsumer<in K, in V>) {
|
||||
for (i in 0 until size) {
|
||||
action.accept(keysArray[i], valuesArray[i])
|
||||
}
|
||||
}
|
||||
|
||||
override fun get(key: K): V? {
|
||||
val index = keysArray.linearSearch(key)
|
||||
index?.let {
|
||||
return valuesArray[index]
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun getOrDefault(key: K, defaultValue: V): V {
|
||||
return get(key) ?: defaultValue
|
||||
}
|
||||
|
||||
override fun isEmpty(): Boolean {
|
||||
return size == 0
|
||||
}
|
||||
|
||||
|
||||
private fun ArrayList<K>.linearSearch(element: K): Int? {
|
||||
var found = 0
|
||||
while (found < keysArray.size) {
|
||||
if (keysArray[found] == element)
|
||||
return found
|
||||
|
||||
found++
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
override fun put(key: K, value: V): V? {
|
||||
val index = keysArray.linearSearch(key)
|
||||
if (index != null) {
|
||||
val oldValue = valuesArray[index]
|
||||
valuesArray[index] = value
|
||||
return oldValue
|
||||
}
|
||||
else {
|
||||
keysArray.add(key)
|
||||
valuesArray.add(value)
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun compute(key: K, remappingFunction: BiFunction<in K, in V?, out V?>): V? {
|
||||
return super.compute(key, remappingFunction)
|
||||
}
|
||||
|
||||
override fun computeIfAbsent(key: K, mappingFunction: Function<in K, out V>): V {
|
||||
return super.computeIfAbsent(key, mappingFunction)
|
||||
}
|
||||
|
||||
override fun computeIfPresent(key: K, remappingFunction: BiFunction<in K, in V, out V?>): V? {
|
||||
return super.computeIfPresent(key, remappingFunction)
|
||||
}
|
||||
|
||||
override fun merge(key: K, value: V, remappingFunction: BiFunction<in V, in V, out V?>): V? {
|
||||
return super.merge(key, value, remappingFunction)
|
||||
}
|
||||
|
||||
override fun putAll(from: Map<out K, V>) {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun putIfAbsent(key: K, value: V): V? {
|
||||
return super.putIfAbsent(key, value)
|
||||
}
|
||||
|
||||
override fun remove(key: K): V? {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun remove(key: K, value: V): Boolean {
|
||||
return super.remove(key, value)
|
||||
}
|
||||
|
||||
override fun replace(key: K, oldValue: V, newValue: V): Boolean {
|
||||
return super.replace(key, oldValue, newValue)
|
||||
}
|
||||
|
||||
override fun replace(key: K, value: V): V? {
|
||||
return super.replace(key, value)
|
||||
}
|
||||
|
||||
override fun replaceAll(function: BiFunction<in K, in V, out V>) {
|
||||
super.replaceAll(function)
|
||||
}
|
||||
|
||||
}
|
||||
171
src/net/torvald/dataclass/Matrix.kt
Normal file
171
src/net/torvald/dataclass/Matrix.kt
Normal file
@@ -0,0 +1,171 @@
|
||||
package net.torvald.dataclass
|
||||
|
||||
/**
|
||||
* Taken and improved from https://introcs.cs.princeton.edu/java/95linear/Matrix.java.html
|
||||
*
|
||||
* Created by minjaesong on 2018-08-01.
|
||||
*/
|
||||
class Matrix {
|
||||
val rows: Int // number of rows; M
|
||||
val cols: Int // number of columns; N
|
||||
val data: Array<DoubleArray> // M-by-N array
|
||||
|
||||
// create M-by-N matrix of 0's
|
||||
constructor(M: Int, N: Int) {
|
||||
this.rows = M
|
||||
this.cols = N
|
||||
data = Array(M) { DoubleArray(N) }
|
||||
}
|
||||
|
||||
// create matrix based on 2d array
|
||||
constructor(data: Array<DoubleArray>) {
|
||||
rows = data.size
|
||||
cols = data[0].size
|
||||
this.data = Array(rows) { DoubleArray(cols) }
|
||||
for (i in 0 until rows)
|
||||
for (j in 0 until cols)
|
||||
this.data[i][j] = data[i][j]
|
||||
}
|
||||
|
||||
// copy constructor
|
||||
private constructor(A: Matrix) : this(A.data) {}
|
||||
|
||||
// swap rows i and j
|
||||
private fun swap(i: Int, j: Int) {
|
||||
val temp = data[i]
|
||||
data[i] = data[j]
|
||||
data[j] = temp
|
||||
}
|
||||
|
||||
// create and return the transpose of the invoking matrix
|
||||
fun transpose(): Matrix {
|
||||
val A = Matrix(cols, rows)
|
||||
for (i in 0 until rows)
|
||||
for (j in 0 until cols)
|
||||
A.data[j][i] = this.data[i][j]
|
||||
return A
|
||||
}
|
||||
|
||||
// return C = A + B
|
||||
operator fun plus(B: Matrix): Matrix {
|
||||
val A = this
|
||||
if (B.rows != A.rows || B.cols != A.cols) throw RuntimeException("Illegal matrix dimensions.")
|
||||
val C = Matrix(rows, cols)
|
||||
for (i in 0 until rows)
|
||||
for (j in 0 until cols)
|
||||
C.data[i][j] = A.data[i][j] + B.data[i][j]
|
||||
return C
|
||||
}
|
||||
|
||||
|
||||
// return C = A - B
|
||||
operator fun minus(B: Matrix): Matrix {
|
||||
val A = this
|
||||
if (B.rows != A.rows || B.cols != A.cols) throw RuntimeException("Illegal matrix dimensions.")
|
||||
val C = Matrix(rows, cols)
|
||||
for (i in 0 until rows)
|
||||
for (j in 0 until cols)
|
||||
C.data[i][j] = A.data[i][j] - B.data[i][j]
|
||||
return C
|
||||
}
|
||||
|
||||
// does A = B exactly?
|
||||
override fun equals(B: Any?): Boolean {
|
||||
if (B !is Matrix) throw RuntimeException("Not a Matrix.")
|
||||
|
||||
val A = this
|
||||
if (B.rows != A.rows || B.cols != A.cols) throw RuntimeException("Illegal matrix dimensions.")
|
||||
for (i in 0 until rows)
|
||||
for (j in 0 until cols)
|
||||
if (A.data[i][j] != B.data[i][j]) return false
|
||||
return true
|
||||
}
|
||||
|
||||
// return C = A * B
|
||||
operator fun times(B: Matrix): Matrix {
|
||||
val A = this
|
||||
if (A.cols != B.rows) throw RuntimeException("Illegal matrix dimensions.")
|
||||
val C = Matrix(A.rows, B.cols)
|
||||
for (i in 0 until C.rows)
|
||||
for (j in 0 until C.cols)
|
||||
for (k in 0 until A.cols)
|
||||
C.data[i][j] += A.data[i][k] * B.data[k][j]
|
||||
return C
|
||||
}
|
||||
|
||||
|
||||
// return x = A^-1 b, assuming A is square and has full rank
|
||||
fun solve(rhs: Matrix): Matrix {
|
||||
if (rows != cols || rhs.rows != cols || rhs.cols != 1)
|
||||
throw RuntimeException("Illegal matrix dimensions.")
|
||||
|
||||
// create copies of the data
|
||||
val A = Matrix(this)
|
||||
val b = Matrix(rhs)
|
||||
|
||||
// Gaussian elimination with partial pivoting
|
||||
for (i in 0 until cols) {
|
||||
|
||||
// find pivot row and swap
|
||||
var max = i
|
||||
for (j in i + 1 until cols)
|
||||
if (Math.abs(A.data[j][i]) > Math.abs(A.data[max][i]))
|
||||
max = j
|
||||
A.swap(i, max)
|
||||
b.swap(i, max)
|
||||
|
||||
// singular
|
||||
if (A.data[i][i] == 0.0) throw RuntimeException("Matrix is singular.")
|
||||
|
||||
// pivot within b
|
||||
for (j in i + 1 until cols)
|
||||
b.data[j][0] -= b.data[i][0] * A.data[j][i] / A.data[i][i]
|
||||
|
||||
// pivot within A
|
||||
for (j in i + 1 until cols) {
|
||||
val m = A.data[j][i] / A.data[i][i]
|
||||
for (k in i + 1 until cols) {
|
||||
A.data[j][k] -= A.data[i][k] * m
|
||||
}
|
||||
A.data[j][i] = 0.0
|
||||
}
|
||||
}
|
||||
|
||||
// back substitution
|
||||
val x = Matrix(cols, 1)
|
||||
for (j in cols - 1 downTo 0) {
|
||||
var t = 0.0
|
||||
for (k in j + 1 until cols)
|
||||
t += A.data[j][k] * x.data[k][0]
|
||||
x.data[j][0] = (b.data[j][0] - t) / A.data[j][j]
|
||||
}
|
||||
return x
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* for idioms of ```element = mat[row][column]```
|
||||
*/
|
||||
operator fun get(i: Int): DoubleArray = data[i]
|
||||
|
||||
companion object {
|
||||
|
||||
// create and return a random M-by-N matrix with values between 0 and 1
|
||||
fun random(M: Int, N: Int): Matrix {
|
||||
val A = Matrix(M, N)
|
||||
for (i in 0 until M)
|
||||
for (j in 0 until N)
|
||||
A.data[i][j] = Math.random()
|
||||
return A
|
||||
}
|
||||
|
||||
// create and return the N-by-N identity matrix
|
||||
fun identity(N: Int): Matrix {
|
||||
val I = Matrix(N, N)
|
||||
for (i in 0 until N)
|
||||
I.data[i][i] = 1.0
|
||||
return I
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -7,10 +7,10 @@ package net.torvald.spriteanimation
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
class SpriteAnimation(val parentActor: ActorWithPhysics) {
|
||||
class SpriteAnimation(val parentActor: ActorWBMovable) {
|
||||
|
||||
private lateinit var textureRegion: TextureRegionPack
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ public class AppLoader implements ApplicationListener {
|
||||
}
|
||||
|
||||
public static final String GAME_NAME = "Terrarum";
|
||||
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2017 Torvald (minjaesong)";
|
||||
public static final String COPYRIGHT_DATE_NAME = "Copyright 2013-2018 Torvald (minjaesong)";
|
||||
public static String GAME_LOCALE = System.getProperty("user.language") + System.getProperty("user.country");
|
||||
|
||||
private static final String[] localeSimple = {"de", "en", "es", "it"}; // must be sorted!!
|
||||
@@ -64,9 +64,6 @@ public class AppLoader implements ApplicationListener {
|
||||
GAME_LOCALE = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fontGame.reload(value);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,8 +96,10 @@ public class AppLoader implements ApplicationListener {
|
||||
appConfig = new LwjglApplicationConfiguration();
|
||||
appConfig.vSyncEnabled = false;
|
||||
appConfig.resizable = false;//true;
|
||||
appConfig.width = 1072;
|
||||
appConfig.height = 742;
|
||||
//appConfig.width = 1072; // IMAX ratio
|
||||
//appConfig.height = 742; // IMAX ratio
|
||||
appConfig.width = 1110; // photographic ratio (1.5:1)
|
||||
appConfig.height = 740; // photographic ratio (1.5:1)
|
||||
appConfig.backgroundFPS = 9999;
|
||||
appConfig.foregroundFPS = 9999;
|
||||
appConfig.title = GAME_NAME;
|
||||
|
||||
@@ -90,6 +90,8 @@ object DefaultConfig {
|
||||
jsonObject.addProperty("fx3dlut", false)
|
||||
|
||||
|
||||
jsonObject.addProperty("__debug", false)
|
||||
|
||||
|
||||
return jsonObject
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package net.torvald.point
|
||||
package net.torvald.terrarum
|
||||
|
||||
import net.torvald.terrarum.sqr
|
||||
import net.torvald.terrarum.sqrt
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.graphics.glutils.ShaderProgram
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
@@ -30,17 +31,13 @@ object PostProcessor {
|
||||
if (textureRegion == null) {
|
||||
textureRegion = TextureRegion(fbo.colorBufferTexture)
|
||||
batch = SpriteBatch()
|
||||
//camera = OrthographicCamera(AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
|
||||
//camera.setToOrtho(true, AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
//camera.update()
|
||||
Gdx.gl20.glViewport(0, 0, AppLoader.appConfig.width, AppLoader.appConfig.height)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Terrarum.debugTimers["GFX.PostProcessor"] = measureNanoTime {
|
||||
Terrarum.debugTimers["Renderer.PostProcessor"] = measureNanoTime {
|
||||
|
||||
Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||
@@ -48,18 +45,20 @@ object PostProcessor {
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
|
||||
val shader = AppLoader.shaderHicolour
|
||||
|
||||
// no-screen screen renders but the game don't? wtf?
|
||||
val shader: ShaderProgram? =
|
||||
if (Terrarum.getConfigBoolean("fxdither"))
|
||||
AppLoader.shaderHicolour
|
||||
else
|
||||
null
|
||||
|
||||
fbo.colorBufferTexture.bind(0)
|
||||
|
||||
shader.begin()
|
||||
shader.setUniformf("resolution", AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
shader.setUniformMatrix("u_projTrans", projMat)
|
||||
shader.setUniformi("u_texture", 0)
|
||||
shader?.begin()
|
||||
shader?.setUniformf("resolution", AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
shader?.setUniformMatrix("u_projTrans", projMat)
|
||||
shader?.setUniformi("u_texture", 0)
|
||||
AppLoader.fullscreenQuad.render(shader, GL20.GL_TRIANGLES)
|
||||
shader.end()
|
||||
shader?.end()
|
||||
|
||||
|
||||
Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0) // so that batch that comes next will bind any tex to it
|
||||
|
||||
@@ -12,10 +12,14 @@ import com.badlogic.gdx.utils.GdxRuntimeException
|
||||
import com.google.gson.JsonArray
|
||||
import com.google.gson.JsonPrimitive
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.dataclass.ArrayListMap
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.ui.ConsoleWindow
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import net.torvald.terrarum.utils.JsonWriter
|
||||
@@ -27,7 +31,7 @@ import org.lwjgl.BufferUtils
|
||||
import org.lwjgl.input.Controllers
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
import java.util.ArrayList
|
||||
import java.util.*
|
||||
import java.util.concurrent.locks.Lock
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import javax.swing.JOptionPane
|
||||
@@ -44,7 +48,12 @@ typealias RGBA8888 = Int
|
||||
*/
|
||||
object Terrarum : Screen {
|
||||
|
||||
val debugTimers = HashMap<String, Long>()
|
||||
/**
|
||||
* All singleplayer "Player" must have this exact reference ID.
|
||||
*/
|
||||
const val PLAYER_REF_ID: Int = 0x91A7E2
|
||||
|
||||
val debugTimers = ArrayListMap<String, Long>()
|
||||
|
||||
var screenW = 0
|
||||
var screenH = 0
|
||||
@@ -209,11 +218,12 @@ object Terrarum : Screen {
|
||||
val deltaTime: Float; get() = Gdx.graphics.rawDeltaTime
|
||||
|
||||
|
||||
lateinit var assetManager: AssetManager
|
||||
lateinit var assetManager: AssetManager // TODO
|
||||
|
||||
|
||||
init {
|
||||
println("$NAME version ${AppLoader.getVERSION_STRING()}")
|
||||
println("Java Runtime version ${System.getProperty("java.version")}")
|
||||
|
||||
|
||||
getDefaultDirectory()
|
||||
@@ -401,26 +411,28 @@ object Terrarum : Screen {
|
||||
//appLoader.setScreen(FuckingWorldRenderer(batch))
|
||||
}
|
||||
|
||||
internal fun setScreen(screen: Screen) {
|
||||
fun setScreen(screen: Screen) {
|
||||
AppLoader.getINSTANCE().setScreen(screen)
|
||||
}
|
||||
|
||||
override fun render(delta: Float) {
|
||||
Terrarum.debugTimers["GDX.delta"] = delta.times(1000_000_000f).toLong()
|
||||
AppLoader.getINSTANCE().screen.render(deltaTime)
|
||||
//GLOBAL_RENDER_TIMER += 1
|
||||
// moved to AppLoader; global event must be place at the apploader to prevent ACCIDENTAL forgot-to-update type of bug.
|
||||
}
|
||||
|
||||
override fun pause() {
|
||||
//appLoader.screen.pause()
|
||||
AppLoader.getINSTANCE().screen.pause()
|
||||
}
|
||||
|
||||
override fun resume() {
|
||||
//appLoader.screen.resume()
|
||||
AppLoader.getINSTANCE().screen.resume()
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
//appLoader.screen.dispose()
|
||||
AppLoader.getINSTANCE().screen.dispose()
|
||||
|
||||
fontGame.dispose()
|
||||
fontSmallNumbers.dispose()
|
||||
|
||||
@@ -439,7 +451,7 @@ object Terrarum : Screen {
|
||||
}
|
||||
|
||||
override fun hide() {
|
||||
|
||||
AppLoader.getINSTANCE().screen.hide()
|
||||
}
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
@@ -456,6 +468,11 @@ object Terrarum : Screen {
|
||||
screenH = height
|
||||
|
||||
|
||||
try {
|
||||
AppLoader.getINSTANCE().screen.resize(screenW, screenH)
|
||||
}
|
||||
catch (e: NullPointerException) { }
|
||||
|
||||
// re-calculate fullscreen quad
|
||||
//updateFullscreenQuad(screenW, screenH)
|
||||
|
||||
@@ -664,6 +681,35 @@ object Terrarum : Screen {
|
||||
get() = Gdx.input.x
|
||||
inline val mouseScreenY: Int
|
||||
get() = Gdx.input.y
|
||||
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
*
|
||||
* override var referenceID: Int = generateUniqueReferenceID()
|
||||
*/
|
||||
fun generateUniqueReferenceID(renderOrder: Actor.RenderOrder): ActorID {
|
||||
fun hasCollision(value: ActorID) =
|
||||
try {
|
||||
Terrarum.ingame!!.theGameHasActor(value) ||
|
||||
value < ItemCodex.ACTORID_MIN ||
|
||||
value !in when (renderOrder) {
|
||||
Actor.RenderOrder.BEHIND -> Actor.RANGE_BEHIND
|
||||
Actor.RenderOrder.MIDDLE -> Actor.RANGE_MIDDLE
|
||||
Actor.RenderOrder.MIDTOP -> Actor.RANGE_MIDTOP
|
||||
Actor.RenderOrder.FRONT -> Actor.RANGE_FRONT
|
||||
}
|
||||
}
|
||||
catch (gameNotInitialisedException: KotlinNullPointerException) {
|
||||
false
|
||||
}
|
||||
|
||||
var ret: Int
|
||||
do {
|
||||
ret = HQRNG().nextInt().and(0x7FFFFFFF) // set new ID
|
||||
} while (hasCollision(ret)) // check for collision
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
open class IngameInstance(val batch: SpriteBatch) : Screen {
|
||||
@@ -672,7 +718,16 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
||||
val ZOOM_MAXIMUM = 4.0f
|
||||
val ZOOM_MINIMUM = 0.5f
|
||||
|
||||
lateinit var consoleHandler: ConsoleWindow
|
||||
open lateinit var consoleHandler: ConsoleWindow
|
||||
|
||||
open lateinit var world: GameWorld
|
||||
/** The actor the game is currently allowing you to control.
|
||||
*
|
||||
* Most of the time it'd be the "player", but think about the case where you have possessed
|
||||
* some random actor of the game. Now that actor is now playableActor, the actual gamer's avatar
|
||||
* (reference ID of 0x91A7E2) (must) stay in the actorContainer, but it's not a playableActor.
|
||||
*/
|
||||
open lateinit var playableActor: ActorHumanoid
|
||||
|
||||
val ACTORCONTAINER_INITIAL_SIZE = 64
|
||||
val actorContainer = ArrayList<Actor>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
@@ -760,10 +815,10 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
|
||||
}
|
||||
}
|
||||
|
||||
open /**
|
||||
/**
|
||||
* Check for duplicates, append actor and sort the list
|
||||
*/
|
||||
fun addNewActor(actor: Actor) {
|
||||
open fun addNewActor(actor: Actor) {
|
||||
if (theGameHasActor(actor.referenceID!!)) {
|
||||
throw Error("The actor $actor already exists in the game")
|
||||
}
|
||||
@@ -986,9 +1041,7 @@ inline fun Double.sqrt() = Math.sqrt(this)
|
||||
inline fun Float.sqrt() = FastMath.sqrt(this)
|
||||
inline fun Int.abs() = if (this < 0) -this else this
|
||||
fun Double.bipolarClamp(limit: Double) =
|
||||
if (this > 0 && this > limit) limit
|
||||
else if (this < 0 && this < -limit) -limit
|
||||
else this
|
||||
this.coerceIn(-limit, limit)
|
||||
|
||||
fun absMax(left: Double, right: Double): Double {
|
||||
if (left > 0 && right > 0)
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -18,10 +19,11 @@ import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.*
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.serialise.ReadLayerData
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.modulebasegame.ui.UITitleRemoConRoot
|
||||
import net.torvald.terrarum.weather.WeatherMixer
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.worlddrawer.*
|
||||
import java.io.FileInputStream
|
||||
|
||||
@@ -48,7 +50,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
||||
|
||||
private var loadDone = false
|
||||
|
||||
private lateinit var demoWorld: GameWorld
|
||||
private lateinit var demoWorld: GameWorldExtension
|
||||
private lateinit var cameraNodes: FloatArray // camera Y-pos
|
||||
private val cameraAI = object : ActorAI {
|
||||
private val axisMax = 1f
|
||||
@@ -135,23 +137,23 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
||||
})
|
||||
|
||||
|
||||
cameraPlayer = object : HumanoidNPC(demoWorld, cameraAI, born = 0, usePhysics = false, forceAssignRefID = Player.PLAYER_REF_ID) {
|
||||
cameraPlayer = object : HumanoidNPC(demoWorld, cameraAI, born = 0, usePhysics = false, forceAssignRefID = Terrarum.PLAYER_REF_ID) {
|
||||
init {
|
||||
setHitboxDimension(2, 2, 0, 0)
|
||||
hitbox.setPosition(
|
||||
HQRNG().nextInt(demoWorld.width) * FeaturesDrawer.TILE_SIZE.toDouble(),
|
||||
0.0 // Y pos: placeholder; camera AI will take it over
|
||||
)
|
||||
noClip = true
|
||||
isNoClip = true
|
||||
}
|
||||
}
|
||||
|
||||
demoWorld.time.timeDelta = 150
|
||||
|
||||
|
||||
LightmapRenderer.world = demoWorld
|
||||
BlocksDrawer.world = demoWorld
|
||||
FeaturesDrawer.world = demoWorld
|
||||
//LightmapRenderer.setWorld(demoWorld)
|
||||
//BlocksDrawer.world = demoWorld
|
||||
//FeaturesDrawer.world = demoWorld
|
||||
|
||||
|
||||
uiMenu = UITitleRemoConRoot()
|
||||
|
||||
@@ -137,7 +137,7 @@ class UIItemInventoryElem(
|
||||
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
if (item != null && Terrarum.ingame != null && keycode in Input.Keys.NUM_1..Input.Keys.NUM_0) {
|
||||
val inventory = (Terrarum.ingame!! as Ingame).player.inventory
|
||||
val inventory = (Terrarum.ingame!! as Ingame).playableActor.inventory
|
||||
val slot = if (keycode == Input.Keys.NUM_0) 9 else keycode - Input.Keys.NUM_1
|
||||
val currentSlotItem = inventory?.getQuickBar(slot)
|
||||
|
||||
@@ -167,7 +167,7 @@ class UIItemInventoryElem(
|
||||
|
||||
// equip da shit
|
||||
val itemEquipSlot = item!!.equipPosition
|
||||
val player = (Terrarum.ingame!! as Ingame).player
|
||||
val player = (Terrarum.ingame!! as Ingame).playableActor
|
||||
|
||||
if (item != player.inventory.itemEquipped.get(itemEquipSlot)) { // if this item is unequipped, equip it
|
||||
player.equipItem(item!!)
|
||||
|
||||
@@ -125,7 +125,7 @@ class UIItemInventoryElemSimple(
|
||||
println("keydown elemgrid")
|
||||
|
||||
|
||||
val inventory = (Terrarum.ingame!! as Ingame).player.inventory
|
||||
val inventory = (Terrarum.ingame!! as Ingame).playableActor.inventory
|
||||
val slot = if (keycode == Input.Keys.NUM_0) 9 else keycode - Input.Keys.NUM_1
|
||||
val currentSlotItem = inventory.getQuickBar(slot)
|
||||
|
||||
@@ -157,7 +157,7 @@ class UIItemInventoryElemSimple(
|
||||
|
||||
// equip da shit
|
||||
val itemEquipSlot = item!!.equipPosition
|
||||
val player = (Terrarum.ingame!! as Ingame).player
|
||||
val player = (Terrarum.ingame!! as Ingame).playableActor
|
||||
|
||||
if (item != player.inventory.itemEquipped.get(itemEquipSlot)) { // if this item is unequipped, equip it
|
||||
player.equipItem(item!!)
|
||||
|
||||
@@ -6,10 +6,9 @@ import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.weather.WeatherMixer
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-06-16.
|
||||
@@ -95,7 +94,7 @@ object BlockPropUtil {
|
||||
fun getDynamicLumFunc(baseLum: Color, type: Int): Color {
|
||||
return when (type) {
|
||||
1 -> getTorchFlicker(baseLum)
|
||||
2 -> (Terrarum.ingame!! as Ingame).world.globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT) // current global light
|
||||
2 -> (Terrarum.ingame!!.world).globalLight.cpy().mul(LightmapRenderer.DIV_FLOAT) // current global light
|
||||
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2).cpy().mul(LightmapRenderer.DIV_FLOAT) // daylight at noon
|
||||
4 -> getSlowBreath(baseLum)
|
||||
5 -> getPulsate(baseLum)
|
||||
|
||||
@@ -27,8 +27,8 @@ 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 = (Terrarum.ingame!! as Ingame).world
|
||||
val player = (Terrarum.ingame!! as Ingame).player
|
||||
val map = (Terrarum.ingame!!.world)
|
||||
val player = (Terrarum.ingame!! as Ingame).playableActor
|
||||
|
||||
val renderWidth = FastMath.ceil(Terrarum.WIDTH.toFloat())
|
||||
val renderHeight = FastMath.ceil(Terrarum.HEIGHT.toFloat())
|
||||
|
||||
@@ -23,7 +23,7 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
||||
val GL = Color(r, g, b, a)
|
||||
|
||||
lightOverride = true
|
||||
(Terrarum.ingame!! as Ingame).world.globalLight = GL
|
||||
(Terrarum.ingame!!.world).globalLight = GL
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
Echo("Wrong number input.")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
/**
|
||||
* See [res/raw/Creature_raw_doc.md] for information about raw.
|
||||
@@ -1,9 +1,9 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
@@ -12,12 +12,8 @@ import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockProp
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.Controllable
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import org.dyn4j.geometry.Vector2
|
||||
@@ -25,7 +21,7 @@ import java.util.*
|
||||
|
||||
|
||||
/**
|
||||
* Base class for every actor that has animated sprites. This includes furnishings, paintings, gadgets, etc.
|
||||
* Actor with body movable. Base class for every actor that has animated sprites. This includes furnishings, paintings, gadgets, etc.
|
||||
* Also has all the usePhysics
|
||||
*
|
||||
* @param renderOrder Rendering order (BEHIND, MIDDLE, MIDTOP, FRONT)
|
||||
@@ -34,7 +30,7 @@ import java.util.*
|
||||
*
|
||||
* Created by minjaesong on 2016-01-13.
|
||||
*/
|
||||
open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val immobileBody: Boolean = false, var usePhysics: Boolean = true) :
|
||||
open class ActorWBMovable(val world: GameWorld, renderOrder: RenderOrder, val immobileBody: Boolean = false, var usePhysics: Boolean = true) :
|
||||
ActorWithBody(renderOrder) {
|
||||
|
||||
|
||||
@@ -121,7 +117,7 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
if (value <= 0)
|
||||
throw IllegalArgumentException("mass cannot be less than or equal to zero.")
|
||||
else if (value < MASS_LOWEST) {
|
||||
println("[ActorWithPhysics] input too small; using $MASS_LOWEST instead.")
|
||||
println("[ActorWBMovable] input too small; using $MASS_LOWEST instead.")
|
||||
actorValue[AVKey.BASEMASS] = MASS_LOWEST
|
||||
}
|
||||
|
||||
@@ -134,7 +130,7 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
if (value < 0)
|
||||
throw IllegalArgumentException("invalid elasticity value $value; valid elasticity value is [0, 1].")
|
||||
else if (value >= ELASTICITY_MAX) {
|
||||
println("[ActorWithPhysics] Elasticity were capped to $ELASTICITY_MAX.")
|
||||
println("[ActorWBMovable] Elasticity were capped to $ELASTICITY_MAX.")
|
||||
field = ELASTICITY_MAX
|
||||
}
|
||||
else
|
||||
@@ -158,7 +154,7 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
var density = 1000.0
|
||||
set(value) {
|
||||
if (value < 0)
|
||||
throw IllegalArgumentException("[ActorWithPhysics] $value: density cannot be negative.")
|
||||
throw IllegalArgumentException("[ActorWBMovable] $value: density cannot be negative.")
|
||||
|
||||
field = value
|
||||
}
|
||||
@@ -200,7 +196,7 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
get() = actorValue.getAsDouble(AVKey.DRAGCOEFF) ?: DRAG_COEFF_DEFAULT
|
||||
set(value) {
|
||||
if (value < 0)
|
||||
throw IllegalArgumentException("[ActorWithPhysics] drag coefficient cannot be negative.")
|
||||
throw IllegalArgumentException("[ActorWBMovable] drag coefficient cannot be negative.")
|
||||
actorValue[AVKey.DRAGCOEFF] = value
|
||||
}
|
||||
|
||||
@@ -274,8 +270,8 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
* @param h
|
||||
* @param tx positive: translate sprite to LEFT.
|
||||
* @param ty positive: translate sprite to DOWN.
|
||||
* @see ActorWithPhysics.drawBody
|
||||
* @see ActorWithPhysics.drawGlow
|
||||
* @see ActorWBMovable.drawBody
|
||||
* @see ActorWBMovable.drawGlow
|
||||
*/
|
||||
fun setHitboxDimension(w: Int, h: Int, tx: Int, ty: Int) {
|
||||
baseHitboxH = h
|
||||
@@ -340,7 +336,7 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
if (spriteGlow != null) spriteGlow!!.update(delta)
|
||||
|
||||
// make NoClip work for player
|
||||
if (this is Player) {
|
||||
if (true) {//this == Terrarum.ingame!!.playableActor) {
|
||||
isNoSubjectToGrav = isNoClip || COLLISION_TEST_MODE
|
||||
isNoCollideWorld = isNoClip
|
||||
isNoSubjectToFluidResistance = isNoClip
|
||||
@@ -655,7 +651,7 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
}
|
||||
|
||||
when (selfCollisionStatus) {
|
||||
0 -> { debug1("[ActorWithPhysics] Contradiction -- collision detected by CCD, but isWalled() says otherwise") }
|
||||
0 -> { debug1("[ActorWBMovable] Contradiction -- collision detected by CCD, but isWalled() says otherwise") }
|
||||
5 -> { zeroX = true }
|
||||
10 -> { zeroY = true }
|
||||
15 -> { newHitbox.reassign(sixteenStep[0]); zeroX = true; zeroY = true }
|
||||
@@ -913,23 +909,23 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
val tileY: Int
|
||||
if (side == COLLIDING_LEFT) {
|
||||
tileX = div16TruncateToMapWidth(hitbox.hitboxStart.x.roundInt()
|
||||
+ i + translateX)
|
||||
+ i + translateX)
|
||||
tileY = div16TruncateToMapHeight(hitbox.hitboxEnd.y.roundInt() + translateY)
|
||||
}
|
||||
else if (side == COLLIDING_TOP) {
|
||||
tileX = div16TruncateToMapWidth(hitbox.hitboxStart.x.roundInt()
|
||||
+ i + translateX)
|
||||
+ i + translateX)
|
||||
tileY = div16TruncateToMapHeight(hitbox.hitboxStart.y.roundInt() + translateY)
|
||||
}
|
||||
else if (side == COLLIDING_RIGHT) {
|
||||
tileX = div16TruncateToMapWidth(hitbox.hitboxEnd.x.roundInt() + translateX)
|
||||
tileY = div16TruncateToMapHeight(hitbox.hitboxStart.y.roundInt()
|
||||
+ i + translateY)
|
||||
+ i + translateY)
|
||||
}
|
||||
else if (side == COLLIDING_LEFT) {
|
||||
tileX = div16TruncateToMapWidth(hitbox.hitboxStart.x.roundInt() + translateX)
|
||||
tileY = div16TruncateToMapHeight(hitbox.hitboxStart.y.roundInt()
|
||||
+ i + translateY)
|
||||
+ i + translateY)
|
||||
}
|
||||
else {
|
||||
throw IllegalArgumentException(side.toString() + ": Wrong side input")
|
||||
@@ -1276,8 +1272,15 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
if (x < 0) 0 else if (x >= world.height) world.height - 1 else x
|
||||
|
||||
|
||||
private val isNoClip: Boolean
|
||||
get() = this is ActorHumanoid && this.isNoClip()
|
||||
var isNoClip: Boolean = false
|
||||
set(value) {
|
||||
field = value
|
||||
|
||||
if (value) {
|
||||
externalForce.zero()
|
||||
controllerMoveDelta?.zero()
|
||||
}
|
||||
}
|
||||
|
||||
private val AUTO_CLIMB_RATE: Int
|
||||
get() = Math.min(TILE_SIZE / 8 * Math.sqrt(scale), TILE_SIZE.toDouble()).toInt()
|
||||
@@ -1289,9 +1292,9 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
|
||||
// warnings
|
||||
if (sprite == null && isVisible)
|
||||
println("[ActorWithPhysics] Caution: actor ${this.javaClass.simpleName} is visible but the sprite was not set.")
|
||||
println("[ActorWBMovable] Caution: actor ${this.javaClass.simpleName} is visible but the sprite was not set.")
|
||||
else if (sprite != null && !isVisible)
|
||||
println("[ActorWithPhysics] Caution: actor ${this.javaClass.simpleName} is invisible but the sprite was given.")
|
||||
println("[ActorWBMovable] Caution: actor ${this.javaClass.simpleName} is invisible but the sprite was given.")
|
||||
|
||||
assertPrinted = true
|
||||
}
|
||||
@@ -1301,7 +1304,6 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun forEachOccupyingTileNum(consumer: (Int?) -> Unit) {
|
||||
val tiles = ArrayList<Int?>()
|
||||
for (y in hIntTilewiseHitbox.startY.toInt()..hIntTilewiseHitbox.endY.toInt()) {
|
||||
@@ -1411,8 +1413,8 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
private fun div16TruncateToMapWidth(x: Int): Int {
|
||||
if (x < 0)
|
||||
return 0
|
||||
else if (x >= (Terrarum.ingame!! as Ingame).world.width shl 4)
|
||||
return (Terrarum.ingame!! as 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
|
||||
}
|
||||
@@ -1420,8 +1422,8 @@ open class ActorWithPhysics(val world: GameWorld, renderOrder: RenderOrder, val
|
||||
private fun div16TruncateToMapHeight(y: Int): Int {
|
||||
if (y < 0)
|
||||
return 0
|
||||
else if (y >= (Terrarum.ingame!! as Ingame).world.height shl 4)
|
||||
return (Terrarum.ingame!! as 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,8 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
|
||||
/**
|
||||
* Actor with visible body
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Point2d
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,20 +1,11 @@
|
||||
package net.torvald.terrarum.gameactors.ai
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.gameactors.AIControlled
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import org.luaj.vm2.*
|
||||
import org.luaj.vm2.lib.OneArgFunction
|
||||
import org.luaj.vm2.lib.ZeroArgFunction
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-10-24.
|
||||
*/
|
||||
/*internal class AILuaAPI(g: Globals, actor: ActorWithPhysics) {
|
||||
/*internal class AILuaAPI(g: Globals, actor: ActorWBMovable) {
|
||||
|
||||
// FIXME when actor jumps, the actor releases left/right stick
|
||||
|
||||
@@ -51,9 +42,9 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
|
||||
companion object {
|
||||
/**
|
||||
* Reads arbitrary ActorWithPhysics and returns its information as Lua table
|
||||
* Reads arbitrary ActorWBMovable and returns its information as Lua table
|
||||
*/
|
||||
fun composeActorObject(actor: ActorWithPhysics): LuaTable {
|
||||
fun composeActorObject(actor: ActorWBMovable): LuaTable {
|
||||
val t: LuaTable = LuaTable()
|
||||
val moveDelta = actor.externalForce + actor.controllerMoveDelta
|
||||
|
||||
@@ -80,7 +71,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
operator fun LuaTable.set(index: Int, value: Int) { this[index] = value.toLua() }
|
||||
}
|
||||
|
||||
class GetSelfActorInfo(val actor: ActorWithPhysics) : ZeroArgFunction() {
|
||||
class GetSelfActorInfo(val actor: ActorWBMovable) : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return composeActorObject(actor)
|
||||
}
|
||||
@@ -116,13 +107,13 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
}
|
||||
}
|
||||
|
||||
class GetX(val actor: ActorWithPhysics) : ZeroArgFunction() {
|
||||
class GetX(val actor: ActorWBMovable) : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return LuaValue.valueOf(actor.hitbox.centeredX)
|
||||
}
|
||||
}
|
||||
|
||||
class GetY(val actor: ActorWithPhysics) : ZeroArgFunction() {
|
||||
class GetY(val actor: ActorWBMovable) : ZeroArgFunction() {
|
||||
override fun call(): LuaValue {
|
||||
return LuaValue.valueOf(actor.hitbox.centeredY)
|
||||
}
|
||||
@@ -205,7 +196,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
}
|
||||
}
|
||||
|
||||
class GetNearbyTiles(val actor: ActorWithPhysics) : OneArgFunction() {
|
||||
class GetNearbyTiles(val actor: ActorWBMovable) : OneArgFunction() {
|
||||
/** @param radius
|
||||
*
|
||||
* 3 will return 7x7 array, 0 will return 1x1, 1 will return 3x3
|
||||
@@ -232,7 +223,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
luatable[y - feetTilePos[1]] = LuaTable()
|
||||
|
||||
for (x in feetTilePos[0] - radius..feetTilePos[0] + radius) {
|
||||
val tile = BlockCodex[(Terrarum.ingame!! as 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()
|
||||
@@ -247,7 +238,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
}
|
||||
}
|
||||
|
||||
class GetFloorsHeight(val actor: ActorWithPhysics) : OneArgFunction() {
|
||||
class GetFloorsHeight(val actor: ActorWBMovable) : OneArgFunction() {
|
||||
/** @param radius
|
||||
*
|
||||
* 3 will return len:7 array, 0 will return len:1, 1 will return len:3
|
||||
@@ -276,7 +267,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
// search down
|
||||
var searchDownCounter = 0
|
||||
while (true) {
|
||||
val tile = (Terrarum.ingame!! as 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
|
||||
@@ -290,7 +281,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
}
|
||||
}
|
||||
|
||||
class GetCeilingsHeight(val actor: ActorWithPhysics) : OneArgFunction() {
|
||||
class GetCeilingsHeight(val actor: ActorWBMovable) : OneArgFunction() {
|
||||
/** @param arg radius
|
||||
*
|
||||
* 3 will return 7x7 array, 0 will return 1x1, 1 will return 3x3
|
||||
@@ -319,7 +310,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
// search up
|
||||
var searchUpCounter = 0
|
||||
while (true) {
|
||||
val tile = (Terrarum.ingame!! as 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
|
||||
@@ -333,7 +324,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
}
|
||||
}
|
||||
|
||||
class GetLedgesHeight(val actor: ActorWithPhysics) : OneArgFunction() {
|
||||
class GetLedgesHeight(val actor: ActorWBMovable) : OneArgFunction() {
|
||||
/** @param arg radius
|
||||
* ==
|
||||
* <- (non-solid found)
|
||||
@@ -361,7 +352,7 @@ import org.luaj.vm2.lib.ZeroArgFunction
|
||||
// search up
|
||||
var searchUpCounter = 0
|
||||
while (true) {
|
||||
val tile = (Terrarum.ingame!! as 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
|
||||
|
||||
@@ -41,14 +41,14 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
||||
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
||||
if (ingame.canPlayerControl) {
|
||||
if (Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary")) || Gdx.input.isButtonPressed(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
val itemOnGrip = ingame.player.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||
val itemOnGrip = ingame.playableActor.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||
|
||||
itemOnGrip?.let {
|
||||
if (Gdx.input.isButtonPressed(Terrarum.getConfigInt("mouseprimary"))) {
|
||||
ingame.player.consumePrimary(it)
|
||||
ingame.playableActor.consumePrimary(it)
|
||||
}
|
||||
if (Gdx.input.isButtonPressed(Terrarum.getConfigInt("mousesecondary"))) {
|
||||
ingame.player.consumeSecondary(it)
|
||||
ingame.playableActor.consumeSecondary(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
|
||||
if (ingame.canPlayerControl) {
|
||||
ingame.player.keyDown(keycode)
|
||||
ingame.playableActor.keyDown(keycode)
|
||||
}
|
||||
|
||||
if (Terrarum.getConfigIntArray("keyquickselalt").contains(keycode)
|
||||
@@ -112,7 +112,7 @@ class IngameController(val ingame: Ingame) : InputAdapter() {
|
||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
||||
if (ingame.canPlayerControl) {
|
||||
val itemOnGrip = ingame.player.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||
val itemOnGrip = ingame.playableActor.inventory.itemEquipped[GameItem.EquipPosition.HAND_GRIP]
|
||||
|
||||
if (itemOnGrip != null) {
|
||||
if (button == Terrarum.getConfigInt("mouseprimary")) {
|
||||
|
||||
@@ -4,14 +4,12 @@ package net.torvald.terrarum.gameworld
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameEconomy
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
typealias BlockAddress = Long
|
||||
typealias BlockDamage = Float
|
||||
|
||||
class GameWorld(val width: Int, val height: Int) {
|
||||
open class GameWorld(val width: Int, val height: Int) {
|
||||
|
||||
|
||||
//layers
|
||||
@@ -22,7 +20,8 @@ class GameWorld(val width: Int, val height: Int) {
|
||||
val layerWallLowBits: PairedMapLayer
|
||||
val layerTerrainLowBits: PairedMapLayer
|
||||
|
||||
val layerThermal: MapLayerFloat // in Kelvins
|
||||
val layerThermal: MapLayerHalfFloat // in Kelvins
|
||||
val layerAirPressure: MapLayerHalfFloat // (milibar - 1000)
|
||||
|
||||
/** Tilewise spawn point */
|
||||
var spawnX: Int
|
||||
@@ -42,10 +41,6 @@ class GameWorld(val width: Int, val height: Int) {
|
||||
|
||||
|
||||
|
||||
val time: WorldTime
|
||||
val economy = GameEconomy()
|
||||
|
||||
|
||||
|
||||
var generatorSeed: Long = 0
|
||||
|
||||
@@ -61,14 +56,11 @@ class GameWorld(val width: Int, val height: Int) {
|
||||
layerTerrainLowBits = PairedMapLayer(width, height)
|
||||
layerWallLowBits = PairedMapLayer(width, height)
|
||||
|
||||
layerThermal = MapLayerFloat(width / 2, height / 2, averageTemperature)
|
||||
// temperature layer: 2x2 is one cell
|
||||
layerThermal = MapLayerHalfFloat(width / 2, height / 2, averageTemperature)
|
||||
|
||||
|
||||
time = WorldTime(
|
||||
71 * WorldTime.DAY_LENGTH +
|
||||
7 * WorldTime.HOUR_SEC +
|
||||
30L * WorldTime.MINUTE_SEC
|
||||
)
|
||||
// air pressure layer: 4 * 8 is one cell
|
||||
layerAirPressure = MapLayerHalfFloat(width / 4, height / 8, 13f) // 1013 mBar
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,10 +179,6 @@ class GameWorld(val width: Int, val height: Int) {
|
||||
throw IllegalArgumentException("illegal mode input: " + mode.toString())
|
||||
}
|
||||
|
||||
fun updateWorldTime(delta: Float) {
|
||||
time.update(delta)
|
||||
}
|
||||
|
||||
fun terrainIterator(): Iterator<Int> {
|
||||
return object : Iterator<Int> {
|
||||
|
||||
@@ -297,6 +285,11 @@ class GameWorld(val width: Int, val height: Int) {
|
||||
return layerThermal.getValue((worldTileX fmod width) / 2, worldTileY / 2)
|
||||
}
|
||||
|
||||
fun getAirPressure(worldTileX: Int, worldTileY: Int): Float? {
|
||||
return layerAirPressure.getValue((worldTileX fmod width) / 4, worldTileY / 8)
|
||||
}
|
||||
|
||||
|
||||
|
||||
companion object {
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
package net.torvald.terrarum.gameworld
|
||||
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.ByteArray64
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-17.
|
||||
*/
|
||||
class MapLayer(val width: Int, val height: Int) : Iterable<Byte> {
|
||||
open class MapLayer(val width: Int, val height: Int) : Iterable<Byte> {
|
||||
|
||||
internal @Volatile var data: ByteArray // in parallel programming: do not trust your register; always read freshly from RAM!
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import net.torvald.dataclass.Float16Bits
|
||||
*
|
||||
* Created by minjaesong on 2017-04-21.
|
||||
*/
|
||||
class MapLayerFloat(val width: Int, val height: Int) : Iterable<Float16Bits> {
|
||||
open class MapLayerHalfFloat(val width: Int, val height: Int) : Iterable<Float16Bits> {
|
||||
|
||||
constructor(width: Int, height: Int, init: Float) : this(width, height) {
|
||||
data = Array(height) { Array(width, { Float16.fromFloat(init) }) }
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameworld
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Point2d
|
||||
|
||||
|
||||
class MapPoint {
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.gameworld
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-15.
|
||||
*/
|
||||
class PairedMapLayer(width: Int, val height: Int) : Iterable<Byte> {
|
||||
open class PairedMapLayer(width: Int, val height: Int) : Iterable<Byte> {
|
||||
|
||||
/**
|
||||
* 0b_xxxx_yyyy, x for lower index, y for higher index
|
||||
|
||||
@@ -2,14 +2,11 @@ package net.torvald.terrarum.itemproperties
|
||||
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.KVHashMap
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.CanBeAnItem
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer.TILE_SIZE
|
||||
import java.util.*
|
||||
@@ -75,7 +72,7 @@ object ItemCodex {
|
||||
// check for collision with actors (BLOCK only)
|
||||
if (this.inventoryCategory == Category.BLOCK) {
|
||||
ingame.actorContainer.forEach {
|
||||
if (it is ActorWithPhysics && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -135,7 +132,7 @@ object ItemCodex {
|
||||
|
||||
override fun primaryUse(delta: Float): Boolean {
|
||||
val mousePoint = Point2d(Terrarum.mouseTileX.toDouble(), Terrarum.mouseTileY.toDouble())
|
||||
val actorvalue = ingame.player.actorValue
|
||||
val actorvalue = ingame.playableActor.actorValue
|
||||
|
||||
|
||||
using = true
|
||||
@@ -143,7 +140,7 @@ object ItemCodex {
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
ingame.actorContainer.forEach {
|
||||
if (it is ActorWithPhysics && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -158,7 +155,7 @@ object ItemCodex {
|
||||
ingame.world.inflictTerrainDamage(
|
||||
Terrarum.mouseTileX,
|
||||
Terrarum.mouseTileY,
|
||||
Calculate.pickaxePower(ingame.player, material) * swingDmgToFrameDmg
|
||||
Calculate.pickaxePower(ingame.playableActor, material) * swingDmgToFrameDmg
|
||||
)
|
||||
return true
|
||||
}
|
||||
@@ -166,7 +163,7 @@ object ItemCodex {
|
||||
override fun endPrimaryUse(delta: Float): Boolean {
|
||||
using = false
|
||||
// reset action timer to zero
|
||||
ingame.player.actorValue[AVKey.__ACTION_TIMER] = 0.0
|
||||
ingame.playableActor.actorValue[AVKey.__ACTION_TIMER] = 0.0
|
||||
return true
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -44,13 +44,13 @@ class ItemEffectsLuaAPI(g: Globals) {
|
||||
|
||||
class StrikeEarth : ThreeArgFunction() {
|
||||
override fun call(x: LuaValue, y: LuaValue, power: LuaValue): LuaValue {
|
||||
(Terrarum.ingame!! as 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 {
|
||||
(Terrarum.ingame!! as Ingame).world.inflictWallDamage(x.checkint(), y.checkint(), power.checkdouble())
|
||||
(Terrarum.ingame!!.world).inflictWallDamage(x.checkint(), y.checkint(), power.checkdouble())
|
||||
return LuaValue.NONE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,7 +119,12 @@ object Lang {
|
||||
if (key.startsWith("MENU_LABEL_PRESS_START_SYMBOL"))
|
||||
return ret2.replace('>', Terrarum.joypadLabelStart).capitalize()
|
||||
|
||||
return ret2.capitalize()
|
||||
return if (AppLoader.GAME_LOCALE.contains("bg"))
|
||||
"${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}"
|
||||
else if (AppLoader.GAME_LOCALE.contains("sr"))
|
||||
"${AppLoader.fontGame.charsetOverrideBulgarian}${ret2.capitalize()}${AppLoader.fontGame.charsetOverrideNormal}"
|
||||
else
|
||||
ret2.capitalize()
|
||||
}
|
||||
|
||||
fun pluraliseLang(key: String, count: Int): String {
|
||||
@@ -210,7 +215,7 @@ object Lang {
|
||||
}
|
||||
|
||||
private fun isHangul(c: Char): Boolean {
|
||||
return c.toInt() >= 0xAC00 && c.toInt() <= 0xD7A3
|
||||
return c.toInt() in 0xAC00..0xD7A3
|
||||
}
|
||||
|
||||
private fun getLastChar(s: String): Char {
|
||||
|
||||
201
src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt
Normal file
201
src/net/torvald/terrarum/modulebasegame/BuildingMaker.kt
Normal file
@@ -0,0 +1,201 @@
|
||||
package net.torvald.terrarum.modulebasegame
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.IngameInstance
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.ui.Notification
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIBuildingMakerToolbox
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2018-07-06.
|
||||
*/
|
||||
class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
val gameWorld = GameWorldExtension(1024, 256)
|
||||
|
||||
init {
|
||||
// ghetto world for building
|
||||
|
||||
println("[BuildingMaker] Generating builder world...")
|
||||
|
||||
for (y in 150 until gameWorld.height) {
|
||||
for (x in 0 until gameWorld.width) {
|
||||
// wall layer
|
||||
gameWorld.setTileWall(x, y, Block.DIRT)
|
||||
|
||||
// terrain layer
|
||||
gameWorld.setTileTerrain(x, y, if (y == 150) Block.GRASS else Block.DIRT)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
world = gameWorld
|
||||
}
|
||||
|
||||
|
||||
override var playableActor: ActorHumanoid = MovableWorldCamera(world)
|
||||
|
||||
val uiToolbox = UIBuildingMakerToolbox()
|
||||
val notifier = Notification()
|
||||
|
||||
val uiContainer = ArrayList<UICanvas>()
|
||||
|
||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.FRONT) {
|
||||
|
||||
override var referenceID: ActorID? = Terrarum.generateUniqueReferenceID(renderOrder)
|
||||
val body = TextureRegionPack(Gdx.files.internal("assets/graphics/blocks/block_markings_common.tga"), 16, 16)
|
||||
override val hitbox = Hitbox(0.0, 0.0, 16.0, 16.0)
|
||||
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
batch.color = Color.YELLOW
|
||||
batch.draw(body.get(0, 0), hitbox.startX.toFloat(), hitbox.startY.toFloat())
|
||||
}
|
||||
|
||||
override fun drawGlow(batch: SpriteBatch) { }
|
||||
override fun dispose() {
|
||||
body.dispose()
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
hitbox.setPosition(
|
||||
Terrarum.mouseTileX * 16.0,
|
||||
Terrarum.mouseTileY * 16.0
|
||||
)
|
||||
}
|
||||
|
||||
override fun onActorValueChange(key: String, value: Any?) { }
|
||||
|
||||
override fun run() {
|
||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
protected var updateDeltaCounter = 0.0
|
||||
protected val updateRate = 1.0 / Terrarum.TARGET_INTERNAL_FPS
|
||||
|
||||
private val actorsRenderTop = ArrayList<ActorWithBody>()
|
||||
|
||||
init {
|
||||
actorsRenderTop.add(blockPointingCursor)
|
||||
|
||||
uiContainer.add(uiToolbox)
|
||||
uiContainer.add(notifier)
|
||||
|
||||
|
||||
|
||||
uiToolbox.setPosition(Terrarum.WIDTH - 20, 4)
|
||||
notifier.setPosition(
|
||||
(Terrarum.WIDTH - notifier.width) / 2, Terrarum.HEIGHT - notifier.height)
|
||||
|
||||
|
||||
playableActor.setPosition(512 * 16.0, 149 * 16.0)
|
||||
|
||||
|
||||
|
||||
LightmapRenderer.fireRecalculateEvent()
|
||||
}
|
||||
|
||||
override fun render(delta: Float) {
|
||||
Gdx.graphics.setTitle("${AppLoader.GAME_NAME} Building Maker" +
|
||||
" — 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
|
||||
|
||||
|
||||
|
||||
if (false && Terrarum.getConfigBoolean("multithread")) { // NO MULTITHREADING: camera don't like concurrent modification (jittery actor movements)
|
||||
// else, NOP;
|
||||
}
|
||||
else {
|
||||
var updateTries = 0
|
||||
while (updateDeltaCounter >= updateRate) {
|
||||
|
||||
//updateGame(delta)
|
||||
Terrarum.debugTimers["Ingame.update"] = measureNanoTime { updateGame(delta) }
|
||||
|
||||
updateDeltaCounter -= updateRate
|
||||
updateTries++
|
||||
|
||||
if (updateTries >= Terrarum.UPDATE_CATCHUP_MAX_TRIES) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** RENDER CODE GOES HERE */
|
||||
//renderGame(batch)
|
||||
Terrarum.debugTimers["Ingame.render"] = measureNanoTime { renderGame() }
|
||||
}
|
||||
|
||||
private fun updateGame(delta: Float) {
|
||||
blockPointingCursor.update(delta)
|
||||
playableActor.update(delta)
|
||||
uiContainer.forEach { it.update(delta) }
|
||||
|
||||
WorldCamera.update(world, playableActor)
|
||||
}
|
||||
|
||||
private fun renderGame() {
|
||||
IngameRenderer(world as GameWorldExtension, actorsRenderFront = actorsRenderTop, uisToDraw = uiContainer)
|
||||
}
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
IngameRenderer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
uiToolbox.setPosition(Terrarum.WIDTH - 20, 4)
|
||||
notifier.setPosition(
|
||||
(Terrarum.WIDTH - notifier.width) / 2, Terrarum.HEIGHT - notifier.height)
|
||||
println("[BuildingMaker] Resize event")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class MovableWorldCamera(world: GameWorld) : ActorHumanoid(world, 0, usePhysics = false) {
|
||||
|
||||
init {
|
||||
referenceID = Terrarum.PLAYER_REF_ID
|
||||
isNoClip = true
|
||||
|
||||
setHitboxDimension(1, 1, 0, 0)
|
||||
|
||||
|
||||
actorValue[AVKey.SPEED] = 8.0
|
||||
actorValue[AVKey.SPEEDBUFF] = 1.0
|
||||
actorValue[AVKey.ACCEL] = ActorHumanoid.WALK_ACCEL_BASE
|
||||
actorValue[AVKey.ACCELBUFF] = 1.0
|
||||
actorValue[AVKey.JUMPPOWER] = 0.0
|
||||
}
|
||||
|
||||
override fun drawBody(batch: SpriteBatch) {
|
||||
}
|
||||
|
||||
override fun drawGlow(batch: SpriteBatch) {
|
||||
}
|
||||
|
||||
override fun onActorValueChange(key: String, value: Any?) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.ModuleEntryPoint
|
||||
import net.torvald.terrarum.Terrarum
|
||||
@@ -8,7 +8,7 @@ import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2018-06-21.
|
||||
@@ -61,7 +61,7 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
// check for collision with actors (BLOCK only)
|
||||
if (this.inventoryCategory == Category.BLOCK) {
|
||||
ingame.actorContainer.forEach {
|
||||
if (it is ActorWithPhysics && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package net.torvald.terrarum.modulebasegame
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.Input
|
||||
import com.badlogic.gdx.Screen
|
||||
import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
|
||||
import net.torvald.dataclass.CircularArray
|
||||
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||
@@ -18,28 +15,24 @@ import net.torvald.terrarum.gamecontroller.IngameController
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldSimulator
|
||||
import net.torvald.terrarum.weather.WeatherMixer
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.concurrent.locks.Lock
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
|
||||
import javax.swing.JOptionPane
|
||||
|
||||
import com.badlogic.gdx.graphics.OrthographicCamera
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.modulebasegame.console.AVTracker
|
||||
import net.torvald.terrarum.modulebasegame.console.ActorsList
|
||||
import net.torvald.terrarum.console.Authenticator
|
||||
import net.torvald.terrarum.console.SetGlobalLightOverride
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.*
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.imagefont.Watch7SegMain
|
||||
import net.torvald.terrarum.modulebasegame.imagefont.WatchDotAlph
|
||||
import net.torvald.terrarum.modulebasegame.ui.*
|
||||
@@ -53,14 +46,16 @@ import kotlin.system.measureNanoTime
|
||||
* Created by minjaesong on 2017-06-16.
|
||||
*/
|
||||
|
||||
class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private val ACTOR_UPDATE_RANGE = 4096
|
||||
|
||||
lateinit var world: GameWorld
|
||||
lateinit var historicalFigureIDBucket: ArrayList<Int>
|
||||
|
||||
lateinit var gameworld: GameWorldExtension
|
||||
|
||||
lateinit var theRealGamer: IngamePlayer
|
||||
|
||||
/**
|
||||
* list of Actors that is sorted by Actors' referenceID
|
||||
*/
|
||||
@@ -76,55 +71,18 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
private val actorsRenderMidTop = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
private val actorsRenderFront = ArrayList<ActorWithBody>(ACTORCONTAINER_INITIAL_SIZE)
|
||||
|
||||
lateinit var playableActorDelegate: PlayableActorDelegate // player must exist; use dummy player if there is none (required for camera)
|
||||
private set
|
||||
inline val player: ActorHumanoid // currently POSSESSED actor :)
|
||||
get() = playableActorDelegate.actor
|
||||
|
||||
//var screenZoom = 1.0f // definition moved to IngameInstance
|
||||
//val ZOOM_MAXIMUM = 4.0f // definition moved to IngameInstance
|
||||
//val ZOOM_MINIMUM = 0.5f // definition moved to IngameInstance
|
||||
|
||||
companion object {
|
||||
//val lightmapDownsample = 4f //2f: still has choppy look when the camera moves but unnoticeable when blurred
|
||||
|
||||
|
||||
/** Sets camera position so that (0,0) would be top-left of the screen, (width, height) be bottom-right. */
|
||||
fun setCameraPosition(batch: SpriteBatch, camera: Camera, newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + Terrarum.HALFW).round(), (-newY + Terrarum.HALFH).round(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Usage:
|
||||
*
|
||||
* override var referenceID: Int = generateUniqueReferenceID()
|
||||
*/
|
||||
fun generateUniqueReferenceID(renderOrder: Actor.RenderOrder): ActorID {
|
||||
fun hasCollision(value: ActorID) =
|
||||
try {
|
||||
Terrarum.ingame!!.theGameHasActor(value) ||
|
||||
value < ItemCodex.ACTORID_MIN ||
|
||||
value !in when (renderOrder) {
|
||||
Actor.RenderOrder.BEHIND -> Actor.RANGE_BEHIND
|
||||
Actor.RenderOrder.MIDDLE -> Actor.RANGE_MIDDLE
|
||||
Actor.RenderOrder.MIDTOP -> Actor.RANGE_MIDTOP
|
||||
Actor.RenderOrder.FRONT -> Actor.RANGE_FRONT
|
||||
}
|
||||
}
|
||||
catch (gameNotInitialisedException: KotlinNullPointerException) {
|
||||
false
|
||||
}
|
||||
|
||||
var ret: Int
|
||||
do {
|
||||
ret = HQRNG().nextInt().and(0x7FFFFFFF) // set new ID
|
||||
} while (hasCollision(ret)) // check for collision
|
||||
return ret
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -134,13 +92,6 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
|
||||
private val useShader: Boolean = false
|
||||
private val shaderProgram = 0
|
||||
|
||||
val KEY_LIGHTMAP_RENDER = Input.Keys.F7
|
||||
|
||||
|
||||
|
||||
lateinit var debugWindow: UICanvas
|
||||
lateinit var notifier: UICanvas
|
||||
|
||||
@@ -213,7 +164,7 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
GameLoadMode.LOAD_FROM -> enter(gameLoadInfoPayload as GameSaveData)
|
||||
}
|
||||
|
||||
LightmapRenderer.world = this.world
|
||||
//LightmapRenderer.world = this.world
|
||||
//BlocksDrawer.world = this.world
|
||||
FeaturesDrawer.world = this.world
|
||||
|
||||
@@ -221,9 +172,9 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
data class GameSaveData(
|
||||
val world: GameWorld,
|
||||
val world: GameWorldExtension,
|
||||
val historicalFigureIDBucket: ArrayList<Int>,
|
||||
val realGamePlayer: ActorHumanoid
|
||||
val realGamePlayer: IngamePlayer
|
||||
)
|
||||
|
||||
data class NewWorldParameters(
|
||||
@@ -244,10 +195,12 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
LoadScreen.addMessage("Loading world from save")
|
||||
|
||||
|
||||
world = gameSaveData.world
|
||||
gameworld = gameSaveData.world
|
||||
world = gameworld
|
||||
historicalFigureIDBucket = gameSaveData.historicalFigureIDBucket
|
||||
playableActorDelegate = PlayableActorDelegate(gameSaveData.realGamePlayer)
|
||||
addNewActor(player)
|
||||
theRealGamer = gameSaveData.realGamePlayer
|
||||
playableActor = gameSaveData.realGamePlayer
|
||||
addNewActor(playableActor)
|
||||
|
||||
|
||||
|
||||
@@ -268,7 +221,8 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
// init map as chosen size
|
||||
world = GameWorld(worldParams.width, worldParams.height)
|
||||
gameworld = GameWorldExtension(worldParams.width, worldParams.height)
|
||||
world = gameworld as GameWorld
|
||||
|
||||
// generate terrain for the map
|
||||
WorldGenerator.attachMap(world)
|
||||
@@ -301,7 +255,7 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
/** Load rest of the game with GL context */
|
||||
fun postInit() {
|
||||
//LightmapRenderer.world = this.world
|
||||
BlocksDrawer.world = this.world
|
||||
//BlocksDrawer.world = this.world
|
||||
//FeaturesDrawer.world = this.world
|
||||
|
||||
|
||||
@@ -342,7 +296,7 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
-uiInventoryPlayer.width,
|
||||
70
|
||||
)*/
|
||||
uiInventoryPlayer = UIInventoryFull(player,
|
||||
uiInventoryPlayer = UIInventoryFull(playableActor,
|
||||
toggleKeyLiteral = Terrarum.getConfigInt("keyinventory")
|
||||
)
|
||||
uiInventoryPlayer.setPosition(0, 0)
|
||||
@@ -368,11 +322,11 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
//uiVitalItem.setAsAlwaysVisible()
|
||||
|
||||
// basic watch-style notification bar (temperature, new mail)
|
||||
uiWatchBasic = UIBasicNotifier(player)
|
||||
uiWatchBasic = UIBasicNotifier(playableActor)
|
||||
uiWatchBasic.setAsAlwaysVisible()
|
||||
uiWatchBasic.setPosition(Terrarum.WIDTH - uiWatchBasic.width, 0)
|
||||
|
||||
uiWatchTierOne = UITierOneWatch(player)
|
||||
uiWatchTierOne = UITierOneWatch(playableActor)
|
||||
uiWatchTierOne.setAsAlwaysVisible()
|
||||
uiWatchTierOne.setPosition(Terrarum.WIDTH - uiWatchTierOne.width, uiWatchBasic.height - 2)
|
||||
|
||||
@@ -460,15 +414,15 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
if (!gameFullyLoaded) {
|
||||
|
||||
if (gameLoadMode == GameLoadMode.CREATE_NEW) {
|
||||
playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
|
||||
playableActor = PlayerBuilderSigrid()
|
||||
|
||||
// go to spawn position
|
||||
player.setPosition(
|
||||
playableActor.setPosition(
|
||||
world.spawnX * FeaturesDrawer.TILE_SIZE.toDouble(),
|
||||
world.spawnY * FeaturesDrawer.TILE_SIZE.toDouble()
|
||||
)
|
||||
|
||||
addNewActor(player)
|
||||
addNewActor(playableActor)
|
||||
}
|
||||
|
||||
postInit()
|
||||
@@ -527,6 +481,8 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
|
||||
protected fun updateGame(delta: Float) {
|
||||
val world = this.world as GameWorldExtension
|
||||
|
||||
particlesActive = 0
|
||||
|
||||
|
||||
@@ -542,17 +498,17 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
BlockPropUtil.dynamicLumFuncTickClock()
|
||||
world.updateWorldTime(delta)
|
||||
//WorldSimulator(player, delta)
|
||||
WeatherMixer.update(delta, player)
|
||||
WeatherMixer.update(delta, playableActor)
|
||||
BlockStats.update()
|
||||
if (!(CommandDict["setgl"] as SetGlobalLightOverride).lightOverride)
|
||||
world.globalLight = WeatherMixer.globalLightNow
|
||||
gameworld.globalLight = WeatherMixer.globalLightNow
|
||||
|
||||
|
||||
////////////////////////////
|
||||
// camera-related updates //
|
||||
////////////////////////////
|
||||
FeaturesDrawer.update(delta)
|
||||
WorldCamera.update(world, player)
|
||||
WorldCamera.update(gameworld, playableActor)
|
||||
|
||||
|
||||
|
||||
@@ -589,13 +545,13 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private fun renderGame() {
|
||||
IngameRenderer.invoke(
|
||||
world,
|
||||
world as GameWorldExtension,
|
||||
actorsRenderBehind,
|
||||
actorsRenderMiddle,
|
||||
actorsRenderMidTop,
|
||||
actorsRenderFront,
|
||||
particlesContainer,
|
||||
player,
|
||||
playableActor,
|
||||
uiContainer
|
||||
)
|
||||
}
|
||||
@@ -603,39 +559,32 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private fun repossessActor() {
|
||||
// check if currently pocessed actor is removed from game
|
||||
if (!theGameHasActor(player)) {
|
||||
if (!theGameHasActor(playableActor)) {
|
||||
// re-possess canonical player
|
||||
if (theGameHasActor(Player.PLAYER_REF_ID))
|
||||
changePossession(Player.PLAYER_REF_ID)
|
||||
if (theGameHasActor(Terrarum.PLAYER_REF_ID))
|
||||
changePossession(Terrarum.PLAYER_REF_ID)
|
||||
else
|
||||
changePossession(0x51621D) // FIXME fallback debug mode (FIXME is there for a reminder visible in ya IDE)
|
||||
}
|
||||
}
|
||||
|
||||
private fun changePossession(newActor: PlayableActorDelegate) {
|
||||
if (!theGameHasActor(player)) {
|
||||
private fun changePossession(newActor: ActorHumanoid) {
|
||||
if (!theGameHasActor(playableActor)) {
|
||||
throw IllegalArgumentException("No such actor in the game: $newActor")
|
||||
}
|
||||
|
||||
playableActorDelegate = newActor
|
||||
WorldSimulator(player, Terrarum.deltaTime)
|
||||
playableActor = newActor
|
||||
WorldSimulator(playableActor, Terrarum.deltaTime)
|
||||
}
|
||||
|
||||
private fun changePossession(refid: Int) {
|
||||
// TODO prevent possessing other player on multiplayer
|
||||
val actorToChange = getActorByID(refid)
|
||||
|
||||
if (!theGameHasActor(refid)) {
|
||||
throw IllegalArgumentException(
|
||||
"No such actor in the game: $refid (elemsActive: ${actorContainer.size}, " +
|
||||
"elemsInactive: ${actorContainerInactive.size})")
|
||||
if (actorToChange !is ActorHumanoid) {
|
||||
throw Error("Unpossessable actor $refid: type expected ActorHumanoid, got ${actorToChange.javaClass.canonicalName}")
|
||||
}
|
||||
|
||||
// take care of old delegate
|
||||
playableActorDelegate!!.actor.collisionType = HumanoidNPC.DEFAULT_COLLISION_TYPE
|
||||
// accept new delegate
|
||||
playableActorDelegate = PlayableActorDelegate(getActorByID(refid) as ActorHumanoid)
|
||||
playableActorDelegate!!.actor.collisionType = ActorWithPhysics.COLLISION_KINEMATIC
|
||||
WorldSimulator(player, Terrarum.deltaTime)
|
||||
changePossession(getActorByID(refid) as ActorHumanoid)
|
||||
}
|
||||
|
||||
/** Send message to notifier UI and toggle the UI as opened. */
|
||||
@@ -709,11 +658,11 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
ThreadParallel.startAll()
|
||||
|
||||
playableActorDelegate?.update(delta)
|
||||
playableActor.update(delta)
|
||||
}
|
||||
else {
|
||||
actorContainer.forEach {
|
||||
if (it != playableActorDelegate?.actor) {
|
||||
if (it != playableActor) {
|
||||
it.update(delta)
|
||||
|
||||
if (it is Pocketed) {
|
||||
@@ -726,7 +675,7 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
}
|
||||
}
|
||||
playableActorDelegate?.update(delta)
|
||||
playableActor.update(delta)
|
||||
//AmmoMeterProxy(player, uiVitalItem.UI as UIVitalMetre)
|
||||
}
|
||||
}
|
||||
@@ -779,7 +728,7 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
* This is how remove function of [java.util.ArrayList] is defined.
|
||||
*/
|
||||
override fun removeActor(actor: Actor) {
|
||||
if (actor.referenceID == player.referenceID || actor.referenceID == 0x51621D) // do not delete this magic
|
||||
if (actor.referenceID == theRealGamer.referenceID || actor.referenceID == 0x51621D) // do not delete this magic
|
||||
throw RuntimeException("Attempted to remove player.")
|
||||
val indexToDelete = actorContainer.binarySearch(actor.referenceID!!)
|
||||
if (indexToDelete >= 0) {
|
||||
@@ -929,8 +878,6 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
*/
|
||||
override fun resize(width: Int, height: Int) {
|
||||
|
||||
BlocksDrawer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
LightmapRenderer.resize(Terrarum.WIDTH, Terrarum.HEIGHT)
|
||||
MegaRainGovernor.resize()
|
||||
|
||||
|
||||
|
||||
@@ -13,8 +13,9 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ParticleBase
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.weather.WeatherMixer
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.worlddrawer.BlocksDrawer
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
@@ -50,7 +51,7 @@ object IngameRenderer {
|
||||
|
||||
private var initDone = false
|
||||
|
||||
private var player: ActorHumanoid? = null
|
||||
private var player: ActorWithBody? = null
|
||||
|
||||
var uiListToDraw = ArrayList<UICanvas>()
|
||||
|
||||
@@ -59,13 +60,13 @@ object IngameRenderer {
|
||||
private var debugMode = 0
|
||||
|
||||
operator fun invoke(
|
||||
world: GameWorld,
|
||||
world: GameWorldExtension,
|
||||
actorsRenderBehind: List<ActorWithBody>? = null,
|
||||
actorsRenderMiddle: List<ActorWithBody>? = null,
|
||||
actorsRenderMidTop: List<ActorWithBody>? = null,
|
||||
actorsRenderFront : List<ActorWithBody>? = null,
|
||||
particlesContainer: CircularArray<ParticleBase>? = null,
|
||||
player: ActorHumanoid? = null,
|
||||
player: ActorWithBody? = null,
|
||||
uisToDraw: ArrayList<UICanvas>? = null
|
||||
) {
|
||||
|
||||
@@ -77,8 +78,6 @@ object IngameRenderer {
|
||||
this.player = player
|
||||
|
||||
|
||||
|
||||
|
||||
LightmapRenderer.fireRecalculateEvent()
|
||||
|
||||
prepLightmapRGBA()
|
||||
@@ -141,7 +140,7 @@ object IngameRenderer {
|
||||
batch.fillRect(0f, 0f, 6f, 10f)
|
||||
batch.color = Color.LIME
|
||||
batch.fillRect(6f, 0f, 6f, 10f)
|
||||
batch.color = Color.BLUE
|
||||
batch.color = Color.ROYAL
|
||||
batch.fillRect(12f, 0f, 6f, 10f)
|
||||
batch.color = Color.WHITE
|
||||
}
|
||||
@@ -390,7 +389,7 @@ object IngameRenderer {
|
||||
}
|
||||
|
||||
|
||||
private fun init(world: GameWorld) {
|
||||
private fun init(world: GameWorldExtension) {
|
||||
if (!initDone) {
|
||||
batch = SpriteBatch()
|
||||
camera = OrthographicCamera(widthf, heightf)
|
||||
@@ -401,13 +400,13 @@ object IngameRenderer {
|
||||
|
||||
resize(width, height)
|
||||
|
||||
LightmapRenderer.world = world
|
||||
|
||||
|
||||
|
||||
|
||||
initDone = true
|
||||
}
|
||||
|
||||
|
||||
BlocksDrawer.world = world
|
||||
LightmapRenderer.setWorld(world)
|
||||
FeaturesDrawer.world = world
|
||||
}
|
||||
|
||||
private fun clearBuffer() {
|
||||
@@ -513,6 +512,9 @@ object IngameRenderer {
|
||||
|
||||
BlocksDrawer.resize(width, height)
|
||||
LightmapRenderer.resize(width, height)
|
||||
|
||||
|
||||
//LightmapRenderer.fireRecalculateEvent()
|
||||
}
|
||||
|
||||
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
|
||||
|
||||
@@ -16,7 +16,7 @@ internal object AVTracker : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size < 2) {
|
||||
jPanelInstances.add(ActorValueTracker((Terrarum.ingame!! as Ingame).player))
|
||||
jPanelInstances.add(ActorValueTracker((Terrarum.ingame!! as Ingame).playableActor))
|
||||
}
|
||||
else {
|
||||
try {
|
||||
|
||||
@@ -16,7 +16,7 @@ internal object ExportAV : ConsoleCommand {
|
||||
if (args.size == 2) {
|
||||
try {
|
||||
JsonWriter.writeToFile(
|
||||
(Terrarum.ingame!! as Ingame).player.actorValue,
|
||||
(Terrarum.ingame!! as Ingame).playableActor.actorValue,
|
||||
Terrarum.defaultDir + "/Exports/" + args[1] + ".json")
|
||||
|
||||
Echo("ExportAV: exported to " + args[1] + ".json")
|
||||
|
||||
@@ -62,7 +62,7 @@ internal object ExportMap : ConsoleCommand {
|
||||
}
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val world = (Terrarum.ingame!! as Ingame).world
|
||||
val world = (Terrarum.ingame!!.world)
|
||||
|
||||
if (args.size == 2) {
|
||||
|
||||
|
||||
@@ -17,9 +17,9 @@ internal object GetAV : ConsoleCommand {
|
||||
val ingame = Terrarum.ingame!! as Ingame
|
||||
|
||||
|
||||
if (args.size == 1 && ingame.player != null) {
|
||||
if (args.size == 1 && ingame.playableActor != null) {
|
||||
// print all actorvalue of player
|
||||
val av = ingame.player.actorValue
|
||||
val av = ingame.playableActor.actorValue
|
||||
val keyset = av.keySet
|
||||
|
||||
Echo("$ccW== ActorValue list for ${ccY}player $ccW==")
|
||||
@@ -37,14 +37,14 @@ internal object GetAV : ConsoleCommand {
|
||||
if (!args[1].isNum()) { // args[1] is ActorValue name
|
||||
Echo("${ccW}player.$ccM${args[1]} $ccW= " +
|
||||
ccG +
|
||||
ingame.player.actorValue[args[1]] +
|
||||
ingame.playableActor.actorValue[args[1]] +
|
||||
" $ccO" +
|
||||
ingame.player.actorValue[args[1]]!!.javaClass.simpleName
|
||||
ingame.playableActor.actorValue[args[1]]!!.javaClass.simpleName
|
||||
)
|
||||
println("[GetAV] player.${args[1]} = " +
|
||||
ingame.player.actorValue[args[1]] +
|
||||
ingame.playableActor.actorValue[args[1]] +
|
||||
" " +
|
||||
ingame.player.actorValue[args[1]]!!.javaClass.simpleName
|
||||
ingame.playableActor.actorValue[args[1]]!!.javaClass.simpleName
|
||||
)
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -6,8 +6,7 @@ import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.gameactors.Factionable
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Player
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
|
||||
import net.torvald.terrarumsansbitmap.gdx.GameFontBase
|
||||
|
||||
/**
|
||||
@@ -29,8 +28,8 @@ internal object GetFactioning : ConsoleCommand {
|
||||
fun printOutFactioning(id: Int) {
|
||||
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()}' ==")
|
||||
Echo("$ccW== Faction assignment for $ccY${if (id == Terrarum.PLAYER_REF_ID) "player" else id.toString()} $ccW==")
|
||||
println("[GetFactioning] == Faction assignment for '${if (id == Terrarum.PLAYER_REF_ID) "player" else id.toString()}' ==")
|
||||
|
||||
// get all factioning data of player
|
||||
val factionSet = a.faction
|
||||
@@ -84,7 +83,7 @@ internal object GetFactioning : ConsoleCommand {
|
||||
}
|
||||
|
||||
if (args.size == 1) {
|
||||
printOutFactioning(Player.PLAYER_REF_ID)
|
||||
printOutFactioning(Terrarum.PLAYER_REF_ID)
|
||||
}
|
||||
else {
|
||||
if (!args[1].isNum()) {
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.console
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-20.
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.Ingame
|
||||
internal object GetTime : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
|
||||
val worldTime = (Terrarum.ingame!! as Ingame).world.time
|
||||
val worldTime = (Terrarum.ingame!!.world as GameWorldExtension).time
|
||||
Echo(worldTime.getFormattedTime())
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import java.io.IOException
|
||||
internal object GsonTest : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 2) {
|
||||
val avelem = Gson().toJsonTree((Terrarum.ingame!! as Ingame).player)
|
||||
val avelem = Gson().toJsonTree((Terrarum.ingame!! as Ingame).playableActor)
|
||||
|
||||
val jsonString = avelem.toString()
|
||||
|
||||
|
||||
@@ -20,10 +20,10 @@ object ImportLayerData : ConsoleCommand {
|
||||
|
||||
//val fis = GZIPInputStream(FileInputStream(args[1])) // this gzip is kaput
|
||||
val fis = FileInputStream(args[1])
|
||||
(Terrarum.ingame!! as Ingame).world = ReadLayerData(fis)
|
||||
(Terrarum.ingame!! as Ingame).player.setPosition(
|
||||
(Terrarum.ingame!! as Ingame).world.spawnY * FeaturesDrawer.TILE_SIZE.toDouble(),
|
||||
(Terrarum.ingame!! as Ingame).world.spawnX * FeaturesDrawer.TILE_SIZE.toDouble()
|
||||
(Terrarum.ingame!!.world) = ReadLayerData(fis)
|
||||
(Terrarum.ingame!! as Ingame).playableActor.setPosition(
|
||||
(Terrarum.ingame!!.world).spawnY * FeaturesDrawer.TILE_SIZE.toDouble(),
|
||||
(Terrarum.ingame!!.world).spawnX * FeaturesDrawer.TILE_SIZE.toDouble()
|
||||
)
|
||||
fis.close()
|
||||
Echo("Successfully loaded ${args[1]}")
|
||||
|
||||
@@ -4,7 +4,7 @@ import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Player
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
@@ -14,7 +14,7 @@ import net.torvald.terrarum.modulebasegame.Ingame
|
||||
*/
|
||||
internal object Inventory : ConsoleCommand {
|
||||
|
||||
private var target: Pocketed? = (Terrarum.ingame!! as Ingame).player
|
||||
private var target: Pocketed? = (Terrarum.ingame!! as Ingame).playableActor
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 1) {
|
||||
@@ -48,7 +48,7 @@ internal object Inventory : ConsoleCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setTarget(actorRefId: Int = Player.PLAYER_REF_ID) {
|
||||
private fun setTarget(actorRefId: Int = Terrarum.PLAYER_REF_ID) {
|
||||
val actor = Terrarum.ingame!!.getActorByID(actorRefId)
|
||||
if (actor !is Pocketed) {
|
||||
EchoError("Cannot edit inventory of incompatible actor: $actor")
|
||||
|
||||
@@ -12,8 +12,8 @@ import net.torvald.terrarum.modulebasegame.Ingame
|
||||
internal object Seed : ConsoleCommand {
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
Echo("Map$ccW: $ccG${(Terrarum.ingame!! as Ingame).world.generatorSeed}")
|
||||
println("[seed] Map$ccW: $ccG${(Terrarum.ingame!! as Ingame).world.generatorSeed}")
|
||||
Echo("Map$ccW: $ccG${(Terrarum.ingame!!.world).generatorSeed}")
|
||||
println("[seed] Map$ccW: $ccG${(Terrarum.ingame!!.world).generatorSeed}")
|
||||
// TODO display randomiser seed
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ internal object SetAV : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
(Terrarum.ingame!! as Ingame).player.actorValue[args[1]] = newValue
|
||||
(Terrarum.ingame!! as Ingame).playableActor.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'.")
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-01-20.
|
||||
@@ -14,13 +14,13 @@ 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 (Terrarum.ingame!! as Ingame).player.referenceID
|
||||
val targetID = if (args.size == 3) args[1].toInt() else (Terrarum.ingame!! as Ingame).playableActor.referenceID
|
||||
val scale = args[if (args.size == 3) 2 else 1].toDouble()
|
||||
|
||||
val target = Terrarum.ingame!!.getActorByID(targetID!!)
|
||||
|
||||
if (target !is ActorWithPhysics) {
|
||||
EchoError("Target is not ActorWithPhysics")
|
||||
if (target !is ActorWBMovable) {
|
||||
EchoError("Target is not ActorWBMovable")
|
||||
}
|
||||
else {
|
||||
target.scale = scale
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.Ingame
|
||||
*/
|
||||
internal object SetTime : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val world = (Terrarum.ingame!! as Ingame).world
|
||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||
|
||||
|
||||
if (args.size == 2) {
|
||||
|
||||
@@ -13,7 +13,7 @@ internal object SetTimeDelta : ConsoleCommand {
|
||||
val HARD_LIMIT = 60
|
||||
|
||||
override fun execute(args: Array<String>) {
|
||||
val world = (Terrarum.ingame!! as Ingame).world
|
||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||
|
||||
|
||||
if (args.size == 2) {
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.dyn4j.geometry.Vector2
|
||||
internal object SpawnPhysTestBall : ConsoleCommand {
|
||||
@Throws(Exception::class)
|
||||
override fun execute(args: Array<String>) {
|
||||
val world = (Terrarum.ingame!! as Ingame).world
|
||||
val world = (Terrarum.ingame!!.world)
|
||||
|
||||
|
||||
val mouseX = Terrarum.mouseX
|
||||
|
||||
@@ -13,7 +13,7 @@ internal object SpawnPhysTestLunarLander : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val mouseX = Terrarum.mouseX
|
||||
val mouseY = Terrarum.mouseY
|
||||
val lander = PhysTestLuarLander((Terrarum.ingame!! as Ingame).world)
|
||||
val lander = PhysTestLuarLander((Terrarum.ingame!!.world))
|
||||
|
||||
lander.setPosition(mouseX, mouseY)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
||||
*/
|
||||
internal object SpawnTikiTorch : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val torch = FixtureTikiTorch((Terrarum.ingame!! as Ingame).world)
|
||||
val torch = FixtureTikiTorch((Terrarum.ingame!!.world))
|
||||
torch.setPosition(Terrarum.mouseX, Terrarum.mouseY)
|
||||
|
||||
Terrarum.ingame!!.addNewActor(torch)
|
||||
|
||||
@@ -6,7 +6,7 @@ import net.torvald.terrarum.console.ConsoleCommand
|
||||
import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.console.EchoError
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-24.
|
||||
@@ -27,32 +27,32 @@ internal object Teleport : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
(Terrarum.ingame!! as Ingame).player.setPosition(x.toDouble(), y.toDouble())
|
||||
(Terrarum.ingame!! as Ingame).playableActor.setPosition(x.toDouble(), y.toDouble())
|
||||
}
|
||||
else if (args.size == 4) {
|
||||
if (args[2].toLowerCase() != "to") {
|
||||
EchoError("missing 'to' on teleport command")
|
||||
return
|
||||
}
|
||||
val fromActor: ActorWithPhysics
|
||||
val targetActor: ActorWithPhysics
|
||||
val fromActor: ActorWBMovable
|
||||
val targetActor: ActorWBMovable
|
||||
try {
|
||||
val fromActorID = args[1].toInt()
|
||||
val targetActorID = if (args[3].toLowerCase() == "player")
|
||||
(Terrarum.ingame!! as Ingame).player.referenceID!!
|
||||
(Terrarum.ingame!! as Ingame).playableActor.referenceID!!
|
||||
else
|
||||
args[3].toInt()
|
||||
|
||||
// if from == target, ignore the action
|
||||
if (fromActorID == targetActorID) return
|
||||
|
||||
if (Terrarum.ingame!!.getActorByID(fromActorID) !is ActorWithPhysics ||
|
||||
Terrarum.ingame!!.getActorByID(targetActorID) !is ActorWithPhysics) {
|
||||
if (Terrarum.ingame!!.getActorByID(fromActorID) !is ActorWBMovable ||
|
||||
Terrarum.ingame!!.getActorByID(targetActorID) !is ActorWBMovable) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
fromActor = Terrarum.ingame!!.getActorByID(fromActorID) as ActorWithPhysics
|
||||
targetActor = Terrarum.ingame!!.getActorByID(targetActorID) as ActorWithPhysics
|
||||
fromActor = Terrarum.ingame!!.getActorByID(fromActorID) as ActorWBMovable
|
||||
targetActor = Terrarum.ingame!!.getActorByID(targetActorID) as ActorWBMovable
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
@@ -75,7 +75,7 @@ internal object Teleport : ConsoleCommand {
|
||||
return
|
||||
}
|
||||
|
||||
val actor: ActorWithPhysics
|
||||
val actor: ActorWBMovable
|
||||
val x: Int
|
||||
val y: Int
|
||||
try {
|
||||
@@ -83,11 +83,11 @@ internal object Teleport : ConsoleCommand {
|
||||
y = args[4].toInt() * FeaturesDrawer.TILE_SIZE + FeaturesDrawer.TILE_SIZE / 2
|
||||
val actorID = args[1].toInt()
|
||||
|
||||
if (Terrarum.ingame!!.getActorByID(actorID) !is ActorWithPhysics) {
|
||||
if (Terrarum.ingame!!.getActorByID(actorID) !is ActorWBMovable) {
|
||||
throw IllegalArgumentException()
|
||||
}
|
||||
else {
|
||||
actor = Terrarum.ingame!!.getActorByID(actorID) as ActorWithPhysics
|
||||
actor = Terrarum.ingame!!.getActorByID(actorID) as ActorWBMovable
|
||||
}
|
||||
}
|
||||
catch (e: NumberFormatException) {
|
||||
|
||||
@@ -10,9 +10,9 @@ import net.torvald.terrarum.modulebasegame.Ingame
|
||||
*/
|
||||
internal object ToggleNoClip : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
val status = (Terrarum.ingame!! as Ingame).player.isNoClip()
|
||||
val status = (Terrarum.ingame!! as Ingame).playableActor.isNoClip
|
||||
|
||||
(Terrarum.ingame!! as Ingame).player.setNoClip(!status)
|
||||
(Terrarum.ingame!! as Ingame).playableActor.isNoClip = !status
|
||||
Echo("Set no-clip status to " + (!status).toString())
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import net.torvald.terrarum.console.Echo
|
||||
import net.torvald.terrarum.modulebasegame.console.SetAV
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import java.awt.BorderLayout
|
||||
import java.awt.GridLayout
|
||||
@@ -29,7 +29,7 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
private val avPosArea = JTextArea()
|
||||
private val avPosScroller = JScrollPane(avPosArea)
|
||||
|
||||
private var actor: ActorWithPhysics? = null
|
||||
private var actor: ActorWBMovable? = null
|
||||
private var actorValue: ActorValue? = null
|
||||
|
||||
private val modavInputKey = JTextField()
|
||||
@@ -84,11 +84,11 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
buttonChangeActor.addMouseListener(object : MouseAdapter() {
|
||||
override fun mousePressed(e: MouseEvent?) {
|
||||
if (actorIDField.text.toLowerCase() == "player") {
|
||||
actor = (Terrarum.ingame!! as Ingame).player
|
||||
actor = (Terrarum.ingame!! as Ingame).playableActor
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
else if (actorIDField.text.isNotBlank()) {
|
||||
actor = Terrarum.ingame!!.getActorByID(actorIDField.text.toInt()) as ActorWithPhysics
|
||||
actor = Terrarum.ingame!!.getActorByID(actorIDField.text.toInt()) as ActorWBMovable
|
||||
actorValue = actor!!.actorValue
|
||||
}
|
||||
}
|
||||
@@ -152,7 +152,7 @@ class ActorValueTracker constructor() : JFrame() {
|
||||
|
||||
this.title = "AVTracker — $actor"
|
||||
|
||||
if (actor is ActorWithPhysics) {
|
||||
if (actor is ActorWBMovable) {
|
||||
this.actor = actor
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.bipolarClamp
|
||||
import net.torvald.terrarum.gameactors.Controllable
|
||||
import net.torvald.terrarum.gameactors.Factionable
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
@@ -32,7 +29,7 @@ open class ActorHumanoid(
|
||||
birth: time_t,
|
||||
death: time_t? = null,
|
||||
usePhysics: Boolean = true
|
||||
) : ActorWithPhysics(world, RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
||||
) : ActorWBMovable(world, RenderOrder.MIDDLE, usePhysics = usePhysics), Controllable, Pocketed, Factionable, Luminous, LandHolder, HistoricalFigure {
|
||||
|
||||
|
||||
|
||||
@@ -139,8 +136,6 @@ open class ActorHumanoid(
|
||||
@Transient private var prevHMoveKey = KEY_NULL
|
||||
@Transient private var prevVMoveKey = KEY_NULL
|
||||
|
||||
internal var noClip = false
|
||||
|
||||
@Transient private val AXIS_KEYBOARD = -13372f // leetz
|
||||
@Transient private val GAMEPAD_JUMP = 7
|
||||
|
||||
@@ -150,7 +145,7 @@ open class ActorHumanoid(
|
||||
protected var isRightDown = false
|
||||
protected var isJumpDown = false
|
||||
protected inline val isGamer: Boolean
|
||||
get() = if (Terrarum.ingame == null) false else this == (Terrarum.ingame!! as Ingame).player
|
||||
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.playableActor
|
||||
|
||||
|
||||
private val nullItem = object : GameItem() {
|
||||
@@ -174,7 +169,7 @@ open class ActorHumanoid(
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
|
||||
if (vehicleRiding is Player)
|
||||
if (vehicleRiding is IngamePlayer)
|
||||
throw Error("Attempted to 'ride' player object. ($vehicleRiding)")
|
||||
if (vehicleRiding != null && vehicleRiding == this)
|
||||
throw Error("Attempted to 'ride' itself. ($vehicleRiding)")
|
||||
@@ -188,7 +183,7 @@ open class ActorHumanoid(
|
||||
|
||||
updateSprite(delta)
|
||||
|
||||
if (noClip) {
|
||||
if (isNoClip) {
|
||||
//grounded = true
|
||||
}
|
||||
|
||||
@@ -277,7 +272,7 @@ open class ActorHumanoid(
|
||||
}
|
||||
// ↑E
|
||||
// ↑D
|
||||
if (isNoClip() && !isUpDown && !isDownDown) {
|
||||
if (isNoClip && !isUpDown && !isDownDown) {
|
||||
walkVStop()
|
||||
prevVMoveKey = KEY_NULL
|
||||
}
|
||||
@@ -313,7 +308,7 @@ open class ActorHumanoid(
|
||||
/**
|
||||
* Up/Down movement
|
||||
*/
|
||||
if (noClip || COLLISION_TEST_MODE) {
|
||||
if (isNoClip || COLLISION_TEST_MODE) {
|
||||
if (hasController) {
|
||||
if (axisY != 0f) {
|
||||
walkVertical(axisY < 0, axisY.abs())
|
||||
@@ -343,7 +338,7 @@ open class ActorHumanoid(
|
||||
* Jump control
|
||||
*/
|
||||
if (isJumpDown) {
|
||||
if (!noClip) {
|
||||
if (!isNoClip) {
|
||||
if (airJumpingAllowed ||
|
||||
(!airJumpingAllowed && walledBottom)) {
|
||||
jumping = true
|
||||
@@ -385,7 +380,7 @@ open class ActorHumanoid(
|
||||
* this code base, ACCELERATION must be changed (in other words, we must deal with JERK) accordingly
|
||||
* to the FRICTION.
|
||||
*
|
||||
* So I'm adding walkX/Y and getting the ActorWithPhysics.setNewNextHitbox to use the velocity value of
|
||||
* So I'm adding walkX/Y and getting the ActorWBMovable.setNewNextHitbox to use the velocity value of
|
||||
* walkX/Y + velocity, which is stored in variable moveDelta.
|
||||
*
|
||||
* Be warned.
|
||||
@@ -608,18 +603,6 @@ open class ActorHumanoid(
|
||||
}
|
||||
}
|
||||
|
||||
fun isNoClip(): Boolean {
|
||||
return noClip
|
||||
}
|
||||
|
||||
fun setNoClip(b: Boolean) {
|
||||
noClip = b
|
||||
|
||||
if (b) {
|
||||
externalForce.zero()
|
||||
controllerMoveDelta?.zero()
|
||||
}
|
||||
}
|
||||
|
||||
fun Float.abs() = FastMath.abs(this)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
@@ -60,10 +61,10 @@ class ActorInventory(val actor: Pocketed, var maxCapacity: Int, var capacityMode
|
||||
if (count < 0)
|
||||
throw IllegalArgumentException("Item count is negative number. If you intended removing items, use remove()\n" +
|
||||
"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
|
||||
if (item.originalID == Terrarum.PLAYER_REF_ID || item.originalID == 0x51621D) // do not delete this magic
|
||||
throw IllegalArgumentException("Attempted to put human player into the inventory.")
|
||||
if (((Terrarum.ingame as? Ingame)?.gameFullyLoaded ?: false) &&
|
||||
(item.originalID == (Terrarum.ingame as? Ingame)?.player?.referenceID))
|
||||
(item.originalID == (Terrarum.ingame as? Ingame)?.playableActor?.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")
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
|
||||
|
||||
@@ -13,8 +15,8 @@ object CreatureBuilder {
|
||||
/**
|
||||
* @Param jsonFileName with extension
|
||||
*/
|
||||
operator fun invoke(world: GameWorld, module: String, jsonFileName: String): ActorWithPhysics {
|
||||
val actor = ActorWithPhysics(world, Actor.RenderOrder.MIDDLE)
|
||||
operator fun invoke(world: GameWorld, module: String, jsonFileName: String): ActorWBMovable {
|
||||
val actor = ActorWBMovable(world, Actor.RenderOrder.MIDDLE)
|
||||
InjectCreatureRaw(actor.actorValue, module, jsonFileName)
|
||||
|
||||
|
||||
|
||||
@@ -173,6 +173,6 @@ object DecodeTapestry {
|
||||
readCounter++
|
||||
}
|
||||
|
||||
return TapestryObject((Terrarum.ingame!! as Ingame).world, outImageData, artName, authorName)
|
||||
return TapestryObject((Terrarum.ingame!!.world), outImageData, artName, authorName)
|
||||
}
|
||||
}
|
||||
@@ -4,12 +4,13 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-15.
|
||||
*/
|
||||
open class DroppedItem(world: GameWorld, private val item: GameItem) : ActorWithPhysics(world, RenderOrder.MIDTOP) {
|
||||
open class DroppedItem(world: GameWorld, private val item: GameItem) : ActorWBMovable(world, RenderOrder.MIDTOP) {
|
||||
|
||||
init {
|
||||
if (item.dynamicID >= ItemCodex.ACTORID_MIN)
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-06-17.
|
||||
*/
|
||||
open class FixtureBase(world: GameWorld, physics: Boolean = true) :
|
||||
ActorWithPhysics(world, RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
|
||||
ActorWBMovable(world, RenderOrder.BEHIND, immobileBody = true, usePhysics = physics) {
|
||||
/**
|
||||
* 0: Open
|
||||
* 1: Blocked
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
|
||||
@@ -2,11 +2,11 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AIControlled
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ai.ActorAI
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics.Companion.COLLISION_DYNAMIC
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
|
||||
|
||||
@@ -10,27 +11,17 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
*/
|
||||
|
||||
class Player(world: GameWorld, born: time_t) : ActorHumanoid(world, born) {
|
||||
|
||||
companion object {
|
||||
@Transient const val PLAYER_REF_ID: Int = 0x91A7E2
|
||||
}
|
||||
class IngamePlayer(world: GameWorldExtension, born: time_t) : ActorHumanoid(world, born) {
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
||||
|
||||
* **Use PlayerFactory to build player!**
|
||||
|
||||
* @throws SlickException
|
||||
*/
|
||||
init {
|
||||
referenceID = PLAYER_REF_ID // forcibly set ID
|
||||
referenceID = Terrarum.PLAYER_REF_ID // forcibly set ID
|
||||
density = BASE_DENSITY
|
||||
collisionType = COLLISION_KINEMATIC
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.torvald.random.Fudge3
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import com.google.gson.JsonObject
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorValue
|
||||
import java.security.SecureRandom
|
||||
|
||||
|
||||
@@ -4,14 +4,13 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics.Companion.SI_TO_GAME_ACC
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable.Companion.SI_TO_GAME_ACC
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
@@ -48,7 +47,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision
|
||||
if (despawnUponCollision) {
|
||||
if (velocity.isZero ||
|
||||
// simple stuck check
|
||||
BlockCodex[(Terrarum.ingame!! as Ingame).world.getTileFromTerrain(
|
||||
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(
|
||||
hitbox.canonicalX.div(TILE_SIZE).floorInt(),
|
||||
hitbox.canonicalY.div(TILE_SIZE).floorInt()
|
||||
) ?: Block.STONE].isSolid) {
|
||||
@@ -62,7 +61,7 @@ open class ParticleBase(renderOrder: Actor.RenderOrder, val despawnUponCollision
|
||||
|
||||
// gravity, winds, etc. (external forces)
|
||||
if (!isNoSubjectToGrav) {
|
||||
velocity += (Terrarum.ingame!! as Ingame).world.gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
velocity += (Terrarum.ingame!!.world).gravitation / dragCoefficient * SI_TO_GAME_ACC
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-12-18.
|
||||
@@ -23,7 +24,7 @@ class ParticleMegaRain(posX: Double, posY: Double) : ParticleBase(Actor.RenderOr
|
||||
w, h
|
||||
)
|
||||
|
||||
velocity.y = 11.5 * ActorWithPhysics.SI_TO_GAME_VEL
|
||||
velocity.y = 11.5 * ActorWBMovable.SI_TO_GAME_VEL
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,14 +3,14 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-05.
|
||||
*/
|
||||
class PhysTestBall(world: GameWorld) : ActorWithPhysics(world, RenderOrder.MIDDLE, immobileBody = true) {
|
||||
class PhysTestBall(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDDLE, immobileBody = true) {
|
||||
|
||||
private var color = Color.GOLD
|
||||
|
||||
@@ -32,13 +32,13 @@ class PhysTestBall(world: GameWorld) : ActorWithPhysics(world, RenderOrder.MIDDL
|
||||
)
|
||||
|
||||
it.circle(
|
||||
hitbox.startX.toFloat() + (Terrarum.ingame!! as 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() - (Terrarum.ingame!! as Ingame).world.width * TILE_SIZE - 1f,
|
||||
hitbox.startX.toFloat() - (Terrarum.ingame!!.world).width * TILE_SIZE - 1f,
|
||||
hitbox.startY.toFloat() - 1f,
|
||||
hitbox.width.toFloat()
|
||||
)
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.Controllable
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -13,7 +15,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
/**
|
||||
* Created by minjaesong on 2018-01-17.
|
||||
*/
|
||||
class PhysTestLuarLander(world: GameWorld) : ActorWithPhysics(world, RenderOrder.MIDTOP), Controllable {
|
||||
class PhysTestLuarLander(world: GameWorld) : ActorWBMovable(world, RenderOrder.MIDTOP), Controllable {
|
||||
|
||||
private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
|
||||
@@ -10,7 +11,9 @@ import net.torvald.terrarum.modulebasegame.Ingame
|
||||
object PlayerBuilder {
|
||||
|
||||
operator fun invoke(): Actor {
|
||||
val p: Actor = Player((Terrarum.ingame!! as Ingame).world, (Terrarum.ingame!! as Ingame).world.time.TIME_T)
|
||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||
|
||||
val p: Actor = IngamePlayer(world, world.time.TIME_T)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -2,8 +2,9 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ai.NullAI
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -12,10 +13,10 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
object PlayerBuilderCynthia {
|
||||
|
||||
operator fun invoke(): ActorWithPhysics {
|
||||
//val p: Player = Player(GameDate(100, 143)) // random value thrown
|
||||
operator fun invoke(): ActorWBMovable {
|
||||
//val p: IngamePlayer = IngamePlayer(GameDate(100, 143)) // random value thrown
|
||||
val p: HumanoidNPC = HumanoidNPC(
|
||||
(Terrarum.ingame!! as Ingame).world,
|
||||
(Terrarum.ingame!!.world),
|
||||
NullAI(),
|
||||
-589141658L) // random value thrown
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
@@ -5,7 +5,9 @@ import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.faction.FactionFactory
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -14,8 +16,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
object PlayerBuilderSigrid {
|
||||
|
||||
operator fun invoke(): Player {
|
||||
val p = Player((Terrarum.ingame!! as Ingame).world, -9223372036854775807L) // XD
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -9223372036854775807L) // XD
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -10,8 +11,8 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
* Created by minjaesong on 2017-02-10.
|
||||
*/
|
||||
object PlayerBuilderTestSubject1 {
|
||||
operator fun invoke(): Player {
|
||||
val p: Player = Player((Terrarum.ingame!! as Ingame).world, -589141658L) // random value thrown
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p: IngamePlayer = IngamePlayer((Terrarum.ingame!! as Ingame).gameworld, -589141658L) // random value thrown
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import java.util.*
|
||||
|
||||
@@ -25,7 +25,7 @@ open class ProjectileSimple(
|
||||
private val type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : ActorWithPhysics(world, RenderOrder.MIDTOP), Luminous, Projectile {
|
||||
) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous, Projectile {
|
||||
|
||||
val damage: Int
|
||||
val displayColour: Color
|
||||
@@ -77,7 +77,7 @@ open class ProjectileSimple(
|
||||
lifetimeCounter += delta
|
||||
if (walledTop || walledBottom || walledRight || walledLeft || lifetimeCounter >= lifetimeMax ||
|
||||
// stuck check
|
||||
BlockCodex[(Terrarum.ingame!! as Ingame).world.getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
BlockCodex[(Terrarum.ingame!!.world).getTileFromTerrain(feetPosTile[0], feetPosTile[1]) ?: Block.STONE].isSolid
|
||||
) {
|
||||
flagDespawn()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
@@ -8,7 +9,7 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
/**
|
||||
* Created by minjaesong on 2016-04-26.
|
||||
*/
|
||||
class WeaponSwung(world: GameWorld, val itemID: Int) : ActorWithPhysics(world, RenderOrder.MIDTOP), Luminous {
|
||||
class WeaponSwung(world: GameWorld, val itemID: Int) : ActorWBMovable(world, RenderOrder.MIDTOP), Luminous {
|
||||
// just let the solver use AABB; it's cheap but works just enough
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ class SmarterSlimes : ActorAI {
|
||||
|
||||
|
||||
// TEST: just target player
|
||||
val playerXPos = (Terrarum.ingame!! as Ingame).player.centrePosPoint.x
|
||||
val playerXPos = (Terrarum.ingame!! as Ingame).playableActor.centrePosPoint.x
|
||||
val thisXPos = actor.centrePosPoint.x
|
||||
val xDiff = thisXPos - playerXPos
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors.physicssolver
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -20,9 +20,9 @@ object CollisionSolver {
|
||||
private val collListX = ArrayList<CollisionMarkings>(COLL_LIST_SIZE)
|
||||
private val collListY = ArrayList<CollisionMarkings>(COLL_LIST_SIZE)
|
||||
|
||||
private val collCandidateX = ArrayList<Pair<ActorWithPhysics, ActorWithPhysics>>(COLL_CANDIDATES_SIZE)
|
||||
private val collCandidateY = ArrayList<Pair<ActorWithPhysics, ActorWithPhysics>>(COLL_CANDIDATES_SIZE)
|
||||
private var collCandidates = ArrayList<Pair<ActorWithPhysics, ActorWithPhysics>>(COLL_FINAL_CANDIDATES_SIZE)
|
||||
private val collCandidateX = ArrayList<Pair<ActorWBMovable, ActorWBMovable>>(COLL_CANDIDATES_SIZE)
|
||||
private val collCandidateY = ArrayList<Pair<ActorWBMovable, ActorWBMovable>>(COLL_CANDIDATES_SIZE)
|
||||
private var collCandidates = ArrayList<Pair<ActorWBMovable, ActorWBMovable>>(COLL_FINAL_CANDIDATES_SIZE)
|
||||
|
||||
private val collCandidateStack = Stack<CollisionMarkings>()
|
||||
|
||||
@@ -40,7 +40,7 @@ object CollisionSolver {
|
||||
|
||||
// mark list x
|
||||
(Terrarum.ingame!! as Ingame).actorContainer.forEach { it ->
|
||||
if (it is ActorWithPhysics) {
|
||||
if (it is ActorWBMovable) {
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxStart.x, STARTPOINT, it))
|
||||
collListX.add(CollisionMarkings(it.hitbox.hitboxEnd.x, ENDPOINT, it))
|
||||
}
|
||||
@@ -73,7 +73,7 @@ object CollisionSolver {
|
||||
|
||||
// mark list y
|
||||
(Terrarum.ingame!! as Ingame).actorContainer.forEach { it ->
|
||||
if (it is ActorWithPhysics) {
|
||||
if (it is ActorWBMovable) {
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxStart.y, STARTPOINT, it))
|
||||
collListY.add(CollisionMarkings(it.hitbox.hitboxEnd.y, ENDPOINT, it))
|
||||
}
|
||||
@@ -89,7 +89,7 @@ object CollisionSolver {
|
||||
else if (it.kind == ENDPOINT) {
|
||||
val mark_this = it
|
||||
val mark_other = collCandidateStack.pop()
|
||||
val collCandidate: Pair<ActorWithPhysics, ActorWithPhysics>
|
||||
val collCandidate: Pair<ActorWBMovable, ActorWBMovable>
|
||||
// make sure actor with lower ID comes first
|
||||
if (mark_this.actor < mark_other.actor)
|
||||
collCandidate = Pair(mark_this.actor, mark_other.actor)
|
||||
@@ -137,7 +137,7 @@ object CollisionSolver {
|
||||
return indexOfEqFn(this, other) >= 0
|
||||
}
|
||||
|
||||
private fun solveCollision(a: ActorWithPhysics, b: ActorWithPhysics) {
|
||||
private fun solveCollision(a: ActorWBMovable, b: ActorWBMovable) {
|
||||
// some of the Pair(a, b) are either duplicates or erroneously reported.
|
||||
// e.g. (A, B), (B, C) and then (A, C);
|
||||
// in some situation (A, C) will not making any contact with each other
|
||||
@@ -173,11 +173,11 @@ object CollisionSolver {
|
||||
}
|
||||
}
|
||||
|
||||
private infix fun ActorWithPhysics.makesCollisionWith(other: ActorWithPhysics) =
|
||||
this.collisionType != ActorWithPhysics.COLLISION_NOCOLLIDE &&
|
||||
other.collisionType != ActorWithPhysics.COLLISION_NOCOLLIDE
|
||||
private infix fun ActorWBMovable.makesCollisionWith(other: ActorWBMovable) =
|
||||
this.collisionType != ActorWBMovable.COLLISION_NOCOLLIDE &&
|
||||
other.collisionType != ActorWBMovable.COLLISION_NOCOLLIDE
|
||||
|
||||
private infix fun ActorWithPhysics.isCollidingWith(other: ActorWithPhysics): Boolean {
|
||||
private infix fun ActorWBMovable.isCollidingWith(other: ActorWBMovable): Boolean {
|
||||
val ax = this.hitbox.centeredX
|
||||
val ay = this.hitbox.centeredY
|
||||
val bx = other.hitbox.centeredX
|
||||
@@ -208,7 +208,7 @@ object CollisionSolver {
|
||||
data class CollisionMarkings(
|
||||
val pos: Double,
|
||||
val kind: Int,
|
||||
val actor: ActorWithPhysics
|
||||
val actor: ActorWBMovable
|
||||
)
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors.physicssolver
|
||||
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-05-01.
|
||||
@@ -11,7 +11,7 @@ object VelocitySolver {
|
||||
|
||||
}
|
||||
|
||||
private fun applyGravity(actor: ActorWithPhysics) {
|
||||
private fun applyGravity(actor: ActorWBMovable) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameworld
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.gameworld.*
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2018-07-03.
|
||||
*/
|
||||
class GameWorldExtension(width: Int, height: Int): GameWorld(width, height) {
|
||||
|
||||
val time: WorldTime
|
||||
val economy = GameEconomy()
|
||||
|
||||
// delegated properties //
|
||||
/*val layerWall: MapLayer; get() = baseworld.layerWall
|
||||
val layerTerrain: MapLayer; get() = baseworld.layerTerrain
|
||||
val layerWire: MapLayer; get() = baseworld.layerWire
|
||||
val layerWallLowBits: PairedMapLayer; get() = baseworld.layerWallLowBits
|
||||
val layerTerrainLowBits: PairedMapLayer; get() = baseworld.layerTerrainLowBits
|
||||
val layerHalfThermal: MapLayerHalfFloat; get() = baseworld.layerHalfThermal
|
||||
var spawnX: Int; get() = baseworld.spawnX; set(v) { baseworld.spawnX = v }
|
||||
var spawnY: Int; get() = baseworld.spawnY; set(v) { baseworld.spawnY = v }
|
||||
val wallDamages: HashMap<BlockAddress, BlockDamage>; get() = baseworld.wallDamages
|
||||
val terrainDamages: HashMap<BlockAddress, BlockDamage>; get() = baseworld.terrainDamages
|
||||
var globalLight: Color; get() = baseworld.globalLight; set(v) { baseworld.globalLight = v }
|
||||
var averageTemperature: Float; get() = baseworld.averageTemperature; set(v) { baseworld.averageTemperature = v }
|
||||
var generatorSeed: Long; get() = baseworld.generatorSeed; set(v) { baseworld.generatorSeed = v }
|
||||
val terrainArray: ByteArray; get() = baseworld.terrainArray
|
||||
val wallArray: ByteArray; get() = baseworld.wallArray
|
||||
val wireArray: ByteArray; get() = baseworld.wireArray
|
||||
val damageDataArray: ByteArray; get() = baseworld.damageDataArray*/
|
||||
|
||||
init {
|
||||
time = WorldTime(
|
||||
71 * WorldTime.DAY_LENGTH +
|
||||
7 * WorldTime.HOUR_SEC +
|
||||
30L * WorldTime.MINUTE_SEC
|
||||
)
|
||||
}
|
||||
|
||||
fun updateWorldTime(delta: Float) {
|
||||
time.update(delta)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -38,7 +38,7 @@ object WorldSimulator {
|
||||
val colourNone = Color(0x808080FF.toInt())
|
||||
val colourWater = Color(0x66BBFFFF.toInt())
|
||||
|
||||
private val world = (Terrarum.ingame!! as Ingame).world
|
||||
private val world = (Terrarum.ingame!!.world)
|
||||
|
||||
operator fun invoke(p: ActorHumanoid?, delta: Float) {
|
||||
if (p != null) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.AVKey
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.itemproperties.Calculate
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
@@ -38,27 +38,27 @@ class PickaxeGeneric(override val originalID: ItemID) : GameItem() {
|
||||
val mouseTileY = Terrarum.mouseTileY
|
||||
|
||||
val mousePoint = Point2d(mouseTileX.toDouble(), mouseTileY.toDouble())
|
||||
val actorvalue = (Terrarum.ingame!! as Ingame).player.actorValue
|
||||
val actorvalue = (Terrarum.ingame!! as Ingame).playableActor.actorValue
|
||||
|
||||
using = true
|
||||
|
||||
// linear search filter (check for intersection with tilewise mouse point and tilewise hitbox)
|
||||
// return false if hitting actors
|
||||
Terrarum.ingame!!.actorContainer.forEach({
|
||||
if (it is ActorWithPhysics && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
if (it is ActorWBMovable && it.hIntTilewiseHitbox.intersects(mousePoint))
|
||||
return false
|
||||
})
|
||||
|
||||
// return false if here's no tile
|
||||
if (Block.AIR == (Terrarum.ingame!! as Ingame).world.getTileFromTerrain(mouseTileX, mouseTileY))
|
||||
if (Block.AIR == (Terrarum.ingame!!.world).getTileFromTerrain(mouseTileX, mouseTileY))
|
||||
return false
|
||||
|
||||
// filter passed, do the job
|
||||
val swingDmgToFrameDmg = delta.toDouble() / actorvalue.getAsDouble(AVKey.ACTION_INTERVAL)!!
|
||||
|
||||
(Terrarum.ingame!! as Ingame).world.inflictTerrainDamage(
|
||||
(Terrarum.ingame!!.world).inflictTerrainDamage(
|
||||
mouseTileX, mouseTileY,
|
||||
Calculate.pickaxePower((Terrarum.ingame!! as Ingame).player, material) * swingDmgToFrameDmg
|
||||
Calculate.pickaxePower((Terrarum.ingame!! as Ingame).playableActor, material) * swingDmgToFrameDmg
|
||||
)
|
||||
|
||||
return true
|
||||
@@ -67,7 +67,7 @@ class PickaxeGeneric(override val originalID: ItemID) : GameItem() {
|
||||
override fun endPrimaryUse(delta: Float): Boolean {
|
||||
using = false
|
||||
// reset action timer to zero
|
||||
(Terrarum.ingame!! as Ingame).player.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
|
||||
(Terrarum.ingame!! as Ingame).playableActor.actorValue.set(AVKey.__ACTION_TIMER, 0.0)
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.magiccontroller
|
||||
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
|
||||
/**
|
||||
|
||||
@@ -115,11 +115,11 @@ class UIBasicNotifier(private val player: ActorHumanoid?) : UICanvas() {
|
||||
if (player != null) {
|
||||
val playerPos = player.hIntTilewiseHitbox
|
||||
lightLevel = (LightmapRenderer.getLight(playerPos.centeredX.toInt(), playerPos.centeredY.toInt()) ?:
|
||||
(Terrarum.ingame!! as Ingame).world.globalLight
|
||||
(Terrarum.ingame!!.world).globalLight
|
||||
)
|
||||
}
|
||||
else {
|
||||
lightLevel = (Terrarum.ingame!! as Ingame).world.globalLight
|
||||
lightLevel = (Terrarum.ingame!!.world).globalLight
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItemImageButton
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
class UIBuildingMakerToolbox : UICanvas() {
|
||||
|
||||
val toolsTexture = TextureRegionPack(ModMgr.getGdxFile("basegame", "gui/building_maker_toolbox.tga"), 16, 16)
|
||||
val tools = Array(toolsTexture.verticalCount, { UIItemImageButton(
|
||||
this, toolsTexture.get(0, it),
|
||||
posX = 0,
|
||||
posY = 20 * it,
|
||||
highlightable = true
|
||||
|
||||
) })
|
||||
|
||||
override var width = 16
|
||||
override var height = 20 * tools.size - 4
|
||||
override var openCloseTime = 0f
|
||||
|
||||
var selectedTool = 0; private set
|
||||
|
||||
init {
|
||||
setAsAlwaysVisible()
|
||||
tools[selectedTool].highlighted = true
|
||||
}
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
tools.forEachIndexed { counter, it ->
|
||||
it.update(delta)
|
||||
|
||||
if (it.highlighted) selectedTool = counter
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
tools.forEach { it.render(batch, camera) }
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) { }
|
||||
|
||||
override fun doClosing(delta: Float) { }
|
||||
|
||||
override fun endOpening(delta: Float) { }
|
||||
|
||||
override fun endClosing(delta: Float) { }
|
||||
|
||||
override fun dispose() {
|
||||
toolsTexture.dispose()
|
||||
}
|
||||
|
||||
override fun mouseMoved(screenX: Int, screenY: Int): Boolean {
|
||||
return super.mouseMoved(screenX, screenY)
|
||||
}
|
||||
|
||||
override fun touchDragged(screenX: Int, screenY: Int, pointer: Int): Boolean {
|
||||
return super.touchDragged(screenX, screenY, pointer)
|
||||
}
|
||||
|
||||
override fun touchDown(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
return super.touchDown(screenX, screenY, pointer, button)
|
||||
}
|
||||
|
||||
override fun touchUp(screenX: Int, screenY: Int, pointer: Int, button: Int): Boolean {
|
||||
return super.touchUp(screenX, screenY, pointer, button)
|
||||
}
|
||||
|
||||
override fun scrolled(amount: Int): Boolean {
|
||||
return super.scrolled(amount)
|
||||
}
|
||||
|
||||
override fun keyDown(keycode: Int): Boolean {
|
||||
return super.keyDown(keycode)
|
||||
}
|
||||
|
||||
override fun keyUp(keycode: Int): Boolean {
|
||||
return super.keyUp(keycode)
|
||||
}
|
||||
|
||||
override fun keyTyped(character: Char): Boolean {
|
||||
return super.keyTyped(character)
|
||||
}
|
||||
|
||||
override fun resize(width: Int, height: Int) {
|
||||
super.resize(width, height)
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.GL20
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.glutils.ShapeRenderer
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorWithPhysics
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory.Companion.CAPACITY_MODE_NO_ENCUMBER
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||
import net.torvald.terrarum.Second
|
||||
@@ -91,7 +91,7 @@ class UIInventoryFull(
|
||||
UIItemInventoryEquippedView(
|
||||
this,
|
||||
actor!!.inventory,
|
||||
actor as ActorWithPhysics,
|
||||
actor as ActorWBMovable,
|
||||
internalWidth - UIItemInventoryEquippedView.width + (Terrarum.WIDTH - internalWidth) / 2,
|
||||
109 + (Terrarum.HEIGHT - internalHeight) / 2
|
||||
)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user