1 package ru.deadsoftware.cavedroid.game.model.item
3 import com.badlogic.gdx.graphics.g2d.Sprite
4 import ru.deadsoftware.cavedroid.game.model.block.Block
5 import kotlin.contracts.ExperimentalContracts
6 import kotlin.contracts.contract
8 @OptIn(ExperimentalContracts::class)
11 abstract val params: CommonItemParams
12 abstract val sprite: Sprite
14 fun isPlaceable(): Boolean {
15 contract { returns(true) implies (this@Item is Placeable) }
16 return this is Placeable
19 fun isTool(): Boolean {
20 contract { returns(true) implies (this@Item is Tool) }
24 fun isUsable(): Boolean {
25 contract { returns(true) implies (this@Item is Placeable) }
26 return this is Placeable
29 sealed class Tool : Item() {
30 abstract val mobDamageMultiplier: Float
31 abstract val blockDamageMultiplier: Float
34 sealed class Usable : Item() {
35 abstract val useActionKey: String
39 override val params: CommonItemParams,
42 override val sprite: Sprite get() = block.sprite
46 override val params: CommonItemParams,
47 override val sprite: Sprite,
48 override val mobDamageMultiplier: Float,
49 override val blockDamageMultiplier: Float,
53 override val params: CommonItemParams,
54 override val sprite: Sprite,
55 override val mobDamageMultiplier: Float,
56 override val blockDamageMultiplier: Float,
60 override val params: CommonItemParams,
61 override val sprite: Sprite,
62 override val useActionKey: String