Refactors modifier system to use StatsComponent

Moves modifier logic to utilize a central StatsComponent for managing and applying stat modifications.

This change centralizes stat management and simplifies the application of modifiers, enhancing code maintainability and reducing redundancy.
It also moves modifier files to the correct directory.
This commit is contained in:
Dan Baker 2025-05-07 15:08:11 +01:00
parent 19cc8cb573
commit 9f66ab0a73
21 changed files with 135 additions and 97 deletions

View file

@ -1,4 +1,4 @@
class_name ModifierManager extends Node
class_name ModifierManagerOLD extends Node
signal modifier_added(modifier)
signal modifier_removed(modifier)

View file

@ -5,7 +5,6 @@ extends CharacterBody2D
@export var ranged: RangedWeaponComponent
@export var melee: MeleeWeaponComponent
var weapon: RangedWeapon
var movement: PlayerMovement
var combat: PlayerCombat
@ -15,7 +14,6 @@ var last_direction = Vector2.DOWN
@onready var animated_sprite = $PlayerSprite
func _ready():
weapon = $RangedWeapon
combat = PlayerCombat.new()
movement = PlayerMovement.new()
@ -27,14 +25,14 @@ func _ready():
combat.animated_sprite = animated_sprite
Log.pr("Adding projectile size additive modifier")
#weapon.add_modifier(ProjectileSizeAdditive.new())
Log.pr(weapon.stats.get_stat("projectile_size")) # Size is now 1.0 + 0.5 = 1.5
ranged.add_modifier(ProjectileSizeAdditive.new())
#Log.pr(weapon.stats.get_stat("projectile_size")) # Size is now 1.0 + 0.5 = 1.5
# Size is now 1.0 + 0.5 = 1.5
# Add the multiplicative size modifier (1.5x multiplier)
Log.pr("Adding projectile size multiplicative modifier")
#weapon.add_modifier(ProjectileSizeMultiplicative.new())
Log.pr(weapon.stats.get_stat("projectile_size"))
#Log.pr(weapon.stats.get_stat("projectile_size"))
# Size is now 1.5 * 1.5 = 2.25
# Add another additive size modifier (+0.7 or 70% increase)
@ -42,9 +40,9 @@ func _ready():
var another_size_mod = ProjectileSizeAdditive.new()
another_size_mod.size_increase = 0.7
#weapon.add_modifier(another_size_mod)
Log.pr(weapon.stats.get_stat("projectile_size"))
#Log.pr(weapon.stats.get_stat("projectile_size"))
#weapon.add_modifier(FireRateAdditive.new())
ranged.add_modifier(FireRateAdditive.new())
func _physics_process(delta):

View file

@ -11,7 +11,7 @@ func process(_delta):
var direction = mouse_position - player_position
var normalized_direction = direction.normalized()
player.weapon.fire(normalized_direction, mouse_position)
player.ranged.fire(normalized_direction, mouse_position)
# Update animation
#update_animation()