Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/main/kotlin/dev/stillya/vpet/animation/Planner.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ class GreedyPlanner(
bridges: List<Bridge>
): PlanResult {
log.trace("Planning from effect: $currentEffect to requirement: $requirement")

if (requirement.isSatisfiedBy(currentEffect)) {
log.trace("Current effect already satisfies requirement")
return PlanResult(emptyList(), currentEffect)
}

val selectedBridges = mutableListOf<Bridge>()
var effect = currentEffect

Expand Down
6 changes: 1 addition & 5 deletions src/main/kotlin/dev/stillya/vpet/game/GameController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -117,18 +117,14 @@ class GameController(private val project: Project) {
val visualCol = mapper.toVisualColF(caretPixelX)

val registry = EntityRegistry()
val player = registry.create()
val player = registry.register(character.id())
registry.add(player, Transform(visualCol, firstVisibleLine.toFloat()))
registry.add(player, Velocity(0f, 0f))
registry.add(player, PhysicsState(isOnGround = false))
registry.add(player, SpriteState())
registry.add(player, PhaseState(GamePhase.ENTRANCE))
registry.add(player, AABB(2, 2))

if (character is dev.stillya.vpet.pet.PetAnimated) {
character.setEntityId(player)
}

return World(registry = registry, player = player)
}
}
5 changes: 5 additions & 0 deletions src/main/kotlin/dev/stillya/vpet/game/ecs/EntityRegistry.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ class EntityRegistry {
return id
}

fun register(id: EntityID): EntityID {
components[id] = mutableMapOf()
return id
}

fun destroy(id: EntityID) {
components.remove(id)
pendingRemovals.remove(id)
Expand Down
8 changes: 1 addition & 7 deletions src/main/kotlin/dev/stillya/vpet/pet/PetAnimated.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class PetAnimated(
private val renderer: IconRenderer
get() = project.service<IconRenderer>()

private var entityId: EntityID? = null

var random: Random = Random
set(value) {
field = value
Expand Down Expand Up @@ -292,11 +290,7 @@ class PetAnimated(
playTransition(pivotSequence to AnimationState.OBSERVING, context)
}

override fun id() = entityId ?: error("EntityID not initialized - call setEntityId first")

fun setEntityId(id: EntityID) {
entityId = id
}
override fun id() = EntityID("pet")

override fun collider() = AABB(width = 2, height = 2)

Expand Down

This file was deleted.

21 changes: 0 additions & 21 deletions src/test/kotlin/dev/stillya/vpet/pet/PetAnimatedIntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import dev.stillya.vpet.AtlasLoader
import dev.stillya.vpet.IconRenderer
import dev.stillya.vpet.animation.Animation
import dev.stillya.vpet.config.AsepriteJsonAtlasLoader
import dev.stillya.vpet.game.ecs.EntityID
import dev.stillya.vpet.graphics.AnimationContext
import dev.stillya.vpet.graphics.AnimationEpochManager
import dev.stillya.vpet.graphics.AnimationTrigger
Expand Down Expand Up @@ -193,7 +192,6 @@ class PetAnimatedIntegrationTest : LightPlatform4TestCase() {
rendererSpy.clear()

petAnimated.onProgress()
val runningAnimationCount = rendererSpy.enqueuedAnimations.size

petAnimated.onFail()
val afterFailCount = rendererSpy.enqueuedAnimations.size
Expand Down Expand Up @@ -278,25 +276,6 @@ class PetAnimatedIntegrationTest : LightPlatform4TestCase() {

assertTrue("Should flip when cursor moves to different sides", flippedLeft || flippedRight)
}

@Test
fun testEntityIdCanBeSetAndRetrieved() {
val newId = EntityID("player_123")
petAnimated.setEntityId(newId)

assertEquals("EntityID should be updated after setEntityId call", newId, petAnimated.id())
}

@Test
fun testEntityIdRequiresInitialization() {
val freshPet = PetAnimated(project)
try {
freshPet.id()
fail("Expected IllegalStateException when accessing uninitialized EntityID")
} catch (e: IllegalStateException) {
assertTrue("Error message should mention initialization", e.message?.contains("not initialized") == true)
}
}
}

class IconRendererSpy(project: Project) : IconRenderer {
Expand Down
Loading