aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/unit_combat.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 13:38:56 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 13:38:56 +0300
commit05da53f0344416a5f14211a73f1f48d72c88b954 (patch)
treed27d22f56a1bd185447b27223c79c9f97f7cc165 /crates/fparkan-runtime/src/unit_combat.rs
parent787279a1f514fbbaf09ca9dd6e5015bdce36635b (diff)
downloadfparkan-05da53f0344416a5f14211a73f1f48d72c88b954.tar.xz
fparkan-05da53f0344416a5f14211a73f1f48d72c88b954.zip
feat(ui): drive a strategic warbot with an automatic gunner
Diffstat (limited to 'crates/fparkan-runtime/src/unit_combat.rs')
-rw-r--r--crates/fparkan-runtime/src/unit_combat.rs17
1 files changed, 14 insertions, 3 deletions
diff --git a/crates/fparkan-runtime/src/unit_combat.rs b/crates/fparkan-runtime/src/unit_combat.rs
index 59c9ec64..799f0009 100644
--- a/crates/fparkan-runtime/src/unit_combat.rs
+++ b/crates/fparkan-runtime/src/unit_combat.rs
@@ -60,6 +60,7 @@ pub fn autonomous_firing_effect_phases(
.loaded
.as_ref()
.and_then(|mission| mission.boarding)
+ .filter(|boarding| boarding.controls_weapons())
.map(|boarding| boarding.cockpit.handle);
engine
.autodemo_combat
@@ -363,6 +364,16 @@ impl AutoDemoCombat {
&self.pose_failures
}
+ pub(super) fn weapons(&self, handle: ObjectHandle) -> Option<&PlayerWeapons> {
+ Some(
+ &self
+ .units
+ .iter()
+ .find(|unit| unit.handle == handle)?
+ .weapons,
+ )
+ }
+
pub(super) fn turret_aim(&self, handle: ObjectHandle, component: usize) -> Option<TurretAim> {
self.units
.iter()
@@ -624,9 +635,9 @@ impl AutoDemoCombat {
.and_then(|identity| identity.owner_id);
let guard = owner
.is_some_and(|owner| self.guard_clans.get(usize::from(owner.0)) == Some(&true));
- let manually_controlled = mission
- .boarding
- .is_some_and(|boarding| boarding.cockpit.handle == unit.handle);
+ let manually_controlled = mission.boarding.is_some_and(|boarding| {
+ boarding.cockpit.handle == unit.handle && boarding.controls_weapons()
+ });
// shortcut: free warbots defend from their current position until the
// default Behavior task and its pursuit rules are wired.
let defends_from_position = matches!(