mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
InventoryItem is now abstract class
Former-commit-id: b7d22a2cc169a89cbe82aae8b13277b1be747b94 Former-commit-id: dcbf2bf830046b97673a0d2bab65e53c4451966f
This commit is contained in:
@@ -5,7 +5,7 @@ import org.newdawn.slick.GameContainer
|
|||||||
/**
|
/**
|
||||||
* Created by minjaesong on 16-01-16.
|
* Created by minjaesong on 16-01-16.
|
||||||
*/
|
*/
|
||||||
interface InventoryItem {
|
abstract class InventoryItem {
|
||||||
/**
|
/**
|
||||||
* Internal ID of an Item, Long
|
* Internal ID of an Item, Long
|
||||||
* 0-4095: Tiles
|
* 0-4095: Tiles
|
||||||
@@ -13,18 +13,18 @@ interface InventoryItem {
|
|||||||
* 32768-16777215: Dynamic items
|
* 32768-16777215: Dynamic items
|
||||||
* >= 16777216: Actor RefID
|
* >= 16777216: Actor RefID
|
||||||
*/
|
*/
|
||||||
val itemID: Int
|
abstract val id: Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Where to equip the item
|
* Where to equip the item
|
||||||
*/
|
*/
|
||||||
val equipPosition: Int
|
abstract val equipPosition: Int
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base mass of the item. Real mass must be calculated from
|
* Base mass of the item. Real mass must be calculated from
|
||||||
* mass * scale^3
|
* mass * scale^3
|
||||||
*/
|
*/
|
||||||
var mass: Double
|
abstract var mass: Double
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scale of the item.
|
* Scale of the item.
|
||||||
@@ -32,42 +32,56 @@ interface InventoryItem {
|
|||||||
* For static item, it must be 1.0. If you tinkered the item to be bigger,
|
* For static item, it must be 1.0. If you tinkered the item to be bigger,
|
||||||
* it must be re-assigned as Dynamic Item
|
* it must be re-assigned as Dynamic Item
|
||||||
*/
|
*/
|
||||||
var scale: Double
|
abstract var scale: Double
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied continuously while in pocket
|
* Effects applied continuously while in pocket
|
||||||
*/
|
*/
|
||||||
fun effectWhileInPocket(gc: GameContainer, delta: Int)
|
open fun effectWhileInPocket(gc: GameContainer, delta: Int) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied immediately only once if picked up
|
* Effects applied immediately only once if picked up
|
||||||
*/
|
*/
|
||||||
fun effectWhenPickedUp(gc: GameContainer, delta: Int)
|
open fun effectWhenPickedUp(gc: GameContainer, delta: Int) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied (continuously or not) while primary button (usually left mouse button) is down
|
* Effects applied (continuously or not) while primary button (usually left mouse button) is down
|
||||||
*/
|
*/
|
||||||
fun primaryUse(gc: GameContainer, delta: Int)
|
open fun primaryUse(gc: GameContainer, delta: Int) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied (continuously or not) while secondary button (usually right mouse button) is down
|
* Effects applied (continuously or not) while secondary button (usually right mouse button) is down
|
||||||
*/
|
*/
|
||||||
fun secondaryUse(gc: GameContainer, delta: Int)
|
open fun secondaryUse(gc: GameContainer, delta: Int) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied immediately only once if thrown from pocket
|
* Effects applied immediately only once if thrown from pocket
|
||||||
*/
|
*/
|
||||||
fun effectWhenThrown(gc: GameContainer, delta: Int)
|
open fun effectWhenThrown(gc: GameContainer, delta: Int) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied (continuously or not) when equipped
|
* Effects applied (continuously or not) when equipped (drawn)
|
||||||
*/
|
*/
|
||||||
fun effectWhenEquipped(gc: GameContainer, delta: Int)
|
open fun effectWhenEquipped(gc: GameContainer, delta: Int) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects applied only once when unequipped
|
* Effects applied only once when unequipped
|
||||||
*/
|
*/
|
||||||
fun effectWhenUnEquipped(gc: GameContainer, delta: Int)
|
open fun effectWhenUnEquipped(gc: GameContainer, delta: Int) { }
|
||||||
|
|
||||||
|
|
||||||
|
override fun toString(): String {
|
||||||
|
return id.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (other == null) return false
|
||||||
|
return id == (other as InventoryItem).id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object EquipPosition {
|
object EquipPosition {
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
package net.torvald.terrarum.gameitem
|
|
||||||
|
|
||||||
import org.newdawn.slick.GameContainer
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by SKYHi14 on 2016-12-12.
|
|
||||||
*/
|
|
||||||
abstract class InventoryItemAdapter : InventoryItem {
|
|
||||||
override abstract val itemID: Int
|
|
||||||
override abstract val equipPosition: Int
|
|
||||||
override abstract var mass: Double
|
|
||||||
override abstract var scale: Double
|
|
||||||
|
|
||||||
override fun effectWhileInPocket(gc: GameContainer, delta: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun effectWhenPickedUp(gc: GameContainer, delta: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun primaryUse(gc: GameContainer, delta: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun secondaryUse(gc: GameContainer, delta: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun effectWhenThrown(gc: GameContainer, delta: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun effectWhenEquipped(gc: GameContainer, delta: Int) {
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun effectWhenUnEquipped(gc: GameContainer, delta: Int) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user