mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 12:04:06 +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)
|
||||
|
||||
Reference in New Issue
Block a user