Work on attack stuff

This commit is contained in:
nelle 2023-11-04 23:47:00 -06:00
parent 45a529c958
commit 087a6a56bd
2 changed files with 21 additions and 0 deletions

View file

@ -2,6 +2,7 @@ package group.ouroboros.potrogue.entity.messages
import group.ouroboros.potrogue.extensions.GameEntity
import group.ouroboros.potrogue.extensions.GameMessage
import group.ouroboros.potrogue.world.GameContext
import org.hexworks.amethyst.api.entity.EntityType
// Our EntityAction is different from a regular GameMessage in a way that it also has a target.
@ -24,4 +25,10 @@ interface EntityAction <S : EntityType, T : EntityType> : GameMessage {
operator fun component1() = context
operator fun component2() = source
operator fun component3() = target
data class Attack(
override val context: GameContext,
override val source: GameEntity<EntityType>,
override val target: GameEntity<EntityType>
) : EntityAction<EntityType, EntityType>
}

View file

@ -0,0 +1,14 @@
package group.ouroboros.potrogue.entity.systems
import group.ouroboros.potrogue.entity.messages.EntityAction
import group.ouroboros.potrogue.world.GameContext
import org.hexworks.amethyst.api.Consumed
import org.hexworks.amethyst.api.Response
import org.hexworks.amethyst.api.base.BaseFacet
object Attackable : BaseFacet<GameContext, EntityAction.Attack>(EntityAction.Attack::class) {
override suspend fun receive(message: EntityAction.Attack): Response {
val (context, _, target) = message
context.world.removeEntity(target)
return Consumed
}
}