Literally Murder IExamine (#7352)
This commit is contained in:
@@ -1,21 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Stacks;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Construction.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
#pragma warning disable 618
|
||||
public sealed class MachineBoardComponent : Component, IExamine
|
||||
#pragma warning restore 618
|
||||
public sealed class MachineBoardComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
@@ -50,42 +39,6 @@ namespace Content.Server.Construction.Components
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Examine(FormattedMessage message, bool inDetailsRange)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("machine-board-component-on-examine-label") + "\n");
|
||||
foreach (var (part, amount) in Requirements)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", amount),
|
||||
("requiredElement", Loc.GetString(part.ToString())))
|
||||
+ "\n");
|
||||
}
|
||||
|
||||
foreach (var (material, amount) in MaterialRequirements)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", amount),
|
||||
("requiredElement", Loc.GetString(material.Name)))
|
||||
+ "\n");
|
||||
}
|
||||
|
||||
foreach (var (_, info) in ComponentRequirements)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", info.Amount),
|
||||
("requiredElement", Loc.GetString(info.ExamineName)))
|
||||
+ "\n");
|
||||
}
|
||||
|
||||
foreach (var (_, info) in TagRequirements)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", info.Amount),
|
||||
("requiredElement", Loc.GetString(info.ExamineName)))
|
||||
+ "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
|
||||
@@ -1,17 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Examine;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Construction.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
#pragma warning disable 618
|
||||
public sealed class MachinePartComponent : Component, IExamine
|
||||
#pragma warning restore 618
|
||||
public sealed class MachinePartComponent : Component
|
||||
{
|
||||
// I'm so sorry for hard-coding this. But trust me, it should make things less painful.
|
||||
public static IReadOnlyDictionary<MachinePart, string> Prototypes { get; } = new Dictionary<MachinePart, string>()
|
||||
@@ -34,11 +24,5 @@ namespace Content.Server.Construction.Components
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("rating")]
|
||||
public int Rating { get; private set; } = 1;
|
||||
|
||||
public void Examine(FormattedMessage message, bool inDetailsRange)
|
||||
{
|
||||
message.AddMarkup(Loc.GetString("machine-part-component-on-examine-rating-text", ("rating", Rating)) + "\n");
|
||||
message.AddMarkup(Loc.GetString("machine-part-component-on-examine-type-text", ("type", PartType)) + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
60
Content.Server/Construction/MachinePartSystem.cs
Normal file
60
Content.Server/Construction/MachinePartSystem.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Shared.Examine;
|
||||
|
||||
namespace Content.Server.Construction
|
||||
{
|
||||
/// <summary>
|
||||
/// Deals with machine parts and machine boards.
|
||||
/// </summary>
|
||||
public sealed class MachinePartSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MachineBoardComponent, ExaminedEvent>(OnMachineBoardExamined);
|
||||
SubscribeLocalEvent<MachinePartComponent, ExaminedEvent>(OnMachinePartExamined);
|
||||
}
|
||||
|
||||
private void OnMachineBoardExamined(EntityUid uid, MachineBoardComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (!args.IsInDetailsRange)
|
||||
return;
|
||||
args.PushMarkup(Loc.GetString("machine-board-component-on-examine-label"));
|
||||
foreach (var (part, amount) in component.Requirements)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", amount),
|
||||
("requiredElement", Loc.GetString(part.ToString()))));
|
||||
}
|
||||
|
||||
foreach (var (material, amount) in component.MaterialRequirements)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", amount),
|
||||
("requiredElement", Loc.GetString(material.Name))));
|
||||
}
|
||||
|
||||
foreach (var (_, info) in component.ComponentRequirements)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", info.Amount),
|
||||
("requiredElement", Loc.GetString(info.ExamineName))));
|
||||
}
|
||||
|
||||
foreach (var (_, info) in component.TagRequirements)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("machine-board-component-required-element-entry-text",
|
||||
("amount", info.Amount),
|
||||
("requiredElement", Loc.GetString(info.ExamineName))));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMachinePartExamined(EntityUid uid, MachinePartComponent component, ExaminedEvent args)
|
||||
{
|
||||
if (!args.IsInDetailsRange)
|
||||
return;
|
||||
args.PushMarkup(Loc.GetString("machine-part-component-on-examine-rating-text", ("rating", component.Rating)));
|
||||
args.PushMarkup(Loc.GetString("machine-part-component-on-examine-type-text", ("type", component.PartType)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user