diff --git a/src/main/kotlin/group/ouroboros/potrogue/builders/EntityFactory.kt b/src/main/kotlin/group/ouroboros/potrogue/builders/EntityFactory.kt index b7ac2b5..ce595e8 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/builders/EntityFactory.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/builders/EntityFactory.kt @@ -7,11 +7,9 @@ import group.ouroboros.potrogue.entity.attributes.flags.BlockOccupier import group.ouroboros.potrogue.entity.attributes.types.Creature import group.ouroboros.potrogue.entity.attributes.types.Player import group.ouroboros.potrogue.entity.attributes.types.Wall +import group.ouroboros.potrogue.entity.messages.Attack import group.ouroboros.potrogue.entity.messages.Dig -import group.ouroboros.potrogue.entity.systems.CameraMover -import group.ouroboros.potrogue.entity.systems.Diggable -import group.ouroboros.potrogue.entity.systems.InputReceiver -import group.ouroboros.potrogue.entity.systems.Movable +import group.ouroboros.potrogue.entity.systems.* import group.ouroboros.potrogue.world.GameContext import org.hexworks.amethyst.api.builder.EntityBuilder import org.hexworks.amethyst.api.entity.EntityType @@ -43,7 +41,7 @@ object EntityFactory { attributes( EntityPosition(), EntityTile(GameTileRepository.PLAYER), - EntityActions(Dig::class) + EntityActions(Dig::class, Attack::class) ) behaviors(InputReceiver) facets(Movable, CameraMover) @@ -53,7 +51,7 @@ object EntityFactory { attributes(BlockOccupier, EntityPosition(), EntityTile(GameTileRepository.CREATURE)) - facets() + facets(Attackable) behaviors() } } \ No newline at end of file diff --git a/src/main/kotlin/group/ouroboros/potrogue/entity/messages/Attack.kt b/src/main/kotlin/group/ouroboros/potrogue/entity/messages/Attack.kt new file mode 100644 index 0000000..1262c00 --- /dev/null +++ b/src/main/kotlin/group/ouroboros/potrogue/entity/messages/Attack.kt @@ -0,0 +1,11 @@ +package group.ouroboros.potrogue.entity.messages + +import group.ouroboros.potrogue.extensions.GameEntity +import group.ouroboros.potrogue.world.GameContext +import org.hexworks.amethyst.api.entity.EntityType + +data class Attack( + override val context: GameContext, + override val source: GameEntity, + override val target: GameEntity +) : EntityAction \ No newline at end of file diff --git a/src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt b/src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt index 1f57e61..a86dfec 100644 --- a/src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt +++ b/src/main/kotlin/group/ouroboros/potrogue/entity/systems/Attackable.kt @@ -1,12 +1,13 @@ package group.ouroboros.potrogue.entity.systems -import group.ouroboros.potrogue.entity.messages.EntityAction +import group.ouroboros.potrogue.entity.messages.Attack 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 { + +object Attackable : BaseFacet(Attack::class) { + override suspend fun receive(message: Attack): Response { val (context, _, target) = message context.world.removeEntity(target) return Consumed