aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/clan_combat_groups.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/fparkan-runtime/src/clan_combat_groups.rs')
-rw-r--r--crates/fparkan-runtime/src/clan_combat_groups.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/fparkan-runtime/src/clan_combat_groups.rs b/crates/fparkan-runtime/src/clan_combat_groups.rs
index 50c86e16..b0b0de11 100644
--- a/crates/fparkan-runtime/src/clan_combat_groups.rs
+++ b/crates/fparkan-runtime/src/clan_combat_groups.rs
@@ -1,6 +1,6 @@
use crate::clan_combat_strength::unit_strength;
use crate::unit_patrol::UnitPatrol;
-use crate::{MissionControlDeviceTableState, MissionDocument, MissionObjectDraft};
+use crate::{MissionControlDeviceTableState, MissionObjectDraft};
use fparkan_script::{Handler15Invocation, Handler15TargetPayload};
use fparkan_world::{identity_metadata, transform_state, ObjectHandle, OwnerId, World};
@@ -19,13 +19,12 @@ pub(super) enum GroupTarget {
impl GroupTarget {
fn resolve(
world: &World,
- mission: &MissionDocument,
+ lookup: impl FnOnce(u32) -> Option<ObjectHandle>,
target: Handler15TargetPayload,
) -> Option<Self> {
match target {
Handler15TargetPayload::ByLogicId(id) => {
- let handle =
- crate::mission_events::placed_logic_objects(mission, world, id).next()?;
+ let handle = lookup(id)?;
Some(Self::Object(
handle,
identity_metadata(world, handle).ok()?.owner_id,
@@ -94,11 +93,11 @@ pub(super) fn recruit(
world: &World,
units: impl Iterator<Item = ObjectHandle>,
controls: &[MissionControlDeviceTableState],
- mission: &MissionDocument,
+ lookup: impl FnOnce(u32) -> Option<ObjectHandle>,
target: Handler15TargetPayload,
requested: u32,
) -> (Option<CombatGroup>, f32) {
- let Some(target) = GroupTarget::resolve(world, mission, target) else {
+ let Some(target) = GroupTarget::resolve(world, lookup, target) else {
return (None, 0.0);
};
let Some([x, y]) = target.position(world) else {
@@ -143,7 +142,7 @@ impl CombatGroup {
&mut self,
patrol: &mut UnitPatrol,
world: &World,
- mission: &MissionDocument,
+ lookup: impl FnOnce(u32) -> Option<ObjectHandle>,
drafts: &[MissionObjectDraft],
order: Handler15Invocation,
) -> Result<(), String> {
@@ -153,7 +152,7 @@ impl CombatGroup {
"Handler(28) requires a supported patrol or attack order on group 0".into(),
);
}
- let target = GroupTarget::resolve(world, mission, order.target)
+ let target = GroupTarget::resolve(world, lookup, order.target)
.ok_or("Handler(28) target is unavailable")?;
for &unit in &self.members {
let class = identity_metadata(world, unit)