Skip to content

Broker Resolver

Class · USeinCommandBrokerResolver : UObject

#include "Brokers/SeinCommandBrokerResolver.h"

abstract: use a subclass · can be subclassed in Blueprint · deterministic: safe in simulation code

Decides, when an order lands on a broker (a group or a multi-unit selection), which members run which abilities against which targets and where each member stands. This is the abstract base to subclass for custom dispatch. The framework ships a concrete default, and a project chooses its own with Default Broker Resolver Class in the Orders settings. Resolve Dispatch is the entry point: it walks the order’s effective members (honoring a targeted subset) and returns a plan of per-member ability and target entries; members left out are skipped. Resolve Member Ability picks the ability for one member and click context; the default consults the member’s own command table and then its fallback tag, and an invalid tag skips the member. Resolve Formation Layout is a side-effect-free solver, so the destination preview shows the exact positions a committed order gets. Resolve Positions is the lower-level per-member placement (the base returns the anchor for every member), and Post Process Positions is an optional pass to nudge positions afterward. All of these run in simulation command processing, so they must be deterministic: fixed-point only, no float or random.

Ability-level dispatch policy: filters the candidates down to the dispatcher set per the ability’s DispatchMode / DispatchSelector / DispatchPreferredTag / DispatchFallback. Every resolver’s predetermined-ability path calls it, so an ability authored once carries its dispatch shape into any broker. Candidates are the entities holding the ability, already intersected with the order’s effective members (a group carrier may be among them). A null ability dispatches to all. Empty = the ability is unavailable this frame. A Blueprint Resolve Dispatch override calls it to keep the ability’s dispatch shape.

TArray<FSeinEntityHandle> ApplyAbilityDispatchPolicy(USeinWorldSubsystem* World, FSeinEntityHandle BrokerHandle, const class USeinAbility* Ability, const TArray<FSeinEntityHandle>& Candidates) const;

Overridable in Blueprint, with a native default

Per-member tag resolution hook — “which ability does THIS member want to run for THIS click context?” The default implementation delegates to the member’s own Ability Data::ResolveCommandContext (walks the unit’s DefaultCommands table, picks highest-priority match, falls back to FallbackAbilityTag). Override this when you want faction / state / diplomacy-based overrides without reimplementing the full dispatch plan — e.g. “workers prefer Repair over Move when right-clicking a damaged ally.”

Return an invalid tag to tell the broker this member cannot service this context — the member will be silently skipped for this order.

FGameplayTag ResolveMemberAbility(USeinWorldSubsystem* World, FSeinEntityHandle Member, const FGameplayTagContainer& Context);

Overridable in Blueprint, with a native default

Resolve a broker order into per-member dispatches.

Implementations iterate Order.EffectiveMembers (NOT the broker’s full Members list — EffectiveMembers is subset-aware, honoring the queued order’s TargetMembers field). For each effective member, call ResolveMemberAbility to pick the ability, decide target + position, and emit a dispatch tuple. Members that don’t appear in the returned plan are silently skipped for this order. Resolver implementations must not mutate broker state. Return optional facing/settled-slot changes through the plan; the broker system validates and commits them transactionally.

FSeinBrokerDispatchPlan ResolveDispatch(USeinWorldSubsystem* World, FSeinEntityHandle BrokerHandle, const FSeinBrokerOrderInput& Order);

Overridable in Blueprint, with a native default

Compute desired world positions for the given members around an anchor. Returned array is index-aligned with Members. Default implementation returns Anchor for every member (no formation); subclasses override for tight-rank / class-cluster / wedge layouts.

TArray<FFixedVector> ResolvePositions(USeinWorldSubsystem* World, const TArray<FSeinEntityHandle>& Members, FFixedVector Anchor, FFixedQuaternion Facing);

Overridable in Blueprint, with a native default

Pure formation solver: given the members and the order target, returns the formation’s facing and a world position for each member. The destination preview calls it as well as dispatch, so it must have no side effects and stay deterministic. The base version keeps the current facing and places every member at the anchor; the default resolver asks the selected formation for the layout and then re-matches members to slots. Reassign Lateral and Reassign Depth choose the anti-cross re-match: left-right rank, front-back rank, both for nearest-slot matching in 2D, or neither for raw index order.

FSeinFormationLayout ResolveFormationLayout(USeinWorldSubsystem* World, const TArray<FSeinEntityHandle>& Members, const FSeinOrderTarget& Target, bool bReassignLateral, bool bReassignDepth);

Overridable in Blueprint, with a native default

Optional post-process pass on the per-member positions computed by ResolvePositions. Called inside ResolveFormationLayout after the default geometry is laid out. Default impl is a no-op — subclasses override to apply system-specific position adjustments without having to reimplement the whole layout pipeline.

Designed as a generic extension point — not coupled to any one system. A game might snap members onto authored standing points, reposition them by terrain cost, or keep a group together. When the game also registers a selection destination plan provider that adjusts the same layout, skip the adjustment while the order subsystem reports IsSelectionDestinationBaseLayoutInProgress, so it applies once.

InOutPositions is index-aligned with Members and starts populated with whatever ResolvePositions returned. Subclasses can mutate any entries in place. Adding/removing entries is forbidden — the index alignment with Members is part of the contract.

void PostProcessPositions(USeinWorldSubsystem* World, const TArray<FSeinEntityHandle>& Members, TArray<FFixedVector>& InOutPositions, FFixedVector TargetLocation);
C++ members (2)
  • void GetGroupMembers(const USeinWorldSubsystem& World, FSeinEntityHandle BrokerHandle, TArray<FSeinEntityHandle>& OutMembers) const; The broker’s members in the group’s own order (the default: the broker’s member list). Presentation lists a group’s members in this order.
  • FInnerLayout GetInnerLayout(const USeinWorldSubsystem& World, FSeinEntityHandle BrokerHandle) const; The default: no formation of its own, no re-matching, the broker’s centroid.