Files
wwdpublic/Content.Shared/_Arcadis/Computer/DiskBurnerSystem.cs
Eris 9b433faddc Hotfix for Disk Burner Examine (#1656)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

Had an aneurysm seeing this live on arcadis and webedited a fix. Fixes
an issue on examining a disk burner without a board.

---

# Changelog

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

no

Signed-off-by: Eris <erisfiregamer1@gmail.com>
(cherry picked from commit 8eafa7ab0f7295bdd8350fc9c2954b02e7d50d1b)
2025-01-29 20:19:44 +03:00

118 lines
4.0 KiB
C#

using Content.Shared.Containers.ItemSlots;
using Content.Shared.Coordinates;
using Robust.Shared.Audio;
using Content.Shared.Audio;
using Robust.Shared.Network;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Audio.Systems;
using Content.Shared.Popups;
using Content.Shared.Examine;
using Content.Shared.Interaction;
using Robust.Shared.Timing;
using Content.Shared.Construction.Components;
using Content.Shared.Verbs;
using Robust.Shared.Utility;
namespace Content.Shared._Arcadis.Computer;
public sealed class DiskBurnerSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlots = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DiskBurnerComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<DiskBurnerComponent, GetVerbsEvent<Verb>>(GetVerb);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
}
private void GetVerb(EntityUid uid, DiskBurnerComponent component, GetVerbsEvent<Verb> args)
{
args.Verbs.Add(new Verb
{
Act = () => BurnDisk(args.User, uid, component),
Text = Loc.GetString(component.VerbName),
// TODO VERB ICON find a better icon
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/settings.svg.192dpi.png")),
});
}
private void BurnDisk(EntityUid user, EntityUid entity, DiskBurnerComponent component)
{
if (!TryComp(entity, out ItemSlotsComponent? slots)
|| !_itemSlots.TryGetSlot(entity, component.DiskSlot, out var diskSlot)
|| !_itemSlots.TryGetSlot(entity, component.BoardSlot, out var boardSlot)
|| diskSlot.Item is null
|| boardSlot.Item is null
|| !TryComp(boardSlot.Item.Value, out ComputerBoardComponent? boardComp)
|| boardComp.ModularComputerProgramPrototype is null
|| !TryComp(diskSlot.Item.Value, out ComputerDiskComponent? diskComp))
{
_popupSystem.PopupPredicted(Loc.GetString("disk-burner-activate-not-ready"), entity, user);
return;
}
diskComp.ProgramPrototype = boardComp.ModularComputerProgramPrototype.Value;
_popupSystem.PopupPredicted(Loc.GetString("disk-burner-activate-finished"), entity, user);
}
private void OnExamined(EntityUid uid, DiskBurnerComponent component, ExaminedEvent args)
{
if (!TryComp(uid, out ItemSlotsComponent? slots)
|| !_itemSlots.TryGetSlot(uid, component.DiskSlot, out var diskSlot)
|| !_itemSlots.TryGetSlot(uid, component.BoardSlot, out var boardSlot))
{
args.PushMarkup(Loc.GetString("disk-burner-admemes-fail"));
return;
}
if (diskSlot.Item is null || boardSlot.Item is null)
{
var missing = new List<string>();
if (diskSlot.Item is null)
missing.Add("disk");
if (boardSlot.Item is null)
missing.Add("board");
args.PushMarkup(Loc.GetString("disk-burner-missing", ("missing", string.Join(", or ", missing))));
return;
}
if (!TryComp(diskSlot.Item.Value, out ComputerDiskComponent? diskComp))
{
args.PushMarkup(Loc.GetString("disk-burner-bad-disk"));
return;
}
if (!TryComp(boardSlot.Item.Value, out ComputerBoardComponent? boardComp))
{
args.PushMarkup(Loc.GetString("disk-burner-incompatible-board"));
return;
}
if (boardComp.ModularComputerProgramPrototype is null)
{
args.PushMarkup(Loc.GetString("disk-burner-incompatible-board"));
return;
}
args.PushMarkup(Loc.GetString("disk-burner-ready"));
}
}