fix(patcher): retain stock tank AI movement

Keep the original behavior tree installed and validate the optional script entry and dependencies after mod overlays. Verified stock tree bytes and the enable/disable rebuild on 2.61.0.58.
This commit is contained in:
N0VAN0M4LY committed 2026-12-03 14:24:32 +08:00
1 parent 975a28441a
commit bb680c6abd
5 files changed
+40 -33

No files matched your search

+1 -25
View File
@@ -35,15 +35,9 @@ export const EXTRA_STORE_BUNDLE_GUIDS: ReadonlyArray<readonly [entitlement: stri
export const EXTRA_STORE_BUNDLE_GUID_MAP: Readonly<Record<string, string>> = Object.fromEntries(EXTRA_STORE_BUNDLE_GUIDS);
export interface MainPackOptions {
/** Replace stock tankBot behavior children with `success` so custom chassis control owns steering. */
readonly yieldStockTankDrive?: boolean;
}
export interface MainPackResult {
readonly pack: Uint8Array;
readonly addresses: readonly AddressChange[];
readonly yieldedStockTankDrive: boolean;
}
export function rebuildMainPack(
@@ -51,7 +45,6 @@ export function rebuildMainPack(
endpoint: LocalEndpoint,
extraBundles: ReadonlyArray<readonly [string, string]> = [],
extraAddonFolders: readonly string[] = [],
options: MainPackOptions = {},
): MainPackResult {
let addresses: AddressChange[] = [];
const edits = [
@@ -68,13 +61,9 @@ export function rebuildMainPack(
path: GUI_CONFIG_PATH,
edit: (root: BlkBlock) => registerStoreBundleGuids(root, [...EXTRA_STORE_BUNDLE_GUIDS, ...extraBundles]),
},
...(options.yieldStockTankDrive ? [{
path: AI_LIST_PATH,
edit: (root: BlkBlock) => yieldTankBotBehaviorTree(root),
}] : []),
];
const pack = editPackBlks(stockPack, edits);
return { pack, addresses, yieldedStockTankDrive: options.yieldStockTankDrive === true };
return { pack, addresses };
}
function registerStoreBundleGuids(guiRoot: BlkBlock, bundles: ReadonlyArray<readonly [string, string]>): void {
@@ -83,16 +72,3 @@ function registerStoreBundleGuids(guiRoot: BlkBlock, bundles: ReadonlyArray<read
setParam(guidBlock, entitlement, { type: 'string', value: guid });
}
}
function yieldTankBotBehaviorTree(aiRoot: BlkBlock): void {
const matches = aiRoot.blocks.filter((block) =>
block.name === 'selector' &&
block.params.some((param) => param.name === 'name' && param.value.type === 'string' && param.value.value === 'tankBot'),
);
if (matches.length !== 1) {
throw new Error(`expected 1 "tankBot" selector in ${AI_LIST_PATH}, found ${matches.length}`);
}
const tankBot = matches[0]!;
tankBot.blocks.length = 0;
tankBot.blocks.push({ name: 'success', params: [], blocks: [] });
}