generated from krampus/template-godot4
Amount is an inherent property of all item pickups
This commit is contained in:
parent
06de956e1a
commit
36399bad33
|
@ -383,6 +383,7 @@ spawn_turns = 2
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.54289, 1.1, 4.28708)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.54289, 1.1, 4.28708)
|
||||||
script = ExtResource("8_5kaye")
|
script = ExtResource("8_5kaye")
|
||||||
item = ExtResource("12_tj0lh")
|
item = ExtResource("12_tj0lh")
|
||||||
|
amount = 5
|
||||||
spawn_on_ready = true
|
spawn_on_ready = true
|
||||||
spawn_turns = 1
|
spawn_turns = 1
|
||||||
|
|
||||||
|
@ -390,6 +391,7 @@ spawn_turns = 1
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.02452, 1.1, 5.12384)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.02452, 1.1, 5.12384)
|
||||||
script = ExtResource("8_5kaye")
|
script = ExtResource("8_5kaye")
|
||||||
item = ExtResource("15_ir4ss")
|
item = ExtResource("15_ir4ss")
|
||||||
|
amount = 5
|
||||||
spawn_on_ready = true
|
spawn_on_ready = true
|
||||||
spawn_turns = 1
|
spawn_turns = 1
|
||||||
|
|
||||||
|
@ -425,6 +427,7 @@ transform = Transform3D(-0.734269, 0.305072, -0.606448, 0, 0.893336, 0.44939, 0.
|
||||||
transform = Transform3D(0.909686, 0, 0.415297, 0, 1, 0, -0.415297, 0, 0.909686, 537.767, 5.1, 452.434)
|
transform = Transform3D(0.909686, 0, 0.415297, 0, 1, 0, -0.415297, 0, 0.909686, 537.767, 5.1, 452.434)
|
||||||
script = ExtResource("8_5kaye")
|
script = ExtResource("8_5kaye")
|
||||||
item = ExtResource("12_tj0lh")
|
item = ExtResource("12_tj0lh")
|
||||||
|
amount = -1
|
||||||
spawn_on_ready = true
|
spawn_on_ready = true
|
||||||
spawn_turns = 1
|
spawn_turns = 1
|
||||||
|
|
||||||
|
@ -447,6 +450,7 @@ transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, 0, -0.
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 25.5, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 25.5, 0)
|
||||||
script = ExtResource("8_5kaye")
|
script = ExtResource("8_5kaye")
|
||||||
item = ExtResource("15_ir4ss")
|
item = ExtResource("15_ir4ss")
|
||||||
|
amount = 3
|
||||||
spawn_on_ready = true
|
spawn_on_ready = true
|
||||||
spawn_turns = 2
|
spawn_turns = 2
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ _data = {
|
||||||
[node name="BrickItem" instance=ExtResource("1_gflnq")]
|
[node name="BrickItem" instance=ExtResource("1_gflnq")]
|
||||||
script = ExtResource("2_vfkkm")
|
script = ExtResource("2_vfkkm")
|
||||||
ball_type = 3
|
ball_type = 3
|
||||||
amount = -1
|
amount = 0
|
||||||
|
|
||||||
[node name="Pivot" parent="Pivot/Octahedron/ItemMeshContainer" index="0"]
|
[node name="Pivot" parent="Pivot/Octahedron/ItemMeshContainer" index="0"]
|
||||||
transform = Transform3D(0.99863, 0.052336, 0, -0.052336, 0.99863, 0, 0, 0, 1, 0, 0, 0)
|
transform = Transform3D(0.99863, 0.052336, 0, -0.052336, 0.99863, 0, 0, 0, 1, 0, 0, 0)
|
||||||
|
|
|
@ -1,13 +1,10 @@
|
||||||
class_name ExtraBall extends Item
|
class_name ExtraBall extends Item
|
||||||
## Item which grants extra balls when picked up.
|
## Item which grants extra balls when picked up.
|
||||||
|
## Amount values < 0 will instead grant the player unlimited ammunition of this type.
|
||||||
|
|
||||||
## Type of ball which will be replenished.
|
## Type of ball which will be replenished.
|
||||||
@export var ball_type: GameBall.Type
|
@export var ball_type: GameBall.Type
|
||||||
|
|
||||||
## Amount to grant.
|
|
||||||
## Values < 0 will instead grant the player unlimited ammunition of this type.
|
|
||||||
@export var amount: int = -1
|
|
||||||
|
|
||||||
|
|
||||||
func _collect(player: WorldPlayer) -> void:
|
func _collect(player: WorldPlayer) -> void:
|
||||||
if amount < 0:
|
if amount < 0:
|
||||||
|
|
|
@ -3,6 +3,10 @@ class_name Item extends Node3D
|
||||||
|
|
||||||
signal on_collect(player: WorldPlayer)
|
signal on_collect(player: WorldPlayer)
|
||||||
|
|
||||||
|
## Quantity of the underlying item this pick-up will grant when collected.
|
||||||
|
## What this actually means is implementation-dependent.
|
||||||
|
@export var amount: int = 1
|
||||||
|
|
||||||
@onready var explosion_player: AnimationPlayer = %ExplosionPlayer
|
@onready var explosion_player: AnimationPlayer = %ExplosionPlayer
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,9 @@ const POP_IN_TIME := 1.618
|
||||||
## Item to be spawned
|
## Item to be spawned
|
||||||
@export var item: PackedScene
|
@export var item: PackedScene
|
||||||
|
|
||||||
|
## Quantity of the given item to include in the spawned item pickup, where applicable.
|
||||||
|
@export var amount: int = 1
|
||||||
|
|
||||||
@export_category("Spawn Conditions")
|
@export_category("Spawn Conditions")
|
||||||
## Spawn an item when the tree is loaded.
|
## Spawn an item when the tree is loaded.
|
||||||
@export var spawn_on_ready: bool = false
|
@export var spawn_on_ready: bool = false
|
||||||
|
@ -43,6 +46,7 @@ func _ready() -> void:
|
||||||
## This can be called manually if an item needs complex spawning logic.
|
## This can be called manually if an item needs complex spawning logic.
|
||||||
func spawn() -> void:
|
func spawn() -> void:
|
||||||
var instance: Item = item.instantiate()
|
var instance: Item = item.instantiate()
|
||||||
|
instance.amount = amount
|
||||||
instance.on_collect.connect(_on_item_collected)
|
instance.on_collect.connect(_on_item_collected)
|
||||||
add_child(instance)
|
add_child(instance)
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ func set_balls(type: GameBall.Type, value: int) -> void:
|
||||||
|
|
||||||
## Change the quantity of a ball type
|
## Change the quantity of a ball type
|
||||||
func mutate_balls(type: GameBall.Type, delta: int) -> void:
|
func mutate_balls(type: GameBall.Type, delta: int) -> void:
|
||||||
if _balls[type] >= 0:
|
if _balls.get(type, 0) >= 0:
|
||||||
_balls[type] = _balls.get(type, 0) + delta
|
_balls[type] = _balls.get(type, 0) + delta
|
||||||
on_balls_changed.emit(type, _balls[type])
|
on_balls_changed.emit(type, _balls[type])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue