Remove dead code

This commit is contained in:
2026-04-18 10:50:44 +02:00
parent dfb1161854
commit 3f49bb42c8
11 changed files with 186 additions and 263 deletions

View File

@@ -39,9 +39,6 @@ const HUGE_COST_EXPONENT: int = 1000000
## Reference to generator UI
@export var info_generator_container: GeneratorPanel
## Reference to research tracker
var research_tracker: Node = null
## True while the pointer is inside the generator Area2D.
var _mouse_entered: bool = false
## Time left until next click/hover grant is allowed.
@@ -108,8 +105,7 @@ func _ready() -> void:
game_state.currency_changed.connect(_on_currency_changed)
game_state.generator_state_changed.connect(_on_generated_state_changed)
game_state.goal_completed.connect(_on_goal_completed)
# Don't cache research_tracker here - it may not be initialized yet
# Access it lazily when needed instead
# Research XP is awarded via game_state.add_research_xp() - buff calculation handled statically
_ensure_registered()
@@ -155,11 +151,7 @@ func _grant_cycle_income(cycle_count: int) -> void:
var amount_float: float = produced.mantissa * pow(10.0, float(produced.exponent))
var research_xp_amount: BigNumber = BigNumber.from_float(data.research_data.xp_per_currency_produced * amount_float)
if game_state != null and research_xp_amount.mantissa > 0.0:
var tracker: ResearchXPTracker = game_state.research_tracker as ResearchXPTracker
if tracker:
tracker.add_xp_with_buffs(data.research_data.id, research_xp_amount)
else:
game_state.add_research_xp(data.research_data.id, research_xp_amount)
game_state.add_research_xp(data.research_data.id, research_xp_amount)
## Convenience helper for the next single-unit purchase cost.
func get_next_cost() -> BigNumber:
@@ -444,11 +436,7 @@ func _try_grant_click_currency() -> void:
var amount_float: float = click_value.mantissa * pow(10.0, float(click_value.exponent))
var research_xp_amount: BigNumber = BigNumber.from_float(data.research_data.xp_per_currency_produced * amount_float)
if game_state != null and research_xp_amount.mantissa > 0.0:
var tracker: ResearchXPTracker = game_state.research_tracker as ResearchXPTracker
if tracker:
tracker.add_xp_with_buffs(data.research_data.id, research_xp_amount)
else:
game_state.add_research_xp(data.research_data.id, research_xp_amount)
game_state.add_research_xp(data.research_data.id, research_xp_amount)
## Resolves click reward from data.

View File

@@ -0,0 +1,22 @@
## Static utility class for research XP buff calculations
class_name ResearchBuffCalculator
static func apply_buffs(game_state: LevelGameState, research_id: StringName, base_xp: BigNumber) -> BigNumber:
if game_state == null:
return base_xp
var multiplier: float = _calculate_buff_multiplier(game_state, research_id)
var multiplier_bn: BigNumber = BigNumber.from_float(multiplier)
return base_xp.multiply(multiplier_bn)
static func _calculate_buff_multiplier(game_state: LevelGameState, research_id: StringName) -> float:
var research: ResearchData = game_state.research_catalogue.get_research_by_id(research_id)
if research == null or research.associated_buff_id.is_empty():
return 1.0
var buff: GeneratorBuffData = game_state.get_buff(research.associated_buff_id)
if buff == null or not game_state.is_buff_active(buff.id):
return 1.0
var level: int = game_state.get_buff_level(buff.id)
return buff.get_effect_multiplier(level)

View File

@@ -0,0 +1 @@
uid://bhrcgp2dna0mb