Skip to content

[ЗАКАЗ] Тела для ИИ/Возможность вселиться в боргов#4535

Draft
ThereDrD0 wants to merge 9 commits into
masterfrom
add/ai-body
Draft

[ЗАКАЗ] Тела для ИИ/Возможность вселиться в боргов#4535
ThereDrD0 wants to merge 9 commits into
masterfrom
add/ai-body

Conversation

@ThereDrD0

@ThereDrD0 ThereDrD0 commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Краткое описание | Short description

Заказ с ласта на возможность ИИ вселиться в борга и управлять им, если в борге есть специальная плата.
Подробности в ветке заказов.

Всякие проблемы вроде синхронизации законов тела, радио каналов между телом и ядром продуманы.
События, когда ИИ переносят на карту, ломают ядро и он в теле нормально обрабатываются, ИИ уходит из тела. Ломание тела аналогично.
Когда множество ИИ пытаются тыкать 1 тело тоже работает штатно.

Ссылка на багрепорт/Предложение | Related Issue/Bug Report

https://discord.com/channels/1499823476360613898/1505533814166917120

Медиа (Видео/Скриншоты) | Media (Video/Screenshots)

https://cdn.discordapp.com/attachments/1505533814166917120/1515713549765316628/2026-06-14_16-42-29.mp4?ex=6a3001be&is=6a2eb03e&hm=82eafadb8bf2c8fe3c44fd43dd4f2fa3ab8baef10438a32c4c55f5deae7a1f4e&

TODO

  • Заказчик хочет отдельные спрайты для тела ИИ, жду, пока нарисует
  • Добавить спрайт кнопки
  • Добавить рецепт платы, если нету
  • Проверить как там с копией доступов ИИ для тела
  • Проверить работает ли ИИ специфичное взаимодействие с дверьми

Пока пусть остальной код пройдет ревью

Changelog

🆑 ThereDrD

  • add: Добавлена механика тела для ИИ. Если вставить плату связи с ИИ в борга, то ИИ сможет играть за борга, имея все свои доступы и возможности.

Summary by CodeRabbit

Новые возможности

  • New Features

    • Добавлена возможность управления станционным ИИ корпусами borgов через коммуникационные платы.
    • Реализован интерфейс выбора и управления доступными AI-телами.
    • Добавлена настройка внешнего вида тел ИИ (мужской, женский, borg модели).
    • Синхронизирована работа радиоканалов и действий при управлении телом.
    • Интегрирована поддержка законов для тел станционного ИИ.
  • Documentation

    • Добавлена локализация интерфейса на английском и русском языках.

@github-actions

Copy link
Copy Markdown
Contributor

RSI Diff Bot; head commit 1b1d749 merging into 8b6932d
This PR makes changes to 1 or more RSIs. Here is a summary of all changes:

Resources/Textures/_Sunrise/Mobs/Silicon/station_ai_body.rsi

State Old New Status
borg Added
female Added
male Added

Resources/Textures/_Sunrise/Objects/Specific/Robotics/station_ai_communication_board.rsi

State Old New Status
board Added

@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Добавлена полноценная система управления телами для Station AI: новые общие компоненты (StationAiBodyComponent, StationAiBodyControllerComponent), серверный автомат состояний с переносом MindComponent, интерфейсный слой (BUI/actions), управление радиоканалами и законами, клиентское окно выбора тела, визуализатор внешности, плата связи AI с рецептом крафта и точки интеграции с воздушными шлюзами, holоpad и чатом.

Changes

Station AI Body Control System

Layer / File(s) Summary
Общие контракты и события
Content.Shared/_Sunrise/Silicons/StationAi/StationAiBodyComponent.cs, StationAiBodyControllerComponent.cs, StationAiBodyUi.cs, StationAiBodyEvents.cs, Content.Shared/Silicons/StationAi/StationAiCustomizationComponent.cs, Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs, Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs
Определены StationAiBodyComponent (состояние борг-тела с кэшем каналов), StationAiBodyControllerComponent (текущее тело + список для BUI), StationAiBodyEntry, BUI-ключ и сообщения, события действий, новый вариант BodyAppearance в StationAiCustomizationType, модификатор partial на SharedBorgSwitchableTypeSystem.
Хелперы резолвинга актора SharedStationAiSystem
Content.Shared/_Sunrise/Silicons/StationAi/SharedStationAiSystem.Body.cs
Добавлены TryGetCoreForAiActor, GetActiveAiActor, TryGetActiveAiActor, TryGetActiveAiBody, ValidateAiActor, UpdateStationAiBodyAppearance — унифицированный способ получить ядро AI по актору, будь то held-сущность или управляемое тело.
SharedBorgSwitchableTypeSystem Sunrise-расширение
Content.Shared/_Sunrise/Silicons/Borgs/SharedBorgSwitchableTypeSystem.Sunrise.cs
Добавлены TrySelectBorgType / CanSelectBorgType для выбора типа борга через существующий модульный пайплайн с валидацией отсутствия уже выбранного типа.
Серверный StationAiBodySystem — точка входа
Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.cs
Partial-класс-оркестратор с SharedContainerSystem-зависимостью и Initialize(), последовательно вызывающим три части инициализации.
Автомат состояний и перенос mind
Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.State.cs
Полная state machine: подписки на вставку/удаление communication board, терминацию тела, смерть мозга; публичный Try/Can API (InitializeBody, EnterBody, ExitBody, EmergencyReturn, ClearFromRemovedBoard); приватные Do*-методы с переносом MindComponent, выдачей/отзывом действий и радиоканалов, обновлением UI; хелперы генерации имён и BodyNumber.
Серверный интерфейсный слой (UI/actions)
Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.Interface.cs
Подписки на события контроллера, открытие BUI по действиям и альтернативному глаголу, обработка BUI-сообщений входа/выхода, сборка BuildBodyEntries, UpdateBodyUiData, EnsureControllerActions, CanUseBodyUi, TryGetStationAiFromActor.
Законы и радиоканалы
Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.Features.cs
OnBodyGetLaws пробрасывает законы от LinkedAi; GrantStationAiRadioChannels копирует и объединяет каналы AI core с телом с кэшированием; RevokeStationAiRadioChannels восстанавливает исходные каналы.
Интеграционные патчи
Content.Server/Silicons/StationAi/StationAiSystem.cs, Content.Server/Holopad/HolopadSystem.cs, Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs, SharedStationAiSystem.Held.cs, SharedStationAiSystem.cs, SharedStationAiSystem.Customization.cs
StationAiSystem: алерты, акцент, IC-чат и GetStationAIs перенаправлены через GetActiveAiActor. HolopadSystem: TryExitBody перед проекцией, GetActiveAiActor при открытии UI. Шлюзы: TryGetCoreForAiActor для проверки доступа. Held: переписана валидация BUI-сообщений и verb-ов. Кастомизация: ветка BodyAppearance.
Клиентское окно выбора тела
Content.Client/_Sunrise/Silicons/StationAi/StationAiBodyWindow.xaml, StationAiBodyWindow.xaml.cs, StationAiBodyBoundUserInterface.cs, StationAiBodySystem.cs
XAML-разметка с BodyList и ExitBodyButton; UpdateState перестраивает список; CreateBodyEntry формирует строки с кнопками входа; BUI открывает окно, отправляет predicted-сообщения; клиентская система обновляет BUI по AfterAutoHandleStateEvent.
Визуализатор внешности тела
Content.Client/_Sunrise/Silicons/StationAi/StationAiBodyVisualizerSystem.cs
StationAiBodyVisualizerSystem резервирует/задаёт или скрывает слой BodyAppearance на спрайте борга при смене AppearanceChangeEvent.
Прототипы, рецепты, ассеты
Resources/Prototypes/Entities/Mobs/Player/silicon.yml, Resources/Prototypes/_Sunrise/Actions/station_ai.yml, Resources/Prototypes/_Sunrise/AppearanceCustomization/station_ai_body.yml, Resources/Prototypes/_Sunrise/Entities/Objects/Specific/Robotics/station_ai_boards.yml, Resources/Prototypes/_Sunrise/Recipes/Lathes/*, Resources/Prototypes/_Sunrise/tags.yml, Resources/Textures/_Sunrise/...
StationAiBrain получает StationAiBodyController и новый BUI-интерфейс. Два action-прототипа (меню тел, выход). Группа кастомизации внешности (male/female/borg). Сущность SunriseStationAiCommunicationBoard с рецептом крафта (Gold/Silver/Plasma) и тегом. Метаданные спрайтов.
Локализация (EN + RU)
Resources/Locale/en-US/_strings/_sunrise/silicons/station-ai.ftl, borg-gender.ftl, Resources/Locale/ru-RU/...
Все строки окна выбора тела, статусы (Current/Free/Occupied), имена типов тел, шаблон station-ai-body-name, действия, окно выбора пола борга, описание платы связи.

Sequence Diagram(s)

sequenceDiagram
    participant Player as Игрок (Station AI)
    participant BUI as StationAiBodyBoundUserInterface
    participant InterfaceServer as StationAiBodySystem.Interface (Server)
    participant StateServer as StationAiBodySystem.State (Server)
    participant Features as StationAiBodySystem.Features (Server)
    participant Mind as MindSystem

    Player->>BUI: нажать "Enter" у тела
    BUI->>InterfaceServer: StationAiBodyEnterMessage(body)
    InterfaceServer->>StateServer: TryEnterBody(stationAi, body)
    StateServer->>StateServer: CanEnterBody → валидация board/связей/mind
    StateServer->>StateServer: ReleaseCurrentBody (если было)
    StateServer->>Mind: TransferTo(body)
    StateServer->>Features: GrantStationAiRadioChannels(body)
    StateServer->>InterfaceServer: GrantControlledBodyActions(body)
    StateServer->>InterfaceServer: UpdateBodyUiData(controller)
    InterfaceServer->>BUI: UpdateState (via AfterAutoHandleStateEvent)

    Player->>BUI: нажать "Leave AI body"
    BUI->>InterfaceServer: StationAiBodyExitMessage
    InterfaceServer->>StateServer: TryExitBody(stationAi)
    StateServer->>Mind: TransferTo(brain)
    StateServer->>Features: RevokeStationAiRadioChannels(body)
    StateServer->>InterfaceServer: RevokeControlledBodyActions(body)
    StateServer->>InterfaceServer: UpdateBodyUiData(controller)
    InterfaceServer->>BUI: UpdateState
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Suggested labels

🖌️ Спрайты 🖌️, 📚 Изменения: Локализация 📚, 🛠️ Есть C# 🛠️, 📦 YAML | Прототип 📦, 🪟 Интерфейс 🪟

Suggested reviewers

  • kanopus952
  • VigersRay

Poem

🤖 ИИ покидает ядро своё,
В борг-корпус входит — вот оно, счастье!
TryEnterBody — и разум в теле,
TryExitBody — домой, к любви, к сети.
Плата связи скована из золота и плазмы,
А строки Fluent — как мелодии фантазий. 🎶

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add/ai-body

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Content.Client/_Sunrise/Silicons/StationAi/StationAiBodyWindow.xaml.cs`:
- Around line 16-21: The StationAiBodyWindow constructor is missing the required
dependency injection call. After the RobustXamlLoader.Load(this) call in the
StationAiBodyWindow constructor, add a call to
IoCManager.InjectDependencies(this) to comply with XAML.cs UI class coding
guidelines that mandate dependency injection immediately after XAML loading.

In `@Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.State.cs`:
- Around line 86-106: The OnStationAiBrainGotRemovedFromCore event handler is
performing direct state mutations (RemComp of RelayInputMoverComponent and
modifying mover.CanMove) before delegating, violating the required OnEvent ->
TryDo -> CanDo -> Do pattern. Extract all side-effects from this event handler
into a separate Do method that performs the component removal and mover state
changes, keeping only validation checks in OnStationAiBrainGotRemovedFromCore
itself. Create a TryExitBody-style method (or expand its responsibilities) to
encapsulate the Do logic that applies the mutations after validation passes,
ensuring the CanDo validation phase remains side-effect free.

In `@Content.Server/Silicons/StationAi/StationAiSystem.cs`:
- Around line 167-171: All Russian inline comments in the Station AI system
files must be translated to English per repository guidelines. In
Content.Server/Silicons/StationAi/StationAiSystem.cs lines 167-171, translate
the comment about clearing alerts for the active AI actor body. In
Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs lines 27-32,
translate the comment about AI core access checking and any other comments in
the airlock event handlers. In
Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs lines 135-166,
translate comments about AI-only BUI interaction and whitelist/power checks,
including those in the verbs block. In
Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs line 176, translate
the inline comment for the TryGetCoreForAiActor method and the notification
comment around line 307. In
Content.Shared/Silicons/StationAi/SharedStationAiSystem.Customization.cs lines
48-51, translate the comment about separate body customization. Replace all
Russian text with clear, equivalent English translations while preserving the
original meaning and context.

In
`@Content.Shared/_Sunrise/Silicons/StationAi/StationAiBodyControllerComponent.cs`:
- Around line 21-23: The `Bodies` field is marked as `[AutoNetworkedField]` but
contains a reference type `StationAiBodyEntry` defined as a `class` without
implementing `IRobustCloneable`, which violates the requirement that reference
types in networked components must support safe state serialization and rollback
during prediction. Either convert `StationAiBodyEntry` from a `class` to a
`record struct` to make it a value-type, or implement the `IRobustCloneable`
interface on the `StationAiBodyEntry` class with proper cloning logic to ensure
safe copying of component state.

In `@Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs`:
- Line 15: The inline comment on the SharedBorgSwitchableTypeSystem class
declaration is written in Russian but must be in English per coding guidelines
for .cs files. Translate the comment "Sunrise-Edit - partial для расширения из
_Sunrise." to English while preserving the meaning about the partial class being
used for extension from _Sunrise.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 10692f0a-df2e-46ce-be6b-7573f4964629

📥 Commits

Reviewing files that changed from the base of the PR and between 8b6932d and 1b1d749.

⛔ Files ignored due to path filters (4)
  • Resources/Textures/_Sunrise/Mobs/Silicon/station_ai_body.rsi/borg.png is excluded by !**/*.png
  • Resources/Textures/_Sunrise/Mobs/Silicon/station_ai_body.rsi/female.png is excluded by !**/*.png
  • Resources/Textures/_Sunrise/Mobs/Silicon/station_ai_body.rsi/male.png is excluded by !**/*.png
  • Resources/Textures/_Sunrise/Objects/Specific/Robotics/station_ai_communication_board.rsi/board.png is excluded by !**/*.png
📒 Files selected for processing (43)
  • Content.Client/_Sunrise/Silicons/StationAi/StationAiBodyBoundUserInterface.cs
  • Content.Client/_Sunrise/Silicons/StationAi/StationAiBodySystem.cs
  • Content.Client/_Sunrise/Silicons/StationAi/StationAiBodyVisualizerSystem.cs
  • Content.Client/_Sunrise/Silicons/StationAi/StationAiBodyWindow.xaml
  • Content.Client/_Sunrise/Silicons/StationAi/StationAiBodyWindow.xaml.cs
  • Content.Server/Holopad/HolopadSystem.cs
  • Content.Server/Silicons/StationAi/StationAiSystem.cs
  • Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.Features.cs
  • Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.Interface.cs
  • Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.State.cs
  • Content.Server/_Sunrise/Silicons/StationAi/StationAiBodySystem.cs
  • Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs
  • Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs
  • Content.Shared/Silicons/StationAi/SharedStationAiSystem.Airlock.cs
  • Content.Shared/Silicons/StationAi/SharedStationAiSystem.Customization.cs
  • Content.Shared/Silicons/StationAi/SharedStationAiSystem.Held.cs
  • Content.Shared/Silicons/StationAi/SharedStationAiSystem.cs
  • Content.Shared/Silicons/StationAi/StationAiCustomizationComponent.cs
  • Content.Shared/_Sunrise/Silicons/Borgs/SharedBorgSwitchableTypeSystem.Sunrise.cs
  • Content.Shared/_Sunrise/Silicons/StationAi/SharedStationAiSystem.Body.cs
  • Content.Shared/_Sunrise/Silicons/StationAi/StationAiBodyComponent.cs
  • Content.Shared/_Sunrise/Silicons/StationAi/StationAiBodyControllerComponent.cs
  • Content.Shared/_Sunrise/Silicons/StationAi/StationAiBodyEvents.cs
  • Content.Shared/_Sunrise/Silicons/StationAi/StationAiBodyUi.cs
  • Resources/Locale/en-US/_prototypes/_sunrise/actions/borg_actions.ftl
  • Resources/Locale/en-US/_prototypes/_sunrise/actions/station_ai.ftl
  • Resources/Locale/en-US/_prototypes/_sunrise/entities/objects/specific/robotics/borg_brains.ftl
  • Resources/Locale/en-US/_strings/_sunrise/borg-gender.ftl
  • Resources/Locale/en-US/_strings/_sunrise/silicons/station-ai.ftl
  • Resources/Locale/ru-RU/_prototypes/_sunrise/actions/borg_actions.ftl
  • Resources/Locale/ru-RU/_prototypes/_sunrise/actions/station_ai.ftl
  • Resources/Locale/ru-RU/_prototypes/_sunrise/entities/objects/specific/robotics/borg_brains.ftl
  • Resources/Locale/ru-RU/_strings/_sunrise/borg-gender.ftl
  • Resources/Locale/ru-RU/_strings/_sunrise/silicons/station-ai.ftl
  • Resources/Prototypes/Entities/Mobs/Player/silicon.yml
  • Resources/Prototypes/_Sunrise/Actions/station_ai.yml
  • Resources/Prototypes/_Sunrise/AppearanceCustomization/station_ai_body.yml
  • Resources/Prototypes/_Sunrise/Entities/Objects/Specific/Robotics/station_ai_boards.yml
  • Resources/Prototypes/_Sunrise/Recipes/Lathes/Packs/robotics.yml
  • Resources/Prototypes/_Sunrise/Recipes/Lathes/robotic.yml
  • Resources/Prototypes/_Sunrise/tags.yml
  • Resources/Textures/_Sunrise/Mobs/Silicon/station_ai_body.rsi/meta.json
  • Resources/Textures/_Sunrise/Objects/Specific/Robotics/station_ai_communication_board.rsi/meta.json

Comment thread Content.Server/Silicons/StationAi/StationAiSystem.cs
Comment thread Content.Shared/Silicons/Borgs/SharedBorgSwitchableTypeSystem.cs
@ThereDrD0 ThereDrD0 marked this pull request as draft June 15, 2026 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: НЕ РАЗОБРАНО

Development

Successfully merging this pull request may close these issues.

1 participant