36 lines
968 B
GDScript
36 lines
968 B
GDScript
extends Node
|
|
|
|
signal productions_update(p: Array[Production])
|
|
signal production_log(producer: Currency, p: Production)
|
|
@export var currencies: Array[Production]
|
|
@export var members: Array
|
|
|
|
func get_currency(c: Currency) -> Production:
|
|
for p in currencies:
|
|
if c == p.currency:
|
|
return p
|
|
var p := Production.new()
|
|
p.currency = c
|
|
p.amount = 0
|
|
currencies.append(p)
|
|
productions_update.emit.call_deferred(currencies)
|
|
return p
|
|
|
|
func sync_currency():
|
|
#for p in currencies:
|
|
#if p.amount == 0:
|
|
#currencies.remove_at()
|
|
productions_update.emit.call_deferred(currencies)
|
|
|
|
|
|
func produce(producer: Currency, production: Production):
|
|
production_log.emit.call_deferred(producer, production)
|
|
|
|
func simulate():
|
|
productions_update.emit.call_deferred(currencies)
|
|
|
|
func _ready() -> void:
|
|
simulate()
|
|
for i in range(100):
|
|
produce(preload("res://currency/sentient/chicken.tres"), currencies[0])
|
|
produce(preload("res://currency/sentient/chicken.tres"), currencies[2])
|