Flashlight definition
This commit is contained in:
parent
d8c644c64b
commit
ae8f8ad658
@ -19,8 +19,12 @@ import ru.dbotthepony.kstarbound.defs.image.AtlasConfiguration
|
|||||||
import ru.dbotthepony.kstarbound.defs.image.SpriteReference
|
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.BackArmorItemPrototype
|
||||||
|
import ru.dbotthepony.kstarbound.defs.item.ChestArmorItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.CurrencyItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.CurrencyItemPrototype
|
||||||
|
import ru.dbotthepony.kstarbound.defs.item.FlashlightPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.HarvestingToolPrototype
|
import ru.dbotthepony.kstarbound.defs.item.HarvestingToolPrototype
|
||||||
|
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.IFossilItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.IFossilItemDefinition
|
||||||
import ru.dbotthepony.kstarbound.defs.item.IItemDefinition
|
import ru.dbotthepony.kstarbound.defs.item.IItemDefinition
|
||||||
@ -28,6 +32,7 @@ import ru.dbotthepony.kstarbound.defs.item.ItemDefinition
|
|||||||
import ru.dbotthepony.kstarbound.defs.item.ItemPrototype
|
import ru.dbotthepony.kstarbound.defs.item.ItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.ItemRarity
|
import ru.dbotthepony.kstarbound.defs.item.ItemRarity
|
||||||
import ru.dbotthepony.kstarbound.defs.item.ItemTooltipKind
|
import ru.dbotthepony.kstarbound.defs.item.ItemTooltipKind
|
||||||
|
import ru.dbotthepony.kstarbound.defs.item.LegsArmorItemPrototype
|
||||||
import ru.dbotthepony.kstarbound.defs.item.LeveledStatusEffect
|
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
|
||||||
@ -508,47 +513,28 @@ 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", ".harvestingtool")
|
val files = linkedMapOf(
|
||||||
|
".item" to ItemPrototype::class.java,
|
||||||
|
".currency" to CurrencyItemPrototype::class.java,
|
||||||
|
".liqitem" to LiquidItemPrototype::class.java,
|
||||||
|
".matitem" to MaterialItemPrototype::class.java,
|
||||||
|
".flashlight" to FlashlightPrototype::class.java,
|
||||||
|
".harvestingtool" to HarvestingToolPrototype::class.java,
|
||||||
|
".head" to HeadArmorItemPrototype::class.java,
|
||||||
|
".chest" to ChestArmorItemPrototype::class.java,
|
||||||
|
".legs" to LegsArmorItemPrototype::class.java,
|
||||||
|
".back" to BackArmorItemPrototype::class.java,
|
||||||
|
)
|
||||||
|
|
||||||
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.keys.any { f.name.endsWith(it) } }) {
|
||||||
try {
|
try {
|
||||||
callback("Loading $listedFile")
|
callback("Loading $listedFile")
|
||||||
|
|
||||||
assetFolder = listedFile.computeDirectory()
|
assetFolder = listedFile.computeDirectory()
|
||||||
|
|
||||||
if (listedFile.name.endsWith(".item")) {
|
val def: ItemPrototype = GSON.fromJson(listedFile.reader(), files.entries.first { listedFile.name.endsWith(it.key) }.value)
|
||||||
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")) {
|
|
||||||
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!" }
|
|
||||||
} else if (listedFile.name.endsWith(".liqitem")) {
|
|
||||||
val def = GSON.fromJson(listedFile.reader(), LiquidItemPrototype::class.java)
|
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
|
||||||
} else if (listedFile.name.endsWith(".currency")) {
|
|
||||||
val def = GSON.fromJson(listedFile.reader(), CurrencyItemPrototype::class.java)
|
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
|
||||||
} else if (listedFile.name.endsWith(".head")) {
|
|
||||||
val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java)
|
|
||||||
def.armorType = ArmorPieceType.HEAD
|
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
|
||||||
} else if (listedFile.name.endsWith(".chest")) {
|
|
||||||
val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java)
|
|
||||||
def.armorType = ArmorPieceType.CHEST
|
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
|
||||||
} else if (listedFile.name.endsWith(".legs")) {
|
|
||||||
val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java)
|
|
||||||
def.armorType = ArmorPieceType.LEGS
|
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
|
||||||
} else if (listedFile.name.endsWith(".back")) {
|
|
||||||
val def = GSON.fromJson(listedFile.reader(), ArmorItemPrototype::class.java)
|
|
||||||
def.armorType = ArmorPieceType.BACK
|
|
||||||
check(items.put(def.itemName, def.assemble()) == null) { "Already has item with name ${def.itemName} loaded!" }
|
|
||||||
}
|
|
||||||
} catch (err: Throwable) {
|
} catch (err: Throwable) {
|
||||||
LOGGER.error("Loading item definition file $listedFile", err)
|
LOGGER.error("Loading item definition file $listedFile", err)
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import ru.dbotthepony.kstarbound.io.json.neverNull
|
|||||||
import ru.dbotthepony.kstarbound.util.NotNullVar
|
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||||
|
|
||||||
@JsonBuilder
|
@JsonBuilder
|
||||||
class ArmorItemPrototype : ItemPrototype(), IArmorItemDefinition {
|
open class ArmorItemPrototype : ItemPrototype(), IArmorItemDefinition {
|
||||||
override var colorOptions: ImmutableList<Map<String, String>> = ImmutableList.of()
|
override var colorOptions: ImmutableList<Map<String, String>> = ImmutableList.of()
|
||||||
override var maleFrames: IArmorItemDefinition.ArmorFrames by NotNullVar()
|
override var maleFrames: IArmorItemDefinition.ArmorFrames by NotNullVar()
|
||||||
override var femaleFrames: IArmorItemDefinition.ArmorFrames by NotNullVar()
|
override var femaleFrames: IArmorItemDefinition.ArmorFrames by NotNullVar()
|
||||||
@ -62,3 +62,31 @@ class ArmorItemPrototype : ItemPrototype(), IArmorItemDefinition {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonBuilder
|
||||||
|
class HeadArmorItemPrototype : ArmorItemPrototype() {
|
||||||
|
init {
|
||||||
|
armorType = ArmorPieceType.HEAD
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonBuilder
|
||||||
|
class ChestArmorItemPrototype : ArmorItemPrototype() {
|
||||||
|
init {
|
||||||
|
armorType = ArmorPieceType.CHEST
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonBuilder
|
||||||
|
class LegsArmorItemPrototype : ArmorItemPrototype() {
|
||||||
|
init {
|
||||||
|
armorType = ArmorPieceType.LEGS
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonBuilder
|
||||||
|
class BackArmorItemPrototype : ArmorItemPrototype() {
|
||||||
|
init {
|
||||||
|
armorType = ArmorPieceType.BACK
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList
|
||||||
|
import ru.dbotthepony.kstarbound.defs.IThingWithDescription
|
||||||
|
import ru.dbotthepony.kstarbound.defs.ThingDescription
|
||||||
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
|
|
||||||
|
data class FlashlightDefinition(
|
||||||
|
override val itemName: String,
|
||||||
|
override val price: Long,
|
||||||
|
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 lightPosition: Vector2d,
|
||||||
|
override val lightColor: Color,
|
||||||
|
override val beamLevel: Int,
|
||||||
|
override val beamAmbience: Double,
|
||||||
|
override val handPosition: Vector2d,
|
||||||
|
|
||||||
|
val descriptionData: ThingDescription,
|
||||||
|
|
||||||
|
val json: Map<String, Any>
|
||||||
|
) : IFlashlightDefinition, IThingWithDescription by descriptionData
|
@ -0,0 +1,49 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import ru.dbotthepony.kstarbound.defs.util.enrollMap
|
||||||
|
import ru.dbotthepony.kstarbound.io.json.builder.JsonBuilder
|
||||||
|
import ru.dbotthepony.kstarbound.util.NotNullVar
|
||||||
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
|
|
||||||
|
@JsonBuilder
|
||||||
|
class FlashlightPrototype : ItemPrototype(), IFlashlightDefinition {
|
||||||
|
override var lightPosition: Vector2d by NotNullVar()
|
||||||
|
override var lightColor: Color by NotNullVar()
|
||||||
|
override var beamLevel: Int by NotNullVar()
|
||||||
|
override var beamAmbience: Double by NotNullVar()
|
||||||
|
override var handPosition: Vector2d by NotNullVar()
|
||||||
|
|
||||||
|
init {
|
||||||
|
maxStack = 1L
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun assemble(): IItemDefinition {
|
||||||
|
return FlashlightDefinition(
|
||||||
|
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),
|
||||||
|
|
||||||
|
lightPosition = lightPosition,
|
||||||
|
lightColor = lightColor,
|
||||||
|
beamLevel = beamLevel,
|
||||||
|
beamAmbience = beamAmbience,
|
||||||
|
handPosition = handPosition,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import ru.dbotthepony.kvector.vector.Color
|
||||||
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
|
|
||||||
|
interface IFlashlightDefinition : IItemDefinition, IItemInHandDefinition {
|
||||||
|
/**
|
||||||
|
* Смещение в пикселях
|
||||||
|
*/
|
||||||
|
val lightPosition: Vector2d
|
||||||
|
|
||||||
|
val lightColor: Color
|
||||||
|
|
||||||
|
val beamLevel: Int
|
||||||
|
|
||||||
|
val beamAmbience: Double
|
||||||
|
}
|
@ -1,9 +1,8 @@
|
|||||||
package ru.dbotthepony.kstarbound.defs.item
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
import ru.dbotthepony.kstarbound.defs.animation.IAnimated
|
import ru.dbotthepony.kstarbound.defs.animation.IAnimated
|
||||||
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
|
||||||
|
|
||||||
interface IHarvestingToolDefinition : IItemDefinition, IAnimated {
|
interface IHarvestingToolDefinition : IItemDefinition, IAnimated, IItemInHandDefinition {
|
||||||
/**
|
/**
|
||||||
* Радиус в тайлах, на какое расстояние действует данный инструмент для сбора
|
* Радиус в тайлах, на какое расстояние действует данный инструмент для сбора
|
||||||
*/
|
*/
|
||||||
@ -24,11 +23,6 @@ interface IHarvestingToolDefinition : IItemDefinition, IAnimated {
|
|||||||
*/
|
*/
|
||||||
val strikeSounds: List<String>
|
val strikeSounds: List<String>
|
||||||
|
|
||||||
/**
|
|
||||||
* Позиция инструмента в руке (смещение в пикселях)
|
|
||||||
*/
|
|
||||||
val handPosition: Vector2d
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Время атаки
|
* Время атаки
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
package ru.dbotthepony.kstarbound.defs.item
|
||||||
|
|
||||||
|
import ru.dbotthepony.kvector.vector.ndouble.Vector2d
|
||||||
|
|
||||||
|
interface IItemInHandDefinition : IItemDefinition {
|
||||||
|
/**
|
||||||
|
* Позиция инструмента в руке (смещение в пикселях)
|
||||||
|
*/
|
||||||
|
val handPosition: Vector2d
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user