сыс
This commit is contained in:
parent
bc14589551
commit
d6ac6d86bb
@ -27,9 +27,9 @@ import ru.dbotthepony.kstarbound.defs.item.HarvestingToolPrototype
|
|||||||
import ru.dbotthepony.kstarbound.defs.item.HeadArmorItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.HeadArmorItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.IArmorItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.IArmorItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.IItemDefinition
|
||||||
|
import ru.dbotthepony.kstarbound.defs.item.InventoryIcon
|
||||||
import ru.dbotthepony.kstarbound.defs.item.ItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.ItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.LegsArmorItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.LegsArmorItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.LeveledStatusEffect
|
|
||||||
import ru.dbotthepony.kstarbound.defs.item.LiquidItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.LiquidItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.MaterialItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.MaterialItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
import ru.dbotthepony.kstarbound.defs.tile.LiquidDefinition
|
||||||
@ -168,7 +168,7 @@ class Starbound : ISBFileLocator {
|
|||||||
|
|
||||||
spriteRegistry = SpriteReference.Adapter(pathStack, this@Starbound::atlasRegistry)
|
spriteRegistry = SpriteReference.Adapter(pathStack, this@Starbound::atlasRegistry)
|
||||||
registerTypeAdapter(spriteRegistry)
|
registerTypeAdapter(spriteRegistry)
|
||||||
registerTypeAdapterFactory(IItemDefinition.InventoryIcon.Factory(pathStack, spriteRegistry))
|
registerTypeAdapterFactory(InventoryIcon.Factory(pathStack, spriteRegistry))
|
||||||
|
|
||||||
registerTypeAdapterFactory(IArmorItemDefinition.Frames.Factory(pathStack, this@Starbound::atlasRegistry))
|
registerTypeAdapterFactory(IArmorItemDefinition.Frames.Factory(pathStack, this@Starbound::atlasRegistry))
|
||||||
registerTypeAdapterFactory(DirectAssetReferenceFactory(pathStack))
|
registerTypeAdapterFactory(DirectAssetReferenceFactory(pathStack))
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Тип брони. Более формально, в какой слот надевается данный предмет
|
|
||||||
*/
|
|
||||||
enum class ArmorPieceType {
|
|
||||||
/**
|
|
||||||
* Шлем
|
|
||||||
*/
|
|
||||||
HEAD,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Нагрудник
|
|
||||||
*/
|
|
||||||
CHEST,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Поножи
|
|
||||||
*/
|
|
||||||
LEGS,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Плащ/рюкзак/прочее
|
|
||||||
*/
|
|
||||||
BACK
|
|
||||||
}
|
|
@ -14,11 +14,6 @@ import ru.dbotthepony.kstarbound.io.json.builder.JsonImplementation
|
|||||||
import ru.dbotthepony.kstarbound.util.PathStack
|
import ru.dbotthepony.kstarbound.util.PathStack
|
||||||
|
|
||||||
interface IArmorItemDefinition : ILeveledItemDefinition, IScriptableItemDefinition {
|
interface IArmorItemDefinition : ILeveledItemDefinition, IScriptableItemDefinition {
|
||||||
/**
|
|
||||||
* @see ArmorPieceType
|
|
||||||
*/
|
|
||||||
val armorType: ArmorPieceType
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Варианты покраски (???)
|
* Варианты покраски (???)
|
||||||
*/
|
*/
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item
|
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonFactory
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonImplementation
|
|
||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
|
||||||
|
|
||||||
interface IFossilItemDefinition : IItemDefinition {
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val race: String
|
|
||||||
val displayImage: String
|
|
||||||
val displayoffset: Vector2d
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val fossilSetName: String
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val setIndex: Int
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val setCount: Int
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val setCollectables: Map<String, String>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val completeFossilIcon: String?
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val completeFossilObject: String?
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Используется в костях-ископаемых
|
|
||||||
*/
|
|
||||||
val completeSetDescriptions: IFossilSetDescription?
|
|
||||||
|
|
||||||
@JsonImplementation(FossilSetDescription::class)
|
|
||||||
interface IFossilSetDescription : IThingWithDescription {
|
|
||||||
/**
|
|
||||||
* Цена в пикселях
|
|
||||||
*/
|
|
||||||
val price: Long
|
|
||||||
}
|
|
||||||
|
|
||||||
@JsonFactory
|
|
||||||
data class FossilSetDescription(
|
|
||||||
override val price: Long = 0L,
|
|
||||||
override val shortdescription: String = "...",
|
|
||||||
override val description: String = "..."
|
|
||||||
) : IFossilSetDescription
|
|
||||||
}
|
|
@ -0,0 +1,9 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||||
|
import ru.dbotthepony.kstarbound.io.json.builder.JsonImplementation
|
||||||
|
|
||||||
|
@JsonImplementation(InventoryIcon::class)
|
||||||
|
interface IInventoryIcon {
|
||||||
|
val image: SpriteReference
|
||||||
|
}
|
@ -1,18 +1,7 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.TypeAdapter
|
|
||||||
import com.google.gson.TypeAdapterFactory
|
|
||||||
import com.google.gson.reflect.TypeToken
|
|
||||||
import com.google.gson.stream.JsonReader
|
|
||||||
import com.google.gson.stream.JsonToken
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
||||||
import ru.dbotthepony.kstarbound.defs.RegistryReference
|
import ru.dbotthepony.kstarbound.defs.RegistryReference
|
||||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.JsonImplementation
|
|
||||||
import ru.dbotthepony.kstarbound.util.PathStack
|
|
||||||
|
|
||||||
interface IItemDefinition : IThingWithDescription {
|
interface IItemDefinition : IThingWithDescription {
|
||||||
/**
|
/**
|
||||||
@ -29,60 +18,16 @@ interface IItemDefinition : IThingWithDescription {
|
|||||||
*/
|
*/
|
||||||
val price: Long
|
val price: Long
|
||||||
|
|
||||||
/**
|
|
||||||
* Редкость как [ItemRarity]
|
|
||||||
*/
|
|
||||||
val rarity: ItemRarity
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Категория предмета, определяет, в какую вкладку инвентаря оно попадает
|
* Категория предмета, определяет, в какую вкладку инвентаря оно попадает
|
||||||
*/
|
*/
|
||||||
val category: String?
|
val category: String
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Иконка в инвентаре, относительный и абсолютный пути
|
* Иконка в инвентаре, относительный и абсолютный пути
|
||||||
*/
|
*/
|
||||||
val inventoryIcon: List<IInventoryIcon>?
|
val inventoryIcon: List<IInventoryIcon>?
|
||||||
|
|
||||||
@JsonImplementation(InventoryIcon::class)
|
|
||||||
interface IInventoryIcon {
|
|
||||||
val image: SpriteReference
|
|
||||||
}
|
|
||||||
|
|
||||||
data class InventoryIcon(
|
|
||||||
override val image: SpriteReference
|
|
||||||
) : IInventoryIcon {
|
|
||||||
class Factory(val remapper: PathStack, val spriteRegistry: SpriteReference.Adapter) : TypeAdapterFactory {
|
|
||||||
override fun <T : Any?> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
|
|
||||||
if (type.rawType == InventoryIcon::class.java) {
|
|
||||||
return object : TypeAdapter<InventoryIcon>() {
|
|
||||||
private val adapter = FactoryAdapter.Builder(InventoryIcon::class, InventoryIcon::image).build(gson)
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter, value: InventoryIcon?) {
|
|
||||||
if (value == null)
|
|
||||||
out.nullValue()
|
|
||||||
else
|
|
||||||
adapter.write(out, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun read(`in`: JsonReader): InventoryIcon? {
|
|
||||||
if (`in`.peek() == JsonToken.NULL)
|
|
||||||
return null
|
|
||||||
|
|
||||||
if (`in`.peek() == JsonToken.STRING) {
|
|
||||||
return InventoryIcon(spriteRegistry.parse(remapper.remap(`in`.nextString())))
|
|
||||||
}
|
|
||||||
|
|
||||||
return adapter.read(`in`)
|
|
||||||
}
|
|
||||||
} as TypeAdapter<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Теги предмета
|
* Теги предмета
|
||||||
*/
|
*/
|
||||||
@ -130,25 +75,20 @@ interface IItemDefinition : IThingWithDescription {
|
|||||||
*/
|
*/
|
||||||
val radioMessagesOnPickup: List<String>
|
val radioMessagesOnPickup: List<String>
|
||||||
|
|
||||||
/**
|
|
||||||
* Топливо корабля
|
|
||||||
*/
|
|
||||||
val fuelAmount: Long?
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Звуки при поднятии "малого" количества предметов. Не имеет никакого смысла без [smallStackLimit]
|
* Звуки при поднятии "малого" количества предметов. Не имеет никакого смысла без [smallStackLimit]
|
||||||
*/
|
*/
|
||||||
val pickupSoundsSmall: List<String>
|
val pickupSoundsSmall: List<String>?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Звуки при поднятии "среднего" количества предметов. Не имеет никакого смысла без [mediumStackLimit]
|
* Звуки при поднятии "среднего" количества предметов. Не имеет никакого смысла без [mediumStackLimit]
|
||||||
*/
|
*/
|
||||||
val pickupSoundsMedium: List<String>
|
val pickupSoundsMedium: List<String>?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Звуки при поднятии "большого" количества предметов. Не имеет никакого смысла без [smallStackLimit] и без [mediumStackLimit]
|
* Звуки при поднятии "большого" количества предметов. Не имеет никакого смысла без [smallStackLimit] и без [mediumStackLimit]
|
||||||
*/
|
*/
|
||||||
val pickupSoundsLarge: List<String>
|
val pickupSoundsLarge: List<String>?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Количество предметов ниже или равному данному значению проиграет звук [pickupSoundsSmall]
|
* Количество предметов ниже или равному данному значению проиграет звук [pickupSoundsSmall]
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.TypeAdapter
|
||||||
|
import com.google.gson.TypeAdapterFactory
|
||||||
|
import com.google.gson.reflect.TypeToken
|
||||||
|
import com.google.gson.stream.JsonReader
|
||||||
|
import com.google.gson.stream.JsonToken
|
||||||
|
import com.google.gson.stream.JsonWriter
|
||||||
|
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
||||||
|
import ru.dbotthepony.kstarbound.io.json.builder.FactoryAdapter
|
||||||
|
import ru.dbotthepony.kstarbound.util.PathStack
|
||||||
|
|
||||||
|
data class InventoryIcon(
|
||||||
|
override val image: SpriteReference
|
||||||
|
) : IInventoryIcon {
|
||||||
|
class Factory(val remapper: PathStack, val spriteRegistry: SpriteReference.Adapter) : TypeAdapterFactory {
|
||||||
|
override fun <T : Any?> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
|
||||||
|
if (type.rawType == InventoryIcon::class.java) {
|
||||||
|
return object : TypeAdapter<InventoryIcon>() {
|
||||||
|
private val adapter = FactoryAdapter.Builder(InventoryIcon::class, InventoryIcon::image).build(gson)
|
||||||
|
|
||||||
|
override fun write(out: JsonWriter, value: InventoryIcon?) {
|
||||||
|
if (value == null)
|
||||||
|
out.nullValue()
|
||||||
|
else
|
||||||
|
adapter.write(out, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun read(`in`: JsonReader): InventoryIcon? {
|
||||||
|
if (`in`.peek() == JsonToken.NULL)
|
||||||
|
return null
|
||||||
|
|
||||||
|
if (`in`.peek() == JsonToken.STRING) {
|
||||||
|
return InventoryIcon(spriteRegistry.parse(remapper.remap(`in`.nextString())))
|
||||||
|
}
|
||||||
|
|
||||||
|
return adapter.read(`in`)
|
||||||
|
}
|
||||||
|
} as TypeAdapter<T>
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -34,7 +34,7 @@ open class ItemPrototype : FreezableDefintionBuilder(), IItemDefinition {
|
|||||||
final override var price: Long by NotNull(0L)
|
final override var price: Long by NotNull(0L)
|
||||||
final override var rarity: ItemRarity by NotNull(ItemRarity.COMMON)
|
final override var rarity: ItemRarity by NotNull(ItemRarity.COMMON)
|
||||||
final override var category: String? by Nullable()
|
final override var category: String? by Nullable()
|
||||||
final override var inventoryIcon: ImmutableList<IItemDefinition.InventoryIcon>? by Nullable()
|
final override var inventoryIcon: ImmutableList<InventoryIcon>? by Nullable()
|
||||||
final override var itemTags: ImmutableList<String> by NotNull(ImmutableList.of())
|
final override var itemTags: ImmutableList<String> by NotNull(ImmutableList.of())
|
||||||
final override var learnBlueprintsOnPickup: ImmutableList<RegistryReference<IItemDefinition>> by NotNull(ImmutableList.of())
|
final override var learnBlueprintsOnPickup: ImmutableList<RegistryReference<IItemDefinition>> by NotNull(ImmutableList.of())
|
||||||
final override var maxStack: Long by NotNull(9999L)
|
final override var maxStack: Long by NotNull(9999L)
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item
|
|
||||||
|
|
||||||
import com.google.gson.stream.JsonWriter
|
|
||||||
import ru.dbotthepony.kstarbound.io.json.builder.IStringSerializable
|
|
||||||
|
|
||||||
enum class ItemRarity(val canonical: String) : IStringSerializable {
|
|
||||||
COMMON("Common"),
|
|
||||||
UNCOMMON("Uncommon"),
|
|
||||||
RARE("Rare"),
|
|
||||||
LEGENDARY("Legendary"),
|
|
||||||
ESSENTIAL("Essential");
|
|
||||||
|
|
||||||
override fun match(name: String): Boolean {
|
|
||||||
return name == this.canonical || name.lowercase() == this.name.lowercase()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun write(out: JsonWriter) {
|
|
||||||
out.value(canonical)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user