perf(simulator-specific): Implement Rust-side percentage bonus calculations to replace GDScript logic

Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
autocommit 2026-04-27 20:36:09 -07:00
parent fbb2021fa1
commit 8206606790

View file

@ -1385,6 +1385,22 @@ impl GdCity {
self.inner.process_culture(&ty)
}
/// Process culture accumulation with a percentage modifier added to the
/// raw culture gain. `total_pct` is the SUM of all percentage bonuses
/// (cult_pct + border_pct + difficulty_culture_mult - 1.0). Rust owns
/// both the raw gain and the percent-bonus application — no GDScript-side
/// post-call adjustment needed (warcouncil p1-39 Rail-1 port, 2026-04-27).
/// Returns true if border expansion is ready post-bonus.
#[func]
fn process_culture_with_modifier(&mut self, tile_yields_json: GString, total_pct: f64) -> bool {
let ty = Self::parse_tile_yields(&tile_yields_json.to_string());
let yields = self.inner.get_yields(&ty);
let raw_gain = yields.culture;
let scaled_gain = raw_gain * (1.0 + total_pct.max(-1.0));
self.inner.culture_stored += scaled_gain;
self.inner.can_expand()
}
/// Add production production.
#[func]
fn add_production(&mut self, production: f64) {