mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
glow/emissive for held items, even if the actor has no glow/emissive sprites
This commit is contained in:
@@ -53,6 +53,7 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
(mainUI as UIJukebox).parent = this
|
||||
|
||||
val itemImage = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/jukebox.tga")
|
||||
val itemImage2 = FixtureItemBase.getItemImageFromSingleImage("basegame", "sprites/fixtures/jukebox_emsv.tga")
|
||||
|
||||
density = 1400.0
|
||||
setHitboxDimension(TILE_SIZE * 2, TILE_SIZE * 3, 0, 0)
|
||||
@@ -60,6 +61,9 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
makeNewSprite(TextureRegionPack(itemImage.texture, TILE_SIZE * 2, TILE_SIZE * 3)).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
makeNewSpriteEmissive(TextureRegionPack(itemImage2.texture, TILE_SIZE * 2, TILE_SIZE * 3)).let {
|
||||
it.setRowsAndFrames(1,1)
|
||||
}
|
||||
|
||||
actorValue[AVKey.BASEMASS] = 200.0
|
||||
|
||||
@@ -130,6 +134,7 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
}
|
||||
|
||||
@Transient private var lampDecay = 0f
|
||||
@Transient private var lampIntensity = 0f
|
||||
|
||||
/**
|
||||
* Try to stop the disc being played, and reset the background music cue
|
||||
@@ -146,15 +151,27 @@ class FixtureJukebox : Electric, PlaysMusic {
|
||||
if (isVisible && musicNowPlaying != null) {
|
||||
val vol0 = (musicTracks[musicNowPlaying]?.processor?.maxSigLevel?.average() ?: 0.0).toFloat()
|
||||
val vol = FastMath.interpolateLinear(0.8f, vol0, lampDecay)
|
||||
lampIntensity = vol.coerceIn(0f, 1f)
|
||||
|
||||
blendScreen(batch)
|
||||
backLamp.colourFilter = Color(0f, vol.coerceIn(0f, 1f), 0f, 1f)
|
||||
backLamp.colourFilter = Color(0f, lampIntensity, 0f, 1f)
|
||||
drawSpriteInGoodPosition(frameDelta, backLamp, batch)
|
||||
|
||||
lampDecay = vol
|
||||
}
|
||||
}
|
||||
|
||||
override fun drawEmissive(frameDelta: Float, batch: SpriteBatch) {
|
||||
blendNormalStraightAlpha(batch)
|
||||
super.drawEmissive(frameDelta, batch)
|
||||
|
||||
if (isVisible && musicNowPlaying != null) {
|
||||
blendScreen(batch)
|
||||
backLamp.colourFilter = Color(0f, lampIntensity / 2f, 0f, 1f)
|
||||
drawSpriteInGoodPosition(frameDelta, backLamp, batch)
|
||||
}
|
||||
}
|
||||
|
||||
private fun stopDiscPlayback() {
|
||||
musicNowPlaying?.let {
|
||||
stopAudio(it)
|
||||
|
||||
@@ -45,9 +45,10 @@ class IngamePlayer : ActorHumanoid, HasAssembledSprite, NoSerialise {
|
||||
|
||||
private constructor()
|
||||
|
||||
constructor(animDescPath: String, animDescPathGlow: String?, born: Long) : super(born) {
|
||||
constructor(animDescPath: String, animDescPathGlow: String?, animDescPathEmissive: String?, born: Long) : super(born) {
|
||||
animDesc = ADProperties(Gdx.files.internal(animDescPath))
|
||||
if (animDescPathGlow != null) animDescGlow = ADProperties(Gdx.files.internal(animDescPathGlow))
|
||||
if (animDescPathEmissive != null) animDescEmissive = ADProperties(Gdx.files.internal(animDescPathEmissive))
|
||||
actorValue[AVKey.__HISTORICAL_BORNTIME] = born
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ object PlayerBuilder {
|
||||
operator fun invoke(): Actor {
|
||||
val world = (Terrarum.ingame!! as TerrarumIngame).world
|
||||
|
||||
val p: Actor = IngamePlayer("lol", "lol_glow", world.worldTime.TIME_T)
|
||||
val p: Actor = IngamePlayer("lol", "lol_glow", "lol_emsv", world.worldTime.TIME_T)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreaturePlayer.json")
|
||||
|
||||
// attach sprite
|
||||
|
||||
@@ -10,9 +10,10 @@ import net.torvald.terrarum.gameactors.AVKey
|
||||
object PlayerBuilderTestSubject1 {
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p: IngamePlayer = IngamePlayer(
|
||||
ModMgr.getGdxFile("basegame", "sprites/test_sprite.properties").path(),
|
||||
ModMgr.getGdxFile("basegame", "sprites/test_sprite_glow.properties").path(),
|
||||
-589141658L // random value thrown
|
||||
ModMgr.getGdxFile("basegame", "sprites/test_sprite.properties").path(),
|
||||
ModMgr.getGdxFile("basegame", "sprites/test_sprite_glow.properties").path(),
|
||||
ModMgr.getGdxFile("basegame", "sprites/test_sprite_emsv.properties").path(),
|
||||
0L // random value thrown
|
||||
)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreaturePlayer.json")
|
||||
|
||||
@@ -23,13 +24,11 @@ object PlayerBuilderTestSubject1 {
|
||||
p.actorValue[AVKey.NAME] = "Test Subject 1"
|
||||
|
||||
|
||||
/*p.makeNewSprite(TextureRegionPack(ModMgr.getGdxFile("basegame", "sprites/npc_template_anim_prototype.tga"), 48, 52))
|
||||
p.sprite!!.delays = floatArrayOf(2f, 1f/12f) // second value does nothing -- overridden by ActorHumanoid.updateSprite(float)
|
||||
p.sprite!!.setRowsAndFrames(2, 4)*/
|
||||
// TODO make null animation if animDesc is null
|
||||
p.animDesc?.let { p.sprite = AssembledSpriteAnimation(it, p, false, false) }
|
||||
p.animDescGlow?.let { p.spriteGlow = AssembledSpriteAnimation(it, p, true, false) }
|
||||
p.animDescEmissive?.let { p.spriteEmissive = AssembledSpriteAnimation(it, p, true, true) }
|
||||
|
||||
p.animDesc?.let { p.sprite = AssembledSpriteAnimation(it, p, false) }
|
||||
p.animDescGlow?.let { p.spriteGlow = AssembledSpriteAnimation(it, p, true) }
|
||||
//p.reassembleSprite(p.sprite, p.spriteGlow, null)
|
||||
p.setHitboxDimension(15, p.actorValue.getAsInt(AVKey.BASEHEIGHT) ?: ActorHumanoid.BASE_HEIGHT, 21, 0)
|
||||
|
||||
// ingame must teleport the player to the spawn point
|
||||
|
||||
@@ -12,9 +12,10 @@ import net.torvald.terrarum.gameactors.AVKey
|
||||
object PlayerBuilderWerebeastTest {
|
||||
operator fun invoke(): IngamePlayer {
|
||||
val p: IngamePlayer = IngamePlayer(
|
||||
ModMgr.getGdxFile("basegame", "sprites/taimu2.properties").path(),
|
||||
ModMgr.getGdxFile("basegame", "sprites/taimu2_glow.properties").path(),
|
||||
-589141658L // random value thrown
|
||||
ModMgr.getGdxFile("basegame", "sprites/taimu2.properties").path(),
|
||||
ModMgr.getGdxFile("basegame", "sprites/taimu2_glow.properties").path(),
|
||||
ModMgr.getGdxFile("basegame", "sprites/taimu2_emsv.properties").path(),
|
||||
-589141658L // random value thrown
|
||||
)
|
||||
InjectCreatureRaw(p.actorValue, "basegame", "CreatureWerebeastBossBase.json")
|
||||
|
||||
@@ -24,9 +25,9 @@ object PlayerBuilderWerebeastTest {
|
||||
p.actorValue[AVKey.ACTION_INTERVAL] = ActorHumanoid.BASE_ACTION_INTERVAL
|
||||
p.actorValue[AVKey.NAME] = "Taimu"
|
||||
|
||||
p.animDesc?.let { p.sprite = AssembledSpriteAnimation(it, p, false) }
|
||||
p.animDescGlow?.let { p.spriteGlow = AssembledSpriteAnimation(it, p, true) }
|
||||
p.animDescEmissive?.let { p.spriteEmissive = AssembledSpriteAnimation(it, p, true) }
|
||||
p.animDesc?.let { p.sprite = AssembledSpriteAnimation(it, p, false, false) }
|
||||
p.animDescGlow?.let { p.spriteGlow = AssembledSpriteAnimation(it, p, true, false) }
|
||||
p.animDescEmissive?.let { p.spriteEmissive = AssembledSpriteAnimation(it, p, false, true) }
|
||||
p.setHitboxDimension(22, p.actorValue.getAsInt(AVKey.BASEHEIGHT)!!, 30, 0)
|
||||
|
||||
p.setPosition(3.0 * TILE_SIZE, 3.0 * TILE_SIZE)
|
||||
|
||||
@@ -14,6 +14,8 @@ class ItemFurnaceAndAnvil(originalID: ItemID) : FixtureItemBase(originalID, "net
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/metalworking_furnace_and_anvil.tga")
|
||||
override val itemImageEmissive: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/metalworking_furnace_and_anvil_emsv.tga")
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var originalName = "ITEM_FURNACE_AND_ANVIL"
|
||||
|
||||
@@ -14,6 +14,8 @@ class ItemJukebox(originalID: ItemID) : FixtureItemBase(originalID, "net.torvald
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/jukebox.tga")
|
||||
override val itemImageEmissive: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/jukebox_emsv.tga")
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var originalName = "ITEM_JUKEBOX"
|
||||
|
||||
@@ -14,6 +14,8 @@ class ItemSmelterBasic(originalID: ItemID) : FixtureItemBase(originalID, "net.to
|
||||
override val materialId = ""
|
||||
override val itemImage: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall.tga")
|
||||
override val itemImageEmissive: TextureRegion
|
||||
get() = getItemImageFromSingleImage("basegame", "sprites/fixtures/smelter_tall_emsv.tga")
|
||||
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var originalName = "ITEM_SMELTER_SMALL"
|
||||
|
||||
@@ -180,8 +180,9 @@ object ReadActor {
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPART_TO_ENTRY_MAP else null,
|
||||
false
|
||||
false, false
|
||||
)
|
||||
|
||||
if (animFileGlow != null) {
|
||||
actor.animDescGlow = ADProperties(ByteArray64Reader(animFileGlow.bytes, Common.CHARSET))
|
||||
actor.spriteGlow = AssembledSpriteAnimation(
|
||||
@@ -189,9 +190,10 @@ object ReadActor {
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTGLOW_TO_ENTRY_MAP else null,
|
||||
true
|
||||
true, false
|
||||
)
|
||||
}
|
||||
|
||||
if (animFileEmissive != null) {
|
||||
actor.animDescEmissive = ADProperties(ByteArray64Reader(animFileEmissive.bytes, Common.CHARSET))
|
||||
actor.spriteEmissive = AssembledSpriteAnimation(
|
||||
@@ -199,7 +201,7 @@ object ReadActor {
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTEMISSIVE_TO_ENTRY_MAP else null,
|
||||
true
|
||||
false, true
|
||||
)
|
||||
}
|
||||
|
||||
@@ -213,12 +215,58 @@ object ReadActor {
|
||||
actor.reassembleSprite(actor.sprite!!, actor.spriteGlow, heldItem)*/
|
||||
}
|
||||
else if (actor is ActorWithBody && actor is HasAssembledSprite) {
|
||||
if (actor.animDesc != null) actor.sprite = AssembledSpriteAnimation(actor.animDesc!!, actor, false)
|
||||
if (actor.animDescGlow != null) actor.spriteGlow = AssembledSpriteAnimation(actor.animDescGlow!!, actor, true)
|
||||
if (actor.animDescEmissive != null) actor.spriteEmissive = AssembledSpriteAnimation(actor.animDescEmissive!!, actor, true)
|
||||
if (actor.animDesc != null) actor.sprite = AssembledSpriteAnimation(actor.animDesc!!, actor, false, false)
|
||||
if (actor.animDescGlow != null) actor.spriteGlow = AssembledSpriteAnimation(actor.animDescGlow!!, actor, true, false)
|
||||
if (actor.animDescEmissive != null) actor.spriteEmissive = AssembledSpriteAnimation(actor.animDescEmissive!!, actor, false, true)
|
||||
|
||||
//actor.reassembleSprite(actor.sprite, actor.spriteGlow, null)
|
||||
}
|
||||
}
|
||||
|
||||
private fun makeSprite(mode: Int, actor: IngamePlayer, disk: SimpleFileSystem, file: EntryFile?, bodypartsFile: EntryFile?) {
|
||||
val animDesc = when (mode) {
|
||||
0 -> actor.animDesc
|
||||
1 -> actor.animDescGlow
|
||||
2 -> actor.animDescEmissive
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
if (file != null) {
|
||||
when (mode) {
|
||||
0 -> { actor.animDesc = ADProperties(ByteArray64Reader(file.bytes, Common.CHARSET)) }
|
||||
1 -> { actor.animDescGlow = ADProperties(ByteArray64Reader(file.bytes, Common.CHARSET)) }
|
||||
2 -> { actor.animDescEmissive = ADProperties(ByteArray64Reader(file.bytes, Common.CHARSET)) }
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
when (mode) {
|
||||
0 -> { actor.sprite = AssembledSpriteAnimation(
|
||||
actor.animDesc!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPART_TO_ENTRY_MAP else null,
|
||||
false, false
|
||||
) }
|
||||
1 -> { actor.spriteGlow = AssembledSpriteAnimation(
|
||||
actor.animDescGlow!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTGLOW_TO_ENTRY_MAP else null,
|
||||
true, false
|
||||
) }
|
||||
2 -> { actor.spriteEmissive = AssembledSpriteAnimation(
|
||||
actor.animDescEmissive!!,
|
||||
actor,
|
||||
if (bodypartsFile != null) disk else null,
|
||||
if (bodypartsFile != null) BODYPARTEMISSIVE_TO_ENTRY_MAP else null,
|
||||
false, true
|
||||
) }
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user