feat: add combat, wild wolves, factions, and tribe war motivation
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
class_name SimulationItems
|
||||
extends RefCounted
|
||||
|
||||
static var _items: Dictionary = {}
|
||||
static var _cache_valid := false
|
||||
|
||||
|
||||
static func _ensure_cache() -> void:
|
||||
if _cache_valid:
|
||||
return
|
||||
_items = {}
|
||||
_add_weapon(SimulationIds.ITEM_SWORD, "Sword", 24.0, 2.4, 0.55)
|
||||
_add_weapon(SimulationIds.ITEM_CLAW, "Claw", 10.0, 1.2, 0.4)
|
||||
_cache_valid = true
|
||||
|
||||
|
||||
static func _add_weapon(
|
||||
item_id: StringName, display_name: String, damage: float, reach: float, cooldown: float
|
||||
) -> void:
|
||||
var item := ItemDefinition.new()
|
||||
item.item_id = item_id
|
||||
item.display_name = display_name
|
||||
item.category = SimulationIds.ITEM_CATEGORY_WEAPON
|
||||
item.equip_slot = SimulationIds.EQUIP_SLOT_HAND
|
||||
item.damage = damage
|
||||
item.reach = reach
|
||||
item.attack_cooldown = cooldown
|
||||
_items[item_id] = item
|
||||
|
||||
|
||||
static func invalidate_cache() -> void:
|
||||
_cache_valid = false
|
||||
|
||||
|
||||
static func get_item(item_id: StringName) -> ItemDefinition:
|
||||
_ensure_cache()
|
||||
return _items.get(item_id) as ItemDefinition
|
||||
|
||||
|
||||
static func get_items() -> Array[ItemDefinition]:
|
||||
_ensure_cache()
|
||||
var values: Array[ItemDefinition] = []
|
||||
for item in _items.values():
|
||||
values.append(item)
|
||||
return values
|
||||
|
||||
|
||||
static func get_weapon(item_id: StringName) -> ItemDefinition:
|
||||
var item := get_item(item_id)
|
||||
return item if item != null and item.is_weapon() else null
|
||||
Reference in New Issue
Block a user