From 8206606790006f50f8862021ff03cbe2b7aece5c Mon Sep 17 00:00:00 2001 From: autocommit Date: Mon, 27 Apr 2026 20:36:09 -0700 Subject: [PATCH] =?UTF-8?q?perf(simulator-specific):=20=E2=9A=A1=20Impleme?= =?UTF-8?q?nt=20Rust-side=20percentage=20bonus=20calculations=20to=20repla?= =?UTF-8?q?ce=20GDScript=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- src/simulator/api-gdext/src/lib.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/simulator/api-gdext/src/lib.rs b/src/simulator/api-gdext/src/lib.rs index 301ed0e7..d133b0c1 100644 --- a/src/simulator/api-gdext/src/lib.rs +++ b/src/simulator/api-gdext/src/lib.rs @@ -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) {