38 lines
1 KiB
GDScript
38 lines
1 KiB
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.01
|
|
@export var nature: EventNature = EventNature.Random
|
|
@export var email_source: Currency = preload("res://currency/sentient/town_crier.tres")
|
|
@export var email_subject: String = "Something is amok!"
|
|
|
|
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
|
|
|
|
func into_letter() -> EventLetter:
|
|
var el := EventLetter.new()
|
|
el.source = email_source
|
|
el.subject_field = email_subject
|
|
el.timeline = timeline
|
|
return el
|