CommandFramework

版本 v0.3.1·更新於 2026-08-30

Tactical unit commanding framework and in-game context menu for Nuclear Option with STOP and RESUME orders, selection protection, and extensible developer API.

模組介紹 作者原文

Command Framework for Nuclear Option

A modular unit commanding framework and in-game tactical context menu for Nuclear Option (BepInEx 5).

Features

  • Tactical Context Menu: Right-click on any unit (on the map or in 3D world view) to open a minimal, green-outlined command popup.
  • Stop / Hold Position: Sets isHoldPosition = true to halt unit movement while keeping weapon turrets, radar, and combat defense active.
  • Resume with Automatic AI Nudge: Resuming a stopped unit (isHoldPosition = false) wakes up pathfinding and AI routines to resume autonomous movement, mission waypoints, or road network patrols.
  • Selection Protection: Right-clicking on other units opens their menu without issuing move or attack orders to previously selected units.
  • Empty Space Left-Click Deselection: Left-clicking on any empty space (terrain, sky, or map) cleanly deselects active target locks or selected units.
  • Developer API: Register custom unit commands, attach custom order states and metadata to units, and filter AI destination changes from other mods.

Installation

  • Install BepInEx 5 into your Nuclear Option game directory.
  • Copy the CommandFramework folder into Nuclear Option/BepInEx/plugins.
  • Start the game.

Developer API Guide

  • Adding a Project Reference

Add a reference to CommandFramework.dll in your.csproj:

path\to\BepInEx\plugins\CommandFramework\CommandFramework.dll

False

Declare the BepInDependency attribute in your plugin class:

[BepInDependency("com.nuclearoption.commandframework")]

public class MyPlugin: BaseUnityPlugin

{

//...

}

  • Registering a Custom Command

Implement IUnitCommandAction and register it using CommandFrameworkAPI.RegisterCommand:

using CommandFramework.API;

using UnityEngine;

public class GuardAreaCommand: IUnitCommandAction

{

public string Id => "com.example.guard_area";

public int Priority => 30;

public string GetDisplayName(Unit unit)

{

var state = CommandFrameworkAPI.GetOrderState(unit);

return state.CustomStateKey == "Guarding"? "STOP GUARDING": "GUARD AREA";

}

public bool IsVisible(Unit unit)

{

return unit is GroundVehicle || unit is Ship;

}

public bool IsEnabled(Unit unit) => unit!= null &&!unit.disabled;

public Color? GetButtonColor(Unit unit)

{

var state = CommandFrameworkAPI.GetOrderState(unit);

return state.CustomStateKey == "Guarding"? new Color(0.8f, 0.3f, 0.2f): new Color(0.1f, 0.6f, 0.9f);

}

public void Execute(Unit unit)

{

var state = CommandFrameworkAPI.GetOrderState(unit);

if (state.CustomStateKey == "Guarding")

{

CommandFrameworkAPI.ClearCustomOrderState(unit);

CommandFrameworkAPI.NudgeAI(unit);

}

else

{

CommandFrameworkAPI.SetCustomOrderState(unit, "Guarding", "GUARDING AREA", Color.cyan);

state.SetData("GuardCenter", unit.transform.position);

state.SetData("GuardRadius", 2000f);

}

}

}

// In your plugin Awake():

CommandFrameworkAPI.RegisterCommand(new GuardAreaCommand());

  • Custom Order States and Metadata Storage

Attach custom states, tags, or metadata to units:

// Get unit state

UnitOrderState state = CommandFrameworkAPI.GetOrderState(unit);

// Store arbitrary data on the unit

state.SetData("PatrolRouteIndex", 3);

state.SetData("CustomTargetHQ", "Alpha_Base");

// Retrieve stored data

int routeIndex = state.GetData("PatrolRouteIndex");

// Set a custom state badge

CommandFrameworkAPI.SetCustomOrderState(unit, "Patrolling", "PATROL ROUTE 3", Color.green);

// Clear custom state

CommandFrameworkAPI.ClearCustomOrderState(unit);

  • Order and Destination Interception Filters

Intercept and block automated destination changes when a custom state is active:

// Register an order filter

CommandFrameworkAPI.RegisterOrderFilter((unit, targetPosition) =>

{

var state = CommandFrameworkAPI.GetOrderState(unit);

// Block destination updates if unit is in custom guard mode

if (state.CustomStateKey == "Guarding")

{

return false;

}

return true;

});

  • Triggering AI Nudge

Force an immediate AI pathfinding recalculation and missio

安裝與使用 安裝:按包內說明操作

  1. 解壓本站下載的壓縮包,先讀包內的 readme / 說明檔案。
  2. 多數模組依賴遊戲的模組載入器:常見做法是用社群模組管理器(如 r2modman)選中本遊戲安裝,由管理器自動處理載入器與依賴。
  3. 手動安裝時,把模組檔案放進遊戲目錄下對應的 Mod / plugins 資料夾。
  4. 啟動遊戲確認載入成功;帶「前置依賴」的模組需要把依賴一併安裝。

不同模組的安裝位置差異較大,包內說明是最可靠的依據。

前置依賴

下面這些內容需要先安裝,否則該模組不會生效:

BepInEx-BepInExPack

檔案與校驗

檔案名稱
CommandFramework-0.3.1.zip
檔案大小
138.9 KiB