Skip to content

1. Class Reference

Lucas Melo edited this page Sep 26, 2025 · 1 revision

StatPool - Class Reference

Inherits

Resource

Brief Description

Pool stat management component.

Description

Component for tracking any numeric stat pool, for example: health, stamina, hunger, etc, where you have current, maximum and minimum values. Handles value modifications, boundary management, and emits various signals for value changes.

Properties

Type Name Default
int max_value 100
int min_value 0
int value 100

Methods

Return Type Method
void decrease(int amount)
void deplete()
void fill()
float get_percentage() const
void increase(int amount)
bool is_depleted() const
bool is_filled() const

Signals

Signal
depleted(StatPool stat)
max_value_changed(int old_max, int new_max, bool increased)
min_value_changed(int old_min, int new_min, bool increased)
restored(StatPool stat)
restored_fully(StatPool stat)
value_changed(int old_value, int new_value, bool increased)

Property Descriptions

max_value: int = 100

Maximum possible stat value. If it ever goes below or equal min_value, then min_value will be automatically adjusted to exactly 1 integer below max_value. Example: If min_value is 0 and you set max_value to 0, then min_value will be adjusted to -1.

min_value: int = 0

Minimum possible stat value. If it ever goes above or equal max_value, then max_value will be automatically adjusted to exactly 1 integer above min_value. Example: If max_value is 100 and you set min_value to 100, then max_value will be adjusted to 101.

value: int = 100

Current stat value. Automatically clamped between min_value and max_value when set.


Method Descriptions

decrease(int amount)

Decreases value by the specified amount in amount.

deplete()

Completely depletes value, setting its value to equal min_value.

fill()

Completely fills value, setting its value to equal max_value.

get_percentage() const

Returns the current value as a percentage (0.0 to 1.0) relative to the range between min_value and max_value.

increase(int amount)

Increases value by the specified amount in amount.

is_depleted() const

Returns true if value is at min_value.

is_filled() const

Returns true if value is at max_value.


Signal Descriptions

depleted(StatPool stat)

Signal emitted when value reaches min_value.

max_value_changed(int old_max, int new_max, bool increased)

Signal emitted when max_value changes. old_max - Represents the previous maximum value before the change. new_max - Represents the new maximum value after the change. increased - Indicates whether the maximum value was increased (true) or decreased (false).

min_value_changed(int old_min, int new_min, bool increased)

Signal emitted when min_value changes. old_min - Represents the previous minimum value before the change. new_min - Represents the new minimum value after the change. increased - Indicates whether the minimum value was increased (true) or decreased (false).

restored(StatPool stat)

Signal emitted when value changes from min_value to any higher value.

restored_fully(StatPool stat)

Signal emitted when value reaches its maximum value max_value.

value_changed(int old_value, int new_value, bool increased)

Signal emitted when value changes. old_value - Represents the previous value before the change. new_value - Represents the new value after the change. increased - Indicates whether the value was increased (true) or decreased (false).