Xenoarch Tweaks (#12429)

* Xenoarch feedback

print out reports, weight node traversal, dialog for destroy menu, slight effect tweaks

* make the popup not bad

* the popup, jimbo...
This commit is contained in:
Nemanja
2022-11-07 16:57:29 -05:00
committed by GitHub
parent 387d1163b4
commit 8ba3d127cc
13 changed files with 199 additions and 11 deletions

View File

@@ -1,6 +1,8 @@
using Content.Shared.MachineLinking;
using Robust.Shared.Audio;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
namespace Content.Server.Xenoarchaeology.Equipment.Components;
@@ -28,4 +30,10 @@ public sealed class AnalysisConsoleComponent : Component
/// </summary>
[DataField("destroySound")]
public SoundSpecifier DestroySound = new SoundPathSpecifier("/Audio/Effects/radpulse11.ogg");
/// <summary>
/// The entity spawned by a report.
/// </summary>
[DataField("reportEntityId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string ReportEntityId = "Paper";
}

View File

@@ -51,6 +51,9 @@ public sealed class ArtifactAnalyzerComponent : Component
[ViewVariables]
public HashSet<EntityUid> Contacts = new();
[ViewVariables(VVAccess.ReadWrite)]
public bool ReadyToPrint = false;
[DataField("scanFinishedSound")]
public readonly SoundSpecifier ScanFinishedSound = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg");

View File

@@ -1,6 +1,7 @@
using System.Linq;
using Content.Server.Construction;
using Content.Server.MachineLinking.Events;
using Content.Server.Paper;
using Content.Server.Power.Components;
using Content.Server.Research;
using Content.Server.Research.Components;
@@ -35,6 +36,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly ArtifactSystem _artifact = default!;
[Dependency] private readonly PaperSystem _paper = default!;
/// <inheritdoc/>
public override void Initialize()
@@ -56,6 +58,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
SubscribeLocalEvent<AnalysisConsoleComponent, AnalysisConsoleServerSelectionMessage>(OnServerSelectionMessage);
SubscribeLocalEvent<AnalysisConsoleComponent, AnalysisConsoleScanButtonPressedMessage>(OnScanButton);
SubscribeLocalEvent<AnalysisConsoleComponent, AnalysisConsolePrintButtonPressedMessage>(OnPrintButton);
SubscribeLocalEvent<AnalysisConsoleComponent, AnalysisConsoleDestroyButtonPressedMessage>(OnDestroyButton);
SubscribeLocalEvent<AnalysisConsoleComponent, ResearchClientServerSelectedMessage>((e,c,_) => UpdateUserInterface(e,c),
@@ -93,6 +96,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
return;
component.LastAnalyzedArtifact = null;
component.ReadyToPrint = false;
UpdateAnalyzerInformation(uid, component);
}
@@ -177,6 +181,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
float? completion = null;
var totalTime = TimeSpan.Zero;
var canScan = false;
var canPrint = false;
if (component.AnalyzerEntity != null && TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity, out var analyzer))
{
artifact = analyzer.LastAnalyzedArtifact;
@@ -184,6 +189,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
completion = analyzer.LastAnalyzedCompletion;
totalTime = analyzer.AnalysisDuration * analyzer.AnalysisDurationMulitplier;
canScan = analyzer.Contacts.Any();
canPrint = analyzer.ReadyToPrint;
}
var analyzerConnected = component.AnalyzerEntity != null;
@@ -192,7 +198,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
var scanning = TryComp<ActiveArtifactAnalyzerComponent>(component.AnalyzerEntity, out var active);
var remaining = active != null ? _timing.CurTime - active.StartTime : TimeSpan.Zero;
var state = new AnalysisConsoleScanUpdateState(artifact, analyzerConnected, serverConnected, canScan,
var state = new AnalysisConsoleScanUpdateState(artifact, analyzerConnected, serverConnected, canScan, canPrint,
node?.Id, node?.Depth, node?.Edges.Count, node?.Triggered, node?.Effect.ID, node?.Trigger.ID, completion,
scanning, remaining, totalTime);
@@ -237,6 +243,68 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
activeArtifact.Scanner = component.AnalyzerEntity.Value;
}
private void OnPrintButton(EntityUid uid, AnalysisConsoleComponent component, AnalysisConsolePrintButtonPressedMessage args)
{
if (component.AnalyzerEntity == null)
return;
if (!TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity, out var analyzer) ||
analyzer.LastAnalyzedNode == null ||
analyzer.LastAnalyzedCompletion == null ||
!analyzer.ReadyToPrint)
{
return;
}
analyzer.ReadyToPrint = false;
var n = analyzer.LastAnalyzedNode;
var report = Spawn(component.ReportEntityId, Transform(uid).Coordinates);
MetaData(report).EntityName = Loc.GetString("analysis-report-title", ("id", n.Id));
var msg = new FormattedMessage();
msg.AddMarkup(Loc.GetString("analysis-console-info-id", ("id", n.Id)));
msg.PushNewline();
msg.AddMarkup(Loc.GetString("analysis-console-info-depth", ("depth", n.Depth)));
msg.PushNewline();
var activated = n.Triggered
? "analysis-console-info-triggered-true"
: "analysis-console-info-triggered-false";
msg.AddMarkup(Loc.GetString(activated));
msg.PushNewline();
msg.PushNewline();
var needSecondNewline = false;
if (n.Trigger.TriggerHint != null)
{
msg.AddMarkup(Loc.GetString("analysis-console-info-trigger",
("trigger", Loc.GetString(n.Trigger.TriggerHint))) + "\n");
needSecondNewline = true;
}
if (n.Effect.EffectHint != null)
{
msg.AddMarkup(Loc.GetString("analysis-console-info-effect",
("effect", Loc.GetString(n.Effect.EffectHint))) + "\n");
needSecondNewline = true;
}
if (needSecondNewline)
msg.PushNewline();
msg.AddMarkup(Loc.GetString("analysis-console-info-edges", ("edges", n.Edges.Count)));
msg.PushNewline();
msg.AddMarkup(Loc.GetString("analysis-console-info-completion",
("percentage", Math.Round(analyzer.LastAnalyzedCompletion.Value * 100))));
_popup.PopupEntity(Loc.GetString("analysis-console-print-popup"), uid, Filter.Pvs(uid));
_paper.SetContent(report, msg.ToMarkup());
UpdateUserInterface(uid, component);
}
/// <summary>
/// destroys the artifact and updates the server points
/// </summary>
@@ -333,6 +401,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
if (!Resolve(uid, ref component, ref active))
return;
component.ReadyToPrint = true;
_audio.PlayPvs(component.ScanFinishedSound, uid);
component.LastAnalyzedArtifact = active.Artifact;
UpdateAnalyzerInformation(uid, component);

View File

@@ -158,7 +158,13 @@ public sealed partial class ArtifactSystem : EntitySystem
component.CurrentNode.Triggered = true;
if (component.CurrentNode.Edges.Any())
{
var undiscoveredNodes = component.CurrentNode.Edges.Where(x => !x.Discovered).ToList();
var newNode = _random.Pick(component.CurrentNode.Edges);
if (undiscoveredNodes.Any() && _random.Prob(0.75f))
{
newNode = _random.Pick(undiscoveredNodes);
}
EnterNode(uid, ref newNode, component);
}
}