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.
50 lines
1.4 KiB
GDScript
50 lines
1.4 KiB
GDScript
extends CharacterBody2D
|
|
|
|
@export var speed = 200
|
|
@export var special_ability: Ability
|
|
@export var ranged: RangedWeaponComponent
|
|
@export var melee: MeleeWeaponComponent
|
|
|
|
var movement: PlayerMovement
|
|
var combat: PlayerCombat
|
|
|
|
# Last direction for idle state
|
|
var last_direction = Vector2.DOWN
|
|
|
|
@onready var animated_sprite = $PlayerSprite
|
|
|
|
func _ready():
|
|
combat = PlayerCombat.new()
|
|
|
|
movement = PlayerMovement.new()
|
|
movement.player = self
|
|
movement.animated_sprite = animated_sprite
|
|
movement.speed = speed
|
|
|
|
combat.player = self
|
|
combat.animated_sprite = animated_sprite
|
|
|
|
Log.pr("Adding projectile size additive modifier")
|
|
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"))
|
|
# Size is now 1.5 * 1.5 = 2.25
|
|
|
|
# Add another additive size modifier (+0.7 or 70% increase)
|
|
Log.pr("Adding another projectile size additive modifier", 2)
|
|
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"))
|
|
|
|
ranged.add_modifier(FireRateAdditive.new())
|
|
|
|
|
|
func _physics_process(delta):
|
|
movement.process(delta)
|
|
combat.process(delta)
|