Table of Contents

Class RefundCalculator

Namespace
GridPlacement.GDScript
Assembly
MoonBark.GridPlacement.GDScript.dll

Pure refund math for the 5.1 refund contract. No node, no scene dependencies — embed it in a [RefundService], a custom [Refunder], or any consumer script.\n\nGiven a resolved [BuildCost], computes id -> refund amount at [member refund_ratio] and optionally applies it to a container through the canonical id interface ([code]try_add_by_id[/code]).

class RefundCalculator extends RefCounted
RefundCalculator

Properties

refund_ratio

How fractional refund amounts are converted to whole items. Fraction of the original cost returned on demolish (1.0 = full refund).

var refund_ratio: float = 1.0

rounding

Rounding policy applied per entry after the ratio multiply.

var rounding: Rounding = Rounding.ROUND

refunds

var refunds = calculate(p_cost)

amount

var amount = _round(entry.quantity * refund_ratio)

refunds

var refunds = calculate(p_cost)

Methods

calculate

func calculate(p_cost: BuildCost) -> Dictionary[StringName, int]:

Parameters

p_cost

Returns

apply_to

func apply_to(p_container: Object, p_cost: BuildCost) -> Dictionary[StringName, int]:

Parameters

p_container
p_cost

Returns