Files
OpenRA/OpenRA.Mods.Common/Widgets/Logic/Ingame/LLMTakeoverLogic.cs
let5sne.win10 9d80847a9a
Some checks failed
Continuous Integration / Linux (.NET 8.0) (push) Has been cancelled
Continuous Integration / Windows (.NET 8.0) (push) Has been cancelled
ra: 托管时镜头自动跟随防守热点
新增 BotTakeoverCameraFollower(Player trait):托管开启时通过 ViewportCenterProvider 自动跟随热点事件,默认偏防守(基地/矿区受击优先,建造落点次之),并使用热点衰减 + 最短驻留时间 + 切换阈值避免多处战斗时镜头抖动。

同时:

- mods/ra/rules/player.yaml 接入该 trait(仅 takeover 激活时生效)

- 修复 ingame-player.yaml 的 TooltipDesc/FTL 校验警告

- 小幅代码风格优化(不改行为)
2026-01-11 23:27:24 +08:00

57 lines
1.6 KiB
C#

#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
using OpenRA.Mods.Common.Traits;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets
{
public class LLMTakeoverLogic : ChromeLogic
{
readonly World world;
[ObjectCreator.UseCtor]
public LLMTakeoverLogic(Widget widget, World world, Dictionary<string, MiniYaml> logicArgs)
{
this.world = world;
var button = widget.Get<ButtonWidget>("LLM_TAKEOVER");
button.GetText = () => IsTakeoverActive() ? "Cancel AI" : "AI";
button.IsHighlighted = IsTakeoverActive;
button.OnClick = OnTakeoverClick;
button.IsDisabled = () => world.LocalPlayer == null
|| world.LocalPlayer.WinState != WinState.Undefined;
}
bool IsTakeoverActive()
{
var player = world.LocalPlayer;
if (player == null)
return false;
var takeover = player.PlayerActor.TraitOrDefault<BotTakeoverManager>();
return takeover != null && takeover.IsActive;
}
void OnTakeoverClick()
{
var player = world.LocalPlayer;
if (player == null)
return;
// Prefer the classic AI takeover manager (uses ModularBot + original bot modules).
var takeover = player.PlayerActor.TraitOrDefault<BotTakeoverManager>();
takeover?.Toggle();
}
}
}