Implements modifier and stats system
Adds a modifier and stats system to manage combat-related attributes. Introduces StatsComponent for storing entity statistics and ModifierManager for applying dynamic modifiers. Recalculates stats based on modifier type and priority. Updates projectile and weapon components to utilize the new stats system.
This commit is contained in:
parent
f97521decc
commit
19cc8cb573
13 changed files with 178 additions and 65 deletions
|
|
@ -1,18 +1,6 @@
|
|||
@icon("res://assets/editor/64x64/fc728.png")
|
||||
extends WeaponComponent
|
||||
extends Node2D
|
||||
class_name MeleeWeaponComponent
|
||||
|
||||
var stats = {
|
||||
"piercing": 3,
|
||||
}
|
||||
var combined_stats = {}
|
||||
|
||||
func _init() -> void:
|
||||
Log.pr("MeleeWeaponComponent initialized")
|
||||
super._init()
|
||||
|
||||
# Combine the base stats with the stats from the parent class
|
||||
combined_stats = base_stats.duplicate()
|
||||
combined_stats.merge(stats)
|
||||
|
||||
Log.pr("Combined stats: ", combined_stats)
|
||||
|
|
@ -1,25 +1,11 @@
|
|||
@icon("res://assets/editor/64x64/fc1515.png")
|
||||
extends WeaponComponent
|
||||
extends Node2D
|
||||
class_name RangedWeaponComponent
|
||||
|
||||
var stats = {
|
||||
"projectile_speed": 500.0,
|
||||
"projectile_size": 1.0,
|
||||
"projectile_lifetime": 1.0,
|
||||
"projectile_quantity": 1,
|
||||
"projectile_spread": 33,
|
||||
"max_pierce": 0
|
||||
}
|
||||
var combined_stats = {}
|
||||
@export var stats: StatsComponent
|
||||
|
||||
func _init() -> void:
|
||||
@onready var modifier_manager = $ModifierManager
|
||||
|
||||
func _ready() -> void:
|
||||
Log.pr("RangedWeaponComponent initialized")
|
||||
super._init()
|
||||
|
||||
# Combine the base stats with the stats from the parent class
|
||||
combined_stats = base_stats.duplicate()
|
||||
combined_stats.merge(stats)
|
||||
|
||||
Log.pr("Combined stats: ", combined_stats)
|
||||
|
||||
Log.pr("ModifierManager: ", modifier_manager)
|
||||
modifier_manager.set_stats(stats)
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
@icon("res://assets/editor/64x64/fc729.png")
|
||||
extends Node2D
|
||||
class_name WeaponComponent
|
||||
|
||||
var modifier_manager
|
||||
|
||||
var base_stats = {
|
||||
"damage": 10.0,
|
||||
"attack_rate": 3.0
|
||||
}
|
||||
|
||||
func _init() -> void:
|
||||
Log.pr("WeaponComponent initialized")
|
||||
|
||||
func _ready() -> void:
|
||||
await get_tree().process_frame
|
||||
modifier_manager = $ModifierManager
|
||||
Log.pr("ModifierManager: ", modifier_manager)
|
||||
|
|
@ -1 +0,0 @@
|
|||
uid://dl3kvbu0rwxky
|
||||
Loading…
Add table
Add a link
Reference in a new issue