mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 11:34:05 +09:00
Revert "trying bytebuf and FloatVector"
This reverts commit 2941a0943f.
Benchmark showed no discernible differences.
This commit is contained in:
@@ -3,10 +3,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.jme3.math.FastMath
|
||||
import jdk.incubator.vector.FloatVector
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.gdx.graphics.VectorArray
|
||||
import net.torvald.gdx.graphics.VectorArray.Companion.NULLVEC
|
||||
import net.torvald.spriteanimation.AssembledSpriteAnimation
|
||||
import net.torvald.spriteanimation.HasAssembledSprite
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
@@ -68,32 +65,32 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
if (houseDesignation != null) houseDesignation!!.clear()
|
||||
}
|
||||
|
||||
var actorValueColour: FloatVector
|
||||
get() = FloatVector.fromArray(VectorArray.SPECIES, floatArrayOf(
|
||||
var actorValueColour: Cvec
|
||||
get() = Cvec(
|
||||
(actorValue.getAsFloat(AVKey.LUMR) ?: 0f),
|
||||
(actorValue.getAsFloat(AVKey.LUMG) ?: 0f),
|
||||
(actorValue.getAsFloat(AVKey.LUMB) ?: 0f),
|
||||
(actorValue.getAsFloat(AVKey.LUMA) ?: 0f)
|
||||
), 0)
|
||||
)
|
||||
set(value) {
|
||||
actorValue[AVKey.LUMR] = value.lane(0)
|
||||
actorValue[AVKey.LUMG] = value.lane(1)
|
||||
actorValue[AVKey.LUMB] = value.lane(2)
|
||||
actorValue[AVKey.LUMA] = value.lane(3)
|
||||
actorValue[AVKey.LUMR] = value.r
|
||||
actorValue[AVKey.LUMG] = value.g
|
||||
actorValue[AVKey.LUMB] = value.b
|
||||
actorValue[AVKey.LUMA] = value.a
|
||||
}
|
||||
|
||||
var actorValueShade: FloatVector
|
||||
get() = FloatVector.fromArray(VectorArray.SPECIES, floatArrayOf(
|
||||
var actorValueShade: Cvec
|
||||
get() = Cvec(
|
||||
(actorValue.getAsFloat(AVKey.OPAR) ?: 0f),
|
||||
(actorValue.getAsFloat(AVKey.OPAG) ?: 0f),
|
||||
(actorValue.getAsFloat(AVKey.OPAB) ?: 0f),
|
||||
(actorValue.getAsFloat(AVKey.OPAA) ?: 0f)
|
||||
), 0)
|
||||
)
|
||||
set(value) {
|
||||
actorValue[AVKey.OPAR] = value.lane(0)
|
||||
actorValue[AVKey.OPAG] = value.lane(1)
|
||||
actorValue[AVKey.OPAB] = value.lane(2)
|
||||
actorValue[AVKey.OPAA] = value.lane(3)
|
||||
actorValue[AVKey.OPAR] = value.r
|
||||
actorValue[AVKey.OPAG] = value.g
|
||||
actorValue[AVKey.OPAB] = value.b
|
||||
actorValue[AVKey.OPAA] = value.a
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,9 +99,9 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
* Hitbox(x-offset, y-offset, width, height)
|
||||
* (Use ArrayList for normal circumstances)
|
||||
*/
|
||||
@Transient override var lightBoxList: List<Lightbox> = listOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), NULLVEC))
|
||||
@Transient override var lightBoxList: List<Lightbox> = listOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), Cvec(0)))
|
||||
// the actual values are update on the update()
|
||||
@Transient override var shadeBoxList: List<Lightbox> = listOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), NULLVEC))
|
||||
@Transient override var shadeBoxList: List<Lightbox> = listOf(Lightbox(Hitbox(2.0, 2.0, baseHitboxW - 3.0, baseHitboxH - 3.0), Cvec(0)))
|
||||
// the actual values are update on the update()
|
||||
|
||||
@Transient val BASE_DENSITY = 980.0
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.gdx.graphics.VectorArray.Companion.NULLVEC
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.ItemCodex
|
||||
@@ -40,9 +39,9 @@ open class DroppedItem : ActorWithBody {
|
||||
private val randKey1 = (Math.random() * 256).toInt()
|
||||
private val randKey2 = (Math.random() * 256).toInt()
|
||||
|
||||
override var lightBoxList = listOf(Lightbox(this.hitbox.clone().setPosition(0.0, 0.0), NULLVEC))
|
||||
override var lightBoxList = listOf(Lightbox(this.hitbox.clone().setPosition(0.0, 0.0), Cvec(0)))
|
||||
// the Cvec will be calculated dynamically on Update
|
||||
override var shadeBoxList = listOf(Lightbox(this.hitbox.clone().setPosition(0.0, 0.0), NULLVEC))
|
||||
override var shadeBoxList = listOf(Lightbox(this.hitbox.clone().setPosition(0.0, 0.0), Cvec(0)))
|
||||
// the Cvec will be calculated dynamically on Update
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import jdk.incubator.vector.FloatVector
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.gdx.graphics.VectorArray
|
||||
import net.torvald.gdx.graphics.VectorArray.Companion.NULLVEC
|
||||
import net.torvald.spriteanimation.SheetSpriteAnimation
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.App.printdbg
|
||||
@@ -29,7 +26,7 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
var tw = 2 // tilewise width of the door when opened
|
||||
var twClosed = 1 // tilewise width of the door when closed
|
||||
var th = 3 // tilewise height of the door
|
||||
var opacity = BlockCodex[Block.STONE].opacity.toCvec()
|
||||
var opacity = BlockCodex[Block.STONE].opacity
|
||||
var isOpacityActuallyLuminosity = false
|
||||
var moduleName = "basegame"
|
||||
var texturePath = "sprites/fixtures/door_test.tga"
|
||||
@@ -46,9 +43,9 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
private var pixelwiseHitboxHeight = TILE_SIZE * tilewiseHitboxHeight
|
||||
private var tilewiseDistToAxis = tw - twClosed
|
||||
|
||||
@Transient override var lightBoxList = listOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), NULLVEC))
|
||||
@Transient override var lightBoxList = listOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), Cvec(0)))
|
||||
// the Cvec will be calculated dynamically on Update
|
||||
@Transient override var shadeBoxList = listOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), NULLVEC))
|
||||
@Transient override var shadeBoxList = listOf(Lightbox(Hitbox(TILE_SIZED * tilewiseDistToAxis, 0.0, TILE_SIZED * twClosed, TILE_SIZED * th), Cvec(0)))
|
||||
// the Cvec will be calculated dynamically on Update
|
||||
|
||||
protected var doorState = 0 // -1: open toward left, 0: closed, 1: open toward right
|
||||
@@ -57,9 +54,6 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
@Transient private lateinit var customNameFun: () -> String
|
||||
@Transient private lateinit var doorHoldLength: HashMap<Int, Second>
|
||||
|
||||
private fun FloatVector.toCvec() = Cvec(this.lane(0), this.lane(1), this.lane(2), this.lane(3))
|
||||
|
||||
|
||||
constructor() : super(
|
||||
BlockBox(BlockBox.FULL_COLLISION, 1, 1), // temporary value, will be overwritten by spawn()
|
||||
nameFun = { "item not loaded properly, alas!" }
|
||||
@@ -68,7 +62,7 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
BlockCodex[Block.STONE].opacity.toCvec(),
|
||||
BlockCodex[Block.STONE].opacity,
|
||||
false,
|
||||
"basegame",
|
||||
"sprites/fixtures/door_test.tga",
|
||||
@@ -79,18 +73,18 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
}
|
||||
|
||||
protected fun _construct(
|
||||
tw: Int, // tilewise width of the door when opened
|
||||
twClosed: Int, // tilewise width of the door when closed
|
||||
th: Int, // tilewise height of the door
|
||||
opacity: Cvec,
|
||||
isOpacityActuallyLuminosity: Boolean,
|
||||
moduleName: String,
|
||||
texturePath: String,
|
||||
textureIdentifier: String,
|
||||
nameKey: String,
|
||||
nameKeyReadFromLang: Boolean,
|
||||
doorCloseHoldLength: Second = 0.1f,
|
||||
doorOpenedHoldLength: Second = 0.25f
|
||||
tw: Int, // tilewise width of the door when opened
|
||||
twClosed: Int, // tilewise width of the door when closed
|
||||
th: Int, // tilewise height of the door
|
||||
opacity: Cvec,
|
||||
isOpacityActuallyLuminosity: Boolean,
|
||||
moduleName: String,
|
||||
texturePath: String,
|
||||
textureIdentifier: String,
|
||||
nameKey: String,
|
||||
nameKeyReadFromLang: Boolean,
|
||||
doorCloseHoldLength: Second = 0.1f,
|
||||
doorOpenedHoldLength: Second = 0.25f
|
||||
) {
|
||||
this.tw = tw
|
||||
this.twClosed = twClosed
|
||||
@@ -129,7 +123,7 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
|
||||
// define light/shadebox
|
||||
// TODO: redefine when opened to left/right
|
||||
(if (isOpacityActuallyLuminosity) lightBoxList else shadeBoxList)[0].light = FloatVector.fromArray(VectorArray.SPECIES, opacity.toFloatArray(), 0)
|
||||
(if (isOpacityActuallyLuminosity) lightBoxList else shadeBoxList)[0].light = opacity
|
||||
|
||||
// define physical size
|
||||
setHitboxDimension(TILE_SIZE * tilewiseHitboxWidth, TILE_SIZE * tilewiseHitboxHeight, 0, 0)
|
||||
@@ -153,16 +147,16 @@ open class FixtureSwingingDoorBase : FixtureBase {
|
||||
|
||||
// define light/shadebox
|
||||
// TODO: redefine when opened to left/right
|
||||
(if (isOpacityActuallyLuminosity) lightBoxList else shadeBoxList)[0].light = FloatVector.fromArray(VectorArray.SPECIES, opacity.toFloatArray(), 0)
|
||||
(if (isOpacityActuallyLuminosity) lightBoxList else shadeBoxList)[0].light = opacity
|
||||
|
||||
}
|
||||
|
||||
private fun setOpacity() {
|
||||
shadeBoxList[0].light = FloatVector.fromArray(VectorArray.SPECIES, opacity.toFloatArray(), 0)
|
||||
shadeBoxList[0].light = opacity
|
||||
}
|
||||
|
||||
private fun unsetOpacity() {
|
||||
shadeBoxList[0].light = NULLVEC
|
||||
shadeBoxList[0].light = Cvec(0)
|
||||
}
|
||||
|
||||
open protected fun closeDoor(doorHandler: Int) {
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import jdk.incubator.vector.FloatVector
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2022-07-28.
|
||||
*/
|
||||
private fun FloatVector.toCvec() = Cvec(this.lane(0), this.lane(1), this.lane(2), this.lane(3))
|
||||
|
||||
class FixtureSwingingDoorOak : FixtureSwingingDoorBase {
|
||||
constructor() : super() {
|
||||
_construct(
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
BlockCodex[Block.STONE].opacity.toCvec(),
|
||||
BlockCodex[Block.STONE].opacity,
|
||||
false,
|
||||
"basegame",
|
||||
"sprites/fixtures/door_basegame-48.tga",
|
||||
@@ -33,7 +29,7 @@ class FixtureSwingingDoorEbony : FixtureSwingingDoorBase {
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
BlockCodex[Block.STONE].opacity.toCvec(),
|
||||
BlockCodex[Block.STONE].opacity,
|
||||
false,
|
||||
"basegame",
|
||||
"sprites/fixtures/door_basegame-49.tga",
|
||||
@@ -50,7 +46,7 @@ class FixtureSwingingDoorBirch : FixtureSwingingDoorBase {
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
BlockCodex[Block.STONE].opacity.toCvec(),
|
||||
BlockCodex[Block.STONE].opacity,
|
||||
false,
|
||||
"basegame",
|
||||
"sprites/fixtures/door_basegame-50.tga",
|
||||
@@ -67,7 +63,7 @@ class FixtureSwingingDoorRosewood : FixtureSwingingDoorBase {
|
||||
2,
|
||||
1,
|
||||
3,
|
||||
BlockCodex[Block.STONE].opacity.toCvec(),
|
||||
BlockCodex[Block.STONE].opacity,
|
||||
false,
|
||||
"basegame",
|
||||
"sprites/fixtures/door_basegame-51.tga",
|
||||
|
||||
@@ -2,9 +2,7 @@ package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import jdk.incubator.vector.FloatVector
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.gdx.graphics.VectorArray
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.Point2d
|
||||
@@ -31,8 +29,8 @@ open class ProjectileSimple : ActorWithBody, Projectile {
|
||||
var speed: Int = 0
|
||||
|
||||
|
||||
private var color: FloatVector
|
||||
get() = bulletDatabase[type][OFFSET_LUMINOSITY] as FloatVector
|
||||
private var color: Cvec
|
||||
get() = (bulletDatabase[type][OFFSET_LUMINOSITY] as Cvec).cpy()
|
||||
set(value) {
|
||||
}
|
||||
/**
|
||||
@@ -117,9 +115,7 @@ open class ProjectileSimple : ActorWithBody, Projectile {
|
||||
|
||||
override fun drawGlow(batch: SpriteBatch) = drawBody(batch)
|
||||
|
||||
|
||||
companion object {
|
||||
private fun Int.toFloatVector() = FloatVector.fromArray(VectorArray.SPECIES, Cvec(this).toFloatArray(), 0)
|
||||
val OFFSET_DAMAGE = 0
|
||||
val OFFSET_COL = 1 // Color or SpriteAnimation
|
||||
val OFFSET_NOGRAVITY = 2
|
||||
@@ -127,8 +123,8 @@ open class ProjectileSimple : ActorWithBody, Projectile {
|
||||
val OFFSET_LUMINOSITY = 4
|
||||
val bulletDatabase = arrayOf(
|
||||
// damage, display colour, no gravity, speed
|
||||
arrayOf(7, 0xFF5429_FF.toInt().toFloatVector(), true, 40, 32),
|
||||
arrayOf(8, 0xFF5429_FF.toInt().toFloatVector(), true, 20, 0)
|
||||
arrayOf(7, Cvec(0xFF5429_FF.toInt()), true, 40, 32),
|
||||
arrayOf(8, Cvec(0xFF5429_FF.toInt()), true, 20, 0)
|
||||
// ...
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user