You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

63 lines
1.2 KiB

extends Node
signal item_changed
enum PLANT_TYPE {
ENGINE_FRONT,
ENGINE_BACK,
O2,
STEERING,
CANON,
DECO
}
var plant_amounts: Dictionary = {
PLANT_TYPE.ENGINE_FRONT: 0,
PLANT_TYPE.ENGINE_BACK: 0,
PLANT_TYPE.O2: 0,
PLANT_TYPE.STEERING: 0,
PLANT_TYPE.CANON: 0,
PLANT_TYPE.DECO: 0,
}
enum ITEM {
EMPTY,
SEED,
FERTILIZER,
WATER
}
var rng: RandomNumberGenerator = RandomNumberGenerator.new()
var o2: float = 1
var o2_drain: float = 0.003
var o2_gain: float = 0.0006
var selected_plant: Spatial = null
var player_inventory: int = ITEM.EMPTY setget set_item
func select_plant(plant: Spatial):
unselect_plant(selected_plant)
selected_plant = plant
selected_plant.highlight.visible = true
func unselect_plant(plant: Spatial):
if plant == selected_plant and selected_plant != null:
selected_plant.highlight.visible = false
selected_plant = null
func set_item(item: int):
assert(item in ITEM.values())
player_inventory = item
emit_signal("item_changed")
func _input(_event):
if Input.is_action_just_pressed("Interact"):
if selected_plant != null:
selected_plant.interact()
func _process(delta):
var net_gain = plant_amounts[PLANT_TYPE.O2] * o2_gain - o2_drain
o2 = min(o2 + net_gain * delta, 1)