harvestingtool
This commit is contained in:
parent
a8e921bfb1
commit
49e90a6dca
@ -20,6 +20,7 @@ import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
|||||||
import ru.dbotthepony.kstarbound.defs.item.ArmorItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.ArmorItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.ArmorPieceType
|
import ru.dbotthepony.kstarbound.defs.item.ArmorPieceType
|
||||||
import ru.dbotthepony.kstarbound.defs.item.CurrencyItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.CurrencyItemPrototype
|
||||||
|
import ru.dbotthepony.kstarbound.defs.item.HarvestingToolPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.IArmorItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.IArmorItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.IFossilItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.IFossilItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.IItemDefinition
|
||||||
@ -507,7 +508,7 @@ object Starbound {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun loadItemDefinitions(callback: (String) -> Unit) {
|
private fun loadItemDefinitions(callback: (String) -> Unit) {
|
||||||
val files = listOf(".item", ".currency", ".head", ".chest", ".legs", ".back", ".activeitem", ".matitem", ".liqitem")
|
val files = listOf(".item", ".currency", ".head", ".chest", ".legs", ".back", ".activeitem", ".matitem", ".liqitem", ".harvestingtool")
|
||||||
|
|
||||||
for (fs in fileSystems) {
|
for (fs in fileSystems) {
|
||||||
for (listedFile in fs.explore().filter { it.isFile }.filter { f -> files.any { f.name.endsWith(it) } }) {
|
for (listedFile in fs.explore().filter { it.isFile }.filter { f -> files.any { f.name.endsWith(it) } }) {
|
||||||
@ -519,6 +520,9 @@ object Starbound {
|
|||||||
if (listedFile.name.endsWith(".item")) {
|
if (listedFile.name.endsWith(".item")) {
|
||||||
val def = GSON.fromJson(listedFile.reader(), ItemPrototype::class.java)
|
val def = GSON.fromJson(listedFile.reader(), ItemPrototype::class.java)
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
||||||
|
} else if (listedFile.name.endsWith(".harvestingtool")) {
|
||||||
|
val def = GSON.fromJson(listedFile.reader(), HarvestingToolPrototype::class.java)
|
||||||
|
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
||||||
} else if (listedFile.name.endsWith(".matitem")) {
|
} else if (listedFile.name.endsWith(".matitem")) {
|
||||||
val def = GSON.fromJson(listedFile.reader(), MaterialItemPrototype::class.java)
|
val def = GSON.fromJson(listedFile.reader(), MaterialItemPrototype::class.java)
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.animation
|
||||||
|
|
||||||
|
interface IAnimated {
|
||||||
|
/**
|
||||||
|
* Сколько кадров в анимации
|
||||||
|
*/
|
||||||
|
val frames: Int
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Время в секундах между кадрами
|
||||||
|
*/
|
||||||
|
val animationCycle: Double
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
||||||
|
import ru.dbotthepony.kstarbound.defs.ThingDescription
|
||||||
|
|
||||||
|
data class HarvestingToolDefinition(
|
||||||
|
override val itemName: String,
|
||||||
|
override val price: Long = 4L,
|
||||||
|
override val rarity: ItemRarity,
|
||||||
|
override val category: String?,
|
||||||
|
override val inventoryIcon: ImmutableList<out IItemDefinition.IInventoryIcon>?,
|
||||||
|
override val itemTags: ImmutableList<String>,
|
||||||
|
override val learnBlueprintsOnPickup: ImmutableList<String>,
|
||||||
|
override val maxStack: Long,
|
||||||
|
override val eventCategory: String?,
|
||||||
|
override val consumeOnPickup: Boolean,
|
||||||
|
override val pickupQuestTemplates: ImmutableList<String>,
|
||||||
|
override val tooltipKind: ItemTooltipKind,
|
||||||
|
override val twoHanded: Boolean,
|
||||||
|
override val radioMessagesOnPickup: ImmutableList<String>,
|
||||||
|
override val fuelAmount: Long?,
|
||||||
|
|
||||||
|
override val frames: Int,
|
||||||
|
override val animationCycle: Double,
|
||||||
|
override val blockRadius: Int,
|
||||||
|
override val altBlockRadius: Int,
|
||||||
|
override val idleSound: ImmutableList<String>,
|
||||||
|
override val strikeSounds: ImmutableList<String>,
|
||||||
|
|
||||||
|
val descriptionData: ThingDescription,
|
||||||
|
|
||||||
|
val json: Map<String, Any>
|
||||||
|
) : IHarvestingToolDefinition, IThingWithDescription by descriptionData
|
@ -0,0 +1,50 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||||
|
import ru.dbotthepony.kstarbound.io.json.builder.JsonBuilder
|
||||||
|
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||||
|
|
||||||
|
@JsonBuilder
|
||||||
|
class HarvestingToolPrototype : ItemPrototype(), IHarvestingToolDefinition {
|
||||||
|
override var frames: Int by NotNullVar()
|
||||||
|
override var animationCycle: Double by NotNullVar()
|
||||||
|
override var blockRadius: Int by NotNullVar()
|
||||||
|
override var altBlockRadius: Int = 0
|
||||||
|
override var idleSound: ImmutableList<String> = ImmutableList.of()
|
||||||
|
override var strikeSounds: ImmutableList<String> = ImmutableList.of()
|
||||||
|
|
||||||
|
init {
|
||||||
|
maxStack = 1L
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun assemble(): IItemDefinition {
|
||||||
|
return HarvestingToolDefinition(
|
||||||
|
descriptionData = descriptionData,
|
||||||
|
itemName = itemName,
|
||||||
|
price = price,
|
||||||
|
rarity = rarity,
|
||||||
|
category = category,
|
||||||
|
inventoryIcon = inventoryIcon,
|
||||||
|
itemTags = itemTags,
|
||||||
|
learnBlueprintsOnPickup = learnBlueprintsOnPickup,
|
||||||
|
maxStack = maxStack,
|
||||||
|
eventCategory = eventCategory,
|
||||||
|
consumeOnPickup = consumeOnPickup,
|
||||||
|
pickupQuestTemplates = pickupQuestTemplates,
|
||||||
|
tooltipKind = tooltipKind,
|
||||||
|
twoHanded = twoHanded,
|
||||||
|
radioMessagesOnPickup = radioMessagesOnPickup,
|
||||||
|
fuelAmount = fuelAmount,
|
||||||
|
|
||||||
|
json = enrollMap(json),
|
||||||
|
|
||||||
|
frames = frames,
|
||||||
|
animationCycle = animationCycle,
|
||||||
|
blockRadius = blockRadius,
|
||||||
|
altBlockRadius = altBlockRadius,
|
||||||
|
idleSound = idleSound,
|
||||||
|
strikeSounds = strikeSounds,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import ru.dbotthepony.kstarbound.defs.animation.IAnimated
|
||||||
|
|
||||||
|
interface IHarvestingToolDefinition : IItemDefinition, IAnimated {
|
||||||
|
/**
|
||||||
|
* Радиус в тайлах, на какое расстояние действует данный инструмент для сбора
|
||||||
|
*/
|
||||||
|
val blockRadius: Int
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Радиус в тайлах, на какое расстояние действует данный инструмент для сбора
|
||||||
|
*/
|
||||||
|
val altBlockRadius: Int
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Звуки в бездействии
|
||||||
|
*/
|
||||||
|
val idleSound: List<String>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Звуки при работе
|
||||||
|
*/
|
||||||
|
val strikeSounds: List<String>
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user