feat: add emergent world foundations
This commit is contained in:
@@ -1,13 +1,17 @@
|
||||
class_name ItemDefinition
|
||||
extends Resource
|
||||
|
||||
const CATEGORY_RESOURCE := &"resource"
|
||||
const CATEGORY_WEAPON := SimulationIds.ITEM_CATEGORY_WEAPON
|
||||
const VALID_CATEGORIES := [CATEGORY_RESOURCE, CATEGORY_WEAPON]
|
||||
|
||||
@export var item_id: StringName
|
||||
@export var display_name: String
|
||||
@export var category: StringName = SimulationIds.ITEM_CATEGORY_WEAPON
|
||||
@export var equip_slot: StringName = SimulationIds.EQUIP_SLOT_HAND
|
||||
@export var category: StringName = CATEGORY_RESOURCE
|
||||
@export var equip_slot: StringName
|
||||
@export_range(0.0, 1000.0, 0.1) var damage := 0.0
|
||||
@export_range(0.0, 50.0, 0.1) var reach := 1.5
|
||||
@export_range(0.0, 5.0, 0.05) var attack_cooldown := 0.6
|
||||
@export_range(0.0, 50.0, 0.1) var reach := 0.0
|
||||
@export_range(0.0, 5.0, 0.05) var attack_cooldown := 0.0
|
||||
|
||||
|
||||
func validate() -> Array[String]:
|
||||
@@ -16,10 +20,27 @@ func validate() -> Array[String]:
|
||||
errors.append("item_id is empty")
|
||||
if display_name.is_empty():
|
||||
errors.append("display_name is empty for '%s'" % item_id)
|
||||
if damage <= 0.0:
|
||||
errors.append("damage must be positive for '%s'" % item_id)
|
||||
if category not in VALID_CATEGORIES:
|
||||
errors.append("category '%s' is invalid for '%s'" % [category, item_id])
|
||||
elif category == CATEGORY_WEAPON:
|
||||
if equip_slot != SimulationIds.EQUIP_SLOT_HAND:
|
||||
errors.append(
|
||||
"weapon '%s' must equip in '%s'" % [item_id, SimulationIds.EQUIP_SLOT_HAND]
|
||||
)
|
||||
if not is_finite(damage) or damage <= 0.0:
|
||||
errors.append("damage must be positive for '%s'" % item_id)
|
||||
if not is_finite(reach) or reach <= 0.0:
|
||||
errors.append("reach must be positive for '%s'" % item_id)
|
||||
if not is_finite(attack_cooldown) or attack_cooldown <= 0.0:
|
||||
errors.append("attack_cooldown must be positive for '%s'" % item_id)
|
||||
elif not equip_slot.is_empty():
|
||||
errors.append("resource item '%s' cannot declare equip_slot '%s'" % [item_id, equip_slot])
|
||||
return errors
|
||||
|
||||
|
||||
func is_weapon() -> bool:
|
||||
return category == SimulationIds.ITEM_CATEGORY_WEAPON
|
||||
return category == CATEGORY_WEAPON
|
||||
|
||||
|
||||
func is_resource() -> bool:
|
||||
return category == CATEGORY_RESOURCE
|
||||
|
||||
Reference in New Issue
Block a user