You can kill Creatures!
This commit is contained in:
parent
b642879da4
commit
571737fea2
3 changed files with 19 additions and 9 deletions
|
@ -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.Creature
|
||||||
import group.ouroboros.potrogue.entity.attributes.types.Player
|
import group.ouroboros.potrogue.entity.attributes.types.Player
|
||||||
import group.ouroboros.potrogue.entity.attributes.types.Wall
|
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.messages.Dig
|
||||||
import group.ouroboros.potrogue.entity.systems.CameraMover
|
import group.ouroboros.potrogue.entity.systems.*
|
||||||
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.world.GameContext
|
import group.ouroboros.potrogue.world.GameContext
|
||||||
import org.hexworks.amethyst.api.builder.EntityBuilder
|
import org.hexworks.amethyst.api.builder.EntityBuilder
|
||||||
import org.hexworks.amethyst.api.entity.EntityType
|
import org.hexworks.amethyst.api.entity.EntityType
|
||||||
|
@ -43,7 +41,7 @@ object EntityFactory {
|
||||||
attributes(
|
attributes(
|
||||||
EntityPosition(),
|
EntityPosition(),
|
||||||
EntityTile(GameTileRepository.PLAYER),
|
EntityTile(GameTileRepository.PLAYER),
|
||||||
EntityActions(Dig::class)
|
EntityActions(Dig::class, Attack::class)
|
||||||
)
|
)
|
||||||
behaviors(InputReceiver)
|
behaviors(InputReceiver)
|
||||||
facets(Movable, CameraMover)
|
facets(Movable, CameraMover)
|
||||||
|
@ -53,7 +51,7 @@ object EntityFactory {
|
||||||
attributes(BlockOccupier,
|
attributes(BlockOccupier,
|
||||||
EntityPosition(),
|
EntityPosition(),
|
||||||
EntityTile(GameTileRepository.CREATURE))
|
EntityTile(GameTileRepository.CREATURE))
|
||||||
facets()
|
facets(Attackable)
|
||||||
behaviors()
|
behaviors()
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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<EntityType>,
|
||||||
|
override val target: GameEntity<EntityType>
|
||||||
|
) : EntityAction<EntityType, EntityType>
|
|
@ -1,12 +1,13 @@
|
||||||
package group.ouroboros.potrogue.entity.systems
|
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 group.ouroboros.potrogue.world.GameContext
|
||||||
import org.hexworks.amethyst.api.Consumed
|
import org.hexworks.amethyst.api.Consumed
|
||||||
import org.hexworks.amethyst.api.Response
|
import org.hexworks.amethyst.api.Response
|
||||||
import org.hexworks.amethyst.api.base.BaseFacet
|
import org.hexworks.amethyst.api.base.BaseFacet
|
||||||
object Attackable : BaseFacet<GameContext, EntityAction.Attack>(EntityAction.Attack::class) {
|
|
||||||
override suspend fun receive(message: EntityAction.Attack): Response {
|
object Attackable : BaseFacet<GameContext, Attack>(Attack::class) {
|
||||||
|
override suspend fun receive(message: Attack): Response {
|
||||||
val (context, _, target) = message
|
val (context, _, target) = message
|
||||||
context.world.removeEntity(target)
|
context.world.removeEntity(target)
|
||||||
return Consumed
|
return Consumed
|
||||||
|
|
Loading…
Reference in a new issue