39 lines
860 B
GDScript
39 lines
860 B
GDScript
extends InspectableEntity
|
|
class_name UndergroundLoot
|
|
|
|
const AREA_WIDTH = 20
|
|
const LOOTED_ITEM_RANDOM_RANGE = 50
|
|
|
|
@export var item_number : int = 1
|
|
|
|
func pointer_text() -> String:
|
|
return tr("BURIED_SEEDS")
|
|
|
|
func generate_collision_shape() -> CollisionShape2D:
|
|
var collision = CollisionShape2D.new()
|
|
var shape = CircleShape2D.new()
|
|
shape.radius = AREA_WIDTH
|
|
|
|
collision.shape = shape
|
|
add_child(collision)
|
|
|
|
return collision
|
|
|
|
func generate_loot() -> Array[Item]:
|
|
var seeds : Array[Item] = []
|
|
if len(GameInfo.game_data.unlocked_plant_types):
|
|
seeds.append(
|
|
Seed.new(
|
|
GameInfo.game_data.unlocked_plant_types.pick_random()
|
|
)
|
|
)
|
|
return seeds
|
|
|
|
|
|
func dig():
|
|
for item in generate_loot():
|
|
planet.drop_item(item, global_position, LOOTED_ITEM_RANDOM_RANGE)
|
|
queue_free()
|
|
|
|
func save() -> UndergroundLootData:
|
|
return UndergroundLootData.new(self) |