mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
throwable cherry bomb (no explosion yet)
This commit is contained in:
10
assets/mods/basegame/crafting/items.json
Normal file
10
assets/mods/basegame/crafting/items.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"item@basegame:31": { /* gunpowder */
|
||||
"workbench": "basiccrafting",
|
||||
"ingredients": [[3, 1, "item@basegame:147", 1, "item@basegame:29", 1, "item@basegame:129"]] /* 1 nitre, 1 charcoal, 1 iron ore */
|
||||
},
|
||||
"item@basegame:32": { /* cherry bomb */
|
||||
"workbench": "",
|
||||
"ingredients": [[1, 1, "item@basegame:31", 1, "item@basegame:25"]] /* 1 gunpowder, 1 clay ball */
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,8 @@ id;classname;tags
|
||||
28;net.torvald.terrarum.modulebasegame.gameitems.ItemJukebox;FIXTURE,MUSIC
|
||||
29;net.torvald.terrarum.modulebasegame.gameitems.ItemCharcoal;COMBUSTIBLE
|
||||
30;net.torvald.terrarum.modulebasegame.gameitems.ItemMusicalTurntable;FIXTURE,MUSIC
|
||||
31;net.torvald.terrarum.modulebasegame.gameitems.ItemGunpowder;POWDER,EXPLOSIVE
|
||||
32;net.torvald.terrarum.modulebasegame.gameitems.ItemCherryBomb;EXPLOSIVE,THROWABLE
|
||||
|
||||
# ingots
|
||||
26;net.torvald.terrarum.modulebasegame.gameitems.IngotSteel;INGOT
|
||||
|
||||
|
Binary file not shown.
@@ -14,6 +14,7 @@
|
||||
"ITEM_GEM_DIAMOND": "Raw Diamond",
|
||||
"ITEM_GEM_AMETHYST": "Raw Amethyst",
|
||||
"ITEM_GEM_QUARTZ": "Raw Quartz",
|
||||
"ITEM_GUNPOWDER": "Gunpowder",
|
||||
"ITEM_HATCHET_COPPER": "Copper Axe",
|
||||
"ITEM_HATCHET_IRON": "Iron Axe",
|
||||
"ITEM_HATCHET_STEEL": "Steel Axe",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
"ITEM_GEM_DIAMOND": "금강석",
|
||||
"ITEM_GEM_AMETHYST": "자수정석",
|
||||
"ITEM_GEM_QUARTZ": "석영석",
|
||||
"ITEM_GUNPOWDER": "화약",
|
||||
"ITEM_HATCHET_COPPER": "구리 도끼",
|
||||
"ITEM_HATCHET_IRON": "철 도끼",
|
||||
"ITEM_HATCHET_STEEL": "강철 도끼",
|
||||
|
||||
76
src/net/torvald/spriteanimation/SingleImageSprite.kt
Normal file
76
src/net/torvald/spriteanimation/SingleImageSprite.kt
Normal file
@@ -0,0 +1,76 @@
|
||||
package net.torvald.spriteanimation
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.jme3.math.FastMath
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-14.
|
||||
*/
|
||||
class SingleImageSprite(parentActor: ActorWithBody, val img: TextureRegion) : SpriteAnimation(parentActor) {
|
||||
|
||||
override val currentDelay: Second = 1f
|
||||
|
||||
override fun update(delta: Float) {
|
||||
}
|
||||
|
||||
var cellWidth: Int = img.regionWidth
|
||||
var cellHeight: Int = img.regionHeight
|
||||
|
||||
override fun render(
|
||||
frameDelta: Float,
|
||||
batch: SpriteBatch,
|
||||
posX: Float,
|
||||
posY: Float,
|
||||
scale: Float,
|
||||
mode: Int,
|
||||
forcedColourFilter: Color?
|
||||
) {
|
||||
batch.color = forcedColourFilter ?: colourFilter
|
||||
|
||||
val tx = (parentActor.hitboxTranslateX) * scale
|
||||
val txF = (parentActor.hitboxTranslateX + parentActor.baseHitboxW) * scale
|
||||
val ty = (parentActor.hitboxTranslateY + (cellHeight - parentActor.baseHitboxH)) * scale
|
||||
val tyF = (parentActor.hitboxTranslateY + parentActor.baseHitboxH) * scale
|
||||
|
||||
if (flipHorizontal && flipVertical) {
|
||||
batch.draw(img,
|
||||
FastMath.floor(posX).toFloat() + txF,
|
||||
FastMath.floor(posY).toFloat() + tyF,
|
||||
-FastMath.floor(cellWidth * scale).toFloat(),
|
||||
-FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
}
|
||||
else if (flipHorizontal && !flipVertical) {
|
||||
batch.draw(img,
|
||||
FastMath.floor(posX).toFloat() + txF,
|
||||
FastMath.floor(posY).toFloat() - ty,
|
||||
-FastMath.floor(cellWidth * scale).toFloat(),
|
||||
FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
}
|
||||
else if (!flipHorizontal && flipVertical) {
|
||||
batch.draw(img,
|
||||
FastMath.floor(posX).toFloat() - tx,
|
||||
FastMath.floor(posY).toFloat() + tyF,
|
||||
FastMath.floor(cellWidth * scale).toFloat(),
|
||||
-FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
}
|
||||
else {
|
||||
batch.draw(img,
|
||||
FastMath.floor(posX).toFloat() - tx,
|
||||
FastMath.floor(posY).toFloat() - ty,
|
||||
FastMath.floor(cellWidth * scale).toFloat(),
|
||||
FastMath.floor(cellHeight * scale).toFloat()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -355,7 +355,7 @@ object Terrarum : Disposable {
|
||||
*
|
||||
* override var referenceID: Int = generateUniqueReferenceID()
|
||||
*/
|
||||
fun generateUniqueReferenceID(renderOrder: Actor.RenderOrder): ActorID {
|
||||
fun generateUniqueReferenceID(): ActorID {
|
||||
// render orders can be changed arbitrarily so the whole "renderorder to actor id" is only there for an initial sorting
|
||||
fun hasCollision(value: ActorID) =
|
||||
try {
|
||||
@@ -644,6 +644,7 @@ inline fun Boolean.toInt(shift: Int = 0) = if (this) 1.shl(shift) else 0
|
||||
inline fun Boolean.toLong(shift: Int = 0) = if (this) 1L.shl(shift) else 0L
|
||||
inline fun Int.bitCount() = java.lang.Integer.bitCount(this)
|
||||
inline fun Long.bitCount() = java.lang.Long.bitCount(this)
|
||||
inline fun Double.signedSqrt() = this.abs().sqrt() * this.sign
|
||||
|
||||
|
||||
fun absMax(left: Double, right: Double): Double {
|
||||
@@ -1011,9 +1012,15 @@ fun distBetweenPoints(a: Vector2, b: Vector2): Double {
|
||||
* @return positive if the otherActor is on the right side of the player, negative if on the left
|
||||
*/
|
||||
fun relativeXposition(thisActor: ActorWithBody, otherActor: ActorWithBody): Double {
|
||||
return relativeXposition(thisActor, otherActor.centrePosVector)
|
||||
}
|
||||
/**
|
||||
* @return positive if the otherActor is on the right side of the player, negative if on the left
|
||||
*/
|
||||
fun relativeXposition(thisActor: ActorWithBody, otherActor: Vector2): Double {
|
||||
val ww = INGAME.world.width * TILE_SIZED
|
||||
val thisPos = thisActor.centrePosVector
|
||||
val pos1 = otherActor.centrePosVector
|
||||
val pos1 = otherActor
|
||||
val pos2 = Vector2(pos1.x + ww, pos1.y)
|
||||
val pos3 = Vector2(pos1.x - ww, pos1.y)
|
||||
val posToUse = listOf(
|
||||
@@ -1023,6 +1030,7 @@ fun relativeXposition(thisActor: ActorWithBody, otherActor: ActorWithBody): Doub
|
||||
).sortedBy { it.second }.first().first
|
||||
return posToUse.x - thisPos.x
|
||||
}
|
||||
|
||||
fun distBetween(a: ActorWithBody, bpos: Vector2): Double {
|
||||
val ww = INGAME.world.width * TILE_SIZED
|
||||
val apos1 = a.centrePosVector
|
||||
|
||||
@@ -27,7 +27,7 @@ abstract class Actor : Comparable<Actor>, Runnable {
|
||||
* Valid RefID is equal to or greater than 16777216.
|
||||
* @return Reference ID. (16777216-0x7FFF_FFFF)
|
||||
*/
|
||||
open var referenceID: ActorID = 0 // in old time this was nullable without initialiser. If you're going to revert to that, add the reason why this should be nullable.
|
||||
open var referenceID: ActorID = Terrarum.generateUniqueReferenceID() // in old time this was nullable without initialiser. If you're going to revert to that, add the reason why this should be nullable.
|
||||
|
||||
/**
|
||||
* RenderOrder does not affect ReferenceID "too much" (ID generation will still depend on it, but it's just because of ye olde tradition by now)
|
||||
@@ -40,7 +40,8 @@ abstract class Actor : Comparable<Actor>, Runnable {
|
||||
|
||||
// needs zero-arg constructor for serialiser to work
|
||||
constructor(renderOrder: RenderOrder, id: ActorID?) : this() {
|
||||
referenceID = id ?: Terrarum.generateUniqueReferenceID(renderOrder)
|
||||
if (id != null) referenceID = id
|
||||
this.renderOrder = renderOrder
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ open class ActorMovingPlatform() : ActorWithBody() {
|
||||
@Transient protected val actorsRiding = ArrayList<ActorID>() // saving actorID due to serialisation issues
|
||||
|
||||
init {
|
||||
physProp = PhysProperties.PHYSICS_OBJECT
|
||||
physProp = PhysProperties.PHYSICS_OBJECT()
|
||||
|
||||
setHitboxDimension(TILE_SIZE * tilewiseWidth, TILE_SIZE, 0, 0)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ import kotlin.math.*
|
||||
*/
|
||||
open class ActorWithBody : Actor {
|
||||
|
||||
var physProp = PhysProperties.HUMANOID_DEFAULT
|
||||
var physProp = PhysProperties.HUMANOID_DEFAULT()
|
||||
|
||||
// copied from old interface Luminous
|
||||
/**
|
||||
@@ -1460,7 +1460,7 @@ open class ActorWithBody : Actor {
|
||||
externalV.y + (controllerV?.y ?: 0.0) >= 0.0 &&
|
||||
this.downButtonHeld == 0 && this.axisY <= 0f) ||
|
||||
// platforms, moving downward, for the case of NOT ActorHumanoid
|
||||
(this !is ActorHumanoid && BlockCodex[tile].isPlatform &&
|
||||
(this !is ActorHumanoid && !physProp.ignorePlatform && BlockCodex[tile].isPlatform &&
|
||||
externalV.y + (controllerV?.y ?: 0.0) >= 0.0)
|
||||
// TODO: as for the platform, only apply it when it's a feet tile
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import kotlin.math.floor
|
||||
*
|
||||
* MarkerMode must be set manually after calling `setGhost` -- the `unsetGhost` will not reset the field.
|
||||
*/
|
||||
class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT), NoSerialise {
|
||||
class BlockMarkerActor : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT()), NoSerialise {
|
||||
|
||||
enum class MarkerMode {
|
||||
FIXTURE_GHOST, BLOCK_MARKER
|
||||
|
||||
@@ -1,33 +1,35 @@
|
||||
package net.torvald.terrarum.gameactors
|
||||
|
||||
data class PhysProperties(
|
||||
val immobileBody: Boolean = false,
|
||||
var usePhysics: Boolean = true,
|
||||
val useStairs: Boolean = false
|
||||
val immobileBody: Boolean = false,
|
||||
var usePhysics: Boolean = true,
|
||||
val useStairs: Boolean = false,
|
||||
val ignorePlatform: Boolean = true
|
||||
) {
|
||||
companion object {
|
||||
val HUMANOID_DEFAULT = PhysProperties(
|
||||
immobileBody = false,
|
||||
usePhysics = true,
|
||||
useStairs = true
|
||||
fun HUMANOID_DEFAULT() = PhysProperties(
|
||||
immobileBody = false,
|
||||
usePhysics = true,
|
||||
useStairs = true,
|
||||
ignorePlatform = false,
|
||||
)
|
||||
/** e.g. dropped items, balls */
|
||||
val PHYSICS_OBJECT = PhysProperties(
|
||||
immobileBody = false,
|
||||
usePhysics = true,
|
||||
useStairs = false
|
||||
fun PHYSICS_OBJECT() = PhysProperties(
|
||||
immobileBody = false,
|
||||
usePhysics = true,
|
||||
useStairs = false,
|
||||
)
|
||||
/** e.g. voice maker */
|
||||
val IMMOBILE = PhysProperties(
|
||||
immobileBody = true,
|
||||
usePhysics = false,
|
||||
useStairs = false
|
||||
fun IMMOBILE() = PhysProperties(
|
||||
immobileBody = true,
|
||||
usePhysics = false,
|
||||
useStairs = false,
|
||||
)
|
||||
/** e.g. camera */
|
||||
val MOBILE_OBJECT = PhysProperties(
|
||||
immobileBody = false,
|
||||
usePhysics = false,
|
||||
useStairs = false
|
||||
fun MOBILE_OBJECT() = PhysProperties(
|
||||
immobileBody = false,
|
||||
usePhysics = false,
|
||||
useStairs = false,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ class WireActor : ActorWithBody, NoSerialise {
|
||||
|
||||
private constructor()
|
||||
|
||||
constructor(id: ActorID) : super(RenderOrder.OVERLAY, PhysProperties.IMMOBILE, id)
|
||||
constructor(id: ActorID) : super(RenderOrder.OVERLAY, PhysProperties.IMMOBILE(), id)
|
||||
|
||||
init {
|
||||
setHitboxDimension(TILE_SIZE, TILE_SIZE, 0, 0)
|
||||
|
||||
@@ -149,12 +149,17 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
||||
terrarumIngame.worldSecondaryClickStart(actor, App.UPDATE_RATE)
|
||||
}
|
||||
|
||||
val itemProp = ItemCodex[itemOnGrip]
|
||||
|
||||
// unlatch when:
|
||||
// - not clicking anymore
|
||||
// - using any item that is not fixture (blocks, picks)
|
||||
// DON'T unlatch when:
|
||||
// - performing barehand action
|
||||
if (!Terrarum.mouseDown || inventoryCategoryAllowClickAndDrag.contains(ItemCodex[itemOnGrip]?.inventoryCategory) || ItemCodex[itemOnGrip]?.tags?.contains("ACTINGBLOCK") == true) {
|
||||
if (!Terrarum.mouseDown ||
|
||||
inventoryCategoryAllowClickAndDrag.contains(itemProp?.inventoryCategory) && itemProp?.disallowToolDragging != true ||
|
||||
itemProp?.tags?.contains("ACTINGBLOCK") == true
|
||||
) {
|
||||
worldPrimaryClickLatched = false
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +217,8 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
*/
|
||||
open val extra = Codex()
|
||||
|
||||
@Transient open val disallowToolDragging = false
|
||||
|
||||
/* called when the instance of the dynamic is loaded from the save; one may use this function to "re-sync" some values,
|
||||
* for the purpose of savegame format update, defence against rogue savegame manipulation, etc.
|
||||
*/
|
||||
|
||||
@@ -104,7 +104,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
val blockMarkings = CommonResourcePool.getAsTextureRegionPack("blockmarkings_common")
|
||||
internal var showSelection = true
|
||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT) {
|
||||
val blockPointingCursor = object : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT()) {
|
||||
|
||||
override var referenceID: ActorID = 1048575 // custom refID
|
||||
override val hitbox = Hitbox(0.0, 0.0, 16.0, 16.0)
|
||||
@@ -145,7 +145,7 @@ class BuildingMaker(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
private var _testMarkerDrawCalls = 0L
|
||||
|
||||
private fun generateNewBlockMarkerVisible(x: Int, y: Int) = object : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT) {
|
||||
private fun generateNewBlockMarkerVisible(x: Int, y: Int) = object : ActorWithBody(Actor.RenderOrder.OVERLAY, physProp = PhysProperties.MOBILE_OBJECT()) {
|
||||
override var referenceID: ActorID = blockPosToRefID(x, y) // custom refID
|
||||
override val hitbox = Hitbox(x * 16.0, y * 16.0, 16.0, 16.0)
|
||||
|
||||
@@ -661,7 +661,7 @@ class BuildingMakerController(val screen: BuildingMaker) : InputAdapter() {
|
||||
}
|
||||
}
|
||||
|
||||
class MovableWorldCamera(val parent: BuildingMaker) : ActorHumanoid(0, physProp = PhysProperties.MOBILE_OBJECT) {
|
||||
class MovableWorldCamera(val parent: BuildingMaker) : ActorHumanoid(0, physProp = PhysProperties.MOBILE_OBJECT()) {
|
||||
|
||||
init {
|
||||
referenceID = Terrarum.PLAYER_REF_ID
|
||||
|
||||
@@ -403,7 +403,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
printdbg(this, "Player localhash: ${codices.player.localHashStr}, hasSprite: ${codices.player.sprite != null}")
|
||||
|
||||
// assign new random referenceID for player
|
||||
codices.player.referenceID = Terrarum.generateUniqueReferenceID(Actor.RenderOrder.MIDDLE)
|
||||
codices.player.referenceID = Terrarum.generateUniqueReferenceID()
|
||||
forceAddActor(codices.player)
|
||||
|
||||
|
||||
|
||||
@@ -591,7 +591,7 @@ class TitleScreen(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
}
|
||||
}
|
||||
|
||||
private class CameraPlayer(val demoWorld: GameWorld, override var ai: ActorAI) : ActorWithBody(RenderOrder.FRONT, physProp = PhysProperties.MOBILE_OBJECT), AIControlled {
|
||||
private class CameraPlayer(val demoWorld: GameWorld, override var ai: ActorAI) : ActorWithBody(RenderOrder.FRONT, physProp = PhysProperties.MOBILE_OBJECT()), AIControlled {
|
||||
|
||||
override val hitbox = Hitbox(0.0, 0.0, 2.0, 2.0)
|
||||
|
||||
|
||||
@@ -29,9 +29,13 @@ import kotlin.math.pow
|
||||
*/
|
||||
open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, LandHolder, HistoricalFigure {
|
||||
|
||||
init {
|
||||
this.physProp = PhysProperties.HUMANOID_DEFAULT()
|
||||
}
|
||||
|
||||
protected constructor()
|
||||
|
||||
constructor(birth: Long, death: Long? = null, physProp: PhysProperties = PhysProperties.HUMANOID_DEFAULT) : super() {
|
||||
constructor(birth: Long, death: Long? = null, physProp: PhysProperties = PhysProperties.HUMANOID_DEFAULT()) : super() {
|
||||
actorValue[AVKey.__HISTORICAL_BORNTIME] = birth
|
||||
death?.let { actorValue[AVKey.__HISTORICAL_DEADTIME] = death }
|
||||
this.physProp = physProp
|
||||
|
||||
@@ -1,33 +1,29 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameactors
|
||||
|
||||
import net.torvald.spriteanimation.SingleImageSprite
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.modulebasegame.ExplosionManager
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-13.
|
||||
*/
|
||||
open class ActorPrimedBomb : ActorWithBody {
|
||||
open class ActorPrimedBomb(
|
||||
private var explosionPower: Float = 1f,
|
||||
private var fuse: Second = 1f,
|
||||
) : ActorWithBody() {
|
||||
|
||||
protected constructor() {
|
||||
init {
|
||||
renderOrder = RenderOrder.MIDTOP
|
||||
physProp = PhysProperties.PHYSICS_OBJECT()
|
||||
}
|
||||
|
||||
private var explosionPower: Float = 1f
|
||||
private var fuse: Second = 1f
|
||||
|
||||
constructor(
|
||||
initialPos: Vector2,
|
||||
initialVelo: Vector2,
|
||||
power: Float,
|
||||
fuse: Second
|
||||
) {
|
||||
protected constructor() : this(1f, 1f) {
|
||||
renderOrder = RenderOrder.MIDTOP
|
||||
|
||||
this.explosionPower = power
|
||||
this.fuse = fuse
|
||||
physProp = PhysProperties.PHYSICS_OBJECT()
|
||||
}
|
||||
|
||||
override fun updateImpl(delta: Float) {
|
||||
@@ -41,4 +37,24 @@ open class ActorPrimedBomb : ActorWithBody {
|
||||
flagDespawn()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-14.
|
||||
*/
|
||||
class ActorCherryBomb : ActorPrimedBomb(500f, 4.5f) {
|
||||
|
||||
init {
|
||||
val itemImage = CommonResourcePool.getAsItemSheet("basegame.items").get(0,13)
|
||||
|
||||
setHitboxDimension(7, 7, 2, -2)
|
||||
sprite = SingleImageSprite(this, itemImage)
|
||||
|
||||
avBaseMass = 1.0
|
||||
density = 1400.0
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -17,7 +17,7 @@ object CreatureBuilder {
|
||||
* @Param jsonFileName with extension
|
||||
*/
|
||||
operator fun invoke(module: String, jsonFileName: String): ActorWithBody {
|
||||
val actor = ActorWithBody(Actor.RenderOrder.MIDDLE, physProp = PhysProperties.HUMANOID_DEFAULT)
|
||||
val actor = ActorWithBody(Actor.RenderOrder.MIDDLE, physProp = PhysProperties.HUMANOID_DEFAULT())
|
||||
InjectCreatureRaw(actor.actorValue, module, jsonFileName)
|
||||
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ open class DroppedItem : ActorWithBody {
|
||||
|
||||
var itemCount = 1L
|
||||
|
||||
protected constructor() : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT)
|
||||
protected constructor() : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT())
|
||||
|
||||
private var timeSinceSpawned = 0f
|
||||
|
||||
@@ -51,7 +51,7 @@ open class DroppedItem : ActorWithBody {
|
||||
* @param topLeftX world-wise coord
|
||||
* @param topLeftY world-wise coord
|
||||
*/
|
||||
constructor(itemID: ItemID, centreX: Double, bottomY: Double, spawnVelo: Vector2? = null) : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT) {
|
||||
constructor(itemID: ItemID, centreX: Double, bottomY: Double, spawnVelo: Vector2? = null) : super(RenderOrder.OVERLAY, PhysProperties.PHYSICS_OBJECT()) {
|
||||
this.itemID = itemID
|
||||
|
||||
if (itemID.isActor())
|
||||
|
||||
@@ -39,7 +39,7 @@ open class Electric : FixtureBase {
|
||||
mainUI: UICanvas? = null,
|
||||
inventory: FixtureInventory? = null,
|
||||
id: ActorID? = null
|
||||
) : super(renderOrder, PhysProperties.IMMOBILE, id) {
|
||||
) : super(renderOrder, PhysProperties.IMMOBILE(), id) {
|
||||
blockBox = blockBox0
|
||||
setHitboxDimension(TILE_SIZE * blockBox.width, TILE_SIZE * blockBox.height, 0, 0)
|
||||
this.blockBoxProps = blockBoxProps
|
||||
@@ -162,7 +162,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
|
||||
internal var actorThatInstalledThisFixture: UUID? = null
|
||||
|
||||
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE, null)
|
||||
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE(), null)
|
||||
protected constructor(renderOrder: RenderOrder, physProp: PhysProperties, id: ActorID?) : super(renderOrder, physProp, id)
|
||||
|
||||
/**
|
||||
@@ -186,7 +186,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
mainUI: UICanvas? = null,
|
||||
inventory: FixtureInventory? = null,
|
||||
id: ActorID? = null
|
||||
) : super(renderOrder, PhysProperties.IMMOBILE, id) {
|
||||
) : super(renderOrder, PhysProperties.IMMOBILE(), id) {
|
||||
blockBox = blockBox0
|
||||
setHitboxDimension(TILE_SIZE * blockBox.width, TILE_SIZE * blockBox.height, 0, 0)
|
||||
this.blockBoxProps = blockBoxProps
|
||||
|
||||
@@ -13,7 +13,7 @@ class ItemCarrying : ActorWithBody {
|
||||
|
||||
private constructor()
|
||||
|
||||
constructor(itemID: ItemID) : super(RenderOrder.MIDTOP, PhysProperties.IMMOBILE) {
|
||||
constructor(itemID: ItemID) : super(RenderOrder.MIDTOP, PhysProperties.IMMOBILE()) {
|
||||
this.itemID = itemID
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import net.torvald.terrarum.modulebasegame.worldgenerator.RoguelikeRandomiser
|
||||
/**
|
||||
* Created by minjaesong on 2016-03-05.
|
||||
*/
|
||||
class PhysTestBall : ActorWithBody(RenderOrder.MIDDLE, PhysProperties.PHYSICS_OBJECT) {
|
||||
class PhysTestBall : ActorWithBody(RenderOrder.MIDDLE, PhysProperties.PHYSICS_OBJECT()) {
|
||||
|
||||
private var color = Color.GOLD
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ import net.torvald.terrarum.gameactors.*
|
||||
/**
|
||||
* Created by minjaesong on 2018-01-17.
|
||||
*/
|
||||
class PhysTestLuarLander : ActorWithBody(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT), Controllable {
|
||||
class PhysTestLuarLander : ActorWithBody(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT()), Controllable {
|
||||
|
||||
@Transient private val texture = Texture(ModMgr.getGdxFile("basegame", "sprites/phystest_lunarlander.tga"))
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ open class ProjectileSimple : ActorWithBody, Projectile {
|
||||
constructor(type: Int,
|
||||
fromPoint: Vector2, // projected coord
|
||||
toPoint: Vector2 // arriving coord
|
||||
) : super(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT) {
|
||||
) : super(RenderOrder.MIDTOP, PhysProperties.PHYSICS_OBJECT()) {
|
||||
this.type = type
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-14.
|
||||
*/
|
||||
open class LightIngredientBase(originalID: ItemID) : GameItem(originalID) {
|
||||
override var baseMass = 1.0
|
||||
override var baseToolSize: Double? = null
|
||||
override var inventoryCategory = Category.GENERIC
|
||||
override val canBeDynamic = false
|
||||
override val materialId = "OORE"
|
||||
override var equipPosition = EquipPosition.HAND_GRIP
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-10-11.
|
||||
*/
|
||||
class OreStick(originalID: ItemID) : LightIngredientBase(originalID) {
|
||||
override var originalName = "ITEM_WOOD_STICK"
|
||||
override val materialId = "WOOD"
|
||||
override var calories = 600.0
|
||||
override var smokiness = 0.2f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,6)
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-12-01.
|
||||
*/
|
||||
class ItemClayBall(originalID: ItemID) : LightIngredientBase(originalID) {
|
||||
override var originalName = "BLOCK_CLAY"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(11,6)
|
||||
}
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-14.
|
||||
*/
|
||||
class ItemGunpowder(originalID: ItemID) : LightIngredientBase(originalID) {
|
||||
override var originalName = "ITEM_GUNPOWDER"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,12)
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package net.torvald.terrarum.modulebasegame.gameitems
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.terrarum.*
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZED
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameitems.mouseInInteractableRange
|
||||
import net.torvald.terrarum.ui.MouseLatch
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-14.
|
||||
*/
|
||||
open class ItemThrowable(originalID: ItemID, private val throwableActorClassName: String) : GameItem(originalID) {
|
||||
override var baseMass = 1.0
|
||||
override var baseToolSize: Double? = baseMass
|
||||
override var inventoryCategory = Category.TOOL
|
||||
override val canBeDynamic = false
|
||||
override val materialId = ""
|
||||
override var equipPosition = EquipPosition.HAND_GRIP
|
||||
override val disallowToolDragging = true
|
||||
|
||||
init {
|
||||
ItemCodex.fixtureToSpawnerItemID[throwableActorClassName] = originalID
|
||||
}
|
||||
|
||||
protected open fun setupLobbedActor(actor: ActorWithBody) {
|
||||
|
||||
}
|
||||
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long = mouseInInteractableRange(actor) { mx, my, mtx, mty ->
|
||||
|
||||
val playerCentrePos = actor.centrePosVector
|
||||
val mousePos = Vector2(mx, my)
|
||||
|
||||
val actorPowMult = actor.avStrength / 2000.0
|
||||
val relativeX = relativeXposition(actor, mousePos)
|
||||
val relativeY = my - playerCentrePos.y
|
||||
val powX = relativeX / TILE_SIZED * 3.0 * actorPowMult
|
||||
val powY = relativeY / TILE_SIZED * 3.0 * actorPowMult
|
||||
|
||||
val lobbed = Class.forName(throwableActorClassName).getDeclaredConstructor().newInstance() as ActorWithBody
|
||||
lobbed.setPosition(playerCentrePos)
|
||||
lobbed.externalV.set(powX, powY)
|
||||
setupLobbedActor(lobbed)
|
||||
|
||||
Terrarum.ingame?.queueActorAddition(lobbed)
|
||||
|
||||
|
||||
|
||||
1L
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2024-02-14.
|
||||
*/
|
||||
class ItemCherryBomb(originalID: ItemID) : ItemThrowable(originalID, "net.torvald.terrarum.modulebasegame.gameactors.ActorCherryBomb") {
|
||||
override var originalName = "ITEM_CHERRY_BOMB"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,13)
|
||||
}
|
||||
@@ -89,14 +89,6 @@ class ItemLogsRosewood(originalID: ItemID) : OreItemBase(originalID) {
|
||||
return BlockBase.blockStartPrimaryUse(actor, this, "basegame:75", delta)
|
||||
}
|
||||
}
|
||||
class OreStick(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "ITEM_WOOD_STICK"
|
||||
override val materialId = "WOOD"
|
||||
override var calories = 600.0
|
||||
override var smokiness = 0.2f
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(0,6)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -262,10 +254,3 @@ class IngotSolder(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(14,5)
|
||||
}
|
||||
|
||||
|
||||
class ItemClayBall(originalID: ItemID) : OreItemBase(originalID) {
|
||||
override var originalName = "BLOCK_CLAY"
|
||||
override val itemImage: TextureRegion
|
||||
get() = CommonResourcePool.getAsItemSheet("basegame.items").get(11,6)
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user