mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 02:54:04 +09:00
throwable cherry bomb (no explosion yet)
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user