Update speed limit, enable embedded PCK format, and enhance brown dwarf production logic

This commit is contained in:
Kirill
2026-09-21 20:42:40 +03:00
parent f246efd6ad
commit 1796829338
9 changed files with 192 additions and 97 deletions
+45 -1
View File
@@ -997,6 +997,8 @@ func _produce_for_period(previous: Dictionary, target: Dictionary, quantities: D
for id in budget:
budget[id] = minf(maxf(0.0, budget[id]), _available(target, id))
target.auto_resources = budget
_produce_brown_dwarfs(target, automatic.get("H", 0.0), from_year, to_year)
budget = _ordinary_star_budget(target)
# One common multiplier preserves the initial count ratios, even under scarcity.
var candidates: Dictionary = {}
@@ -1059,7 +1061,7 @@ func _produce_for_period(previous: Dictionary, target: Dictionary, quantities: D
continue
if not _try_production(target, entity, actual, true):
continue
budget = target.auto_resources
budget = _ordinary_star_budget(target)
created[id] = actual
total_created += actual
for id in candidates:
@@ -1071,6 +1073,48 @@ func _produce_for_period(previous: Dictionary, target: Dictionary, quantities: D
_create_planets(target, id, created[id], from_year, to_year, metallicity)
# HBD quota is in objects. HBD_fuel is prepaid hydrogen removed from free stock.
# Signed rounding debt and the PRNG state survive saving with this dictionary.
func _produce_brown_dwarfs(target: Dictionary, new_hydrogen: float, from_year: float, to_year: float) -> void:
if not entities.has("HBD"):
return
var entity: OwniverseEntity = entities.HBD
var cost: float = entity.cost.get("H", 0.0)
if cost <= 0.0:
return
var quota: float = target.auto_star_deficits.get("HBD", 0.0) + maxf(0.0, new_hydrogen) * 0.001 / cost
var fuel: float = maxf(0.0, target.auto_star_deficits.get("HBD_fuel", 0.0))
var available: float = minf(target.auto_resources.get("H", 0.0), _available(target, "H"))
quota = minf(quota, (available + fuel) / cost)
var expected: float = maxf(0.0, snappedf(quota, 1e-9))
var amount: float = floorf(expected)
# Do not retry a fractional chance on frames with no new automatic fuel.
if new_hydrogen > 0.0 and expected > amount:
var random_state: float = target.auto_star_deficits.get("HBD_random", 1234567.0)
random_state = fmod(random_state * 48271.0, 2147483647.0)
target.auto_star_deficits.HBD_random = random_state
if random_state / 2147483647.0 < expected - amount:
amount += 1.0
amount = minf(amount, floorf(snappedf((available + fuel) / cost, 1e-9)))
var charge: float = ceilf(maxf(0.0, snappedf(amount * cost - fuel, 1e-9)))
if amount > 0.0 and charge <= available:
_take_available(target, "H", charge)
target.auto_resources.H = maxf(0.0, target.auto_resources.get("H", 0.0) - charge)
target.auto_star_deficits.HBD_fuel = maxf(0.0, snappedf(fuel + charge - amount * cost, 1e-9))
quota -= amount
_credit(target, "HBD", amount)
_append_batch(target, "HBD", amount, from_year, to_year)
target.auto_star_deficits.HBD = quota
func _ordinary_star_budget(target: Dictionary) -> Dictionary:
var budget: Dictionary = target.auto_resources.duplicate()
if entities.has("HBD"):
var reserved: float = maxf(0.0, target.auto_star_deficits.get("HBD", 0.0) * entities.HBD.cost.get("H", 0.0) - target.auto_star_deficits.get("HBD_fuel", 0.0))
budget.H = maxf(0.0, budget.get("H", 0.0) - reserved)
return budget
func _auto_capacity(source: Dictionary, entity: OwniverseEntity, budget: Dictionary) -> float:
var capacity: float = INF
var needs: Dictionary = {}