mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
removed unnecessary class Light10B, minor fixes for LightmapRenderer
Former-commit-id: 4cddfb080cc689738d9bf308f7d08852f4c78a8b Former-commit-id: 2354b2483f30e70862a327c1b9688a19bd1b2f66
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
echo "Hello, world! This is a batch test."
|
||||
echo "Will add actorvalue 'batch = true' to player"
|
||||
echo "Will add actorvalue 'batch = __true' to player"
|
||||
setav batch true
|
||||
echo "Checking if command did something."
|
||||
getav batch
|
||||
3073
assets/getlightdata
Normal file
3073
assets/getlightdata
Normal file
File diff suppressed because it is too large
Load Diff
@@ -7,7 +7,8 @@ import net.torvald.colourutil.CIELabUtil.toXYZ
|
||||
import org.newdawn.slick.Color
|
||||
|
||||
/**
|
||||
* RGB in this code is always sRGB.
|
||||
* Cylindrical modification of CIELab colour space
|
||||
*
|
||||
* reference: http://www.brucelindbloom.com/index.html?Equations.html
|
||||
*
|
||||
* Created by minjaesong on 16-09-01.
|
||||
@@ -15,7 +16,7 @@ import org.newdawn.slick.Color
|
||||
|
||||
object CIELChUtil {
|
||||
|
||||
/** Sweet LCh linear gradient */
|
||||
/** Sweet LCh_ab linear gradient */
|
||||
fun getGradient(scale: Float, fromCol: Color, toCol: Color): Color {
|
||||
val from = fromCol.toLCh()
|
||||
val to = toCol.toLCh()
|
||||
@@ -48,8 +49,8 @@ object CIELChUtil {
|
||||
return CIELab(L, a, b, alpha)
|
||||
}
|
||||
|
||||
private fun Color.toLCh() = this.toXYZ().toLab().toLCh()
|
||||
private fun CIELCh.toRGB() = this.toLab().toXYZ().toRGB()
|
||||
fun Color.toLCh() = this.toXYZ().toLab().toLCh()
|
||||
fun CIELCh.toRGB() = this.toLab().toXYZ().toRGB()
|
||||
|
||||
private fun Float.sqr() = this * this
|
||||
private fun Float.sqrt() = Math.sqrt(this.toDouble()).toFloat()
|
||||
@@ -4,9 +4,18 @@ import com.jme3.math.FastMath
|
||||
import org.newdawn.slick.Color
|
||||
|
||||
/**
|
||||
* A modification of CIEXYZ that is useful for surface colours
|
||||
*
|
||||
* If you are trying to mix some colour with other, especially one that
|
||||
* requires additive mixing (such as illuminant), USE CIELuvUtil, this is
|
||||
* not for you.
|
||||
*
|
||||
* RGB in this code is always sRGB.
|
||||
* reference: http://www.brucelindbloom.com/index.html?Equations.html
|
||||
*
|
||||
* If you're using Mac, you can play around with this colour space with
|
||||
* ColorSync Utility's calculator.
|
||||
*
|
||||
* Created by minjaesong on 16-09-01.
|
||||
*/
|
||||
object CIELabUtil {
|
||||
@@ -38,10 +47,12 @@ object CIELabUtil {
|
||||
return CIELab(newL, newA, newB, newAlpha).toRGB()
|
||||
}
|
||||
|
||||
private fun Color.toLab() = this.toXYZ().toLab()
|
||||
private fun CIELab.toRGB() = this.toXYZ().toRGB()
|
||||
fun Color.toLab() = this.toXYZ().toLab()
|
||||
fun RGB.toLab() = this.toXYZ().toLab()
|
||||
fun CIELab.toRGB() = this.toXYZ().toRGB()
|
||||
fun CIELab.toRawRGB() = this.toXYZ().toRawRGB()
|
||||
|
||||
fun Color.toXYZ(): CIEXYZ {
|
||||
fun RGB.toXYZ(): CIEXYZ {
|
||||
val newR = if (r > 0.04045f)
|
||||
((r + 0.055f) / 1.055f).powerOf(2.4f)
|
||||
else r / 12.92f
|
||||
@@ -56,13 +67,15 @@ object CIELabUtil {
|
||||
val y = 0.2126729f * newR + 0.7151522f * newG + 0.0721750f * newB
|
||||
val z = 0.0193339f * newR + 0.1191920f * newG + 0.9503041f * newB
|
||||
|
||||
return CIEXYZ(x, y, z, a)
|
||||
return CIEXYZ(x, y, z, alpha)
|
||||
}
|
||||
|
||||
fun CIEXYZ.toRGB(): Color {
|
||||
var r = 3.2404542f * x - 1.5371385f * y - 0.4985314f * z
|
||||
var g = -0.9692660f * x + 1.8760108f * y + 0.0415560f * z
|
||||
var b = 0.0556434f * x - 0.2040259f * y + 1.0572252f * z
|
||||
fun Color.toXYZ(): CIEXYZ = RGB(this).toXYZ()
|
||||
|
||||
fun CIEXYZ.toRawRGB(): RGB {
|
||||
var r = 3.2404542f * X - 1.5371385f * Y - 0.4985314f * Z
|
||||
var g = -0.9692660f * X + 1.8760108f * Y + 0.0415560f * Z
|
||||
var b = 0.0556434f * X - 0.2040259f * Y + 1.0572252f * Z
|
||||
|
||||
if (r > 0.0031308f)
|
||||
r = 1.055f * r.powerOf(1f / 2.4f) - 0.055f
|
||||
@@ -77,13 +90,18 @@ object CIELabUtil {
|
||||
else
|
||||
b *= 12.92f
|
||||
|
||||
return Color(r, g, b, alpha)
|
||||
return RGB(r, g, b, alpha)
|
||||
}
|
||||
|
||||
fun CIEXYZ.toRGB(): Color {
|
||||
val rgb = this.toRawRGB()
|
||||
return Color(rgb.r, rgb.g, rgb.b, rgb.alpha)
|
||||
}
|
||||
|
||||
fun CIEXYZ.toLab(): CIELab {
|
||||
val x = pivotXYZ(x / whitePoint.x)
|
||||
val y = pivotXYZ(y / whitePoint.y)
|
||||
val z = pivotXYZ(z / whitePoint.z)
|
||||
val x = pivotXYZ(X / D65.X)
|
||||
val y = pivotXYZ(Y / D65.Y)
|
||||
val z = pivotXYZ(Z / D65.Z)
|
||||
|
||||
val L = Math.max(0f, 116 * y - 16)
|
||||
val a = 500 * (x - y)
|
||||
@@ -101,23 +119,28 @@ object CIELabUtil {
|
||||
val z3 = z.cube()
|
||||
|
||||
return CIEXYZ(
|
||||
whitePoint.x * if (x3 > epsilon) x3 else (x - 16f / 116f) / 7.787f,
|
||||
whitePoint.y * if (L > kappa * epsilon) (L.plus(16f) / 116f).cube() else L / kappa,
|
||||
whitePoint.z * if (z3 > epsilon) z3 else (z - 16f / 116f) / 7.787f,
|
||||
D65.X * if (x3 > epsilon) x3 else (x - 16f / 116f) / 7.787f,
|
||||
D65.Y * if (L > kappa * epsilon) (L.plus(16f) / 116f).cube() else L / kappa,
|
||||
D65.Z * if (z3 > epsilon) z3 else (z - 16f / 116f) / 7.787f,
|
||||
alpha
|
||||
)
|
||||
}
|
||||
|
||||
private fun pivotXYZ(n: Float) = if (n > epsilon) n.cbrt() else (kappa * n + 16f) / 116f
|
||||
|
||||
val epsilon = 0.008856f
|
||||
val kappa = 903.3f
|
||||
val whitePoint = CIEXYZ(95.047f, 100f, 108.883f)
|
||||
|
||||
private fun Float.cbrt() = FastMath.pow(this, 1f / 3f)
|
||||
private fun Float.cube() = this * this * this
|
||||
private fun Float.powerOf(exp: Float) = FastMath.pow(this, exp)
|
||||
}
|
||||
|
||||
data class CIEXYZ(var x: Float = 0f, var y: Float = 0f, var z: Float = 0f, val alpha: Float = 1f)
|
||||
internal val D65 = CIEXYZ(95.047f, 100f, 108.883f)
|
||||
val epsilon = 216.0.div(24389.0).toFloat()
|
||||
val kappa = 24389.0.div(27.0).toFloat()
|
||||
|
||||
data class CIEXYZ(var X: Float = 0f, var Y: Float = 0f, var Z: Float = 0f, val alpha: Float = 1f)
|
||||
data class CIELab(var L: Float = 0f, var a: Float = 0f, var b: Float = 0f, val alpha: Float = 1f)
|
||||
data class RGB(var r: Float = 0f, var g: Float = 0f, var b: Float = 0f, val alpha: Float = 1f) {
|
||||
constructor(color: Color) : this() {
|
||||
r = color.r; g = color.g; b = color.b
|
||||
}
|
||||
}
|
||||
|
||||
102
src/net/torvald/colourutil/CIELuvUtil.kt
Normal file
102
src/net/torvald/colourutil/CIELuvUtil.kt
Normal file
@@ -0,0 +1,102 @@
|
||||
package net.torvald.colourutil
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import org.newdawn.slick.Color
|
||||
import net.torvald.colourutil.CIELabUtil.toXYZ
|
||||
import net.torvald.colourutil.CIELabUtil.toRawRGB
|
||||
import net.torvald.colourutil.CIELabUtil.toRGB
|
||||
|
||||
/**
|
||||
* A modification of CIEXYZ that is useful for additive mixtures of lights.
|
||||
*
|
||||
* reference: http://www.brucelindbloom.com/index.html?Equations.html
|
||||
*
|
||||
* If you're using Mac, you can play around with this colour space with
|
||||
* ColorSync Utility's calculator.
|
||||
*
|
||||
* Created by minjaesong on 16-09-06.
|
||||
*/
|
||||
object CIELuvUtil {
|
||||
|
||||
fun Color.brighterLuv(scale: Float): Color {
|
||||
val brighten = scale + 1f
|
||||
|
||||
val luv = this.toLuv()
|
||||
luv.L *= brighten
|
||||
return luv.toRGB()
|
||||
}
|
||||
|
||||
fun Color.darkerLuv(scale: Float): Color {
|
||||
val darken = 1f - scale
|
||||
|
||||
val luv = this.toLuv()
|
||||
luv.L *= darken
|
||||
return luv.toRGB()
|
||||
}
|
||||
|
||||
/**
|
||||
* Alpha value will be overwritten to 1.0
|
||||
*/
|
||||
infix fun Color.additiveLuv(other: Color): Color {
|
||||
val rgb = RGB(r, g, b) additiveLuv RGB(other.r, other.g, other.b)
|
||||
return Color(rgb.r, rgb.g, rgb.b, a)
|
||||
}
|
||||
|
||||
/**
|
||||
* Alpha value will be overwritten to 1.0
|
||||
*/
|
||||
infix fun RGB.additiveLuv(other: RGB): RGB {
|
||||
val thisLuv = this.toXYZ().toLuv()
|
||||
val otherLuv = other.toXYZ().toLuv()
|
||||
|
||||
val newL = 1f - (1f - thisLuv.L) * (1 - otherLuv.L)
|
||||
val newU = thisLuv.u.times(otherLuv.L / newL) + otherLuv.u.times(otherLuv.L).times(1f - thisLuv.L).div(newL)
|
||||
val newV = thisLuv.v.times(otherLuv.L / newL) + otherLuv.v.times(otherLuv.L).times(1f - thisLuv.L).div(newL)
|
||||
|
||||
return CIELuv(newL, newU, newV).toRawRGB()
|
||||
}
|
||||
|
||||
fun CIEXYZ.toLuv(): CIELuv {
|
||||
val yRef = Y / D65.Y
|
||||
val uPrime = 4f * X / (X + 15f * Y + 3f * Z)
|
||||
val vPrime = 9f * Y / (X + 15f * Y + 3f * Z)
|
||||
val uRefPrime = 4f * D65.X / (D65.X + 15f * D65.Y + 3f * D65.Z)
|
||||
val vRefPrime = 9f * D65.Y / (D65.X + 15f * D65.Y + 3f * D65.Z)
|
||||
|
||||
val L = if (yRef > epsilon)
|
||||
116f * yRef.cbrt() - 16f
|
||||
else
|
||||
kappa * yRef
|
||||
|
||||
val u = 13f * L * (uPrime - uRefPrime)
|
||||
val v = 13f * L * (vPrime - vRefPrime)
|
||||
|
||||
return CIELuv(L, u, v, alpha)
|
||||
}
|
||||
|
||||
fun CIELuv.toXYZ(): CIEXYZ {
|
||||
val Y = if (L > kappa * epsilon)
|
||||
L.plus(16f).div(116f).cube()
|
||||
else
|
||||
L.div(kappa)
|
||||
val uRef = 4f * D65.X / (D65.X + 15f * D65.Y + 3f * D65.Z)
|
||||
val vRef = 9f * D65.Y / (D65.X + 15f * D65.Y + 3f * D65.Z)
|
||||
val a = (1f / 3f) * (52.times(L) / u.plus(13 * L * uRef)).minus(1f)
|
||||
val b = -5f * Y
|
||||
val c = -1f / 3f
|
||||
val d = Y * (39f.times(L) / v.plus(13f * L * vRef)).minus(5f)
|
||||
val X = (d - b) / (a - c)
|
||||
val Z = X * a + b
|
||||
|
||||
return CIEXYZ(X, Y, Z, alpha)
|
||||
}
|
||||
|
||||
fun Color.toLuv() = this.toXYZ().toLuv()
|
||||
fun CIELuv.toRawRGB() = this.toXYZ().toRawRGB()
|
||||
fun CIELuv.toRGB() = this.toXYZ().toRGB()
|
||||
|
||||
private fun Float.cbrt() = FastMath.pow(this, 1f / 3f)
|
||||
private fun Float.cube() = this * this * this
|
||||
}
|
||||
|
||||
data class CIELuv(var L: Float = 0f, var u: Float = 0f, var v: Float = 0f, val alpha: Float = 1f)
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.torvald.point
|
||||
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-01-15.
|
||||
*/
|
||||
@@ -13,4 +15,35 @@ class Point2d(var x: Double, var y: Double) : Cloneable {
|
||||
this.x = x
|
||||
this.y = y
|
||||
}
|
||||
|
||||
fun set(other: Point2d) {
|
||||
this.x = other.x
|
||||
this.y = other.y
|
||||
}
|
||||
|
||||
/**
|
||||
* Rotate transform this point, with pivot (0, 0)
|
||||
* @return new Point2d that is rotated
|
||||
*/
|
||||
infix fun rot(deg_delta: Double) = Point2d(
|
||||
x * Math.cos(deg_delta) - y * Math.sin(deg_delta),
|
||||
x * Math.sin(deg_delta) + y * Math.cos(deg_delta)
|
||||
)
|
||||
|
||||
fun translate(other: Point2d) {
|
||||
x += other.x
|
||||
y += other.y
|
||||
}
|
||||
fun translate(tx: Double, ty: Double) {
|
||||
x += tx
|
||||
y += ty
|
||||
}
|
||||
operator fun plus(other: Point2d) = Point2d(x + other.x, y + other.y)
|
||||
operator fun minus(other: Point2d) = Point2d(x - other.x, y - other.y)
|
||||
operator fun times(scalar: Double) = Point2d(x * scalar, y * scalar)
|
||||
operator fun times(other: Point2d) = Point2d(x * other.x, y * other.y)
|
||||
operator fun div(scalar: Double) = Point2d(x / scalar, y / scalar)
|
||||
operator fun div(other: Point2d) = Point2d(x / other.x, y / other.y)
|
||||
|
||||
fun toVector() = Vector2(x, y)
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import net.torvald.terrarum.gamemap.GameWorld
|
||||
import net.torvald.terrarum.gamemap.WorldSimulator
|
||||
import net.torvald.terrarum.gamemap.WorldTime
|
||||
import net.torvald.terrarum.mapdrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.mapdrawer.LightmapRenderer.constructRGBFromInt
|
||||
import net.torvald.terrarum.mapdrawer.MapCamera
|
||||
import net.torvald.terrarum.mapdrawer.MapDrawer
|
||||
import net.torvald.terrarum.mapgenerator.WorldGenerator
|
||||
@@ -121,8 +122,8 @@ constructor() : BasicGameState() {
|
||||
|
||||
|
||||
// add new player and put it to actorContainer
|
||||
//player = PBSigrid.create()
|
||||
player = PBCynthia.create()
|
||||
player = PBSigrid.create()
|
||||
//player = PBCynthia.create()
|
||||
//player.setNoClip(true);
|
||||
addActor(player)
|
||||
|
||||
@@ -177,7 +178,11 @@ constructor() : BasicGameState() {
|
||||
WeatherMixer.update(gc, delta)
|
||||
TileStats.update()
|
||||
if (!(CommandDict["setgl"] as SetGlobalLightOverride).lightOverride)
|
||||
world.globalLight = globalLightByTime.toInt()
|
||||
world.globalLight = constructRGBFromInt(
|
||||
globalLightByTime.redByte,
|
||||
globalLightByTime.greenByte,
|
||||
globalLightByTime.blueByte
|
||||
)
|
||||
|
||||
|
||||
///////////////////////////
|
||||
@@ -438,7 +443,9 @@ constructor() : BasicGameState() {
|
||||
}
|
||||
// inactivate distant actors
|
||||
else if (actor is Visible && !actor.inUpdateRange()) {
|
||||
actorContainerInactive.add(actor) // naïve add; duplicates are checked when the actor is re-activated
|
||||
if (actor !is Projectile) { // if it's a projectile, just kill it.
|
||||
actorContainerInactive.add(actor) // naïve add; duplicates are checked when the actor is re-activated
|
||||
}
|
||||
actorContainer.removeAt(actorIndex)
|
||||
actorContainerSize -= 1
|
||||
i-- // array removed 1 elem, so we also decrement counter by 1
|
||||
@@ -570,3 +577,5 @@ constructor() : BasicGameState() {
|
||||
return -(low + 1) // key not found
|
||||
}
|
||||
}
|
||||
|
||||
fun Color.toInt() = redByte.shl(16) or greenByte.shl(8) or blueByte
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import net.torvald.CSVFetcher
|
||||
import net.torvald.colourutil.CIELabUtil.toXYZ
|
||||
import net.torvald.colourutil.CIELabUtil.toLab
|
||||
import net.torvald.colourutil.CIELabUtil.toRGB
|
||||
import net.torvald.colourutil.CIELuv
|
||||
import net.torvald.colourutil.CIELuvUtil.toRawRGB
|
||||
import net.torvald.colourutil.CIELuvUtil.toLuv
|
||||
import net.torvald.colourutil.RGB
|
||||
import org.apache.commons.csv.CSVRecord
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
@@ -13,14 +19,22 @@ import org.newdawn.slick.state.StateBasedGame
|
||||
* Created by minjaesong on 16-09-05.
|
||||
*/
|
||||
class StateTestingSandbox : BasicGameState() {
|
||||
val colRGB = Color(0x51621D)
|
||||
val colAfter1 = colRGB.toXYZ().toRGB()
|
||||
//val colAfter2 = colRGB.toXYZ().toLab().toXYZ().toRGB()
|
||||
|
||||
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
||||
println("Color:\n$colRGB")
|
||||
println("Color -> XYZ -> Color:\n$colAfter1")
|
||||
//println("Color -> XYZ -> Lab -> XYZ -> Color:\n$colAfter2")
|
||||
val records = CSVFetcher("./src/net/torvald/terrarum/tileproperties/tileprop_10bcol.csv")
|
||||
records.forEach {
|
||||
val tenOpacity = intVal(it, "opacity")
|
||||
val tenLum = intVal(it, "lumcolor")
|
||||
|
||||
val eightOpacity = tenOpacity.and(0xff) or
|
||||
tenOpacity.ushr(10).and(0xff).shl(8) or
|
||||
tenOpacity.ushr(20).and(0xff).shl(16)
|
||||
val eightLum = tenLum.and(0xff) or
|
||||
tenLum.ushr(10).and(0xff).shl(8) or
|
||||
tenLum.ushr(20).and(0xff).shl(16)
|
||||
|
||||
println("$eightOpacity\t$eightLum")
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
|
||||
@@ -31,4 +45,15 @@ class StateTestingSandbox : BasicGameState() {
|
||||
|
||||
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
|
||||
}
|
||||
|
||||
private fun intVal(rec: CSVRecord, s: String): Int {
|
||||
var ret = -1
|
||||
try {
|
||||
ret = Integer.decode(rec.get(s))!!
|
||||
}
|
||||
catch (e: NullPointerException) {
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
}
|
||||
27
src/net/torvald/terrarum/StateVTTest.kt
Normal file
27
src/net/torvald/terrarum/StateVTTest.kt
Normal file
@@ -0,0 +1,27 @@
|
||||
package net.torvald.terrarum
|
||||
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.state.BasicGameState
|
||||
import org.newdawn.slick.state.StateBasedGame
|
||||
|
||||
/**
|
||||
* ComputerCraft/OpenComputers like-alike, just for fun!
|
||||
*
|
||||
* Created by minjaesong on 16-09-07.
|
||||
*/
|
||||
class StateVTTest : BasicGameState() {
|
||||
override fun init(container: GameContainer?, game: StateBasedGame?) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun update(container: GameContainer?, game: StateBasedGame?, delta: Int) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
override fun getID() = Terrarum.STATE_ID_TEST_TTY
|
||||
|
||||
override fun render(container: GameContainer?, game: StateBasedGame?, g: Graphics?) {
|
||||
throw UnsupportedOperationException("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
@@ -193,6 +193,7 @@ constructor(gamename: String) : StateBasedGame(gamename) {
|
||||
val STATE_ID_CONFIG_CALIBRATE = 0x11
|
||||
|
||||
val STATE_ID_TEST_FONT = 0x100
|
||||
val STATE_ID_TEST_TTY = 0x110
|
||||
val STATE_ID_TEST_SHIT = 0x5617
|
||||
|
||||
var hasController = false
|
||||
|
||||
@@ -38,6 +38,8 @@ object CommandDict {
|
||||
Pair("help", Help()),
|
||||
Pair("version", Version()),
|
||||
Pair("seed", Seed()),
|
||||
Pair("testgetlight", TestGetLight()),
|
||||
Pair("println", EchoConsole()),
|
||||
|
||||
// Test codes
|
||||
Pair("bulletintest", SetBulletin()),
|
||||
|
||||
33
src/net/torvald/terrarum/console/EchoConsole.kt
Normal file
33
src/net/torvald/terrarum/console/EchoConsole.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-09-07.
|
||||
*/
|
||||
class EchoConsole : ConsoleCommand {
|
||||
/**
|
||||
* Args 0: command given
|
||||
* Args 1: first argument
|
||||
*
|
||||
* e.g. in ```setav mass 74```, zeroth args will be ```setav```.
|
||||
*/
|
||||
override fun execute(args: Array<String>) {
|
||||
val argsWoHeader = Array<String>(args.size - 1, {it -> args[it + 1]})
|
||||
argsWoHeader.forEach { execute(it) }
|
||||
}
|
||||
|
||||
fun execute(single_line: String) {
|
||||
val sb = StringBuilder()
|
||||
for (ch in single_line) {
|
||||
if (ch == '\n') {
|
||||
println(sb.toString())
|
||||
sb.delete(0, sb.length - 1)
|
||||
}
|
||||
else
|
||||
sb.append(ch)
|
||||
}
|
||||
println(sb.toString())
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
}
|
||||
}
|
||||
24
src/net/torvald/terrarum/console/TestGetLight.kt
Normal file
24
src/net/torvald/terrarum/console/TestGetLight.kt
Normal file
@@ -0,0 +1,24 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.mapdrawer.LightmapRenderer
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-09-07.
|
||||
*/
|
||||
class TestGetLight : ConsoleCommand {
|
||||
/**
|
||||
* Args 0: command given
|
||||
* Args 1: first argument
|
||||
*
|
||||
* e.g. in ```setav mass 74```, zeroth args will be ```setav```.
|
||||
*/
|
||||
override fun execute(args: Array<String>) {
|
||||
val x = args[1].toInt()
|
||||
val y = args[2].toInt()
|
||||
val l = LightmapRenderer.getLightRawPos(16, 16)
|
||||
EchoConsole().execute(l.toString())
|
||||
}
|
||||
|
||||
override fun printUsage() {
|
||||
}
|
||||
}
|
||||
@@ -79,5 +79,5 @@ object AVKey {
|
||||
|
||||
|
||||
|
||||
const val _PLAYER_QUICKBARSEL = "__quickbarselection"
|
||||
const val __PLAYER_QUICKBARSEL = "__quickbarselection"
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gamemap.GameWorld
|
||||
import net.torvald.terrarum.mapdrawer.MapDrawer
|
||||
@@ -36,6 +37,7 @@ open class ActorWithBody : Actor(), Visible {
|
||||
/**
|
||||
* * Position: top-left point
|
||||
* * Unit: pixel
|
||||
* !! external class should not hitbox.set(); use setHitboxDimension() and setPosition()
|
||||
*/
|
||||
override val hitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
|
||||
@Transient val nextHitbox = Hitbox(0.0, 0.0, 0.0, 0.0)
|
||||
@@ -261,6 +263,13 @@ open class ActorWithBody : Actor(), Visible {
|
||||
baseHitboxH * scale)
|
||||
}
|
||||
|
||||
val centrePosition: Vector2
|
||||
get() = Vector2(hitbox.centeredX, hitbox.centeredY)
|
||||
val centrePosPoint: Point2d
|
||||
get() = Point2d(hitbox.centeredX, hitbox.centeredY)
|
||||
val feetPosition: Vector2
|
||||
get() = Vector2(hitbox.centeredX, hitbox.posY + hitbox.height)
|
||||
|
||||
override fun run() = update(Terrarum.appgc, Terrarum.ingame.UPDATE_DELTA)
|
||||
|
||||
/**
|
||||
@@ -325,8 +334,10 @@ open class ActorWithBody : Actor(), Visible {
|
||||
* If and only if:
|
||||
* This body is NON-STATIC and the other body is STATIC
|
||||
*/
|
||||
displaceByCCD()
|
||||
applyNormalForce()
|
||||
if (!isPlayerNoClip) {
|
||||
displaceByCCD()
|
||||
applyNormalForce()
|
||||
}
|
||||
|
||||
setHorizontalFriction()
|
||||
if (isPlayerNoClip) // or hanging on the rope, etc.
|
||||
@@ -342,6 +353,10 @@ open class ActorWithBody : Actor(), Visible {
|
||||
// cheap solution for sticking into the wall while Left or Right is held
|
||||
walledLeft = isTouchingSide(nextHitbox, COLLIDING_LEFT)
|
||||
walledRight = isTouchingSide(nextHitbox, COLLIDING_RIGHT)
|
||||
if (isPlayerNoClip) {
|
||||
walledLeft = false
|
||||
walledRight = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,7 +443,8 @@ open class ActorWithBody : Actor(), Visible {
|
||||
else if (moveDelta.y < 0.0) { // or was moving upward?
|
||||
grounded = false
|
||||
if (isTouchingSide(nextHitbox, COLLIDING_TOP)) { // actor hit something on its top
|
||||
hitAndForciblyReflectY()
|
||||
//hitAndForciblyReflectY()
|
||||
hitAndReflectY()
|
||||
}
|
||||
else { // the actor is not grounded at all
|
||||
}
|
||||
@@ -491,6 +507,7 @@ open class ActorWithBody : Actor(), Visible {
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated("it's no use!")
|
||||
private fun hitAndForciblyReflectY() {
|
||||
if (veloY.abs() * CEILING_HIT_ELASTICITY > A_PIXEL)
|
||||
veloY = -veloY * CEILING_HIT_ELASTICITY
|
||||
|
||||
@@ -12,7 +12,7 @@ object PBCynthia {
|
||||
val p: Player = Player()
|
||||
CreatureRawInjector.inject(p.actorValue, "CreatureHuman.json")
|
||||
|
||||
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
|
||||
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
|
||||
p.actorValue["__selectedtile"] = 16
|
||||
|
||||
|
||||
|
||||
@@ -58,6 +58,7 @@ object PBSigrid {
|
||||
|
||||
p.actorValue[AVKey.BASEDEFENCE] = 141
|
||||
|
||||
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
|
||||
p.actorValue["__selectedtile"] = 16 // test code; replace with <tile_item>.primaryUse(gc, delta)
|
||||
p.actorValue["__aimhelper"] = true
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ object PlayerBuilder {
|
||||
// attach sprite
|
||||
|
||||
// do etc.
|
||||
p.actorValue[AVKey._PLAYER_QUICKBARSEL] = 0
|
||||
p.actorValue[AVKey.__PLAYER_QUICKBARSEL] = 0
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
9
src/net/torvald/terrarum/gameactors/Projectile.kt
Normal file
9
src/net/torvald/terrarum/gameactors/Projectile.kt
Normal file
@@ -0,0 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
/**
|
||||
* Projectile marker. Used to kill them when they're far away from the player, instead of making them sleep.
|
||||
*
|
||||
* Created by minjaesong on 16-09-05.
|
||||
*/
|
||||
interface Projectile {
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import org.dyn4j.geometry.Vector2
|
||||
class ProjectileHoming(
|
||||
type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2, // arriving coord
|
||||
override var luminosity: Int = 0) : ProjectileSimple(type, fromPoint, toPoint, luminosity) {
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : ProjectileSimple(type, fromPoint, toPoint) {
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.colourutil.CIELabUtil.brighterLab
|
||||
import net.torvald.colourutil.CIELabUtil.darkerLab
|
||||
import net.torvald.point.Point2d
|
||||
import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.GameContainer
|
||||
@@ -14,16 +16,21 @@ import java.util.*
|
||||
* Created by minjaesong on 16-08-29.
|
||||
*/
|
||||
open class ProjectileSimple(
|
||||
type: Int,
|
||||
private val type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2, // arriving coord
|
||||
override var luminosity: Int = 0) : ActorWithBody(), Luminous {
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : ActorWithBody(), Luminous, Projectile {
|
||||
|
||||
val damage: Int
|
||||
val displayColour: Color
|
||||
/** scalar part of velocity */
|
||||
val speed: Int
|
||||
|
||||
|
||||
override var luminosity: Int
|
||||
get() = bulletDatabase[type][OFFSET_LUMINOSITY] as Int
|
||||
set(value) {
|
||||
}
|
||||
/**
|
||||
* Arguments:
|
||||
*
|
||||
@@ -32,8 +39,14 @@ open class ProjectileSimple(
|
||||
*/
|
||||
override val lightBoxList = ArrayList<Hitbox>()
|
||||
|
||||
val lifetimeMax = 2500
|
||||
var lifetimeCounter = 0
|
||||
|
||||
val posPre: Point2d
|
||||
|
||||
init {
|
||||
hitbox.set(fromPoint.x, fromPoint.y, 2.0, 2.0) // 2.0: size of the hitbox in pixels
|
||||
setPosition(fromPoint.x, fromPoint.y)
|
||||
posPre = Point2d(fromPoint.x, fromPoint.y)
|
||||
// lightbox sized 8x8 centered to the bullet
|
||||
lightBoxList.add(Hitbox(-4.0, -4.0, 8.0, 8.0))
|
||||
this.velocity.set(velocity)
|
||||
@@ -43,16 +56,10 @@ open class ProjectileSimple(
|
||||
isNoSubjectToGrav = bulletDatabase[type][OFFSET_NOGRAVITY] as Boolean
|
||||
speed = bulletDatabase[type][OFFSET_SPEED] as Int
|
||||
|
||||
if (displayColour == Color(254, 0, 0, 0)) {
|
||||
sprite = bulletDatabase[type][OFFSET_SPRITE] as SpriteAnimation
|
||||
}
|
||||
setHitboxDimension(2, 2, 0, 0) // should be following sprite's properties if there IS one
|
||||
|
||||
|
||||
|
||||
val initVelo = Vector2(speed.toDouble(), 0.0)
|
||||
initVelo.setDirection((fromPoint to toPoint).direction)
|
||||
|
||||
velocity.set(initVelo)
|
||||
velocity.set((fromPoint to toPoint).setMagnitude(speed.toDouble()))
|
||||
|
||||
|
||||
|
||||
@@ -61,34 +68,42 @@ open class ProjectileSimple(
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
// hit something and despawn
|
||||
if (ccdCollided || grounded) flagDespawn()
|
||||
lifetimeCounter += delta
|
||||
if ((ccdCollided || grounded) || lifetimeCounter >= lifetimeMax) flagDespawn()
|
||||
|
||||
posPre.set(centrePosPoint)
|
||||
|
||||
super.update(gc, delta)
|
||||
}
|
||||
|
||||
override fun drawBody(gc: GameContainer, g: Graphics) {
|
||||
val colourTail = displayColour.darker(0f) // clone a colour
|
||||
colourTail.a = 0.16f
|
||||
|
||||
// draw trail of solid colour (Terraria style maybe?)
|
||||
g.lineWidth = 3f
|
||||
g.lineWidth = 2f * Terrarum.ingame.screenZoom
|
||||
g.drawGradientLine(
|
||||
nextHitbox.centeredX.toFloat(),
|
||||
nextHitbox.centeredY.toFloat(),
|
||||
hitbox.centeredX.toFloat() * Terrarum.ingame.screenZoom,
|
||||
hitbox.centeredY.toFloat() * Terrarum.ingame.screenZoom,
|
||||
displayColour,
|
||||
hitbox.centeredX.toFloat(),
|
||||
hitbox.centeredY.toFloat(),
|
||||
displayColour.brighterLab(0.8f)
|
||||
posPre.x.toFloat() * Terrarum.ingame.screenZoom,
|
||||
posPre.y.toFloat() * Terrarum.ingame.screenZoom,
|
||||
colourTail
|
||||
)
|
||||
}
|
||||
|
||||
override fun drawGlow(gc: GameContainer, g: Graphics) = drawBody(gc, g)
|
||||
|
||||
companion object {
|
||||
val OFFSET_DAMAGE = 0
|
||||
val OFFSET_COL = 1 // set it to Color(254, 0, 0, 0) to use sprite
|
||||
val OFFSET_COL = 1 // Color or SpriteAnimation
|
||||
val OFFSET_NOGRAVITY = 2
|
||||
val OFFSET_SPEED = 3
|
||||
val OFFSET_SPRITE = 4
|
||||
val OFFSET_LUMINOSITY = 4
|
||||
val bulletDatabase = arrayOf(
|
||||
// damage, display colour, no gravity, speed
|
||||
arrayOf(7, Color(0xFF5429), true, 50),
|
||||
arrayOf(8, Color(0xFF5429), true, 50)
|
||||
arrayOf(7, Color(0xFF5429), true, 40, 32),
|
||||
arrayOf(8, Color(0xFF5429), true, 20, 0)
|
||||
// ...
|
||||
)
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import net.torvald.terrarum.gameactors.Player
|
||||
import net.torvald.terrarum.mapdrawer.MapCamera
|
||||
import net.torvald.terrarum.mapdrawer.MapDrawer
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ProjectileSimple
|
||||
import net.torvald.terrarum.tileproperties.TileNameCode
|
||||
import net.torvald.terrarum.tileproperties.TilePropCodex
|
||||
import net.torvald.terrarum.ui.UIHandler
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import org.newdawn.slick.Input
|
||||
|
||||
/**
|
||||
@@ -15,10 +17,16 @@ import org.newdawn.slick.Input
|
||||
*/
|
||||
object GameController {
|
||||
|
||||
fun processInput(input: Input) {
|
||||
val mouseTileX = ((MapCamera.cameraX + input.mouseX / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
||||
val mouseTileY = ((MapCamera.cameraY + input.mouseY / Terrarum.ingame.screenZoom) / MapDrawer.TILE_SIZE).toInt()
|
||||
val mouseX: Float
|
||||
get() = (MapCamera.cameraX + Terrarum.appgc.input.mouseX / Terrarum.ingame.screenZoom)
|
||||
val mouseY: Float
|
||||
get() = (MapCamera.cameraY + Terrarum.appgc.input.mouseY / Terrarum.ingame.screenZoom)
|
||||
val mouseTileX: Int
|
||||
get() = (mouseX / MapDrawer.TILE_SIZE).toInt()
|
||||
val mouseTileY: Int
|
||||
get() = (mouseY / MapDrawer.TILE_SIZE).toInt()
|
||||
|
||||
fun processInput(input: Input) {
|
||||
|
||||
KeyToggler.update(input)
|
||||
|
||||
@@ -48,6 +56,7 @@ object GameController {
|
||||
catch (e: ArrayIndexOutOfBoundsException) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
else if (input.isMouseButtonDown(Input.MOUSE_RIGHT_BUTTON)) {
|
||||
// test tile place
|
||||
@@ -100,7 +109,13 @@ object GameController {
|
||||
}
|
||||
|
||||
fun mousePressed(button: Int, x: Int, y: Int) {
|
||||
|
||||
if (button == 0) {
|
||||
Terrarum.ingame.addActor(ProjectileSimple(
|
||||
0,
|
||||
Terrarum.ingame.player.centrePosition,
|
||||
Vector2(mouseX.toDouble(), mouseY.toDouble())
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fun mouseReleased(button: Int, x: Int, y: Int) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.newdawn.slick.Color
|
||||
* Created by minjaesong on 16-07-08.
|
||||
*/
|
||||
|
||||
class Light10B {
|
||||
/*class Light10B {
|
||||
|
||||
private var data = 0
|
||||
|
||||
@@ -192,4 +192,4 @@ class Light10B {
|
||||
(this.rawG() + other.rawG()).clampChannel() ,
|
||||
(this.rawB() + other.rawB()).clampChannel()
|
||||
)
|
||||
}
|
||||
}*/
|
||||
@@ -4,12 +4,13 @@ import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.tileproperties.TilePropCodex
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.colourutil.RGB
|
||||
import net.torvald.colourutil.CIELuvUtil.additiveLuv
|
||||
import net.torvald.terrarum.gameactors.Visible
|
||||
import net.torvald.terrarum.tileproperties.TileNameCode
|
||||
import net.torvald.terrarum.tileproperties.TilePropUtil
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.Graphics
|
||||
import org.newdawn.slick.Image
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
@@ -41,7 +42,7 @@ object LightmapRenderer {
|
||||
|
||||
// color model related constants
|
||||
const val MUL = 1024 // modify this to 1024 to implement 30-bit RGB
|
||||
const val CHANNEL_MAX_DECIMAL = 4f
|
||||
const val CHANNEL_MAX_DECIMAL = 1f
|
||||
const val MUL_2 = MUL * MUL
|
||||
const val CHANNEL_MAX = MUL - 1
|
||||
const val CHANNEL_MAX_FLOAT = CHANNEL_MAX.toFloat()
|
||||
@@ -52,6 +53,8 @@ object LightmapRenderer {
|
||||
internal var for_x_end: Int = 0
|
||||
internal var for_y_end: Int = 0
|
||||
|
||||
fun getLightRawPos(x: Int, y: Int) = lightmap[y][x]
|
||||
|
||||
fun getLight(x: Int, y: Int): Int? {
|
||||
/*if (x !in 0..Terrarum.game.map.width - 1 || y !in 0..Terrarum.game.map.height - 1)
|
||||
// if out of range then
|
||||
@@ -240,11 +243,11 @@ object LightmapRenderer {
|
||||
lightLevelThis = sunLight
|
||||
}
|
||||
// luminous tile on top of air
|
||||
else if (thisWall == AIR && thisTileLuminosity.toInt() > 0) {
|
||||
else if (thisWall == AIR && thisTileLuminosity > 0) {
|
||||
lightLevelThis = sunLight maxBlend thisTileLuminosity // maximise to not exceed 1.0 with normal (<= 1.0) light
|
||||
}
|
||||
// opaque wall and luminous tile
|
||||
else if (thisWall != AIR && thisTileLuminosity.toInt() > 0) {
|
||||
else if (thisWall != AIR && thisTileLuminosity > 0) {
|
||||
lightLevelThis = thisTileLuminosity
|
||||
}
|
||||
// END MIX TILE
|
||||
@@ -278,7 +281,7 @@ object LightmapRenderer {
|
||||
}
|
||||
else if (xoff != 0 && yoff != 0) {
|
||||
// 'a' tiles
|
||||
nearby = darkenUniformInt(getLight(x + xoff, y + yoff) ?: 0, 12) //2 for 40step
|
||||
nearby = darkenUniformInt(getLight(x + xoff, y + yoff) ?: 0, 12)
|
||||
// mix some to have more 'spreading'
|
||||
// so that light spreads in a shape of an octagon instead of a diamond
|
||||
}
|
||||
@@ -290,8 +293,7 @@ object LightmapRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
ambient = darkenColoured(ambient,
|
||||
thisTileOpacity) // get real ambient by appling opacity value
|
||||
ambient = darkenColoured(ambient, thisTileOpacity) // get real ambient by appling opacity value
|
||||
|
||||
// mix and return lightlevel and ambient
|
||||
return lightLevelThis maxBlend ambient
|
||||
@@ -371,7 +373,7 @@ object LightmapRenderer {
|
||||
|
||||
for (iy in 0..1) {
|
||||
for (ix in 0..1) {
|
||||
g.color = Color(colourMapItoL[iy * 2 + ix].rgb30ClampTo24())
|
||||
g.color = colourMapItoL[iy * 2 + ix].normaliseToColour()
|
||||
|
||||
g.fillRect(
|
||||
(x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round()
|
||||
@@ -398,7 +400,7 @@ object LightmapRenderer {
|
||||
if (x + sameLevelCounter >= this_x_end) break
|
||||
}
|
||||
|
||||
g.color = Color((getLight(x, y) ?: 0).rgb30ClampTo24())
|
||||
g.color = (getLight(x, y) ?: 0).normaliseToColour()
|
||||
g.fillRect(
|
||||
(x.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
|
||||
(y.toFloat() * TSIZE.toFloat() * Terrarum.ingame.screenZoom).round().toFloat(),
|
||||
@@ -434,9 +436,9 @@ object LightmapRenderer {
|
||||
if (darken.toInt() < 0 || darken.toInt() >= COLOUR_RANGE_SIZE)
|
||||
throw IllegalArgumentException("darken: out of range ($darken)")
|
||||
|
||||
val r = data.r() * (1f - darken.r() * 6) // 6: Arbitrary value
|
||||
val g = data.g() * (1f - darken.g() * 6) // TODO gamma correction?
|
||||
val b = data.b() * (1f - darken.b() * 6)
|
||||
val r = data.r() * (1f - darken.r() * 4f)
|
||||
val g = data.g() * (1f - darken.g() * 4f)
|
||||
val b = data.b() * (1f - darken.b() * 4f)
|
||||
|
||||
return constructRGBFromFloat(r.clampZero(), g.clampZero(), b.clampZero())
|
||||
}
|
||||
@@ -452,9 +454,9 @@ object LightmapRenderer {
|
||||
if (brighten.toInt() < 0 || brighten.toInt() >= COLOUR_RANGE_SIZE)
|
||||
throw IllegalArgumentException("brighten: out of range ($brighten)")
|
||||
|
||||
val r = data.r() * (1f + brighten.r() * 6) // 6: Arbitrary value
|
||||
val g = data.g() * (1f + brighten.g() * 6) // TODO gamma correction?
|
||||
val b = data.b() * (1f + brighten.b() * 6)
|
||||
val r = data.r() * (1f + brighten.r() * 4f)
|
||||
val g = data.g() * (1f + brighten.g() * 4f)
|
||||
val b = data.b() * (1f + brighten.b() * 4f)
|
||||
|
||||
return constructRGBFromFloat(r.clampChannel(), g.clampChannel(), b.clampChannel())
|
||||
}
|
||||
@@ -498,29 +500,44 @@ object LightmapRenderer {
|
||||
* @return
|
||||
*/
|
||||
private infix fun Int.maxBlend(other: Int): Int {
|
||||
val r1 = this.rawR()
|
||||
val r2 = other.rawR()
|
||||
val newR = if (r1 > r2) r1 else r2
|
||||
val g1 = this.rawG()
|
||||
val g2 = other.rawG()
|
||||
val newG = if (g1 > g2) g1 else g2
|
||||
val b1 = this.rawB()
|
||||
val b2 = other.rawB()
|
||||
val newB = if (b1 > b2) b1 else b2
|
||||
val r1 = this.rawR(); val r2 = other.rawR(); val newR = if (r1 > r2) r1 else r2
|
||||
val g1 = this.rawG(); val g2 = other.rawG(); val newG = if (g1 > g2) g1 else g2
|
||||
val b1 = this.rawB(); val b2 = other.rawB(); val newB = if (b1 > b2) b1 else b2
|
||||
|
||||
return constructRGBFromInt(newR, newG, newB)
|
||||
}
|
||||
|
||||
|
||||
// TODO LUT of 1024 entries (int resulting light, int rectified light)
|
||||
val compLut = floatArrayOf(0f, 0.61328125f, 0.6875f, 0.68359375f, 0.66015625f, 0.62109375f, 0.56640625f, 0.515625f, 0.46484375f, 0.40625f, 0.3515625f, 0.29296875f, 0.234375f, 0.17578125f, 0.1171875f, 0.0546875f, 0f)
|
||||
fun getComp(lum: Float) = FastMath.interpolateLinear(
|
||||
lum.mod(1f / compLut.size),
|
||||
compLut[lum.times(compLut.size).toInt() / compLut.size],
|
||||
compLut[lum.times(compLut.size).toInt() / compLut.size + 1])
|
||||
|
||||
/**
|
||||
* Deprecated: Fuck it, this vittupää just doesn't want to work
|
||||
*/
|
||||
private infix fun Int.screenBlend(other: Int): Int {
|
||||
val r1 = this.r()
|
||||
val r2 = other.r()
|
||||
val newR = 1 - (1 - r1) * (1 - r2)
|
||||
val g1 = this.g()
|
||||
val g2 = other.g()
|
||||
val newG = 1 - (1 - g1) * (1 - g2)
|
||||
val b1 = this.b()
|
||||
val b2 = other.b()
|
||||
val newB = 1 - (1 - b1) * (1 - b2)
|
||||
/*val r1 = this.r(); val r2 = other.r(); val newR = 1 - (1 - r1) * (1 - r2)
|
||||
val g1 = this.g(); val g2 = other.g(); val newG = 1 - (1 - g1) * (1 - g2)
|
||||
val b1 = this.b(); val b2 = other.b(); val newB = 1 - (1 - b1) * (1 - b2)*/
|
||||
|
||||
val r1 = this.r(); val r2 = other.r()
|
||||
val g1 = this.g(); val g2 = other.g()
|
||||
val b1 = this.b(); val b2 = other.b()
|
||||
|
||||
var screenR = 1f - (1f - r1).clampZero() * (1f - r2).clampZero()
|
||||
var screenG = 1f - (1f - g1).clampZero() * (1f - g2).clampZero()
|
||||
var screenB = 1f - (1f - b1).clampZero() * (1f - b2).clampZero()
|
||||
|
||||
// hax.
|
||||
val addR = if (r1 > r2) r1 else r2
|
||||
val addG = if (g1 > g2) g1 else g2
|
||||
val addB = if (b1 > b2) b1 else b2
|
||||
|
||||
val newR = Math.min(screenR, addR)
|
||||
val newG = Math.min(screenG, addG)
|
||||
val newB = Math.min(screenB, addB)
|
||||
|
||||
return constructRGBFromFloat(newR, newG, newB)
|
||||
}
|
||||
@@ -541,6 +558,7 @@ object LightmapRenderer {
|
||||
fun Int.rawG() = this % MUL_2 / MUL
|
||||
fun Int.rawB() = this % MUL
|
||||
|
||||
/** 0.0 - 1.0 for 0-1023 (0.0 - 0.25 for 0-255) */
|
||||
fun Int.r(): Float = this.rawR() / CHANNEL_MAX_FLOAT
|
||||
fun Int.g(): Float = this.rawG() / CHANNEL_MAX_FLOAT
|
||||
fun Int.b(): Float = this.rawB() / CHANNEL_MAX_FLOAT
|
||||
@@ -570,17 +588,17 @@ object LightmapRenderer {
|
||||
if (r !in 0..CHANNEL_MAX) throw IllegalArgumentException("Red: out of range ($r)")
|
||||
if (g !in 0..CHANNEL_MAX) throw IllegalArgumentException("Green: out of range ($g)")
|
||||
if (b !in 0..CHANNEL_MAX) throw IllegalArgumentException("Blue: out of range ($b)")
|
||||
return (r * MUL_2 + g * MUL + b)
|
||||
return r * MUL_2 + g * MUL + b
|
||||
}
|
||||
|
||||
fun constructRGBFromFloat(r: Float, g: Float, b: Float): Int {
|
||||
if (r < 0 || r > 1.0f) throw IllegalArgumentException("Red: out of range ($r)")
|
||||
if (g < 0 || g > 1.0f) throw IllegalArgumentException("Green: out of range ($g)")
|
||||
if (b < 0 || b > 1.0f) throw IllegalArgumentException("Blue: out of range ($b)")
|
||||
if (r < 0 || r > CHANNEL_MAX_DECIMAL) throw IllegalArgumentException("Red: out of range ($r)")
|
||||
if (g < 0 || g > CHANNEL_MAX_DECIMAL) throw IllegalArgumentException("Green: out of range ($g)")
|
||||
if (b < 0 || b > CHANNEL_MAX_DECIMAL) throw IllegalArgumentException("Blue: out of range ($b)")
|
||||
|
||||
val intR = (r * CHANNEL_MAX).floor()
|
||||
val intG = (g * CHANNEL_MAX).floor()
|
||||
val intB = (b * CHANNEL_MAX).floor()
|
||||
val intR = (r * CHANNEL_MAX).round()
|
||||
val intG = (g * CHANNEL_MAX).round()
|
||||
val intB = (b * CHANNEL_MAX).round()
|
||||
|
||||
return constructRGBFromInt(intR, intG, intB)
|
||||
}
|
||||
@@ -622,14 +640,6 @@ object LightmapRenderer {
|
||||
|
||||
private fun Int.clamp256() = if (this > 255) 255 else this
|
||||
|
||||
fun Int.rgb30ClampTo24(): Int {
|
||||
val r = this.rawR().clamp256()
|
||||
val g = this.rawG().clamp256()
|
||||
val b = this.rawB().clamp256()
|
||||
|
||||
return r.shl(16) or g.shl(8) or b
|
||||
}
|
||||
|
||||
infix fun Float.powerOf(f: Float) = FastMath.pow(this, f)
|
||||
private fun Float.sqr() = this * this
|
||||
private fun Float.sqrt() = FastMath.sqrt(this)
|
||||
@@ -641,6 +651,11 @@ object LightmapRenderer {
|
||||
fun Float.ceil() = FastMath.ceil(this)
|
||||
fun Int.even(): Boolean = this and 1 == 0
|
||||
fun Int.odd(): Boolean = this and 1 == 1
|
||||
fun Int.normaliseToColour(): Color = Color(
|
||||
Math.min(this.rawR(), 256),
|
||||
Math.min(this.rawG(), 256),
|
||||
Math.min(this.rawB(), 256)
|
||||
)
|
||||
|
||||
data class Lantern(val posX: Int, val posY: Int, val luminosity: Int)
|
||||
|
||||
|
||||
@@ -33,9 +33,8 @@ object TilePropCodex {
|
||||
|
||||
println("[TilePropCodex] Building tile properties table")
|
||||
|
||||
records.forEach { record -> setProp(
|
||||
tileProps[idDamageToIndex(intVal(record, "id"), intVal(record, "dmg"))]
|
||||
, record)
|
||||
records.forEach { setProp(
|
||||
tileProps[idDamageToIndex(intVal(it, "id"), intVal(it, "dmg"))], it)
|
||||
}
|
||||
}
|
||||
catch (e: IOException) {
|
||||
|
||||
@@ -5,7 +5,9 @@ import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gamemap.WorldTime
|
||||
import net.torvald.terrarum.mapdrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.toInt
|
||||
import net.torvald.terrarum.weather.WeatherMixer
|
||||
import org.newdawn.slick.Color
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 16-06-16.
|
||||
|
||||
@@ -127,7 +127,7 @@
|
||||
## Notes ##
|
||||
|
||||
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
||||
# Opacity/Lumcolor: 30-bit RGB. Light diffusers have a value of ZERO.
|
||||
# Opacity/Lumcolor: 30-bit RGB. Only the light diffusers have a opacity value of ZERO.
|
||||
# Solid: whether the tile has full collision
|
||||
# movr: Movement resistance, (walkspeedmax) / (1 + (n/16)), 16 halves movement speed
|
||||
# dsty: density. As we are putting water an 1000, it is identical to specific gravity. [g/l]
|
||||
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 18.
|
156
src/net/torvald/terrarum/tileproperties/tileprop_8bcol.csv
Normal file
156
src/net/torvald/terrarum/tileproperties/tileprop_8bcol.csv
Normal file
@@ -0,0 +1,156 @@
|
||||
"id";"dmg";"name" ; "opacity";"strength";"dsty";"fluid";"solid";"wall";"lumcolor";"drop";"ddmg";"fall";"dlfn";"friction"
|
||||
"0"; "0";"TILE_AIR" ; "526344"; "0"; "1"; "0"; "0"; "0"; "0"; "0"; "0"; "0"; "0";"4"
|
||||
"1"; "0";"TILE_STONE" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "0"; "0"; "0";"16"
|
||||
"1"; "1";"TILE_STONE_QUARRIED" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "1"; "0"; "0";"16"
|
||||
"1"; "2";"TILE_STONE_TILE_WHITE" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "2"; "0"; "0";"16"
|
||||
"1"; "3";"TILE_STONE_BRICKS" ; "2105376"; "25";"2400"; "0"; "1"; "1"; "0"; "1"; "3"; "0"; "0";"16"
|
||||
"2"; "0";"TILE_DIRT" ; "2105376"; "6";"1400"; "0"; "1"; "1"; "0"; "2"; "0"; "0"; "0";"16"
|
||||
"2"; "1";"TILE_GRASS" ; "2105376"; "6";"1400"; "0"; "1"; "1"; "0"; "2"; "1"; "0"; "0";"16"
|
||||
"3"; "0";"TILE_PLANK_NORMAL" ; "2105376"; "12"; "740"; "0"; "1"; "1"; "0"; "3"; "0"; "0"; "0";"16"
|
||||
"3"; "1";"TILE_PLANK_EBONY" ; "2105376"; "12";"1200"; "0"; "1"; "1"; "0"; "3"; "1"; "0"; "0";"16"
|
||||
"3"; "2";"TILE_PLANK_BIRCH" ; "2105376"; "12"; "670"; "0"; "1"; "1"; "0"; "3"; "2"; "0"; "0";"16"
|
||||
"3"; "3";"TILE_PLANK_BLOODROSE" ; "2105376"; "12"; "900"; "0"; "1"; "1"; "0"; "3"; "3"; "0"; "0";"16"
|
||||
"4"; "0";"TILE_TRUNK_NORMAL" ; "2105376"; "12"; "740"; "0"; "1"; "0"; "0"; "3"; "0"; "0"; "0";"16"
|
||||
"4"; "1";"TILE_TRUNK_EBONY" ; "2105376"; "12";"1200"; "0"; "1"; "0"; "0"; "3"; "1"; "0"; "0";"16"
|
||||
"4"; "2";"TILE_TRUNK_BIRCH" ; "2105376"; "12"; "670"; "0"; "1"; "0"; "0"; "3"; "2"; "0"; "0";"16"
|
||||
"4"; "3";"TILE_TRUNK_BLOODROSE" ; "2105376"; "12"; "900"; "0"; "1"; "0"; "0"; "3"; "3"; "0"; "0";"16"
|
||||
"5"; "0";"TILE_SAND" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "0"; "1"; "0";"16"
|
||||
"5"; "1";"TILE_SAND_WHITE" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "1"; "1"; "0";"16"
|
||||
"5"; "2";"TILE_SAND_RED" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "2"; "1"; "0";"16"
|
||||
"5"; "3";"TILE_SAND_DESERT" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "3"; "1"; "0";"16"
|
||||
"5"; "4";"TILE_SAND_BLACK" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "4"; "1"; "0";"16"
|
||||
"5"; "5";"TILE_SAND_GREEN" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "5"; "5"; "1"; "0";"16"
|
||||
"6"; "0";"TILE_GRAVEL" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "6"; "0"; "1"; "0";"16"
|
||||
"6"; "1";"TILE_GRAVEL_GREY" ; "2105376"; "6";"2400"; "0"; "1"; "0"; "0"; "6"; "1"; "1"; "0";"16"
|
||||
"7"; "0";"TILE_ORE_MALACHITE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "0"; "0"; "0";"16"
|
||||
"7"; "1";"TILE_ORE_HEMATITE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "1"; "0"; "0";"16"
|
||||
"7"; "2";"TILE_ORE_NATURAL_GOLD" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "2"; "0"; "0";"16"
|
||||
"7"; "3";"TILE_ORE_NATURAL_SILVER" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "3"; "0"; "0";"16"
|
||||
"7"; "4";"TILE_ORE_RUTILE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "4"; "0"; "0";"16"
|
||||
"7"; "5";"TILE_ORE_AURICHALCUMITE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "7"; "5"; "0"; "0";"16"
|
||||
"8"; "0";"TILE_GEM_RUBY" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "0"; "0"; "0";"16"
|
||||
"8"; "1";"TILE_GEM_EMERALD" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "1"; "0"; "0";"16"
|
||||
"8"; "2";"TILE_GEM_SAPPHIRE" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "2"; "0"; "0";"16"
|
||||
"8"; "3";"TILE_GEM_TOPAZ" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "3"; "0"; "0";"16"
|
||||
"8"; "4";"TILE_GEM_DIAMOND" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "4"; "0"; "0";"16"
|
||||
"8"; "5";"TILE_GEM_AMETHYST" ; "2105376"; "25";"2400"; "0"; "1"; "0"; "0"; "8"; "5"; "0"; "0";"16"
|
||||
"9"; "0";"TILE_SNOW" ; "2105376"; "6"; "500"; "0"; "1"; "1"; "0"; "9"; "0"; "0"; "0";"16"
|
||||
"9"; "1";"TILE_ICE_FRAGILE" ; "855309"; "1"; "930"; "0"; "1"; "0"; "0"; "9"; "1"; "0"; "0";"16"
|
||||
"9"; "2";"TILE_ICE_NATURAL" ; "1710618"; "25"; "930"; "0"; "1"; "1"; "0"; "9"; "2"; "0"; "0"; "8"
|
||||
"9"; "3";"TILE_ICE_CLEAR_MAGICAL" ; "2105376"; "25";"3720"; "0"; "1"; "1"; "1253434"; "9"; "3"; "0"; "0"; "8"
|
||||
"9"; "4";"TILE_GLASS_CRUDE" ; "196867"; "1";"2500"; "0"; "1"; "1"; "0"; "9"; "4"; "0"; "0";"16"
|
||||
"9"; "5";"TILE_GLASS_CLEAN" ; "65793"; "1";"2203"; "0"; "1"; "1"; "0"; "9"; "5"; "0"; "0";"16"
|
||||
"10"; "0";"TILE_PLATFORM_STONE" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "0"; "0"; "0";"16"
|
||||
"10"; "1";"TILE_PLATFORM_WOODEN" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "1"; "0"; "0";"16"
|
||||
"10"; "2";"TILE_PLATFORM_EBONY" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "2"; "0"; "0";"16"
|
||||
"10"; "3";"TILE_PLATFORM_BIRCH" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "3"; "0"; "0";"16"
|
||||
"10"; "4";"TILE_PLATFORM_BLOODROSE" ; "526344"; "1"; "N/A"; "0"; "0"; "0"; "0"; "10"; "4"; "0"; "0";"16"
|
||||
"11"; "0";"TILE_TORCH" ; "526344"; "0"; "N/A"; "0"; "0"; "0";"16674864"; "11"; "0"; "0"; "1";"16"
|
||||
"11"; "1";"TILE_TORCH_FROST" ; "526344"; "0"; "N/A"; "0"; "0"; "0"; "5143807"; "11"; "1"; "0"; "1";"16"
|
||||
"12"; "0";"TILE_TORCH" ; "526344"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "0"; "0"; "0";"16"
|
||||
"12"; "1";"TILE_TORCH_FROST" ; "526344"; "0"; "N/A"; "0"; "0"; "0"; "0"; "11"; "1"; "0"; "0";"16"
|
||||
"13"; "0";"TILE_ILLUMINATOR_WHITE" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"15003370"; "13"; "0"; "0"; "0";"16"
|
||||
"13"; "1";"TILE_ILLUMINATOR_YELLOW" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"16766720"; "13"; "1"; "0"; "0";"16"
|
||||
"13"; "2";"TILE_ILLUMINATOR_ORANGE" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"16751616"; "13"; "2"; "0"; "0";"16"
|
||||
"13"; "3";"TILE_ILLUMINATOR_RED" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"15400960"; "13"; "3"; "0"; "0";"16"
|
||||
"13"; "4";"TILE_ILLUMINATOR_FUCHSIA" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"15401143"; "13"; "4"; "0"; "0";"16"
|
||||
"13"; "5";"TILE_ILLUMINATOR_PURPLE" ; "526344"; "0"; "N/A"; "0"; "1"; "1";"11993323"; "13"; "5"; "0"; "0";"16"
|
||||
"13"; "6";"TILE_ILLUMINATOR_BLUE" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "13311"; "13"; "6"; "0"; "0";"16"
|
||||
"13"; "7";"TILE_ILLUMINATOR_CYAN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "55039"; "13"; "7"; "0"; "0";"16"
|
||||
"13"; "8";"TILE_ILLUMINATOR_GREEN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "3604224"; "13"; "8"; "0"; "0";"16"
|
||||
"13"; "9";"TILE_ILLUMINATOR_GREEN_DARK"; "526344"; "0"; "N/A"; "0"; "1"; "1"; "2123776"; "13"; "9"; "0"; "0";"16"
|
||||
"13"; "10";"TILE_ILLUMINATOR_BROWN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "5578752"; "13"; "10"; "0"; "0";"16"
|
||||
"13"; "11";"TILE_ILLUMINATOR_TAN" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "9857076"; "13"; "11"; "0"; "0";"16"
|
||||
"13"; "12";"TILE_ILLUMINATOR_GREY_LIGHT"; "526344"; "0"; "N/A"; "0"; "1"; "1";"12434877"; "13"; "12"; "0"; "0";"16"
|
||||
"13"; "13";"TILE_ILLUMINATOR_GREY_MED" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "7697781"; "13"; "13"; "0"; "0";"16"
|
||||
"13"; "14";"TILE_ILLUMINATOR_GREY_DARK" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "4276545"; "13"; "14"; "0"; "0";"16"
|
||||
"13"; "15";"TILE_ILLUMINATOR_BLACK" ; "526344"; "0"; "N/A"; "0"; "1"; "1"; "7274751"; "13"; "15"; "0"; "0";"16"
|
||||
"14"; "0";"TILE_ILLUMINATOR_WHITE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "0"; "0"; "0";"16"
|
||||
"14"; "1";"TILE_ILLUMINATOR_YELLOW" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "1"; "0"; "0";"16"
|
||||
"14"; "2";"TILE_ILLUMINATOR_ORANGE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "2"; "0"; "0";"16"
|
||||
"14"; "3";"TILE_ILLUMINATOR_RED" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "3"; "0"; "0";"16"
|
||||
"14"; "4";"TILE_ILLUMINATOR_FUCHSIA" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "4"; "0"; "0";"16"
|
||||
"14"; "5";"TILE_ILLUMINATOR_PURPLE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "5"; "0"; "0";"16"
|
||||
"14"; "6";"TILE_ILLUMINATOR_BLUE" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "6"; "0"; "0";"16"
|
||||
"14"; "7";"TILE_ILLUMINATOR_CYAN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "7"; "0"; "0";"16"
|
||||
"14"; "8";"TILE_ILLUMINATOR_GREEN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "8"; "0"; "0";"16"
|
||||
"14"; "9";"TILE_ILLUMINATOR_GREEN_DARK"; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "9"; "0"; "0";"16"
|
||||
"14"; "10";"TILE_ILLUMINATOR_BROWN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "10"; "0"; "0";"16"
|
||||
"14"; "11";"TILE_ILLUMINATOR_TAN" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "11"; "0"; "0";"16"
|
||||
"14"; "12";"TILE_ILLUMINATOR_GREY_LIGHT"; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "12"; "0"; "0";"16"
|
||||
"14"; "13";"TILE_ILLUMINATOR_GREY_MED" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "13"; "0"; "0";"16"
|
||||
"14"; "14";"TILE_ILLUMINATOR_GREY_DARK" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "14"; "0"; "0";"16"
|
||||
"14"; "15";"TILE_ILLUMINATOR_BLACK" ; "2105376"; "0"; "N/A"; "0"; "1"; "1"; "0"; "13"; "15"; "0"; "0";"16"
|
||||
"15"; "0";"TILE_SANDSTONE" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "0"; "0"; "0";"16"
|
||||
"15"; "1";"TILE_SANDSTONE_WHITE" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "1"; "0"; "0";"16"
|
||||
"15"; "2";"TILE_SANDSTONE_RED" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "2"; "0"; "0";"16"
|
||||
"15"; "3";"TILE_SANDSTONE_DESERT" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "3"; "0"; "0";"16"
|
||||
"15"; "4";"TILE_SANDSTONE_BLACK" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "4"; "0"; "0";"16"
|
||||
"15"; "5";"TILE_SANDSTONE_BLACK" ; "2105376"; "25";"1900"; "0"; "1"; "1"; "0"; "15"; "5"; "0"; "0";"16"
|
||||
"16"; "0";"TILE_LANTERN_IRON_REGULAR" ; "526344"; "0"; "N/A"; "0"; "0"; "0";"16674864"; "16"; "0"; "0"; "0";"16"
|
||||
"16"; "1";"TILE_SUNSTONE" ; "2105376"; "0"; "N/A"; "0"; "1"; "0"; "0"; "16"; "1"; "0"; "2";"16"
|
||||
"16"; "2";"TILE_DAYLIGHT_CAPACITOR" ; "2105376"; "0"; "N/A"; "0"; "1"; "0"; "0"; "16"; "2"; "0"; "3";"16"
|
||||
"254"; "0";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "1";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "2";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "3";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "4";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "5";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "6";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "7";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "8";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "9";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "10";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "11";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "12";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "13";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "14";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"254"; "15";"TILE_LAVA" ;"16316664"; "100";"2600"; "1"; "0"; "0";"12858368"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "0";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "1";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "2";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "3";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "4";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "5";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "6";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "7";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "8";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "9";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "10";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "11";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "12";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "13";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "14";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"255"; "15";"TILE_WATER" ; "1708813"; "100";"1000"; "1"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
"256"; "0";"TILE_NULL" ; "0"; "-1";"2600"; "0"; "0"; "0"; "0"; "N/A"; "N/A"; "0"; "0";"16"
|
||||
|
||||
## Notes ##
|
||||
|
||||
# Friction: 0: frictionless, <16: slippery, 16: regular, >16: sticky
|
||||
# Opacity/Lumcolor: 24-bit RGB. Only the light diffusers have a opacity value of ZERO.
|
||||
# Solid: whether the tile has full collision
|
||||
# movr: Movement resistance, (walkspeedmax) / (1 + (n/16)), 16 halves movement speed
|
||||
# dsty: density. As we are putting water an 1000, it is identical to specific gravity. [g/l]
|
||||
# dlfn: dynamic luminosity function.
|
||||
# 0-static, 1-torch flicker, 2-current global light (sun, star, moon), 3-daylight at noon,
|
||||
# 4-slow breath, 5-pulsate
|
||||
|
||||
|
||||
## Illuminators ##
|
||||
|
||||
# Illuminator white: RGB(228,238,234), simulation of a halophosphate FL lamp (If you want high CRI lamp, collect a daylight!)
|
||||
# Defalut torch : L 64 a 51 b 59; real candlelight colour taken from properly configured camera.
|
||||
# Sunstone: Artificial sunlight, change colour over time in sync with sunlight. The light is set by game's code.
|
||||
# Sunlight capacitor: daylight at noon. Set by game's code.
|
||||
|
||||
|
||||
## Tiles ##
|
||||
|
||||
# 16 colour palette : Old Apple Macintosh 16-colour palette
|
||||
# Magical ice: theoretical __metallic__ ice that might form under super-high pressure (> 5 TPa). Its density is a wild guess.
|
||||
|
||||
|
||||
## References ##
|
||||
|
||||
# * Density of various woods : http://www.engineeringtoolbox.com/wood-density-d_40.html
|
||||
# * Density of various phases of ice : http://www1.lsbu.ac.uk/water/ice_phases.html
|
||||
|
Can't render this file because it contains an unexpected character in line 1 and column 18.
|
@@ -34,7 +34,7 @@ class UIPieMenu : UICanvas {
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
if (selection >= 0)
|
||||
Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] =
|
||||
Terrarum.ingame.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] =
|
||||
selection % slotCount
|
||||
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@ class UIQuickBar : UICanvas, MouseControlled {
|
||||
override var handler: UIHandler? = null
|
||||
|
||||
private var selection: Int
|
||||
get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey._PLAYER_QUICKBARSEL)!!
|
||||
set(value) { Terrarum.ingame.player.actorValue[AVKey._PLAYER_QUICKBARSEL] = value }
|
||||
get() = Terrarum.ingame.player.actorValue.getAsInt(AVKey.__PLAYER_QUICKBARSEL)!!
|
||||
set(value) { Terrarum.ingame.player.actorValue[AVKey.__PLAYER_QUICKBARSEL] = value }
|
||||
|
||||
override fun update(gc: GameContainer, delta: Int) {
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import net.torvald.colourutil.ColourUtil
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gamemap.WorldTime
|
||||
import net.torvald.terrarum.mapdrawer.Light10B
|
||||
import org.newdawn.slick.Color
|
||||
import org.newdawn.slick.GameContainer
|
||||
import org.newdawn.slick.Graphics
|
||||
@@ -32,7 +31,7 @@ object WeatherMixer {
|
||||
|
||||
private var skyBoxCurrent = Rectangle(0f, 0f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||
private var skyBoxNext = Rectangle(0f, 0f, Terrarum.WIDTH.toFloat(), Terrarum.HEIGHT.toFloat())
|
||||
val globalLightNow = Light10B(0)
|
||||
val globalLightNow = Color(0)
|
||||
|
||||
// Weather indices
|
||||
const val WEATHER_GENERIC = "generic"
|
||||
@@ -91,11 +90,14 @@ object WeatherMixer {
|
||||
g.fill(skyBoxCurrent, skyColourFill)
|
||||
|
||||
// calculate global light
|
||||
globalLightNow.fromSlickColor(getGradientColour(lightColourMap, 0, timeNow))
|
||||
val gradCol = getGradientColour(lightColourMap, 0, timeNow)
|
||||
globalLightNow.r = gradCol.r
|
||||
globalLightNow.g = gradCol.g
|
||||
globalLightNow.b = gradCol.b
|
||||
}
|
||||
|
||||
fun getGlobalLightOfTime(timeInSec: Int): Light10B =
|
||||
Light10B(getGradientColour(currentWeather.globalLightColourMap, 0, timeInSec))
|
||||
fun getGlobalLightOfTime(timeInSec: Int): Color =
|
||||
getGradientColour(currentWeather.globalLightColourMap, 0, timeInSec)
|
||||
|
||||
fun getGradientColour(image: Image, row: Int, timeInSec: Int): Color {
|
||||
val dataPointDistance = WorldTime.DAY_LENGTH / image.width
|
||||
|
||||
Reference in New Issue
Block a user