mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
Compare commits
10 Commits
light-prel
...
test-cvec-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ae52de85a2 | ||
|
|
585a20542f | ||
|
|
2ab1443885 | ||
|
|
046f2d4b6c | ||
|
|
e3fbb57530 | ||
|
|
92d5cac2ff | ||
|
|
471b0c805d | ||
|
|
16b7457d08 | ||
|
|
5c20ceeedc | ||
|
|
49df5f9676 |
23
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
23
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@@ -0,0 +1,23 @@
|
||||
<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_10" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="false" project-jdk-name="13-incubate" 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.
BIN
assets/mods/basegame/blocks/223.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/223.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/blocks/wire.tga
LFS
Normal file
BIN
assets/mods/basegame/blocks/wire.tga
LFS
Normal file
Binary file not shown.
@@ -1,5 +1,6 @@
|
||||
"id";"classname"
|
||||
"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"
|
||||
"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"
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
// following two are NOT UNUSED!
|
||||
|
||||
40
assets/mods/basegame/sprites/furry_sprite.properties
Normal file
40
assets/mods/basegame/sprites/furry_sprite.properties
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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
|
||||
40
assets/mods/basegame/sprites/furry_sprite_glow.properties
Normal file
40
assets/mods/basegame/sprites/furry_sprite_glow.properties
Normal file
@@ -0,0 +1,40 @@
|
||||
# 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
|
||||
BIN
assets/mods/basegame/sprites/test_furry/furbud_arm_rest_left.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_arm_rest_left.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_arm_rest_right.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_arm_rest_right.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_foot_left.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_foot_left.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_foot_right.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_foot_right.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_hand_rest_left.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_hand_rest_left.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_hand_rest_right.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_hand_rest_right.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_head.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_head.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_leg_rest_left.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_leg_rest_left.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_leg_rest_right.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_leg_rest_right.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_lower_torso.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_lower_torso.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_tail_0.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_tail_0.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_tail_1.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_tail_1.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_tail_2.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_tail_2.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbud_upper_torso.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbud_upper_torso.tga
LFS
Normal file
Binary file not shown.
BIN
assets/mods/basegame/sprites/test_furry/furbudglow_head.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/test_furry/furbudglow_head.tga
LFS
Normal file
Binary file not shown.
@@ -2,6 +2,7 @@
|
||||
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
|
||||
@@ -13,14 +14,15 @@ 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?
|
||||
# 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.
|
||||
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
|
||||
ARM_REST_LEFT 5,24;HAND_REST_LEFT 6,12;\
|
||||
TAIL0 0,13
|
||||
|
||||
# skeleton_stand is used for testing purpose
|
||||
ANIM_RUN=DELAY 0.15;ROW 2;SKELETON SKELETON_STAND
|
||||
|
||||
@@ -56,8 +56,9 @@ task gamedebug(type: JavaExec) {
|
||||
classpath sourceSets.main.runtimeClasspath
|
||||
main = 'net.torvald.terrarum.AppLoader'
|
||||
group = "Application"
|
||||
description = "Launches the game with debuy key."
|
||||
description = "Launches the game with the debug key."
|
||||
args = ["isdev=true"]
|
||||
jvmArgs = ["-ea"]
|
||||
}
|
||||
|
||||
task spriteassembler(type: JavaExec) {
|
||||
|
||||
Binary file not shown.
@@ -11,12 +11,17 @@ 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) {
|
||||
fun reassembleSprite(sprite: SpriteAnimation, spriteGlow: SpriteAnimation? = null) {
|
||||
_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,9 +19,10 @@ class GdxColorMap {
|
||||
height = pixmap.height
|
||||
is2D = pixmap.height > 1
|
||||
|
||||
data = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||
dataRaw = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||
pixmap.getPixel(it % pixmap.width, it / pixmap.width)
|
||||
}
|
||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||
|
||||
pixmap.dispose()
|
||||
}
|
||||
@@ -31,39 +32,46 @@ class GdxColorMap {
|
||||
height = pixmap.height
|
||||
is2D = pixmap.height > 1
|
||||
|
||||
data = kotlin.IntArray(pixmap.width * pixmap.height) {
|
||||
dataRaw = 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) {
|
||||
data = intArrayOf(color.toIntBits())
|
||||
dataRaw = intArrayOf(color.toIntBits())
|
||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||
width = 1
|
||||
height = 1
|
||||
is2D = false
|
||||
}
|
||||
|
||||
constructor(gradStart: Color, gradEnd: Color) {
|
||||
data = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
||||
dataRaw = intArrayOf(gradStart.toIntBits(), gradEnd.toIntBits())
|
||||
dataGdxColor = dataRaw.map { Color(it) }.toTypedArray()
|
||||
width = 1
|
||||
height = 2
|
||||
is2D = true
|
||||
}
|
||||
|
||||
private val data: IntArray
|
||||
private val dataRaw: IntArray
|
||||
private val dataGdxColor: Array<Color>
|
||||
//private val dataCvec: Array<Cvec>
|
||||
val width: Int
|
||||
val height: Int
|
||||
val is2D: Boolean
|
||||
|
||||
|
||||
|
||||
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 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 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]
|
||||
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]
|
||||
|
||||
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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.gameitem.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, forceAssignRefID = Terrarum.PLAYER_REF_ID) {
|
||||
cameraPlayer = object : HumanoidNPC(cameraAI, born = 0, usePhysics = false) {
|
||||
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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.Ingame
|
||||
import net.torvald.terrarum.modulebasegame.ui.UIInventoryFull
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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
|
||||
@@ -8,6 +7,7 @@ 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 = Color(prop.shadeColR, prop.shadeColG, prop.shadeColB, prop.shadeColA)
|
||||
prop.opacity = Cvec(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 = Color(prop.lumColR, prop.lumColG, prop.lumColB, prop.lumColA)
|
||||
prop.internalLumCol = Cvec(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 com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-16.
|
||||
@@ -17,7 +17,7 @@ class BlockProp {
|
||||
var shadeColB = 0f
|
||||
var shadeColA = 0f
|
||||
|
||||
lateinit var opacity: Color
|
||||
var opacity: Cvec = Cvec()
|
||||
|
||||
var strength: Int = 0
|
||||
var density: Int = 0
|
||||
@@ -36,12 +36,12 @@ class BlockProp {
|
||||
var lumColG = 0f
|
||||
var lumColB = 0f
|
||||
var lumColA = 0f
|
||||
lateinit var internalLumCol: Color
|
||||
var internalLumCol: Cvec = Cvec()
|
||||
|
||||
/**
|
||||
* @param luminosity
|
||||
*/
|
||||
inline val luminosity: Color
|
||||
inline val luminosity: Cvec
|
||||
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: Color): Color {
|
||||
private fun getTorchFlicker(baseLum: Cvec): Cvec {
|
||||
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: Color): Color {
|
||||
private fun getSlowBreath(baseLum: Cvec): Cvec {
|
||||
val funcY = FastMath.sin(FastMath.PI * breathFuncX / breathCycleDuration) * breathRange
|
||||
|
||||
return LightmapRenderer.alterBrightnessUniform(baseLum, funcY)
|
||||
}
|
||||
|
||||
private fun getPulsate(baseLum: Color): Color {
|
||||
private fun getPulsate(baseLum: Cvec): Cvec {
|
||||
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: Color, type: Int): Color {
|
||||
fun getDynamicLumFunc(baseLum: Cvec, type: Int): Cvec {
|
||||
return when (type) {
|
||||
1 -> getTorchFlicker(baseLum)
|
||||
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
|
||||
2 -> (Terrarum.ingame!!.world).globalLight * LightmapRenderer.DIV_FLOAT // current global light
|
||||
3 -> WeatherMixer.getGlobalLightOfTime(WorldTime.DAY_LENGTH / 2) * LightmapRenderer.DIV_FLOAT // daylight at noon
|
||||
4 -> getSlowBreath(baseLum)
|
||||
5 -> getPulsate(baseLum)
|
||||
else -> baseLum
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.torvald.terrarum.console
|
||||
|
||||
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
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
import net.torvald.terrarum.worlddrawer.LightmapRenderer
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-17.
|
||||
@@ -14,11 +13,12 @@ internal object SetGlobalLightOverride : ConsoleCommand {
|
||||
override fun execute(args: Array<String>) {
|
||||
if (args.size == 5) {
|
||||
try {
|
||||
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)
|
||||
val GL = Cvec(
|
||||
args[1].toFloat(),
|
||||
args[2].toFloat(),
|
||||
args[3].toFloat(),
|
||||
args[4].toFloat()
|
||||
)
|
||||
|
||||
WeatherMixer.globalLightOverridden = true
|
||||
(Terrarum.ingame!!.world).globalLight = GL
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-02-19.
|
||||
@@ -26,7 +26,7 @@ interface Luminous {
|
||||
actorValue[AVKey.LUMA] = value.a * LightmapRenderer.MUL_FLOAT
|
||||
}
|
||||
*/
|
||||
var color: Color
|
||||
var color: Cvec
|
||||
|
||||
/**
|
||||
* Arguments:
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
package net.torvald.terrarum.itemproperties
|
||||
package net.torvald.terrarum.gameitem
|
||||
|
||||
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
|
||||
@@ -12,15 +14,18 @@ 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 : Comparable<GameItem>, Cloneable {
|
||||
abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneable {
|
||||
|
||||
abstract var dynamicID: ItemID
|
||||
open var dynamicID: ItemID = originalID
|
||||
/**
|
||||
* 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!!
|
||||
|
||||
|
||||
/**
|
||||
@@ -268,6 +273,7 @@ abstract class GameItem : Comparable<GameItem>, Cloneable {
|
||||
@JvmStatic val BLOCK = "block"
|
||||
@JvmStatic val WALL = "wall"
|
||||
@JvmStatic val WIRE = "wire"
|
||||
@JvmStatic val FIXTURE = "fixture"
|
||||
@JvmStatic val MISC = "misc"
|
||||
}
|
||||
|
||||
@@ -281,7 +287,7 @@ abstract class GameItem : Comparable<GameItem>, Cloneable {
|
||||
|
||||
|
||||
fun generateUniqueDynamicID(inventory: ActorInventory): GameItem {
|
||||
dynamicID = GameItem.generateUniqueDynamicID(inventory)
|
||||
dynamicID = Companion.generateUniqueDynamicID(inventory)
|
||||
ItemCodex.registerNewDynamicItem(dynamicID, this)
|
||||
return this
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
|
||||
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
|
||||
@@ -10,6 +9,7 @@ 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 = Color(0f,0f,0f,0f)
|
||||
var globalLight = Cvec()
|
||||
var averageTemperature = 288f // 15 deg celsius; simulates global warming
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ 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
|
||||
@@ -174,9 +176,7 @@ object ItemCodex {
|
||||
|
||||
|
||||
// test water bucket
|
||||
itemCodex[9000] = object : GameItem() {
|
||||
override var dynamicID: ItemID = 9000
|
||||
override val originalID: ItemID = 9000
|
||||
itemCodex[9000] = object : GameItem(9000) {
|
||||
|
||||
override val isUnique: Boolean = true
|
||||
override val originalName: String = "Infinite Water Bucket"
|
||||
@@ -203,9 +203,7 @@ object ItemCodex {
|
||||
|
||||
|
||||
// test lava bucket
|
||||
itemCodex[9001] = object : GameItem() {
|
||||
override var dynamicID: ItemID = 9001
|
||||
override val originalID: ItemID = 9001
|
||||
itemCodex[9001] = object : GameItem(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.itemproperties.ItemID
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.GameWorldExtension
|
||||
import net.torvald.terrarum.modulebasegame.gameworld.WorldTime
|
||||
@@ -27,6 +27,7 @@ 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
|
||||
@@ -279,7 +280,7 @@ class BuildingMaker(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
init {
|
||||
gameWorld.time.setTimeOfToday(WorldTime.HOUR_SEC * 10)
|
||||
gameWorld.globalLight = Color(.8f,.8f,.8f,.8f)
|
||||
gameWorld.globalLight = Cvec(.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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,9 +56,7 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
val blockProp = BlockCodex.getOrNull(i % ItemCodex.ITEM_WALLS.first)
|
||||
|
||||
if (blockProp != null) {
|
||||
ItemCodex.itemCodex[i] = object : GameItem() {
|
||||
override val originalID = i
|
||||
override var dynamicID = i
|
||||
ItemCodex.itemCodex[i] = object : GameItem(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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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: Color
|
||||
get() = Color(
|
||||
override var color: Cvec
|
||||
get() = Cvec(
|
||||
(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.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
|
||||
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
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,9 +154,7 @@ open class ActorHumanoid(
|
||||
get() = if (Terrarum.ingame == null) false else this == Terrarum.ingame!!.actorNowPlaying
|
||||
|
||||
|
||||
@Transient private val nullItem = object : GameItem() {
|
||||
override var dynamicID: Int = 0
|
||||
override val originalID = dynamicID
|
||||
@Transient private val nullItem = object : GameItem(0) {
|
||||
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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.ItemID
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,10 +27,11 @@ open class FixtureBase(val blockBox: BlockBox, val blockBoxProps: BlockBoxProps
|
||||
/**
|
||||
* Adds this instance of the fixture to the world
|
||||
*
|
||||
* @param posX top-left position of the fixture, tile-wise
|
||||
* @param posY top-left position of the fixture, tile-wise
|
||||
* @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)
|
||||
*/
|
||||
open fun spawn(posX: Int, posY: Int) {
|
||||
open fun spawn(posX: Int, posY: Int): Boolean {
|
||||
// place filler blocks
|
||||
// place the filler blocks where:
|
||||
// origin posX: centre-left if mouseX is on the right-half of the game window,
|
||||
@@ -52,6 +53,9 @@ 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: Color
|
||||
override var color: Cvec
|
||||
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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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,9 +29,7 @@ open class HumanoidNPC(
|
||||
}
|
||||
|
||||
// we're having GameItem data so that this class could be somewhat universal
|
||||
override var itemData: GameItem = object : GameItem() {
|
||||
override var dynamicID = referenceID ?: forceAssignRefID!!
|
||||
override val originalID = dynamicID
|
||||
override var itemData: GameItem = object : GameItem(referenceID) {//GameItem(referenceID ?: forceAssignRefID!!) {
|
||||
override val isUnique = true
|
||||
override var baseMass: Double
|
||||
get() = actorValue.getAsDouble(AVKey.BASEMASS)!!
|
||||
|
||||
@@ -11,7 +11,11 @@ import net.torvald.terrarum.modulebasegame.gameworld.time_t
|
||||
* Created by minjaesong on 2015-12-31.
|
||||
*/
|
||||
|
||||
class IngamePlayer(override var animDescPath: String, born: time_t) : ActorHumanoid(born), HasAssembledSprite {
|
||||
class IngamePlayer(
|
||||
override var animDescPath: String,
|
||||
override var animDescPathGlow: String? = null,
|
||||
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", world.time.TIME_T)
|
||||
val p: Actor = IngamePlayer("lol", "lol_glow", 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", - 9223372036854775807L) // XD
|
||||
val p = IngamePlayer("lol", "lol_glow", - 9223372036854775807L) // XD
|
||||
|
||||
p.referenceID = 0x51621D // the only constant of this procedural universe
|
||||
|
||||
@@ -82,10 +82,13 @@ 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,14 +4,17 @@ 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/test_sprite.properties"), -589141658L) // random value thrown
|
||||
val p: IngamePlayer = IngamePlayer(
|
||||
ModMgr.getPath("basegame", "sprites/furry_sprite.properties"),
|
||||
ModMgr.getPath("basegame", "sprites/furry_sprite_glow.properties"),
|
||||
-589141658L // random value thrown
|
||||
)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureHuman.json")
|
||||
|
||||
|
||||
@@ -26,7 +29,8 @@ object PlayerBuilderTestSubject1 {
|
||||
p.sprite!!.setRowsAndFrames(2, 4)*/
|
||||
|
||||
p.sprite = SpriteAnimation(p)
|
||||
p.reassembleSprite(p.sprite!!)
|
||||
p.spriteGlow = SpriteAnimation(p)
|
||||
p.reassembleSprite(p.sprite!!, p.spriteGlow)
|
||||
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)
|
||||
@@ -34,10 +38,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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-01-15.
|
||||
|
||||
@@ -9,6 +9,7 @@ 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.*
|
||||
|
||||
@@ -31,8 +32,8 @@ open class ProjectileSimple(
|
||||
val speed: Int
|
||||
|
||||
|
||||
override var color: Color
|
||||
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Color).cpy()
|
||||
override var color: Cvec
|
||||
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Cvec)
|
||||
set(value) {
|
||||
}
|
||||
/**
|
||||
@@ -118,8 +119,8 @@ open class ProjectileSimple(
|
||||
val OFFSET_LUMINOSITY = 4
|
||||
val bulletDatabase = arrayOf(
|
||||
// damage, display colour, no gravity, speed
|
||||
arrayOf(7, Color(0xFF5429_FF.toInt()), true, 40, 32),
|
||||
arrayOf(8, Color(0xFF5429_FF.toInt()), true, 20, 0)
|
||||
arrayOf(7, Cvec(1f, .329f, .161f, 1f), true, 40, 32),
|
||||
arrayOf(8, Cvec(1f, .329f, .161f, 1f), true, 20, 0)
|
||||
// ...
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import net.torvald.terrarum.gameactors.ActorWBMovable
|
||||
import net.torvald.terrarum.gameactors.Hitbox
|
||||
import net.torvald.terrarum.gameactors.Luminous
|
||||
import net.torvald.terrarum.gameworld.GameWorld
|
||||
import net.torvald.terrarum.worlddrawer.Cvec
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2016-04-26.
|
||||
@@ -21,7 +20,7 @@ class WeaponSwung(val itemID: Int) : ActorWBMovable(RenderOrder.MIDTOP), Luminou
|
||||
actorValue[AVKey.LUMINOSITY] = value
|
||||
}
|
||||
*/
|
||||
override var color: Color
|
||||
override var color: Cvec
|
||||
get() = throw UnsupportedOperationException()
|
||||
set(value) {
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.items
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
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.items.PickaxeCore.BASE_MASS_AND_SIZE
|
||||
import net.torvald.terrarum.modulebasegame.items.PickaxeCore.TOOL_DURABILITY_BASE
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.BASE_MASS_AND_SIZE
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.PickaxeCore.TOOL_DURABILITY_BASE
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@@ -74,9 +74,8 @@ object PickaxeCore {
|
||||
/**
|
||||
* Created by minjaesong on 2017-07-17.
|
||||
*/
|
||||
class PickaxeCopper(override val originalID: ItemID) : GameItem() {
|
||||
class PickaxeCopper(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "PACKAGED_PICK"
|
||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||
override var stackable = true
|
||||
@@ -102,9 +101,8 @@ class PickaxeCopper(override val originalID: ItemID) : GameItem() {
|
||||
/**
|
||||
* Created by minjaesong on 2019-03-10.
|
||||
*/
|
||||
class PickaxeIron(override val originalID: ItemID) : GameItem() {
|
||||
class PickaxeIron(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "PACKAGED_PICK"
|
||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||
override var stackable = true
|
||||
@@ -130,9 +128,8 @@ class PickaxeIron(override val originalID: ItemID) : GameItem() {
|
||||
/**
|
||||
* Created by minjaesong on 2019-03-10.
|
||||
*/
|
||||
class PickaxeSteel(override val originalID: ItemID) : GameItem() {
|
||||
class PickaxeSteel(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "PACKAGED_PICK"
|
||||
override var baseToolSize: Double? = BASE_MASS_AND_SIZE
|
||||
override var stackable = true
|
||||
@@ -0,0 +1,34 @@
|
||||
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,8 +1,9 @@
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import net.torvald.random.Fudge3
|
||||
import net.torvald.random.HQRNG
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorHumanoid
|
||||
import kotlin.math.pow
|
||||
|
||||
@@ -24,6 +25,6 @@ object WeaponMeleeCore {
|
||||
|
||||
}
|
||||
|
||||
abstract class WeaponMeleeBase : GameItem() {
|
||||
abstract class WeaponMeleeBase(originalID: ItemID) : GameItem(originalID) {
|
||||
abstract val velocityMod: Double
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
package net.torvald.terrarum.modulebasegame.items
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import net.torvald.terrarum.blockproperties.Wire
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemID
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.gameitem.ItemID
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2019-03-10.
|
||||
*/
|
||||
class WirePieceSignalWire(override val originalID: ItemID) : GameItem() {
|
||||
class WirePieceSignalWire(originalID: ItemID) : GameItem(originalID) {
|
||||
|
||||
override var dynamicID: ItemID = originalID
|
||||
override val originalName = "ITEM_WIRE"
|
||||
@@ -23,7 +22,7 @@ class WirePieceSignalWire(override val originalID: ItemID) : GameItem() {
|
||||
override val isDynamic = false
|
||||
override val material = Material()
|
||||
override val itemImage: TextureRegion?
|
||||
get() = (AppLoader.resourcePool["basegame.items16"] as TextureRegionPack).get(1,9)
|
||||
get() = AppLoader.resourcePool.getAsTextureRegionPack("basegame.items16").get(1,9)
|
||||
|
||||
init {
|
||||
super.equipPosition = GameItem.EquipPosition.HAND_GRIP
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import net.torvald.terrarum.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.GameItem
|
||||
import net.torvald.terrarum.itemproperties.ItemCodex
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.ActorInventory
|
||||
import net.torvald.terrarum.modulebasegame.ui.ItemSlotImageFactory.CELLCOLOUR_BLACK
|
||||
|
||||
@@ -22,6 +22,7 @@ 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.*
|
||||
@@ -51,7 +52,8 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
lateinit var mixedWeather: BaseModularWeather
|
||||
|
||||
val globalLightNow = Color(0)
|
||||
var globalLightNow = Cvec()
|
||||
private set
|
||||
|
||||
// Weather indices
|
||||
const val WEATHER_GENERIC = "generic"
|
||||
@@ -133,7 +135,7 @@ internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
// calculate global light
|
||||
val globalLight = getGradientColour(skyboxColourMap, 2, timeNow)
|
||||
globalLightNow.set(globalLight)
|
||||
globalLightNow = Cvec(globalLight.r, globalLight.g, globalLight.b, globalLight.a)
|
||||
|
||||
|
||||
/* (copied from the shader source)
|
||||
@@ -178,8 +180,10 @@ internal object WeatherMixer : RNGConsumer {
|
||||
/**
|
||||
* Get a GL of specific time
|
||||
*/
|
||||
fun getGlobalLightOfTime(timeInSec: Int): Color =
|
||||
getGradientColour(currentWeather.skyboxGradColourMap, 2, timeInSec)
|
||||
fun getGlobalLightOfTime(timeInSec: Int): Cvec {
|
||||
val c = getGradientColour(currentWeather.skyboxGradColourMap, 2, timeInSec)
|
||||
return Cvec(c.r, c.g, c.b, c.a)
|
||||
}
|
||||
|
||||
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.itemproperties.GameItem
|
||||
import net.torvald.terrarum.gameitem.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?.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)
|
||||
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)
|
||||
|
||||
lightVal = if (valRaw == null) "—"
|
||||
else "$rawR $rawG $rawB $rawA"
|
||||
|
||||
@@ -161,6 +161,10 @@ 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
|
||||
|
||||
75
src/net/torvald/terrarum/worlddrawer/Cvec.kt
Normal file
75
src/net/torvald/terrarum/worlddrawer/Cvec.kt
Normal file
@@ -0,0 +1,75 @@
|
||||
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,19 +1,5 @@
|
||||
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)
|
||||
*
|
||||
@@ -24,7 +10,7 @@ import java.util.*
|
||||
|
||||
// NOTE: no Float16 on this thing: 67 kB of memory footage is totally acceptable
|
||||
|
||||
object LightmapRendererOld {
|
||||
/*object LightmapRendererOld {
|
||||
lateinit var world: GameWorld
|
||||
|
||||
|
||||
@@ -771,4 +757,4 @@ object LightmapRendererOld {
|
||||
}
|
||||
return (1f - scale) * startValue + scale * endValue
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@@ -72,8 +72,8 @@ object LightmapRenderer {
|
||||
|
||||
// TODO resize(int, int) -aware
|
||||
|
||||
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
|
||||
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 noopMask = HashSet<Point2i>((LIGHTMAP_WIDTH + LIGHTMAP_HEIGHT) * 2)
|
||||
|
||||
@@ -82,8 +82,8 @@ 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 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.
|
||||
private val lanternMap = HashMap<BlockAddress, Color>((Terrarum.ingame?.ACTORCONTAINER_INITIAL_SIZE ?: 2) * 4)
|
||||
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)
|
||||
|
||||
init {
|
||||
printdbg(this, "Overscan open: $overscan_open; opaque: $overscan_opaque")
|
||||
@@ -120,13 +120,13 @@ object LightmapRenderer {
|
||||
* @param x world tile coord
|
||||
* @param y world tile coord
|
||||
*/
|
||||
internal fun getLight(x: Int, y: Int): Color? {
|
||||
internal fun getLight(x: Int, y: Int): Cvec? {
|
||||
val col = getLightInternal(x, y)
|
||||
if (col == null) {
|
||||
return null
|
||||
}
|
||||
else {
|
||||
return Color(col.r * MUL_FLOAT, col.g * MUL_FLOAT, col.b * MUL_FLOAT, col.a * MUL_FLOAT)
|
||||
return col * MUL_FLOAT
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +137,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): Color? {
|
||||
private fun getLightInternal(x: Int, y: Int): Cvec? {
|
||||
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 +164,7 @@ object LightmapRenderer {
|
||||
* @param colour Color to write
|
||||
* @param applyFun A function ```foo(old_colour, given_colour)```
|
||||
*/
|
||||
private fun setLightOf(list: Array<Color>, x: Int, y: Int, colour: Color, applyFun: (Color, Color) -> Color = { _, c -> c }) {
|
||||
private fun setLightOf(list: Array<Cvec>, x: Int, y: Int, colour: Cvec, applyFun: (Cvec, Cvec) -> Cvec = { _, 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) {
|
||||
|
||||
@@ -220,7 +220,7 @@ object LightmapRenderer {
|
||||
*/
|
||||
|
||||
// set sunlight
|
||||
sunLight.set(world.globalLight); sunLight.mul(DIV_FLOAT)
|
||||
sunLight = world.globalLight * DIV_FLOAT
|
||||
|
||||
// set no-op mask from solidity of the block
|
||||
AppLoader.measureDebugTime("Renderer.LightNoOpMask") {
|
||||
@@ -394,15 +394,15 @@ object LightmapRenderer {
|
||||
|
||||
|
||||
//private val ambientAccumulator = Color(0f,0f,0f,0f)
|
||||
private val lightLevelThis = Color(0)
|
||||
private var lightLevelThis = Cvec()
|
||||
private var thisTerrain = 0
|
||||
private var thisFluid = GameWorld.FluidInfo(Fluid.NULL, 0f)
|
||||
private val fluidAmountToCol = Color(0)
|
||||
private var fluidAmountToCol = Cvec()
|
||||
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)
|
||||
private var thisTileLuminosity = Cvec()
|
||||
private var thisTileOpacity = Cvec()
|
||||
private var thisTileOpacity2 = Cvec() // thisTileOpacity * sqrt(2)
|
||||
private var sunLight = Cvec()
|
||||
|
||||
/**
|
||||
* This function will alter following variables:
|
||||
@@ -416,35 +416,35 @@ object LightmapRenderer {
|
||||
* - sunlight
|
||||
*/
|
||||
private fun getLightsAndShades(x: Int, y: Int) {
|
||||
lightLevelThis.set(colourNull)
|
||||
lightLevelThis = 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.set(thisFluid.amount, thisFluid.amount, thisFluid.amount, thisFluid.amount)
|
||||
fluidAmountToCol = Cvec(thisFluid.amount)
|
||||
|
||||
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
|
||||
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
|
||||
}
|
||||
else {
|
||||
thisTileLuminosity.set(BlockCodex[thisTerrain].luminosity)
|
||||
thisTileOpacity.set(BlockCodex[thisTerrain].opacity)
|
||||
thisTileLuminosity = BlockCodex[thisTerrain].luminosity
|
||||
thisTileOpacity = BlockCodex[thisTerrain].opacity
|
||||
}
|
||||
|
||||
thisTileOpacity2.set(thisTileOpacity); thisTileOpacity2.mul(1.41421356f)
|
||||
thisTileOpacity2 = thisTileOpacity * 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.set(sunLight)
|
||||
lightLevelThis = sunLight
|
||||
}
|
||||
|
||||
// blend lantern
|
||||
lightLevelThis.maxAndAssign(thisTileLuminosity).maxAndAssign(lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: colourNull)
|
||||
lightLevelThis = lightLevelThis.max(thisTileLuminosity).max(lanternMap[LandUtil.getBlockAddr(world, x, y)] ?: colourNull)
|
||||
|
||||
}
|
||||
|
||||
@@ -499,7 +499,7 @@ object LightmapRenderer {
|
||||
/**
|
||||
* Calculates the light simulation, using main lightmap as one of the input.
|
||||
*/
|
||||
private fun calculateAndAssign(lightmap: Array<Color>, x: Int, y: Int) {
|
||||
private fun calculateAndAssign(lightmap: Array<Cvec>, x: Int, y: Int) {
|
||||
|
||||
if (inNoopMask(x, y)) return
|
||||
|
||||
@@ -517,32 +517,27 @@ object LightmapRenderer {
|
||||
|
||||
// will "overwrite" what's there in the lightmap if it's the first pass
|
||||
// takes about 2 ms on 6700K
|
||||
/* + */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))
|
||||
/* + */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))
|
||||
|
||||
|
||||
//return lightLevelThis.cpy() // it HAS to be a cpy(), otherwise all cells gets the same instance
|
||||
setLightOf(lightmap, x, y, lightLevelThis.cpy())
|
||||
setLightOf(lightmap, x, y, lightLevelThis)
|
||||
}
|
||||
|
||||
private fun getLightForOpaque(x: Int, y: Int): Color? { // ...so that they wouldn't appear too dark
|
||||
private fun getLightForOpaque(x: Int, y: Int): Cvec? { // ...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 Color(
|
||||
(l.r * 1.2f),
|
||||
(l.g * 1.2f),
|
||||
(l.b * 1.2f),
|
||||
(l.a * 1.2f)
|
||||
)
|
||||
return l * 1.2f
|
||||
}
|
||||
else {
|
||||
return l
|
||||
@@ -551,8 +546,7 @@ object LightmapRenderer {
|
||||
|
||||
var lightBuffer: Pixmap = Pixmap(1, 1, Pixmap.Format.RGBA8888)
|
||||
|
||||
private val colourNull = Color(0)
|
||||
private val epsilon = 1f/1024f
|
||||
private val colourNull = Cvec()
|
||||
|
||||
private var _lightBufferAsTex: Texture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
||||
|
||||
@@ -568,7 +562,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(colourNull)
|
||||
lightBuffer.setColor(0)
|
||||
lightBuffer.fill()
|
||||
|
||||
|
||||
@@ -581,12 +575,11 @@ object LightmapRenderer {
|
||||
|
||||
for (x in this_x_start..this_x_end) {
|
||||
|
||||
val color = (getLightForOpaque(x, y) ?: Color(0f, 0f, 0f, 0f)).normaliseToHDR()
|
||||
val color: RGBA8888 = (getLightForOpaque(x, y) ?: Cvec()).normaliseToHDR().toRGBA8888()
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
@@ -611,6 +604,7 @@ object LightmapRenderer {
|
||||
|
||||
}
|
||||
|
||||
private val CVEC_ONE = Cvec(1f)
|
||||
val lightScalingMagic = 8f
|
||||
|
||||
/**
|
||||
@@ -620,15 +614,13 @@ object LightmapRenderer {
|
||||
* @param darken (0-255) per channel
|
||||
* @return darkened data (0-255) per channel
|
||||
*/
|
||||
fun darkenColoured(data: Color, darken: Color): Color {
|
||||
fun darkenColoured(data: Cvec, darken: Cvec): Cvec {
|
||||
// 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)
|
||||
|
||||
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))
|
||||
// equation: data * (1 - darken * magic)
|
||||
|
||||
return data * (CVEC_ONE - darken * lightScalingMagic)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -638,13 +630,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
|
||||
@@ -653,26 +645,12 @@ object LightmapRenderer {
|
||||
* @param brighten (-1.0 - 1.0) negative means darkening
|
||||
* @return processed colour
|
||||
*/
|
||||
fun alterBrightnessUniform(data: Color, brighten: Float): Color {
|
||||
return Color(
|
||||
data.r + brighten,
|
||||
data.g + brighten,
|
||||
data.b + brighten,
|
||||
data.a + brighten
|
||||
)
|
||||
fun alterBrightnessUniform(data: Cvec, brighten: Float): Cvec {
|
||||
// equation = data + brighten
|
||||
|
||||
return data + 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)
|
||||
@@ -713,6 +691,9 @@ 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()
|
||||
}
|
||||
@@ -720,6 +701,7 @@ object LightmapRenderer {
|
||||
_init = true
|
||||
}
|
||||
lightBuffer = Pixmap(tilesInHorizontal, tilesInVertical, Pixmap.Format.RGBA8888)
|
||||
lightmap = Array<Cvec>(LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT) { Cvec() }
|
||||
|
||||
|
||||
printdbg(this, "Resize event")
|
||||
@@ -793,14 +775,11 @@ 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 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
|
||||
internal fun Cvec.normaliseToHDR(): Cvec {
|
||||
// equation: hdr(this.coerceIn)
|
||||
val arr = this.vec.toArray().map { hdr(it.coerceIn(0f, 1f)) }
|
||||
return Cvec(arr.toFloatArray())
|
||||
}
|
||||
|
||||
val histogram: Histogram
|
||||
get() {
|
||||
@@ -816,10 +795,10 @@ object LightmapRenderer {
|
||||
try {
|
||||
//val colour = lightmap[y][x]
|
||||
val colour = lightmap[y * LIGHTMAP_WIDTH + x]
|
||||
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
|
||||
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
|
||||
}
|
||||
catch (e: ArrayIndexOutOfBoundsException) { }
|
||||
}
|
||||
|
||||
@@ -2,10 +2,10 @@
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="kotlin-language" name="Kotlin">
|
||||
<configuration version="3" platform="JVM 1.8">
|
||||
<configuration version="3" platform="JVM 9">
|
||||
<compilerSettings />
|
||||
<compilerArguments>
|
||||
<option name="jvmTarget" value="1.8" />
|
||||
<option name="jvmTarget" value="10" />
|
||||
</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="jdk" jdkName="11" jdkType="JavaSDK" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<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.
BIN
work_files/graphics/fonts/hangul_johab2.psd
LFS
Normal file
BIN
work_files/graphics/fonts/hangul_johab2.psd
LFS
Normal file
Binary file not shown.
BIN
work_files/graphics/fonts/tibetan_variable.psd
LFS
Normal file
BIN
work_files/graphics/fonts/tibetan_variable.psd
LFS
Normal file
Binary file not shown.
Binary file not shown.
BIN
work_files/graphics/sprites/fanu_jointed.psd
LFS
Normal file
BIN
work_files/graphics/sprites/fanu_jointed.psd
LFS
Normal file
Binary file not shown.
BIN
work_files/graphics/sprites/fanu_jointed.tga
LFS
Normal file
BIN
work_files/graphics/sprites/fanu_jointed.tga
LFS
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user