Files
idle/core/prestige/prestige_buff_node.gd
2026-05-06 23:37:52 +02:00

70 lines
2.9 KiB
GDScript

## A single node in the prestige buff graph.
## Each node represents a permanent upgrade that persists across prestige resets and is purchased with prestige currency.
class_name PrestigeBuffNode
extends Resource
enum EffectType {
CURRENCY_PRODUCTION_MULTIPLIER, ## Multiply currency output by x%
BUILDING_CREATION_BONUS, ## When a building is created, increase currency gain by x%
WORKER_THRESHOLD_MULTIPLIER, ## When 10+ workers are assigned to a building, increase currency gain by x%
CARRYOVER_BUILDINGS, ## After prestige, start with some buildings and workers already assigned
UNLOCK_AUTO_BUY_WORKER, ## Unlock option to auto-buy workers
HOVER_SPEED_BOOST, ## Hovering over a place speeds up workers instead of clicking
UNLOCK_BUILDING, ## Unlock a new building (generator)
WORKER_PRODUCTIVITY, ## Increase worker productivity by x%
RESEARCH_XP_MULTIPLIER, ## Increase research XP gain by x%
}
## Unique node identifier.
@export var id: StringName = &""
## UI display label.
@export var display_name: String = ""
## Tooltip / description text.
@export_multiline var description: String = ""
## Icon shown in the graph UI.
@export var icon: Texture2D
## Prerequisite node IDs that must be unlocked before this node becomes available.
@export var parent_ids: Array[StringName] = []
## What kind of effect this buff provides.
@export var effect_type: EffectType = EffectType.CURRENCY_PRODUCTION_MULTIPLIER
## Magnitude of the effect (interpreted per effect type).
@export var effect_value: float = 1.0
## Target generator, building, or currency ID for type-specific effects. Empty means global.
@export var target_id: StringName = &""
## Prestige currency cost mantissa (combined with cost_exponent for BigNumber).
@export var cost_mantissa: float = 1.0
## Prestige currency cost exponent (combined with cost_mantissa for BigNumber).
@export var cost_exponent: int = 0
## Visual tier / row in the graph UI.
@export var tier: int = 0
## Visual column / horizontal position in the graph UI.
@export var x_position: float = 0.0
## Builds and returns the fixed prestige currency cost as a BigNumber.
func get_cost() -> BigNumber:
return BigNumber.new(cost_mantissa, cost_exponent)
## Returns true if this node has any prerequisite parent nodes.
func has_parents() -> bool:
return not parent_ids.is_empty()
## Checks whether all prerequisites are unlocked in the provided dictionary.
## [param unlocked] maps node_id (StringName) → bool (true if unlocked).
func all_parents_unlocked(unlocked: Dictionary) -> bool:
for parent_id in parent_ids:
if not bool(unlocked.get(parent_id, false)):
return false
return true
## Returns true if this node has valid required data (non-empty id, positive cost).
func is_valid() -> bool:
if id == &"":
return false
if cost_mantissa <= 0.0:
return false
return true