30 lines
761 B
GDScript
30 lines
761 B
GDScript
extends Resource
|
|
class_name Event
|
|
@export var modified_resource: Production
|
|
@export var extra_mods: Array[Production]
|
|
@export var timeline: DialogicTimeline
|
|
@export var requirements: Array[Production]
|
|
|
|
enum EventNature {
|
|
Random,
|
|
Certain,
|
|
}
|
|
@export var probability: float = 0.005
|
|
@export var nature: EventNature = EventNature.Random
|
|
|
|
func requirements_satisfied() -> bool:
|
|
for requirement in requirements:
|
|
if Economy.get_currency_amount(requirement.currency) < requirement.amount:
|
|
return false
|
|
return true
|
|
|
|
func will_happen() -> bool:
|
|
if nature == EventNature.Certain:
|
|
return true
|
|
return randf() <= probability
|
|
|
|
func outcome() -> Array[Production]:
|
|
var stuff: Array[Production] = [modified_resource]
|
|
stuff.append_array(extra_mods)
|
|
return stuff
|
|
|