-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9986a6f
commit e906f03
Showing
11 changed files
with
130 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/org/hexworks/cavesofzircon/attributes/FungusSpread.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.hexworks.cavesofzircon.attributes | ||
|
||
import org.hexworks.amethyst.api.Attribute | ||
import org.hexworks.cavesofzircon.GameConfig | ||
|
||
data class FungusSpread( | ||
var spreadCount: Int = 0, | ||
val maximumSpread: Int = GameConfig.MAXIMUM_FUNGUS_SPREAD) : Attribute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/kotlin/org/hexworks/cavesofzircon/commands/Attack.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.hexworks.cavesofzircon.commands | ||
|
||
import org.hexworks.amethyst.api.entity.EntityType | ||
import org.hexworks.cavesofzircon.extensions.GameEntity | ||
import org.hexworks.cavesofzircon.world.GameContext | ||
|
||
data class Attack(override val context: GameContext, | ||
override val source: GameEntity<EntityType>, | ||
override val target: GameEntity<EntityType>) : EntityAction<EntityType, EntityType> |
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/org/hexworks/cavesofzircon/systems/Attackable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.hexworks.cavesofzircon.systems | ||
|
||
import org.hexworks.amethyst.api.Consumed | ||
import org.hexworks.amethyst.api.base.BaseFacet | ||
import org.hexworks.amethyst.api.entity.EntityType | ||
import org.hexworks.cavesofzircon.commands.Attack | ||
import org.hexworks.cavesofzircon.extensions.GameCommand | ||
import org.hexworks.cavesofzircon.world.GameContext | ||
|
||
object Attackable : BaseFacet<GameContext>() { | ||
|
||
override fun executeCommand(command: GameCommand<out EntityType>) = command.responseWhenCommandIs(Attack::class) { (context, attacker, target) -> | ||
context.world.removeEntity(target) | ||
Consumed | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/org/hexworks/cavesofzircon/systems/FungusGrowth.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.hexworks.cavesofzircon.systems | ||
|
||
import org.hexworks.amethyst.api.base.BaseBehavior | ||
import org.hexworks.amethyst.api.entity.EntityType | ||
import org.hexworks.cavesofzircon.attributes.FungusSpread | ||
import org.hexworks.cavesofzircon.builders.EntityFactory | ||
import org.hexworks.cavesofzircon.extensions.GameEntity | ||
import org.hexworks.cavesofzircon.extensions.position | ||
import org.hexworks.cavesofzircon.extensions.tryToFindAttribute | ||
import org.hexworks.cavesofzircon.world.GameContext | ||
import org.hexworks.cobalt.datatypes.extensions.map | ||
import org.hexworks.zircon.api.Sizes | ||
|
||
object FungusGrowth : BaseBehavior<GameContext>(FungusSpread::class) { | ||
|
||
override fun update(entity: GameEntity<out EntityType>, context: GameContext): Boolean { | ||
val world = context.world | ||
val fungusSpread = entity.tryToFindAttribute(FungusSpread::class) | ||
val (spreadCount, maxSpread) = fungusSpread | ||
return if (spreadCount < maxSpread && Math.random() < 0.015) { | ||
world.findEmptyLocationWithin( | ||
offset = entity.position | ||
.withRelativeX(-1) | ||
.withRelativeY(-1), | ||
size = Sizes.create3DSize(3, 3, 0)).map { emptyLocation -> | ||
world.addEntity(EntityFactory.newFungus(fungusSpread), emptyLocation) | ||
fungusSpread.spreadCount++ | ||
} | ||
true | ||
} else false | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters