Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions Content.Client/Silicons/Borgs/BorgSelectTypeMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ public sealed partial class BorgSelectTypeMenu : FancyWindow

private BorgTypePrototype? _selectedBorgType;

public event Action<ProtoId<BorgTypePrototype>>? ConfirmedBorgType;
public event Action<ProtoId<BorgSubtypePrototype>>? ConfirmedBorgSubtype;
public event Action<BorgTypePrototype, BorgSubtypePrototype?>? ConfirmedBorgType; // ADT-Tweak: тип и подтип одним событием

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ты все ещё кардинально меняешь систему. Мне это не нравится, я думаю можно сделать нормальный багфикс.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ну почему нету никаких уточнений как по другому, что можно сделать? Если тебя не устраивает предлагай.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Посмотри есть ли этот баг у оффов. Если нет, то значит у них это исправлено. Если не исправлено, то значит баг в ADT коде.
Каким образом при рассинхроне могло потеряться одно сообщение, но при этом остаться другое? Это бред, если такое случается, то раз в миллион случаев, а баг постоянный.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Проверил официальный репозиторий (space-wizards/space-station-14) через GitHub API. Факты:

  1. У оффов вообще нет системы скинов боргов: поиск по BorgSubtype дал 0 результатов. BorgSwitchableSubtypeComponent, BorgSelectSubtypeMessage, BorgSubtypePrototype - целиком ADT-фича. Баг "двух сообщений" у оффов невозможен в принципе.

  2. У оффов выбор шасси атомарный: одно сообщение BorgSelectTypeMessage -> один обработчик -> SelectBorgModule (модули + внешний вид) -> CloseUi тут же. В нашем форке CloseUi в ванильном SelectBorgModule закомментирован ADT-правкой, а закрытие UI переехало в обработчик второго сообщения BorgSelectSubtypeMessage. Атомарность разорвана на два независимых шага - в этом первопричина постоянного бага, а не в "рассинхроне" (ты прав, это бред).

  3. ERROR-спрайт после перезахода: ванильный клиентский BorgSystem.UpdateBorgAppearance безусловно ставит стейт слоя Light из ванильного шасси (HasMindState/NoMindState), которого нет в RSI скина. У оффов этого бага нет, потому что скинов нет.

Вывод: баг целиком в ADT-слое. Текущий фикс (тип и подтип одним сообщением) по сути восстанавливает оффовскую атомарность выбора - это багфикс, а не редизайн системы.


private static readonly List<ProtoId<GuideEntryPrototype>> GuidebookEntries = new() { "Cyborgs", "Robotics" };

Expand Down Expand Up @@ -80,14 +79,8 @@ private void ConfirmButtonPressed(BaseButton.ButtonEventArgs obj)
if (_selectedBorgType == null)
return;

ConfirmedBorgType?.Invoke(_selectedBorgType);

//Start ADT Tweak
if (ChassisSpriteSelection.SelectedBorgSubtype == null)
return;

ConfirmedBorgSubtype?.Invoke(ChassisSpriteSelection.SelectedBorgSubtype);
//End ADT Tweak
// ADT-Tweak: тип и подтип одним событием
ConfirmedBorgType?.Invoke(_selectedBorgType, ChassisSpriteSelection.SelectedBorgSubtype);
}

private static string PrototypeName(BorgTypePrototype prototype)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ protected override void Open()
base.Open();

_menu = this.CreateWindow<BorgSelectTypeMenu>();
_menu.ConfirmedBorgType += prototype => SendMessage(new BorgSelectTypeMessage(prototype));
_menu.ConfirmedBorgSubtype += subtype => SendMessage(new BorgSelectSubtypeMessage(subtype)); // ADT-Borg-Subtype
// ADT-Tweak: тип и подтип одним сообщением
_menu.ConfirmedBorgType += (prototype, subtype) => SendMessage(
new BorgSelectTypeMessage(prototype, subtype?.ID));
}
}
7 changes: 5 additions & 2 deletions Content.Client/Silicons/Borgs/BorgSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Alert;
using Content.Shared.ADT.Silicons.Borgs.Components;
using Content.Shared.Alert;
using Content.Shared.Mobs;
using Content.Shared.Power.EntitySystems;
using Content.Shared.PowerCell;
Expand Down Expand Up @@ -90,7 +91,9 @@ private void UpdateBorgAppearance(Entity<BorgChassisComponent?, AppearanceCompon
hasPlayer = false;

_sprite.LayerSetVisible((ent.Owner, ent.Comp3), BorgVisualLayers.Light, ent.Comp1.BrainEntity != null || hasPlayer);
_sprite.LayerSetRsiState((ent.Owner, ent.Comp3), BorgVisualLayers.Light, hasPlayer ? ent.Comp1.HasMindState : ent.Comp1.NoMindState);
// ADT-Tweak: стейт Light у борга с подтипом ставит ADT-система (в RSI подтипа нет robot_e)
if (!TryComp<BorgSwitchableSubtypeComponent>(ent.Owner, out var subtype) || subtype.BorgSubtype == null)
_sprite.LayerSetRsiState((ent.Owner, ent.Comp3), BorgVisualLayers.Light, hasPlayer ? ent.Comp1.HasMindState : ent.Comp1.NoMindState);
}

private void OnMMIAppearanceChanged(EntityUid uid, MMIComponent component, ref AppearanceChangeEvent args)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
using Content.Shared.ADT.Silicons.Borgs;
using Content.Shared.ADT.Silicons.Borgs.Components;
using Content.Shared.Silicons.Borgs;
using Content.Shared.Silicons.Borgs.Components;

namespace Content.Server.ADT.Silicons.Borgs;

public sealed class BorgSwitchableSubtypeSystem : SharedBorgSwitchableSubtypeSystem
{
[Dependency] private readonly SharedUserInterfaceSystem _userInterface = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<BorgSwitchableSubtypeComponent, BorgSelectSubtypeMessage>(OnSubtypeSelected);
SubscribeLocalEvent<BorgSwitchableSubtypeComponent, BorgSelectTypeMessage>(OnTypeSelected);
}

private void OnSubtypeSelected(Entity<BorgSwitchableSubtypeComponent> ent, ref BorgSelectSubtypeMessage args)
// ADT-Tweak: подтип выбирается тем же сообщением, что и тип, чтобы модули и скин применялись вместе
private void OnTypeSelected(Entity<BorgSwitchableSubtypeComponent> ent, ref BorgSelectTypeMessage args)
{
ent.Comp.BorgSubtype = args.Subtype;
if (args.Subtype is not { } subtype)
return;

// Тип уже выбран и не совпадает - отклоняем сообщение, чтобы не записать чужой подтип
if (TryComp<BorgSwitchableTypeComponent>(ent.Owner, out var typeComp)
&& typeComp.SelectedBorgType is { } selected
&& selected != args.Prototype)
return;

ent.Comp.BorgSubtype = subtype;
Dirty(ent);
UpdateVisuals(ent);
_userInterface.CloseUi((ent.Owner, null), BorgSwitchableTypeUiKey.SelectBorgType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;

namespace Content.Shared.ADT.Silicons.Borgs.Components;

Expand All @@ -11,9 +10,3 @@ public sealed partial class BorgSwitchableSubtypeComponent : Component
[DataField, AutoNetworkedField]
public ProtoId<BorgSubtypePrototype>? BorgSubtype;
}

[Serializable, NetSerializable]
public sealed class BorgSelectSubtypeMessage(ProtoId<BorgSubtypePrototype> subtype) : BoundUserInterfaceMessage
{
public ProtoId<BorgSubtypePrototype> Subtype = subtype;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Shared.Actions;
using Content.Shared.ADT.Silicons.Borgs;
using Content.Shared.Radio;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
Expand Down Expand Up @@ -56,10 +57,12 @@ public sealed partial class BorgToggleSelectTypeEvent : InstantActionEvent;
/// UI message used by a borg to select their type with <see cref="BorgSwitchableTypeComponent"/>.
/// </summary>
/// <param name="prototype">The borg type prototype that the user selected.</param>
// ADT-Tweak: подтип выбирается тем же сообщением
[Serializable, NetSerializable]
public sealed class BorgSelectTypeMessage(ProtoId<BorgTypePrototype> prototype) : BoundUserInterfaceMessage
public sealed class BorgSelectTypeMessage(ProtoId<BorgTypePrototype> prototype, ProtoId<BorgSubtypePrototype>? subtype = null) : BoundUserInterfaceMessage
{
public ProtoId<BorgTypePrototype> Prototype = prototype;
public ProtoId<BorgSubtypePrototype>? Subtype = subtype;
}

/// <summary>
Expand Down
Loading