mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
Compare commits
4 Commits
test-cvec-
...
light-prel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
82d675fd59 | ||
|
|
bda2f7ba82 | ||
|
|
dfdd0ef411 | ||
|
|
4b3736cfa7 |
23
.idea/inspectionProfiles/Project_Default.xml
generated
23
.idea/inspectionProfiles/Project_Default.xml
generated
@@ -1,23 +0,0 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="ArrayEquality" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="ConstantConditionIf" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="CsvValidation" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="ExplicitThis" enabled="false" level="INFORMATION" enabled_by_default="false" />
|
||||
<inspection_tool class="KotlinDoubleNegation" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||
<inspection_tool class="NullChecksToSafeCall" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RedundantCompanionReference" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RedundantExplicitType" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RedundantGetter" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RedundantSetter" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RedundantUnitExpression" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RedundantUnitReturnType" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RemoveCurlyBracesFromTemplate" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RemoveEmptyPrimaryConstructor" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RemoveEmptySecondaryConstructorBody" enabled="false" level="WEAK WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RemoveRedundantBackticks" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RemoveRedundantQualifierName" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
<inspection_tool class="RemoveSingleExpressionStringTemplate" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||
</profile>
|
||||
</component>
|
||||
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_X" default="false" project-jdk-name="13-incubate" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_10" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,5 @@
|
||||
"id";"classname"
|
||||
"8448";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper"
|
||||
"8449";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeIron"
|
||||
"8450";"net.torvald.terrarum.modulebasegame.gameitems.PickaxeSteel"
|
||||
"8466";"net.torvald.terrarum.modulebasegame.gameitems.WirePieceSignalWire"
|
||||
"8467";"net.torvald.terrarum.modulebasegame.gameitems.TikiTorchTester"
|
||||
"8448";"net.torvald.terrarum.modulebasegame.items.PickaxeCopper"
|
||||
"8449";"net.torvald.terrarum.modulebasegame.items.PickaxeIron"
|
||||
"8450";"net.torvald.terrarum.modulebasegame.items.PickaxeSteel"
|
||||
"8466";"net.torvald.terrarum.modulebasegame.items.WirePieceSignalWire"
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import org.jetbrains.annotations.NotNull
|
||||
import org.jetbrains.annotations.Nullable
|
||||
|
||||
@@ -9,7 +9,7 @@ import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.itemproperties.Calculate
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
// following two are NOT UNUSED!
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
# complete file name is: SPRITESHEET + bodypart name + EXTENSION
|
||||
SPRITESHEET=mods/basegame/sprites/test_furry/furbud_
|
||||
EXTENSION=.tga
|
||||
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
|
||||
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
|
||||
CONFIG=SIZE 48,56;ORIGINX 29
|
||||
|
||||
# note to self: don't implement skeleton hierarchy: there's too many exceptions
|
||||
# besides, you have "ALL" key.
|
||||
|
||||
! a skeleton also defines what body parts (images) be used.
|
||||
! you can also write multiline text using reverse solidus; this is a feature of .properties
|
||||
! skeleton joints are ordered: foremost-drawn object comes first, which means lowermost object IN THIS LIST
|
||||
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
||||
! first reversed then being iterated.
|
||||
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
|
||||
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
|
||||
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
||||
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
||||
HAIR 0,32;HEAD 0,32;\
|
||||
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
||||
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
||||
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
||||
TAIL_0 0,13;TAIL_1 0,13
|
||||
|
||||
# skeleton_stand is used for testing purpose
|
||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
||||
ANIM_RUN_1=TAIL_0 0,-999;LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0
|
||||
ANIM_RUN_2=TAIL_1 0,-999;ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1
|
||||
ANIM_RUN_3=TAIL_1 0,-999;LEG_REST_RIGHT -1,0;FOOT_RIGHT -1,0;LEG_REST_LEFT 1,1;FOOT_LEFT 1,1
|
||||
ANIM_RUN_4=TAIL_0 0,-999;ALL 0,1;LEG_REST_RIGHT 0,1;FOOT_RIGHT 0,1;LEG_REST_LEFT 0,-1;FOOT_LEFT 0,-1
|
||||
|
||||
|
||||
ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND
|
||||
ANIM_IDLE_1=TAIL_1 0,-999
|
||||
ANIM_IDLE_2=TAIL_1 0,-999;\
|
||||
UPPER_TORSO 0,-1;HEAD 0,-1;HAIR 0,-1;HELD_ITEM 0,-1;\
|
||||
ARM_REST_LEFT 0,-1;ARM_REST_RIGHT 0,-1;HAND_REST_LEFT 0,-1;HAND_REST_RIGHT 0,-1;\
|
||||
HAIR_FORE 0,-1;HEADGEAR 0,-1
|
||||
@@ -1,40 +0,0 @@
|
||||
# complete file name is: SPRITESHEET + bodypart name + EXTENSION
|
||||
SPRITESHEET=mods/basegame/sprites/test_furry/furbudglow_
|
||||
EXTENSION=.tga
|
||||
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
|
||||
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
|
||||
CONFIG=SIZE 48,56;ORIGINX 29
|
||||
|
||||
# note to self: don't implement skeleton hierarchy: there's too many exceptions
|
||||
# besides, you have "ALL" key.
|
||||
|
||||
! a skeleton also defines what body parts (images) be used.
|
||||
! you can also write multiline text using reverse solidus; this is a feature of .properties
|
||||
! skeleton joints are ordered: foremost-drawn object comes first, which means lowermost object IN THIS LIST
|
||||
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
||||
! first reversed then being iterated.
|
||||
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
|
||||
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
|
||||
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
||||
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
||||
HAIR 0,32;HEAD 0,32;\
|
||||
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
||||
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
||||
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
||||
TAIL_0 0,13;TAIL_1 0,13
|
||||
|
||||
# skeleton_stand is used for testing purpose
|
||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
||||
ANIM_RUN_1=TAIL_0 0,-999;LEG_REST_RIGHT 1,1;FOOT_RIGHT 1,1;LEG_REST_LEFT -1,0;FOOT_LEFT -1,0
|
||||
ANIM_RUN_2=TAIL_1 0,-999;ALL 0,1;LEG_REST_RIGHT 0,-1;FOOT_RIGHT 0,-1;LEG_REST_LEFT 0,1;FOOT_LEFT 0,1
|
||||
ANIM_RUN_3=TAIL_1 0,-999;LEG_REST_RIGHT -1,0;FOOT_RIGHT -1,0;LEG_REST_LEFT 1,1;FOOT_LEFT 1,1
|
||||
ANIM_RUN_4=TAIL_0 0,-999;ALL 0,1;LEG_REST_RIGHT 0,1;FOOT_RIGHT 0,1;LEG_REST_LEFT 0,-1;FOOT_LEFT 0,-1
|
||||
|
||||
|
||||
ANIM_IDLE=DELAY 2;ROW 1;SKELETON SKELETON_STAND
|
||||
ANIM_IDLE_1=TAIL_1 0,-999
|
||||
ANIM_IDLE_2=TAIL_1 0,-999;\
|
||||
UPPER_TORSO 0,-1;HEAD 0,-1;HAIR 0,-1;HELD_ITEM 0,-1;\
|
||||
ARM_REST_LEFT 0,-1;ARM_REST_RIGHT 0,-1;HAND_REST_LEFT 0,-1;HAND_REST_RIGHT 0,-1;\
|
||||
HAIR_FORE 0,-1;HEADGEAR 0,-1
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,7 +2,6 @@
|
||||
SPRITESHEET=mods/basegame/sprites/sprite_assembler_test_assets/test_
|
||||
EXTENSION=.tga
|
||||
# defines frame size and origin point. Origin point is given as: (originx, size.y - 1)
|
||||
# ORIGINY is deduced from the sprite size as shown in above; you only need to set ORIGINX
|
||||
CONFIG=SIZE 48,56;ORIGINX 29
|
||||
|
||||
# note to self: don't implement skeleton hierarchy: there's too many exceptions
|
||||
@@ -14,15 +13,14 @@ CONFIG=SIZE 48,56;ORIGINX 29
|
||||
! are painted first, and any object that comes before it will paint over it. In other words, this list is
|
||||
! first reversed then being iterated.
|
||||
! Joints' original point is defined in the document sprite_joints.psd. It also has visual representations.
|
||||
# TODO right now accessory points are explicitly defined. Should they be injected in run-time? In that case, certain names (e.g. headgear, held_item) will act as an anchor.
|
||||
# TODO right now accessory points are explicitly defined. Should they be injected in run-time?
|
||||
SKELETON_STAND=HEADGEAR 0,32;HAIR_FORE 0,32;\
|
||||
ARM_REST_RIGHT -7,23;HAND_REST_RIGHT -6,11;HELD_ITEM -6,11;\
|
||||
HAIR 0,32;HEAD 0,32;\
|
||||
UPPER_TORSO 0,23;LOWER_TORSO 0,15;\
|
||||
FOOT_RIGHT -2,2;LEG_REST_RIGHT -2,7;\
|
||||
FOOT_LEFT 2,2;LEG_REST_LEFT 2,7;\
|
||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
||||
TAIL0 0,13
|
||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12
|
||||
|
||||
# skeleton_stand is used for testing purpose
|
||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
||||
|
||||
@@ -56,9 +56,8 @@ task gamedebug(type: JavaExec) {
|
||||
classpath sourceSets.main.runtimeClasspath
|
||||
main = 'net.torvald.terrarum.AppLoader'
|
||||
group = "Application"
|
||||
description = "Launches the game with the debug key."
|
||||
description = "Launches the game with debuy key."
|
||||
args = ["isdev=true"]
|
||||
jvmArgs = ["-ea"]
|
||||
}
|
||||
|
||||
task spriteassembler(type: JavaExec) {
|
||||
|
||||
Binary file not shown.
@@ -93,6 +93,13 @@ public class Color {
|
||||
this.a = a;
|
||||
}
|
||||
|
||||
public Color (float c) {
|
||||
this.r = c;
|
||||
this.g = c;
|
||||
this.b = c;
|
||||
this.a = c;
|
||||
}
|
||||
|
||||
/** Constructs a new color using the given color
|
||||
*
|
||||
* @param color the color */
|
||||
|
||||
@@ -11,17 +11,12 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
*/
|
||||
interface HasAssembledSprite {
|
||||
|
||||
/** ADL path for main sprite. Necessary. */
|
||||
var animDescPath: String
|
||||
/** ADL path for glow sprite. Optional. */
|
||||
var animDescPathGlow: String?
|
||||
|
||||
// FIXME sometimes the animmation is invisible (row and nFrames mismatch -- row is changed to 1 but it's drawing 3rd frame?)
|
||||
|
||||
fun reassembleSprite(sprite: SpriteAnimation, spriteGlow: SpriteAnimation? = null) {
|
||||
fun reassembleSprite(sprite: SpriteAnimation) {
|
||||
_rebuild(ADProperties(Gdx.files.internal(animDescPath).read()), sprite)
|
||||
if (spriteGlow != null)
|
||||
_rebuild(ADProperties(Gdx.files.internal(animDescPathGlow).read()), spriteGlow)
|
||||
}
|
||||
|
||||
/*fun rebuild(animDescPath: String, spriteAnimation: SpriteAnimation) {
|
||||
|
||||
@@ -19,10 +19,9 @@ class GdxColorMap {
|
||||
height = pixmap.height
|
||||
is2D = pixmap.height > 1
|
||||
|
||||
dataRaw = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||
data = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
||||
}
|
||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||
|
||||
pixmap.dispose()
|
||||
}
|
||||
@@ -32,46 +31,39 @@ class GdxColorMap {
|
||||
height = pixmap.height
|
||||
is2D = pixmap.height > 1
|
||||
|
||||
dataRaw = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||
data = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
||||
}
|
||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||
|
||||
if (disposePixmap) pixmap.dispose()
|
||||
}
|
||||
|
||||
constructor(color: Color) {
|
||||
dataRaw = intArrayOf(color.toIntBits())
|
||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||
data = intArrayOf(color.toIntBits())
|
||||
width = 1
|
||||
height = 1
|
||||
is2D = false
|
||||
}
|
||||
|
||||
constructor(gradStart: Color, gradEnd: Color) {
|
||||
dataRaw = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||
data = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
||||
width = 1
|
||||
height = 2
|
||||
is2D = true
|
||||
}
|
||||
|
||||
private val dataRaw: IntArray
|
||||
private val dataGdxColor: Array<Color>
|
||||
//private val dataCvec: Array<Cvec>
|
||||
private val data: IntArray
|
||||
val width: Int
|
||||
val height: Int
|
||||
val is2D: Boolean
|
||||
|
||||
|
||||
|
||||
fun get(x: Int, y: Int): Color = dataGdxColor[y * width + x]
|
||||
operator fun get(x: Int): Color = if (is2D) throw OperationNotSupportedException("This is 2D color map") else dataGdxColor[x]
|
||||
fun get(x: Int, y: Int): Color = Color(data[y * width + x])
|
||||
operator fun get(x: Int): Color = if (is2D) throw OperationNotSupportedException("This is 2D color map") else Color(data[x])
|
||||
|
||||
fun getRaw(x: Int, y: Int): RGBA8888 = dataRaw[y * width + x]
|
||||
fun getRaw(x: Int): RGBA8888 = if (is2D) throw OperationNotSupportedException("This is 2D color map") else dataRaw[x]
|
||||
|
||||
//fun getAsCvec(x: Int, y: Int): Cvec = dataCvec[y * width + x]
|
||||
fun getRaw(x: Int, y: Int): RGBA8888 = data[y * width + x]
|
||||
fun getRaw(x: Int): RGBA8888 = if (is2D) throw OperationNotSupportedException("This is 2D color map") else data[x]
|
||||
|
||||
override fun toString(): String {
|
||||
val sb = StringBuilder()
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.files.FileHandle
|
||||
import net.torvald.terrarum.AppLoader.*
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.utils.CSVFetcher
|
||||
|
||||
@@ -145,7 +145,7 @@ class TitleScreen(val batch: SpriteBatch) : Screen {
|
||||
}
|
||||
|
||||
|
||||
cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false) {
|
||||
cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false, forceAssignRefID = Terrarum.PLAYER_REF_ID) {
|
||||
init {
|
||||
setHitboxDimension(2, 2, 0, 0)
|
||||
hitbox.setPosition(
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.blockproperties
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.AppLoader.printmsg
|
||||
import net.torvald.terrarum.gameworld.FluidType
|
||||
@@ -7,7 +8,6 @@ import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameworld.MapLayer
|
||||
import net.torvald.terrarum.gameworld.PairedMapLayer
|
||||
import net.torvald.terrarum.utils.CSVFetcher
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import org.apache.commons.csv.CSVRecord
|
||||
import java.io.IOException
|
||||
@@ -110,7 +110,7 @@ object BlockCodex {
|
||||
prop.shadeColG = floatVal(record, "shdg") / LightmapRenderer.MUL_FLOAT
|
||||
prop.shadeColB = floatVal(record, "shdb") / LightmapRenderer.MUL_FLOAT
|
||||
prop.shadeColA = floatVal(record, "shduv") / LightmapRenderer.MUL_FLOAT
|
||||
prop.opacity = Cvec(prop.shadeColR, prop.shadeColG, prop.shadeColB, prop.shadeColA)
|
||||
prop.opacity = Color(prop.shadeColR, prop.shadeColG, prop.shadeColB, prop.shadeColA)
|
||||
|
||||
prop.strength = intVal(record, "str")
|
||||
prop.density = intVal(record, "dsty")
|
||||
@@ -119,7 +119,7 @@ object BlockCodex {
|
||||
prop.lumColG = floatVal(record, "lumg") / LightmapRenderer.MUL_FLOAT
|
||||
prop.lumColB = floatVal(record, "lumb") / LightmapRenderer.MUL_FLOAT
|
||||
prop.lumColA = floatVal(record, "lumuv") / LightmapRenderer.MUL_FLOAT
|
||||
prop.internalLumCol = Cvec(prop.lumColR, prop.lumColG, prop.lumColB, prop.lumColA)
|
||||
prop.internalLumCol = Color(prop.lumColR, prop.lumColG, prop.lumColB, prop.lumColA)
|
||||
|
||||
prop.friction = intVal(record, "fr")
|
||||
prop.viscosity = intVal(record, "vscs")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.blockproperties
|
||||
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-16.
|
||||
@@ -16,8 +16,7 @@ class BlockProp {
|
||||
var shadeColG = 0f
|
||||
var shadeColB = 0f
|
||||
var shadeColA = 0f
|
||||
|
||||
var opacity: Cvec = Cvec()
|
||||
var opacity: Color = Color(0)
|
||||
|
||||
var strength: Int = 0
|
||||
var density: Int = 0
|
||||
@@ -36,12 +35,12 @@ class BlockProp {
|
||||
var lumColG = 0f
|
||||
var lumColB = 0f
|
||||
var lumColA = 0f
|
||||
var internalLumCol: Cvec = Cvec()
|
||||
var internalLumCol: Color = Color(0)
|
||||
|
||||
/**
|
||||
* @param luminosity
|
||||
*/
|
||||
inline val luminosity: Cvec
|
||||
inline val luminosity: Color
|
||||
get() = BlockPropUtil.getDynamicLumFunc(internalLumCol, dynamicLuminosityFunction)
|
||||
|
||||
var drop: Int = 0
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package net.torvald.terrarum.blockproperties
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
|
||||
/**
|
||||
@@ -37,7 +37,7 @@ object BlockPropUtil {
|
||||
|
||||
}
|
||||
|
||||
private fun getTorchFlicker(baseLum: Cvec): Cvec {
|
||||
private fun getTorchFlicker(baseLum: Color): Color {
|
||||
val funcY = FastMath.interpolateCatmullRom(0.0f, flickerFuncX / flickerFuncDomain,
|
||||
flickerP0, flickerP1, flickerP2, flickerP3
|
||||
)
|
||||
@@ -45,13 +45,13 @@ object BlockPropUtil {
|
||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||
}
|
||||
|
||||
private fun getSlowBreath(baseLum: Cvec): Cvec {
|
||||
private fun getSlowBreath(baseLum: Color): Color {
|
||||
val funcY = FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
|
||||
|
||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||
}
|
||||
|
||||
private fun getPulsate(baseLum: Cvec): Cvec {
|
||||
private fun getPulsate(baseLum: Color): Color {
|
||||
val funcY = FastMath.sin(FastMath.PI * pulsateFuncX / pulsateCycleDuration) * pulsateRange
|
||||
|
||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||
@@ -91,11 +91,11 @@ object BlockPropUtil {
|
||||
|
||||
private fun linearInterpolation1D(a: Float, b: Float, x: Float) = a * (1 - x) + b * x
|
||||
|
||||
fun getDynamicLumFunc(baseLum: Cvec, type: Int): Cvec {
|
||||
fun getDynamicLumFunc(baseLum: Color, type: Int): Color {
|
||||
return when (type) {
|
||||
1 -> getTorchFlicker(baseLum)
|
||||
2 -> (Terrarum.ingame!!.world).globalLight * LightmapRenderer.DIV_FLOAT // current global light
|
||||
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2) * LightmapRenderer.DIV_FLOAT // daylight at noon
|
||||
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)
|
||||
else -> baseLum
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.weather.WeatherMixer
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-17.
|
||||
@@ -13,12 +14,11 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 5) {
|
||||
try {
|
||||
val GL = Cvec(
|
||||
args[1].toFloat(),
|
||||
args[2].toFloat(),
|
||||
args[3].toFloat(),
|
||||
args[4].toFloat()
|
||||
)
|
||||
val r = args[1].toFloat()
|
||||
val g = args[2].toFloat()
|
||||
val b = args[3].toFloat()
|
||||
val a = args[4].toFloat()
|
||||
val GL = Color(r, g, b, a)
|
||||
|
||||
WeatherMixer.globalLightOverridden = true
|
||||
(Terrarum.ingame!!.world).globalLight = GL
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-19.
|
||||
@@ -26,7 +26,7 @@ interface Luminous {
|
||||
actorValue[AVKey.LUMA] = value.a * LightmapRenderer.MUL_FLOAT
|
||||
}
|
||||
*/
|
||||
var color: Cvec
|
||||
var color: Color
|
||||
|
||||
/**
|
||||
* Arguments:
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
package net.torvald.terrarum.gameworld
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
@@ -9,7 +10,6 @@ import net.torvald.terrarum.blockproperties.Fluid
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldSimulator
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarum.serialise.ReadLayerDataZip
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import net.torvald.util.SortedArrayList
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import kotlin.math.absoluteValue
|
||||
@@ -90,7 +90,7 @@ open class GameWorld {
|
||||
/** Meter per second squared. Currently only the downward gravity is supported. No reverse gravity :p */
|
||||
var gravitation: Vector2 = Vector2(0.0, 9.80665)
|
||||
/** 0.0..1.0+ */
|
||||
var globalLight = Cvec()
|
||||
var globalLight = Color(0f,0f,0f,0f)
|
||||
var averageTemperature = 288f // 15 deg celsius; simulates global warming
|
||||
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package net.torvald.terrarum.gameitem
|
||||
package net.torvald.terrarum.itemproperties
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.ItemValue
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_DYNAMIC
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.langpack.Lang
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||
@@ -14,18 +12,15 @@ import net.torvald.terrarum.modulebasegame.gameactors.Pocketed
|
||||
typealias ItemID = Int
|
||||
|
||||
/**
|
||||
* Instances of the GameItem (e.g. net.torvald.terrarum.modulebasegame.gameitems.PickaxeCopper) are preferably referenced
|
||||
* from the ```<module>/items/itemid.csv``` file only, and not from the actual game code.
|
||||
*
|
||||
* Created by minjaesong on 2016-01-16.
|
||||
*/
|
||||
abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneable {
|
||||
abstract class GameItem : Comparable<GameItem>, Cloneable {
|
||||
|
||||
open var dynamicID: ItemID = originalID
|
||||
abstract var dynamicID: ItemID
|
||||
/**
|
||||
* if the ID is a Actor range, it's an actor contained in a pocket.
|
||||
*/
|
||||
//abstract val originalID: ItemID // WUT?! using init does not work!!
|
||||
abstract val originalID: ItemID // WUT?! using init does not work!!
|
||||
|
||||
|
||||
/**
|
||||
@@ -273,7 +268,6 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
@JvmStatic val BLOCK = "block"
|
||||
@JvmStatic val WALL = "wall"
|
||||
@JvmStatic val WIRE = "wire"
|
||||
@JvmStatic val FIXTURE = "fixture"
|
||||
@JvmStatic val MISC = "misc"
|
||||
}
|
||||
|
||||
@@ -287,7 +281,7 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
|
||||
|
||||
fun generateUniqueDynamicID(inventory: ActorInventory): GameItem {
|
||||
dynamicID = Companion.generateUniqueDynamicID(inventory)
|
||||
dynamicID = GameItem.generateUniqueDynamicID(inventory)
|
||||
ItemCodex.registerNewDynamicItem(dynamicID, this)
|
||||
return this
|
||||
}
|
||||
@@ -5,8 +5,6 @@ import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Fluid
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.CanBeAnItem
|
||||
@@ -176,7 +174,9 @@ object ItemCodex {
|
||||
|
||||
|
||||
// test water bucket
|
||||
itemCodex[9000] = object : GameItem(9000) {
|
||||
itemCodex[9000] = object : GameItem() {
|
||||
override var dynamicID: ItemID = 9000
|
||||
override val originalID: ItemID = 9000
|
||||
|
||||
override val isUnique: Boolean = true
|
||||
override val originalName: String = "Infinite Water Bucket"
|
||||
@@ -203,7 +203,9 @@ object ItemCodex {
|
||||
|
||||
|
||||
// test lava bucket
|
||||
itemCodex[9001] = object : GameItem(9001) {
|
||||
itemCodex[9001] = object : GameItem() {
|
||||
override var dynamicID: ItemID = 9001
|
||||
override val originalID: ItemID = 9001
|
||||
|
||||
override val isUnique: Boolean = true
|
||||
override val originalName: String = "Infinite Lava Bucket"
|
||||
|
||||
@@ -10,7 +10,7 @@ import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.BlockPropUtil
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
@@ -27,7 +27,6 @@ import net.torvald.terrarum.serialise.toULittle48
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UINSMenu
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas.TILE_SIZE
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
@@ -280,7 +279,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
init {
|
||||
gameWorld.time.setTimeOfToday(WorldTime.HOUR_SEC * 10)
|
||||
gameWorld.globalLight = Cvec(.8f)
|
||||
gameWorld.globalLight = Color(.8f,.8f,.8f,.8f)
|
||||
|
||||
essentialOverlays.add(blockPointingCursor)
|
||||
|
||||
|
||||
@@ -6,11 +6,11 @@ import net.torvald.terrarum.AppLoader.printdbg
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.ModuleEntryPoint
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.BlockBase
|
||||
import net.torvald.terrarum.modulebasegame.imagefont.WatchFont
|
||||
import net.torvald.terrarum.modulebasegame.items.BlockBase
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,9 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
val blockProp = BlockCodex.getOrNull(i % ItemCodex.ITEM_WALLS.first)
|
||||
|
||||
if (blockProp != null) {
|
||||
ItemCodex.itemCodex[i] = object : GameItem(i) {
|
||||
ItemCodex.itemCodex[i] = object : GameItem() {
|
||||
override val originalID = i
|
||||
override var dynamicID = i
|
||||
override val isUnique: Boolean = false
|
||||
override var baseMass: Double = blockProp.density / 1000.0
|
||||
override var baseToolSize: Double? = null
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gamecontroller.IngameController
|
||||
import net.torvald.terrarum.gamecontroller.KeyToggler
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.console.AVTracker
|
||||
import net.torvald.terrarum.modulebasegame.console.ActorsList
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.spriteanimation.HasAssembledSprite
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.*
|
||||
import net.torvald.terrarum.gameactors.faction.Faction
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import java.util.*
|
||||
@@ -68,18 +68,18 @@ open class ActorHumanoid(
|
||||
if (houseDesignation != null) houseDesignation!!.clear()
|
||||
}
|
||||
|
||||
override var color: Cvec
|
||||
get() = Cvec(
|
||||
override var color: Color
|
||||
get() = Color(
|
||||
(actorValue.getAsFloat(AVKey.LUMR) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
||||
(actorValue.getAsFloat(AVKey.LUMG) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
||||
(actorValue.getAsFloat(AVKey.LUMB) ?: 0f) / LightmapRenderer.MUL_FLOAT,
|
||||
(actorValue.getAsFloat(AVKey.LUMA) ?: 0f) / LightmapRenderer.MUL_FLOAT
|
||||
)
|
||||
set(value) {
|
||||
actorValue[AVKey.LUMR] = value.vec.lane(0) * LightmapRenderer.MUL_FLOAT
|
||||
actorValue[AVKey.LUMG] = value.vec.lane(1) * LightmapRenderer.MUL_FLOAT
|
||||
actorValue[AVKey.LUMB] = value.vec.lane(2) * LightmapRenderer.MUL_FLOAT
|
||||
actorValue[AVKey.LUMA] = value.vec.lane(3) * LightmapRenderer.MUL_FLOAT
|
||||
actorValue[AVKey.LUMR] = value.r * LightmapRenderer.MUL_FLOAT
|
||||
actorValue[AVKey.LUMG] = value.g * LightmapRenderer.MUL_FLOAT
|
||||
actorValue[AVKey.LUMB] = value.b * LightmapRenderer.MUL_FLOAT
|
||||
actorValue[AVKey.LUMA] = value.a * LightmapRenderer.MUL_FLOAT
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +154,9 @@ open class ActorHumanoid(
|
||||
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.actorNowPlaying
|
||||
|
||||
|
||||
@Transient private val nullItem = object : GameItem(0) {
|
||||
@Transient private val nullItem = object : GameItem() {
|
||||
override var dynamicID: Int = 0
|
||||
override val originalID = dynamicID
|
||||
override val isUnique: Boolean = false
|
||||
override var baseMass: Double = 0.0
|
||||
override var baseToolSize: Double? = null
|
||||
|
||||
@@ -5,11 +5,11 @@ 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.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_DYNAMIC
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex.ITEM_WALLS
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.lock
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIQuickslotBar
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-31.
|
||||
|
||||
@@ -3,7 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,11 +27,10 @@ open class FixtureBase(val blockBox: BlockBox, val blockBoxProps: BlockBoxProps
|
||||
/**
|
||||
* Adds this instance of the fixture to the world
|
||||
*
|
||||
* @param posX tile-wise top-left position of the fixture
|
||||
* @param posY tile-wise top-left position of the fixture
|
||||
* @return true if successfully spawned, false if was not (e.g. occupied space)
|
||||
* @param posX top-left position of the fixture, tile-wise
|
||||
* @param posY top-left position of the fixture, tile-wise
|
||||
*/
|
||||
open fun spawn(posX: Int, posY: Int): Boolean {
|
||||
open fun spawn(posX: Int, posY: Int) {
|
||||
// place filler blocks
|
||||
// place the filler blocks where:
|
||||
// origin posX: centre-left if mouseX is on the right-half of the game window,
|
||||
@@ -53,9 +52,6 @@ open class FixtureBase(val blockBox: BlockBox, val blockBoxProps: BlockBoxProps
|
||||
this.isVisible = true
|
||||
this.hitbox.setFromWidthHeight(posX * TSIZE, posY * TSIZE, blockBox.width * TSIZE, blockBox.height * TSIZE)
|
||||
|
||||
|
||||
|
||||
return true // TODO for the tests' sake, just get fucking spawned
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
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.worlddrawer.Cvec
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.util.*
|
||||
|
||||
@@ -17,7 +17,7 @@ internal class FixtureTikiTorch : FixtureBase(
|
||||
BlockBox(BlockBox.NO_COLLISION, 1, 2)
|
||||
), Luminous {
|
||||
|
||||
override var color: Cvec
|
||||
override var color: Color
|
||||
get() = BlockCodex[Block.TORCH].luminosity
|
||||
set(value) {
|
||||
throw UnsupportedOperationException()
|
||||
|
||||
@@ -4,7 +4,7 @@ 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.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
|
||||
@@ -16,8 +16,8 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
open class HumanoidNPC(
|
||||
override val ai: ActorAI, // it's there for written-in-Kotlin, "hard-wired" AIs
|
||||
born: time_t,
|
||||
usePhysics: Boolean = true
|
||||
//forceAssignRefID: Int? = null
|
||||
usePhysics: Boolean = true,
|
||||
forceAssignRefID: Int? = null
|
||||
) : ActorHumanoid(born, usePhysics = usePhysics), AIControlled, CanBeAnItem {
|
||||
|
||||
companion object {
|
||||
@@ -29,7 +29,9 @@ open class HumanoidNPC(
|
||||
}
|
||||
|
||||
// we're having GameItem data so that this class could be somewhat universal
|
||||
override var itemData: GameItem = object : GameItem(referenceID) {//GameItem(referenceID ?: forceAssignRefID!!) {
|
||||
override var itemData: GameItem = object : GameItem() {
|
||||
override var dynamicID = referenceID ?: forceAssignRefID!!
|
||||
override val originalID = dynamicID
|
||||
override val isUnique = true
|
||||
override var baseMass: Double
|
||||
get() = actorValue.getAsDouble(AVKey.BASEMASS)!!
|
||||
|
||||
@@ -11,11 +11,7 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
*/
|
||||
|
||||
class IngamePlayer(
|
||||
override var animDescPath: String,
|
||||
override var animDescPathGlow: String? = null,
|
||||
born: time_t
|
||||
) : ActorHumanoid(born), HasAssembledSprite {
|
||||
class IngamePlayer(override var animDescPath: String, born: time_t) : ActorHumanoid(born), HasAssembledSprite {
|
||||
|
||||
/**
|
||||
* Creates new Player instance with empty elements (sprites, actorvalue, etc.).
|
||||
|
||||
@@ -13,7 +13,7 @@ object PlayerBuilder {
|
||||
operator fun invoke(): Actor {
|
||||
val world = (Terrarum.ingame!! as Ingame).gameworld
|
||||
|
||||
val p: Actor = IngamePlayer("lol", "lol_glow", world.time.TIME_T)
|
||||
val p: Actor = IngamePlayer("lol", world.time.TIME_T)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -14,7 +14,7 @@ import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
object PlayerBuilderSigrid {
|
||||
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p = IngamePlayer("lol", "lol_glow", - 9223372036854775807L) // XD
|
||||
val p = IngamePlayer("lol", - 9223372036854775807L) // XD
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
@@ -82,13 +82,10 @@ object PlayerBuilderSigrid {
|
||||
}
|
||||
}
|
||||
|
||||
// item ids are defined in <module>/items/itemid.csv
|
||||
|
||||
inventory.add(8448) // copper pick
|
||||
inventory.add(8449) // iron pick
|
||||
inventory.add(8450) // steel pick
|
||||
inventory.add(8466, 9995) // wire piece
|
||||
inventory.add(8467, 9995) // test tiki torch
|
||||
inventory.add(9000) // TEST water bucket
|
||||
inventory.add(9001) // TEST lava bucket
|
||||
}
|
||||
|
||||
@@ -4,17 +4,14 @@ import net.torvald.spriteanimation.SpriteAnimation
|
||||
import net.torvald.terrarum.ModMgr
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.FeaturesDrawer
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2017-02-10.
|
||||
*/
|
||||
object PlayerBuilderTestSubject1 {
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p: IngamePlayer = IngamePlayer(
|
||||
ModMgr.getPath("basegame", "sprites/furry_sprite.properties"),
|
||||
ModMgr.getPath("basegame", "sprites/furry_sprite_glow.properties"),
|
||||
-589141658L // random value thrown
|
||||
)
|
||||
val p: IngamePlayer = IngamePlayer(ModMgr.getPath("basegame", "sprites/test_sprite.properties"), -589141658L) // random value thrown
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
|
||||
@@ -29,8 +26,7 @@ object PlayerBuilderTestSubject1 {
|
||||
p.sprite!!.setRowsAndFrames(2, 4)*/
|
||||
|
||||
p.sprite = SpriteAnimation(p)
|
||||
p.spriteGlow = SpriteAnimation(p)
|
||||
p.reassembleSprite(p.sprite!!, p.spriteGlow)
|
||||
p.reassembleSprite(p.sprite!!)
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
p.setPosition(3.0 * CreateTileAtlas.TILE_SIZE, 3.0 * CreateTileAtlas.TILE_SIZE)
|
||||
@@ -38,10 +34,10 @@ object PlayerBuilderTestSubject1 {
|
||||
|
||||
PlayerBuilderSigrid.fillTestInventory(p.inventory)
|
||||
|
||||
//p.actorValue[AVKey.LUMR] = 0.84
|
||||
//p.actorValue[AVKey.LUMG] = 0.93
|
||||
//p.actorValue[AVKey.LUMB] = 1.37
|
||||
//p.actorValue[AVKey.LUMA] = 1.93
|
||||
p.actorValue[AVKey.LUMR] = 0.84
|
||||
p.actorValue[AVKey.LUMG] = 0.93
|
||||
p.actorValue[AVKey.LUMB] = 1.37
|
||||
p.actorValue[AVKey.LUMA] = 1.93
|
||||
|
||||
return p
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-15.
|
||||
|
||||
@@ -9,7 +9,6 @@ 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.worlddrawer.Cvec
|
||||
import org.dyn4j.geometry.Vector2
|
||||
import java.util.*
|
||||
|
||||
@@ -32,8 +31,8 @@ open class ProjectileSimple(
|
||||
val speed: Int
|
||||
|
||||
|
||||
override var color: Cvec
|
||||
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Cvec)
|
||||
override var color: Color
|
||||
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Color).cpy()
|
||||
set(value) {
|
||||
}
|
||||
/**
|
||||
@@ -119,8 +118,8 @@ open class ProjectileSimple(
|
||||
val OFFSET_LUMINOSITY = 4
|
||||
val bulletDatabase = arrayOf(
|
||||
// damage, display colour, no gravity, speed
|
||||
arrayOf(7, Cvec(1f, .329f, .161f, 1f), true, 40, 32),
|
||||
arrayOf(8, Cvec(1f, .329f, .161f, 1f), true, 20, 0)
|
||||
arrayOf(7, Color(0xFF5429_FF.toInt()), true, 40, 32),
|
||||
arrayOf(8, Color(0xFF5429_FF.toInt()), true, 20, 0)
|
||||
// ...
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
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.worlddrawer.Cvec
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-04-26.
|
||||
@@ -20,7 +21,7 @@ class WeaponSwung(val itemID: Int) : ActorWBMovable(RenderOrder.MIDTOP), Luminou
|
||||
actorValue[AVKey.LUMINOSITY] = value
|
||||
}
|
||||
*/
|
||||
override var color: Cvec
|
||||
override var color: Color
|
||||
get() = throw UnsupportedOperationException()
|
||||
set(value) {
|
||||
}
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureTikiTorch
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-05-16.
|
||||
*/
|
||||
class TikiTorchTester(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "Tiki Torch"
|
||||
override var baseMass = 1.0
|
||||
override var stackable = true
|
||||
override var inventoryCategory = Category.FIXTURE
|
||||
override val isUnique = false
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
override val itemImage: TextureRegion?
|
||||
get() = AppLoader.resourcePool.getAsTextureRegion("itemplaceholder_48")
|
||||
override var baseToolSize: Double? = baseMass
|
||||
|
||||
override fun startPrimaryUse(delta: Float): Boolean {
|
||||
val torch = FixtureTikiTorch()
|
||||
|
||||
return torch.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY - torch.blockBox.height + 1)
|
||||
// return true when placed, false when cannot be placed
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
|
||||
import net.torvald.terrarum.Point2d
|
||||
import net.torvald.terrarum.Point2i
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AppLoader
|
||||
@@ -7,13 +7,13 @@ import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Calculate
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.itemproperties.MaterialCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.TOOL_DURABILITY_BASE
|
||||
import net.torvald.terrarum.modulebasegame.items.PickaxeCore.BASE_MASS_AND_SIZE
|
||||
import net.torvald.terrarum.modulebasegame.items.PickaxeCore.TOOL_DURABILITY_BASE
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -74,8 +74,9 @@ object PickaxeCore {
|
||||
/**
|
||||
* Created by minjaesong on 2017-07-17.
|
||||
*/
|
||||
class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
|
||||
class PickaxeCopper(override val originalID: ItemID) : GameItem() {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "PACKAGED_PICK"
|
||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||
override var stackable = true
|
||||
@@ -101,8 +102,9 @@ class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
|
||||
/**
|
||||
* Created by minjaesong on 2019-03-10.
|
||||
*/
|
||||
class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
|
||||
class PickaxeIron(override val originalID: ItemID) : GameItem() {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "PACKAGED_PICK"
|
||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||
override var stackable = true
|
||||
@@ -128,8 +130,9 @@ class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
|
||||
/**
|
||||
* Created by minjaesong on 2019-03-10.
|
||||
*/
|
||||
class PickaxeSteel(originalID: ItemID) : GameItem(originalID) {
|
||||
class PickaxeSteel(override val originalID: ItemID) : GameItem() {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "PACKAGED_PICK"
|
||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||
override var stackable = true
|
||||
@@ -1,9 +1,8 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
|
||||
import net.torvald.random.Fudge3
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import kotlin.math.pow
|
||||
|
||||
@@ -25,6 +24,6 @@ object WeaponMeleeCore {
|
||||
|
||||
}
|
||||
|
||||
abstract class WeaponMeleeBase(originalID: ItemID) : GameItem(originalID) {
|
||||
abstract class WeaponMeleeBase : GameItem() {
|
||||
abstract val velocityMod: Double
|
||||
}
|
||||
@@ -1,16 +1,17 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.blockproperties.Wire
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-03-10.
|
||||
*/
|
||||
class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
|
||||
class WirePieceSignalWire(override val originalID: ItemID) : GameItem() {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "ITEM_WIRE"
|
||||
@@ -22,7 +23,7 @@ class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
override val itemImage: TextureRegion?
|
||||
get() = AppLoader.resourcePool.getAsTextureRegionPack("basegame.items16").get(1,9)
|
||||
get() = (AppLoader.resourcePool["basegame.items16"] as TextureRegionPack).get(1,9)
|
||||
|
||||
init {
|
||||
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.toInt
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.GdxColorMap
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
|
||||
@@ -5,7 +5,7 @@ import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
import net.torvald.terrarum.modulebasegame.worldgenerator.WorldGenerator
|
||||
import net.torvald.terrarum.utils.JsonFetcher
|
||||
import net.torvald.terrarum.worlddrawer.CreateTileAtlas
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import net.torvald.terrarum.worlddrawer.WorldCamera
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
@@ -52,8 +51,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
lateinit var mixedWeather: BaseModularWeather
|
||||
|
||||
var globalLightNow = Cvec()
|
||||
private set
|
||||
val globalLightNow = Color(0)
|
||||
|
||||
// Weather indices
|
||||
const val WEATHER_GENERIC = "generic"
|
||||
@@ -135,7 +133,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
// calculate global light
|
||||
val globalLight = getGradientColour(skyboxColourMap, 2, timeNow)
|
||||
globalLightNow = Cvec(globalLight.r, globalLight.g, globalLight.b, globalLight.a)
|
||||
globalLightNow.set(globalLight)
|
||||
|
||||
|
||||
/* (copied from the shader source)
|
||||
@@ -180,10 +178,8 @@ internal object WeatherMixer : RNGConsumer {
|
||||
/**
|
||||
* Get a GL of specific time
|
||||
*/
|
||||
fun getGlobalLightOfTime(timeInSec: Int): Cvec {
|
||||
val c = getGradientColour(currentWeather.skyboxGradColourMap, 2, timeInSec)
|
||||
return Cvec(c.r, c.g, c.b, c.a)
|
||||
}
|
||||
fun getGlobalLightOfTime(timeInSec: Int): Color =
|
||||
getGradientColour(currentWeather.skyboxGradColourMap, 2, timeInSec)
|
||||
|
||||
fun getGradientColour(colorMap: GdxColorMap, row: Int, timeInSec: Int): Color {
|
||||
val dataPointDistance = WorldTime.DAY_LENGTH / colorMap.width
|
||||
|
||||
@@ -5,7 +5,7 @@ import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.gameactors.AVKey
|
||||
import net.torvald.terrarum.gameactors.Actor
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.*
|
||||
import net.torvald.terrarum.roundInt
|
||||
|
||||
@@ -140,10 +140,10 @@ class BasicDebugInfoWindow : UICanvas() {
|
||||
val mtX = mouseTileX.toString()
|
||||
val mtY = mouseTileY.toString()
|
||||
val valRaw = LightmapRenderer.getLight(mouseTileX, mouseTileY)
|
||||
val rawR = valRaw?.vec?.lane(0)?.times(100f)?.round()?.div(100f)
|
||||
val rawG = valRaw?.vec?.lane(1)?.times(100f)?.round()?.div(100f)
|
||||
val rawB = valRaw?.vec?.lane(2)?.times(100f)?.round()?.div(100f)
|
||||
val rawA = valRaw?.vec?.lane(3)?.times(100f)?.round()?.div(100f)
|
||||
val rawR = valRaw?.r?.times(100f)?.round()?.div(100f)
|
||||
val rawG = valRaw?.g?.times(100f)?.round()?.div(100f)
|
||||
val rawB = valRaw?.b?.times(100f)?.round()?.div(100f)
|
||||
val rawA = valRaw?.a?.times(100f)?.round()?.div(100f)
|
||||
|
||||
lightVal = if (valRaw == null) "—"
|
||||
else "$rawR $rawG $rawB $rawA"
|
||||
|
||||
@@ -161,10 +161,6 @@ internal object BlocksDrawer {
|
||||
private val connectLut47 = intArrayOf(17,1,17,1,2,3,2,14,17,1,17,1,2,3,2,14,9,7,9,7,4,5,4,35,9,7,9,7,16,37,16,15,17,1,17,1,2,3,2,14,17,1,17,1,2,3,2,14,9,7,9,7,4,5,4,35,9,7,9,7,16,37,16,15,8,10,8,10,0,12,0,43,8,10,8,10,0,12,0,43,11,13,11,13,6,20,6,34,11,13,11,13,36,33,36,46,8,10,8,10,0,12,0,43,8,10,8,10,0,12,0,43,30,42,30,42,38,26,38,18,30,42,30,42,23,45,23,31,17,1,17,1,2,3,2,14,17,1,17,1,2,3,2,14,9,7,9,7,4,5,4,35,9,7,9,7,16,37,16,15,17,1,17,1,2,3,2,14,17,1,17,1,2,3,2,14,9,7,9,7,4,5,4,35,9,7,9,7,16,37,16,15,8,28,8,28,0,41,0,21,8,28,8,28,0,41,0,21,11,44,11,44,6,27,6,40,11,44,11,44,36,19,36,32,8,28,8,28,0,41,0,21,8,28,8,28,0,41,0,21,30,29,30,29,38,39,38,25,30,29,30,29,23,24,23,22)
|
||||
private val connectLut16 = intArrayOf(0,2,0,2,4,6,4,6,0,2,0,2,4,6,4,6,8,10,8,10,12,14,12,14,8,10,8,10,12,14,12,14,0,2,0,2,4,6,4,6,0,2,0,2,4,6,4,6,8,10,8,10,12,14,12,14,8,10,8,10,12,14,12,14,1,3,1,3,5,7,5,7,1,3,1,3,5,7,5,7,9,11,9,11,13,15,13,15,9,11,9,11,13,15,13,15,1,3,1,3,5,7,5,7,1,3,1,3,5,7,5,7,9,11,9,11,13,15,13,15,9,11,9,11,13,15,13,15,0,2,0,2,4,6,4,6,0,2,0,2,4,6,4,6,8,10,8,10,12,14,12,14,8,10,8,10,12,14,12,14,0,2,0,2,4,6,4,6,0,2,0,2,4,6,4,6,8,10,8,10,12,14,12,14,8,10,8,10,12,14,12,14,1,3,1,3,5,7,5,7,1,3,1,3,5,7,5,7,9,11,9,11,13,15,13,15,9,11,9,11,13,15,13,15,1,3,1,3,5,7,5,7,1,3,1,3,5,7,5,7,9,11,9,11,13,15,13,15,9,11,9,11,13,15,13,15)
|
||||
|
||||
init {
|
||||
assert(256 == connectLut47.size && 256 == connectLut16.size)
|
||||
}
|
||||
|
||||
/**
|
||||
* Tiles that half-transparent and has hue
|
||||
* will blend colour using colour multiplication
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import jdk.incubator.vector.FloatVector
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
|
||||
/**
|
||||
* Get and compile your OpenJDK-Panama for linux/mac/windows at https://jdk.java.net/panama/
|
||||
* Or use pre-built ones in https://github.com/minjaesong/openjdk13-vectorintrinsic/tree/master
|
||||
*
|
||||
* NOTE: Panama's new vectors are all immutable.
|
||||
* NOTE2: Class inlining vastly improves the performance
|
||||
*
|
||||
* Created by minjaesong on 2019-05-20.
|
||||
*/
|
||||
inline class Cvec constructor(val vec: FloatVector) {
|
||||
|
||||
/*
|
||||
Test log
|
||||
|
||||
I ran with following jvm args:
|
||||
-XX:TypeProfileLevel=121 -XX:+UseVectorApiIntrinsics --add-modules=jdk.incubator.vector
|
||||
and it's slower than the legacy.
|
||||
|
||||
This time I removed the TypeProfileLevel part. It now runs slightly faster than the legacy?
|
||||
-XX:+UseVectorApiIntrinsics --add-modules=jdk.incubator.vector
|
||||
|
||||
<<append from here>>
|
||||
*/
|
||||
|
||||
constructor(floatArray: FloatArray) : this(FloatVector.fromArray(SPECIES, floatArray, 0))
|
||||
constructor(r: Float, g: Float, b: Float, a: Float) : this(FloatVector.scalars(SPECIES, r, g, b, a))
|
||||
constructor(scalar: Float) : this(FloatVector.scalars(SPECIES, scalar, scalar, scalar, scalar))
|
||||
constructor() : this(FloatVector.zero(SPECIES))
|
||||
|
||||
companion object {
|
||||
private val EPSILON = 1f / 512f
|
||||
private val SPECIES = FloatVector.SPECIES_128
|
||||
}
|
||||
|
||||
//fun cpy(): Cvec = Cvec(this.vec)
|
||||
|
||||
fun multiply(other: FloatVector) = Cvec(vec.mul(other))
|
||||
infix operator fun times(other: Cvec) = multiply(other.vec)
|
||||
infix operator fun times(scalar: Float) = Cvec(vec.mul(scalar))
|
||||
|
||||
fun subtract(other: FloatVector) = Cvec(vec.sub(other))
|
||||
infix operator fun minus(other: Cvec) = subtract(other.vec)
|
||||
infix operator fun minus(scalar: Float) = Cvec(vec.sub(scalar))
|
||||
|
||||
fun addition(other: FloatVector) = Cvec(vec.add(other))
|
||||
infix operator fun plus(other: Cvec) = addition(other.vec)
|
||||
infix operator fun plus(scalar: Float) = Cvec(vec.add(scalar))
|
||||
|
||||
fun maximum(other: FloatVector): Cvec = Cvec(vec.max(other))
|
||||
infix fun max(other: Cvec): Cvec = maximum(other.vec)
|
||||
|
||||
/**
|
||||
* true if at least one element in the vector is not zero.
|
||||
*/
|
||||
fun nonZero(): Boolean = vec.mulLanes() != 0f
|
||||
|
||||
fun toRGBA8888(): Int {
|
||||
var acc = 0
|
||||
for (i in 0..3)
|
||||
acc += vec.lane(i).coerceIn(0f, 1f).times(255f).roundToInt().shl(8 * (3 - i))
|
||||
|
||||
return acc
|
||||
}
|
||||
|
||||
/*override fun equals(other: Any?): Boolean {
|
||||
return this.vec.equal((other as Cvec).vec).allTrue()
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -1,5 +1,19 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.blockproperties.BlockCodex
|
||||
import net.torvald.terrarum.fillRect
|
||||
import net.torvald.terrarum.floorInt
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
import java.util.*
|
||||
|
||||
/**
|
||||
* Warning: you are not going to store float value to the lightmap -- see RGB_HDR_LUT (beziér)
|
||||
*
|
||||
@@ -10,7 +24,7 @@ package net.torvald.terrarum.worlddrawer
|
||||
|
||||
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
||||
|
||||
/*object LightmapRendererOld {
|
||||
object LightmapRendererOld {
|
||||
lateinit var world: GameWorld
|
||||
|
||||
|
||||
@@ -757,4 +771,4 @@ package net.torvald.terrarum.worlddrawer
|
||||
}
|
||||
return (1f - scale) * startValue + scale * endValue
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.torvald.terrarum.concurrent.ParallelUtils.sliceEvenly
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.BlockAddress
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.modulebasegame.IngameRenderer
|
||||
import net.torvald.terrarum.realestate.LandUtil
|
||||
@@ -34,6 +33,7 @@ import net.torvald.terrarum.realestate.LandUtil
|
||||
*/
|
||||
object LightmapRenderer {
|
||||
private const val TILE_SIZE = CreateTileAtlas.TILE_SIZE
|
||||
private const val SQRT2 = 1.41421356f
|
||||
|
||||
private var world: GameWorld = GameWorld.makeNullWorld()
|
||||
private lateinit var lightCalcShader: ShaderProgram
|
||||
@@ -72,8 +72,8 @@ object LightmapRenderer {
|
||||
|
||||
// TODO resize(int, int) -aware
|
||||
|
||||
var LIGHTMAP_WIDTH = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.WIDTH).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
var LIGHTMAP_HEIGHT = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.HEIGHT).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
val LIGHTMAP_WIDTH = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.WIDTH).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
val LIGHTMAP_HEIGHT = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.HEIGHT).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
|
||||
val noopMask = HashSet<Point2i>((LIGHTMAP_WIDTH + LIGHTMAP_HEIGHT) * 2)
|
||||
|
||||
@@ -82,8 +82,52 @@ object LightmapRenderer {
|
||||
*/
|
||||
// it utilises alpha channel to determine brightness of "glow" sprites (so that alpha channel works like UV light)
|
||||
//private val lightmap: Array<Array<Color>> = Array(LIGHTMAP_HEIGHT) { Array(LIGHTMAP_WIDTH, { Color(0f,0f,0f,0f) }) } // Can't use framebuffer/pixmap -- this is a fvec4 array, whereas they are ivec4.
|
||||
private var lightmap: Array<Cvec> = Array(LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT) { Cvec() } // Can't use framebuffer/pixmap -- this is a fvec4 array, whereas they are ivec4.
|
||||
private val lanternMap = HashMap<BlockAddress, Cvec>((Terrarum.ingame?.ACTORCONTAINER_INITIAL_SIZE ?: 2) * 4)
|
||||
private val lightmap: Array<Color> = Array(LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT) { Color(0f,0f,0f,0f) } // Can't use framebuffer/pixmap -- this is a fvec4 array, whereas they are ivec4.
|
||||
|
||||
/**
|
||||
* Sstores both the block light sources and actor light sources.
|
||||
*/
|
||||
//private val lightSourcesMap = HashMap<BlockAddress, Color>((Terrarum.ingame?.ACTORCONTAINER_INITIAL_SIZE ?: 2) * 4)
|
||||
private val lightSourcesMap = Array<Color>(LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT) { Color(0) }
|
||||
private fun toLightOffset(y: Int, x: Int): Int {
|
||||
val xpos = x - for_x_start + overscan_open
|
||||
val ypos = y - for_y_start + overscan_open
|
||||
val index = ypos * LIGHTMAP_WIDTH + xpos
|
||||
|
||||
if (index >= lightSourcesMap.size)
|
||||
println("$x, $y | $xpos, $ypos | $for_x_start, $for_y_start | $index")
|
||||
|
||||
return index
|
||||
}
|
||||
private fun getLightSourceMap(worldX: Int, worldY: Int) =
|
||||
lightSourcesMap[toLightOffset(worldX, worldY)]
|
||||
private fun setLightSourcesMap(worldX: Int, worldY: Int, value: Color) {
|
||||
lightSourcesMap[toLightOffset(worldX, worldY)] = value
|
||||
}
|
||||
private fun mixLightSourcesMap(worldX: Int, worldY: Int, value: Color) {
|
||||
lightSourcesMap[toLightOffset(worldX, worldY)].maxAndAssign(value)
|
||||
}
|
||||
private fun clearLightSourcesOffset() {
|
||||
for (i in 0 until lightSourcesMap.size) { lightSourcesMap[i] = Color(0) }
|
||||
}
|
||||
/**
|
||||
* Pair of: Regular shade, the former shade times 1.4142
|
||||
*/
|
||||
//private val shadesMap = HashMap<BlockAddress, Pair<Color, Color>>((Terrarum.ingame?.ACTORCONTAINER_INITIAL_SIZE ?: 2) * 4)
|
||||
private val shadesMap = Array<Pair<Color, Color>>(LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT) { Color(0) to Color(0) }
|
||||
private fun getShadesMap(worldX: Int, worldY: Int) =
|
||||
shadesMap[toLightOffset(worldX, worldY)]
|
||||
private fun setShadesMap(worldX: Int, worldY: Int, value: Color) {
|
||||
shadesMap[toLightOffset(worldX, worldY)] = value to (value.cpy().mul(SQRT2))
|
||||
}
|
||||
private fun mixShadesMap(worldX: Int, worldY: Int, value: Color) {
|
||||
val field = shadesMap[toLightOffset(worldX, worldY)]
|
||||
val baseval = field.first.maxAndAssign(value)
|
||||
field.second.set(baseval); field.second.mul(SQRT2)
|
||||
}
|
||||
private fun clearShadesMap() {
|
||||
for (i in 0 until shadesMap.size) { shadesMap[i] = Color(0) to Color(0) }
|
||||
}
|
||||
|
||||
init {
|
||||
printdbg(this, "Overscan open: $overscan_open; opaque: $overscan_opaque")
|
||||
@@ -120,13 +164,13 @@ object LightmapRenderer {
|
||||
* @param x world tile coord
|
||||
* @param y world tile coord
|
||||
*/
|
||||
internal fun getLight(x: Int, y: Int): Cvec? {
|
||||
internal fun getLight(x: Int, y: Int): Color? {
|
||||
val col = getLightInternal(x, y)
|
||||
if (col == null) {
|
||||
return null
|
||||
}
|
||||
else {
|
||||
return col * MUL_FLOAT
|
||||
return Color(col.r * MUL_FLOAT, col.g * MUL_FLOAT, col.b * MUL_FLOAT, col.a * MUL_FLOAT)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +181,7 @@ object LightmapRenderer {
|
||||
* @param y world tile coord
|
||||
*/
|
||||
// TODO in regard of "colour math against integers", return Int?
|
||||
private fun getLightInternal(x: Int, y: Int): Cvec? {
|
||||
private fun getLightInternal(x: Int, y: Int): Color? {
|
||||
if (y - for_y_start + overscan_open in 0 until LIGHTMAP_HEIGHT &&
|
||||
x - for_x_start + overscan_open in 0 until LIGHTMAP_WIDTH) {
|
||||
|
||||
@@ -164,7 +208,7 @@ object LightmapRenderer {
|
||||
* @param colour Color to write
|
||||
* @param applyFun A function ```foo(old_colour, given_colour)```
|
||||
*/
|
||||
private fun setLightOf(list: Array<Cvec>, x: Int, y: Int, colour: Cvec, applyFun: (Cvec, Cvec) -> Cvec = { _, c -> c }) {
|
||||
private fun setLightOf(list: Array<Color>, x: Int, y: Int, colour: Color, applyFun: (Color, Color) -> Color = { _, c -> c }) {
|
||||
if (y - for_y_start + overscan_open in 0 until LIGHTMAP_HEIGHT &&
|
||||
x - for_x_start + overscan_open in 0 until LIGHTMAP_WIDTH) {
|
||||
|
||||
@@ -201,8 +245,15 @@ object LightmapRenderer {
|
||||
|
||||
//println("$for_x_start..$for_x_end, $for_x\t$for_y_start..$for_y_end, $for_y")
|
||||
|
||||
AppLoader.measureDebugTime("Renderer.Lanterns") {
|
||||
buildLanternmap(actorContainers)
|
||||
// set sunlight
|
||||
sunLight.set(world.globalLight); sunLight.mul(DIV_FLOAT)
|
||||
|
||||
AppLoader.measureDebugTime("Renderer.LightPreload") {
|
||||
// this is to recycle pre-calculated lights and shades for all 4 rounds.
|
||||
// the old code always re-calculates them (calls 'getLightsAndShades()') for every blocks for every round.
|
||||
// the light source information can also be used to create no-op mask? I'm sceptical about that, there must
|
||||
// exist some edge cases like the other time...
|
||||
buildLightSourcesMap(actorContainers)
|
||||
} // usually takes 3000 ns
|
||||
|
||||
/*
|
||||
@@ -219,9 +270,6 @@ object LightmapRenderer {
|
||||
* If you run only 4 sets, orthogonal/diagonal artefacts are bound to occur,
|
||||
*/
|
||||
|
||||
// set sunlight
|
||||
sunLight = world.globalLight * DIV_FLOAT
|
||||
|
||||
// set no-op mask from solidity of the block
|
||||
AppLoader.measureDebugTime("Renderer.LightNoOpMask") {
|
||||
noopMask.clear()
|
||||
@@ -245,6 +293,7 @@ object LightmapRenderer {
|
||||
// The skipping is dependent on how you get ambient light,
|
||||
// in this case we have 'spillage' due to the fact calculate() samples 3x3 area.
|
||||
|
||||
|
||||
AppLoader.measureDebugTime("Renderer.LightTotal") {
|
||||
// Round 2
|
||||
for (y in for_y_end + overscan_open downTo for_y_start) {
|
||||
@@ -331,8 +380,22 @@ object LightmapRenderer {
|
||||
internal data class ThreadedLightmapUpdateMessage(val x: Int, val y: Int)
|
||||
|
||||
|
||||
private fun buildLanternmap(actorContainers: Array<out List<ActorWithBody>?>) {
|
||||
lanternMap.clear()
|
||||
private var _block = 0
|
||||
private var _blockProp = BlockCodex[0]
|
||||
private var _wall = 0
|
||||
private var _blockLum = Color(0)
|
||||
private var _fluid = GameWorld.FluidInfo(Fluid.NULL, 0f)
|
||||
private var _fluidProp = BlockCodex[_fluid.type]
|
||||
private var _tileAddr = 0L
|
||||
private var _fluidAmountToCol = Color(0)
|
||||
|
||||
private fun buildLightSourcesMap(actorContainers: Array<out List<ActorWithBody>?>) {
|
||||
clearLightSourcesOffset()
|
||||
clearShadesMap()
|
||||
|
||||
//lightSourcesMapOffset.set(for_x_start - overscan_open, for_y_start + overscan_open)
|
||||
|
||||
// lanterns from actors
|
||||
actorContainers.forEach { actorContainer ->
|
||||
actorContainer?.forEach {
|
||||
if (it is Luminous && it is ActorWBMovable) {
|
||||
@@ -349,17 +412,55 @@ object LightmapRenderer {
|
||||
|
||||
val normalisedColor = it.color//.cpy().mul(DIV_FLOAT)
|
||||
|
||||
lanternMap[LandUtil.getBlockAddr(world, x, y)] = normalisedColor
|
||||
//lanternMap[Point2i(x, y)] = normalisedColor
|
||||
//lightSourcesMap[LandUtil.getBlockAddr(world, x, y)] = normalisedColor
|
||||
setLightSourcesMap(x, y, normalisedColor)
|
||||
|
||||
//lightSourcesMap[Point2i(x, y)] = normalisedColor
|
||||
// Q&D fix for Roundworld anomaly
|
||||
//lanternMap[Point2i(x + world.width, y)] = normalisedColor
|
||||
//lanternMap[Point2i(x - world.width, y)] = normalisedColor
|
||||
//lightSourcesMap[Point2i(x + world.width, y)] = normalisedColor
|
||||
//lightSourcesMap[Point2i(x - world.width, y)] = normalisedColor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// light sources and shades from a block
|
||||
for (y in for_y_start - overscan_open..for_y_end + overscan_open) {
|
||||
for (x in for_x_start - overscan_open..for_x_end + overscan_open) {
|
||||
_block = world.getTileFromTerrain(x, y) ?: Block.STONE
|
||||
_blockProp = BlockCodex[_block]
|
||||
_wall = world.getTileFromWall(x, y) ?: Block.STONE
|
||||
_blockLum = _blockProp.luminosity
|
||||
_fluid = world.getFluid(x, y)
|
||||
_fluidProp = BlockCodex[_fluid.type]
|
||||
_tileAddr = LandUtil.getBlockAddr(world, x, y)
|
||||
_fluidAmountToCol = Color(_fluid.amount.coerceIn(0f, 1f))
|
||||
|
||||
// light sources from blocks //
|
||||
|
||||
// mix with the existing value
|
||||
mixLightSourcesMap(x, y, _blockLum)
|
||||
|
||||
// see if sunlight is applicable. If it does, mix with the existing value
|
||||
if ((_block == AIR && _wall == AIR) || (_blockLum.nonZero() && _wall == AIR)) {
|
||||
mixLightSourcesMap(x, y, sunLight)
|
||||
}
|
||||
|
||||
// mix the lava light
|
||||
if (_fluid.type != Fluid.NULL) {
|
||||
mixLightSourcesMap(x, y, _fluidProp.luminosity mul _fluidAmountToCol)
|
||||
}
|
||||
|
||||
// deal with the shades //
|
||||
|
||||
// shade from the block
|
||||
setShadesMap(x, y, _blockProp.opacity)
|
||||
// shade from the fluid
|
||||
mixShadesMap(x, y, _fluidProp.opacity mul _fluidAmountToCol)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildNoopMask() {
|
||||
@@ -394,15 +495,15 @@ object LightmapRenderer {
|
||||
|
||||
|
||||
//private val ambientAccumulator = Color(0f,0f,0f,0f)
|
||||
private var lightLevelThis = Cvec()
|
||||
private var thisTerrain = 0
|
||||
private var thisFluid = GameWorld.FluidInfo(Fluid.NULL, 0f)
|
||||
private var fluidAmountToCol = Cvec()
|
||||
private var thisWall = 0
|
||||
private var thisTileLuminosity = Cvec()
|
||||
private var thisTileOpacity = Cvec()
|
||||
private var thisTileOpacity2 = Cvec() // thisTileOpacity * sqrt(2)
|
||||
private var sunLight = Cvec()
|
||||
//private val lightLevelThis = Color(0)
|
||||
//private var thisTerrain = 0
|
||||
//private var thisFluid = GameWorld.FluidInfo(Fluid.NULL, 0f)
|
||||
//private val fluidAmountToCol = Color(0)
|
||||
//private var thisWall = 0
|
||||
//private val thisTileLuminosity = Color(0)
|
||||
//private val thisTileOpacity = Color(0)
|
||||
//private val thisTileOpacity2 = Color(0) // thisTileOpacity * sqrt(2)
|
||||
private val sunLight = Color(0)
|
||||
|
||||
/**
|
||||
* This function will alter following variables:
|
||||
@@ -415,38 +516,41 @@ object LightmapRenderer {
|
||||
* - thisTileOpacity2
|
||||
* - sunlight
|
||||
*/
|
||||
private fun getLightsAndShades(x: Int, y: Int) {
|
||||
lightLevelThis = colourNull
|
||||
/*private fun getLightsAndShades(x: Int, y: Int) {
|
||||
// TODO lanternmap now also holds light sources (incl. sunlight)
|
||||
|
||||
|
||||
lightLevelThis.set(colourNull)
|
||||
thisTerrain = world.getTileFromTerrain(x, y) ?: Block.STONE
|
||||
thisFluid = world.getFluid(x, y)
|
||||
thisWall = world.getTileFromWall(x, y) ?: Block.STONE
|
||||
|
||||
if (thisFluid.type != Fluid.NULL) {
|
||||
fluidAmountToCol = Cvec(thisFluid.amount)
|
||||
fluidAmountToCol.set(thisFluid.amount, thisFluid.amount, thisFluid.amount, thisFluid.amount)
|
||||
|
||||
thisTileLuminosity = BlockCodex[thisTerrain].luminosity
|
||||
thisTileLuminosity = thisTileLuminosity.max(BlockCodex[thisFluid.type].luminosity * fluidAmountToCol) // already been div by four
|
||||
thisTileOpacity = BlockCodex[thisTerrain].opacity
|
||||
thisTileOpacity = thisTileOpacity.max(BlockCodex[thisFluid.type].opacity * fluidAmountToCol) // already been div by four
|
||||
thisTileLuminosity.set(BlockCodex[thisTerrain].luminosity)
|
||||
thisTileLuminosity.maxAndAssign(BlockCodex[thisFluid.type].luminosity mul fluidAmountToCol) // already been div by four
|
||||
thisTileOpacity.set(BlockCodex[thisTerrain].opacity)
|
||||
thisTileOpacity.maxAndAssign(BlockCodex[thisFluid.type].opacity mul fluidAmountToCol) // already been div by four
|
||||
}
|
||||
else {
|
||||
thisTileLuminosity = BlockCodex[thisTerrain].luminosity
|
||||
thisTileOpacity = BlockCodex[thisTerrain].opacity
|
||||
thisTileLuminosity.set(BlockCodex[thisTerrain].luminosity)
|
||||
thisTileOpacity.set(BlockCodex[thisTerrain].opacity)
|
||||
}
|
||||
|
||||
thisTileOpacity2 = thisTileOpacity * 1.41421356f
|
||||
thisTileOpacity2.set(thisTileOpacity); thisTileOpacity2.mul(1.41421356f)
|
||||
//sunLight.set(world.globalLight); sunLight.mul(DIV_FLOAT) // moved to fireRecalculateEvent()
|
||||
|
||||
|
||||
// open air || luminous tile backed by sunlight
|
||||
if ((thisTerrain == AIR && thisWall == AIR) || (thisTileLuminosity.nonZero() && thisWall == AIR)) {
|
||||
lightLevelThis = sunLight
|
||||
lightLevelThis.set(sunLight)
|
||||
}
|
||||
|
||||
// blend lantern
|
||||
lightLevelThis = lightLevelThis.max(thisTileLuminosity).max(lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: colourNull)
|
||||
lightLevelThis.maxAndAssign(thisTileLuminosity).maxAndAssign(lightSourcesMap[LandUtil.getBlockAddr(world, x, y)] ?: colourNull)
|
||||
|
||||
}
|
||||
}*/
|
||||
|
||||
private val inNoopMaskp = Point2i(0,0)
|
||||
|
||||
@@ -499,13 +603,15 @@ object LightmapRenderer {
|
||||
/**
|
||||
* Calculates the light simulation, using main lightmap as one of the input.
|
||||
*/
|
||||
private fun calculateAndAssign(lightmap: Array<Cvec>, x: Int, y: Int) {
|
||||
private fun calculateAndAssign(lightmap: Array<Color>, x: Int, y: Int) {
|
||||
|
||||
if (inNoopMask(x, y)) return
|
||||
|
||||
// O(9n) == O(n) where n is a size of the map
|
||||
|
||||
getLightsAndShades(x, y)
|
||||
//getLightsAndShades(x, y)
|
||||
val lightLevelThis = getLightSourceMap(x, y) // it HAS to be a cpy()...?, otherwise all cells gets the same instance
|
||||
val (thisTileOpacity, thisTileOpacity2) = getShadesMap(x, y)
|
||||
|
||||
// calculate ambient
|
||||
/* + * + 0 4 1
|
||||
@@ -516,28 +622,34 @@ object LightmapRenderer {
|
||||
*/
|
||||
|
||||
// will "overwrite" what's there in the lightmap if it's the first pass
|
||||
// using "map"s actually makes it slower. Guess I'll keep it dirty...
|
||||
// takes about 2 ms on 6700K
|
||||
/* + */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x - 1, y - 1) ?: colourNull, thisTileOpacity2))
|
||||
/* + */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x + 1, y - 1) ?: colourNull, thisTileOpacity2))
|
||||
/* + */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x - 1, y + 1) ?: colourNull, thisTileOpacity2))
|
||||
/* + */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x + 1, y + 1) ?: colourNull, thisTileOpacity2))
|
||||
/* * */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x, y - 1) ?: colourNull, thisTileOpacity))
|
||||
/* * */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x, y + 1) ?: colourNull, thisTileOpacity))
|
||||
/* * */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x - 1, y) ?: colourNull, thisTileOpacity))
|
||||
/* * */lightLevelThis = lightLevelThis.max(darkenColoured(getLightInternal(x + 1, y) ?: colourNull, thisTileOpacity))
|
||||
/* + */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x - 1, y - 1) ?: colourNull, thisTileOpacity2))
|
||||
/* + */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x + 1, y - 1) ?: colourNull, thisTileOpacity2))
|
||||
/* + */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x - 1, y + 1) ?: colourNull, thisTileOpacity2))
|
||||
/* + */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x + 1, y + 1) ?: colourNull, thisTileOpacity2))
|
||||
/* * */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x, y - 1) ?: colourNull, thisTileOpacity))
|
||||
/* * */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x, y + 1) ?: colourNull, thisTileOpacity))
|
||||
/* * */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x - 1, y) ?: colourNull, thisTileOpacity))
|
||||
/* * */lightLevelThis.maxAndAssign(darkenColoured(getLightInternal(x + 1, y) ?: colourNull, thisTileOpacity))
|
||||
|
||||
|
||||
//return lightLevelThis.cpy() // it HAS to be a cpy(), otherwise all cells gets the same instance
|
||||
setLightOf(lightmap, x, y, lightLevelThis)
|
||||
}
|
||||
|
||||
private fun getLightForOpaque(x: Int, y: Int): Cvec? { // ...so that they wouldn't appear too dark
|
||||
private fun getLightForOpaque(x: Int, y: Int): Color? { // ...so that they wouldn't appear too dark
|
||||
val l = getLightInternal(x, y)
|
||||
if (l == null) return null
|
||||
|
||||
// brighten if solid
|
||||
if (BlockCodex[world.getTileFromTerrain(x, y)].isSolid) {
|
||||
return l * 1.2f
|
||||
return Color(
|
||||
(l.r * 1.2f),
|
||||
(l.g * 1.2f),
|
||||
(l.b * 1.2f),
|
||||
(l.a * 1.2f)
|
||||
)
|
||||
}
|
||||
else {
|
||||
return l
|
||||
@@ -546,7 +658,8 @@ object LightmapRenderer {
|
||||
|
||||
var lightBuffer: Pixmap = Pixmap(1, 1, Pixmap.Format.RGBA8888)
|
||||
|
||||
private val colourNull = Cvec()
|
||||
private val colourNull = Color(0)
|
||||
private val epsilon = 1f/1024f
|
||||
|
||||
private var _lightBufferAsTex: Texture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
||||
|
||||
@@ -562,7 +675,7 @@ object LightmapRenderer {
|
||||
|
||||
// wipe out beforehand. You DO need this
|
||||
lightBuffer.blending = Pixmap.Blending.None // gonna overwrite (remove this line causes the world to go bit darker)
|
||||
lightBuffer.setColor(0)
|
||||
lightBuffer.setColor(colourNull)
|
||||
lightBuffer.fill()
|
||||
|
||||
|
||||
@@ -575,11 +688,12 @@ object LightmapRenderer {
|
||||
|
||||
for (x in this_x_start..this_x_end) {
|
||||
|
||||
val color: RGBA8888 = (getLightForOpaque(x, y) ?: Cvec()).normaliseToHDR().toRGBA8888()
|
||||
val color = (getLightForOpaque(x, y) ?: Color(0f, 0f, 0f, 0f)).normaliseToHDR()
|
||||
|
||||
lightBuffer.setColor(color)
|
||||
|
||||
//lightBuffer.drawPixel(x - this_x_start, y - this_y_start)
|
||||
|
||||
lightBuffer.drawPixel(x - this_x_start, lightBuffer.height - 1 - y + this_y_start) // flip Y
|
||||
}
|
||||
}
|
||||
@@ -604,7 +718,6 @@ object LightmapRenderer {
|
||||
|
||||
}
|
||||
|
||||
private val CVEC_ONE = Cvec(1f)
|
||||
val lightScalingMagic = 8f
|
||||
|
||||
/**
|
||||
@@ -614,13 +727,15 @@ object LightmapRenderer {
|
||||
* @param darken (0-255) per channel
|
||||
* @return darkened data (0-255) per channel
|
||||
*/
|
||||
fun darkenColoured(data: Cvec, darken: Cvec): Cvec {
|
||||
fun darkenColoured(data: Color, darken: Color): Color {
|
||||
// use equation with magic number 8.0
|
||||
// this function, when done recursively (A_x = darken(A_x-1, C)), draws exponential curve. (R^2 = 1)
|
||||
|
||||
// equation: data * (1 - darken * magic)
|
||||
|
||||
return data * (CVEC_ONE - darken * lightScalingMagic)
|
||||
return Color(
|
||||
data.r * (1f - darken.r * lightScalingMagic),//.clampZero(),
|
||||
data.g * (1f - darken.g * lightScalingMagic),//.clampZero(),
|
||||
data.b * (1f - darken.b * lightScalingMagic),//.clampZero(),
|
||||
data.a * (1f - darken.a * lightScalingMagic))
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -630,13 +745,13 @@ object LightmapRenderer {
|
||||
* @param darken (0-255)
|
||||
* @return
|
||||
*/
|
||||
/*fun darkenUniformInt(data: Color, darken: Float): Color {
|
||||
fun darkenUniformInt(data: Color, darken: Float): Color {
|
||||
if (darken < 0 || darken > CHANNEL_MAX)
|
||||
throw IllegalArgumentException("darken: out of range ($darken)")
|
||||
|
||||
val darkenColoured = Color(darken, darken, darken, darken)
|
||||
return darkenColoured(data, darkenColoured)
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Darken or brighten colour by 'brighten' argument
|
||||
@@ -645,12 +760,26 @@ object LightmapRenderer {
|
||||
* @param brighten (-1.0 - 1.0) negative means darkening
|
||||
* @return processed colour
|
||||
*/
|
||||
fun alterBrightnessUniform(data: Cvec, brighten: Float): Cvec {
|
||||
// equation = data + brighten
|
||||
|
||||
return data + brighten
|
||||
fun alterBrightnessUniform(data: Color, brighten: Float): Color {
|
||||
return Color(
|
||||
data.r + brighten,
|
||||
data.g + brighten,
|
||||
data.b + brighten,
|
||||
data.a + brighten
|
||||
)
|
||||
}
|
||||
|
||||
/** infix is removed to clarify the association direction */
|
||||
fun Color.maxAndAssign(other: Color): Color {
|
||||
this.set(
|
||||
if (this.r > other.r) this.r else other.r,
|
||||
if (this.g > other.g) this.g else other.g,
|
||||
if (this.b > other.b) this.b else other.b,
|
||||
if (this.a > other.a) this.a else other.a
|
||||
)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
private fun Float.inv() = 1f / this
|
||||
fun Float.floor() = FastMath.floor(this)
|
||||
@@ -691,9 +820,6 @@ object LightmapRenderer {
|
||||
val tilesInHorizontal = (screenW.toFloat() / TILE_SIZE).ceilInt() + 1
|
||||
val tilesInVertical = (screenH.toFloat() / TILE_SIZE).ceilInt() + 1
|
||||
|
||||
LIGHTMAP_WIDTH = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.WIDTH).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
LIGHTMAP_HEIGHT = (Terrarum.ingame?.ZOOM_MINIMUM ?: 1f).inv().times(Terrarum.HEIGHT).div(TILE_SIZE).ceil() + overscan_open * 2 + 3
|
||||
|
||||
if (_init) {
|
||||
lightBuffer.dispose()
|
||||
}
|
||||
@@ -701,7 +827,6 @@ object LightmapRenderer {
|
||||
_init = true
|
||||
}
|
||||
lightBuffer = Pixmap(tilesInHorizontal, tilesInVertical, Pixmap.Format.RGBA8888)
|
||||
lightmap = Array<Cvec>(LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT) { Cvec() }
|
||||
|
||||
|
||||
printdbg(this, "Resize event")
|
||||
@@ -775,11 +900,14 @@ object LightmapRenderer {
|
||||
1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f,1.0000f // isn't it beautiful?
|
||||
)
|
||||
/** To eliminated visible edge on the gradient when 255/1023 is exceeded */
|
||||
internal fun Cvec.normaliseToHDR(): Cvec {
|
||||
// equation: hdr(this.coerceIn)
|
||||
val arr = this.vec.toArray().map { hdr(it.coerceIn(0f, 1f)) }
|
||||
return Cvec(arr.toFloatArray())
|
||||
}
|
||||
internal fun Color.normaliseToHDR() = Color(
|
||||
hdr(this.r.coerceIn(0f,1f)),
|
||||
hdr(this.g.coerceIn(0f,1f)),
|
||||
hdr(this.b.coerceIn(0f,1f)),
|
||||
hdr(this.a.coerceIn(0f,1f))
|
||||
)
|
||||
|
||||
private fun Color.nonZero() = this.r + this.g + this.b + this.a > epsilon
|
||||
|
||||
val histogram: Histogram
|
||||
get() {
|
||||
@@ -795,10 +923,10 @@ object LightmapRenderer {
|
||||
try {
|
||||
//val colour = lightmap[y][x]
|
||||
val colour = lightmap[y * LIGHTMAP_WIDTH + x]
|
||||
reds[minOf(CHANNEL_MAX, colour.vec.lane(0).times(MUL).floorInt())] += 1
|
||||
greens[minOf(CHANNEL_MAX, colour.vec.lane(1).times(MUL).floorInt())] += 1
|
||||
blues[minOf(CHANNEL_MAX, colour.vec.lane(2).times(MUL).floorInt())] += 1
|
||||
uvs[minOf(CHANNEL_MAX, colour.vec.lane(3).times(MUL).floorInt())] += 1
|
||||
reds[minOf(CHANNEL_MAX, colour.r.times(MUL).floorInt())] += 1
|
||||
greens[minOf(CHANNEL_MAX, colour.g.times(MUL).floorInt())] += 1
|
||||
blues[minOf(CHANNEL_MAX, colour.b.times(MUL).floorInt())] += 1
|
||||
uvs[minOf(CHANNEL_MAX, colour.a.times(MUL).floorInt())] += 1
|
||||
}
|
||||
catch (e: ArrayIndexOutOfBoundsException) { }
|
||||
}
|
||||
@@ -866,4 +994,4 @@ object LightmapRenderer {
|
||||
}
|
||||
|
||||
fun Color.toRGBA() = (255 * r).toInt() shl 24 or ((255 * g).toInt() shl 16) or ((255 * b).toInt() shl 8) or (255 * a).toInt()
|
||||
|
||||
//fun Color(c: Float) = Color(c, c, c, c)
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="3" platform="JVM 9">
|
||||
<configuration version="3" platform="JVM 1.8">
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="jvmTarget" value="10" />
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
</compilerArguments>
|
||||
</configuration>
|
||||
</facet>
|
||||
@@ -16,7 +16,7 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/net/torvald/terrarum/tests" isTestSource="true" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="jdk" jdkName="11" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||
<orderEntry type="library" name="lib" level="project" />
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user