From 087a6a56bdb20351012094bc928c9ec923c14399 Mon Sep 17 00:00:00 2001 From: LimePotato Date: Sat, 4 Nov 2023 23:47:00 -0600 Subject: [PATCH] Work on attack stuff --- .../potrogue/entity/messages/EntityAction.kt | 7 +++++++ .../potrogue/entity/systems/Attackable.kt | 14 ++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt diff --git a/src/main/kotlin/group/ouroboros/potrogue/entity/messages/EntityAction.kt b/src/main/kotlin/group/ouroboros/potrogue/entity/messages/EntityAction.kt index 8740549..50238c2 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/entity/messages/EntityAction.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/entity/messages/EntityAction.kt @@ -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 : GameMessage { operator fun component1() = context operator fun component2() = source operator fun component3() = target + + data class Attack( + override val context: GameContext, + override val source: GameEntity, + override val target: GameEntity + ) : EntityAction } diff --git a/src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt b/src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt new file mode 100644 index 0000000..1f57e61 --- /dev/null +++ b/src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt @@ -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(EntityAction.Attack::class) { + override suspend fun receive(message: EntityAction.Attack): Response { + val (context, _, target) = message + context.world.removeEntity(target) + return Consumed + } +} \ No newline at end of file