40 lines
1.2 KiB
GDScript
40 lines
1.2 KiB
GDScript
class_name EventTypeDefinition
|
|
extends Resource
|
|
|
|
const CATEGORY_ECONOMY := &"economy"
|
|
const CATEGORY_ACTIVITY := &"activity"
|
|
const CATEGORY_WELFARE := &"welfare"
|
|
const CATEGORY_ANIMAL := &"animal"
|
|
const CATEGORY_SOCIAL := &"social"
|
|
const CATEGORY_CONFLICT := &"conflict"
|
|
const CATEGORIES: Array[StringName] = [
|
|
CATEGORY_ECONOMY,
|
|
CATEGORY_ACTIVITY,
|
|
CATEGORY_WELFARE,
|
|
CATEGORY_ANIMAL,
|
|
CATEGORY_SOCIAL,
|
|
CATEGORY_CONFLICT,
|
|
]
|
|
|
|
@export var event_type_id: StringName
|
|
@export var display_name: String
|
|
@export_multiline var description: String
|
|
@export_enum("economy", "activity", "welfare", "animal", "social", "conflict")
|
|
var category: String = String(CATEGORY_ECONOMY)
|
|
@export var parameters: Dictionary = {}
|
|
|
|
|
|
func validate() -> Array[String]:
|
|
var errors: Array[String] = []
|
|
if event_type_id.is_empty():
|
|
errors.append("event_type_id is empty")
|
|
if display_name.is_empty():
|
|
errors.append("display_name is empty for event type '%s'" % event_type_id)
|
|
if StringName(category) not in CATEGORIES:
|
|
errors.append("event type '%s' has unknown category '%s'" % [event_type_id, category])
|
|
for error in DefinitionParameterValidator.validate(
|
|
parameters, "Event type '%s'" % event_type_id
|
|
):
|
|
errors.append(error)
|
|
return errors
|