various xenoarch adjustments (#12677)

* magboots can now activate magnet artifacts

* more shit

* Update artifact_analyzer.yml

* Update item_artifacts.yml
This commit is contained in:
Nemanja
2022-11-20 01:52:32 -05:00
committed by GitHub
parent e21fc05a06
commit 619fdc7241
9 changed files with 95 additions and 142 deletions

View File

@@ -172,30 +172,26 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
return;
EntityUid? artifact = null;
ArtifactNode? node = null;
int? pointValue = null;
FormattedMessage? msg = 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;
node = analyzer.LastAnalyzedNode;
pointValue = analyzer.LastAnalyzerPointValue;
msg = GetArtifactScanMessage(analyzer);
totalTime = analyzer.AnalysisDuration * analyzer.AnalysisDurationMulitplier;
canScan = analyzer.Contacts.Any();
canPrint = analyzer.ReadyToPrint;
}
var analyzerConnected = component.AnalyzerEntity != null;
var serverConnected = TryComp<ResearchClientComponent>(uid, out var client) && client.ConnectedToServer;
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, canPrint,
node?.Id, node?.Depth, node?.Edges.Count, node?.Triggered, node?.Effect.ID, node?.Trigger.ID, pointValue,
scanning, remaining, totalTime);
var state = new AnalysisConsoleScanUpdateState(artifact, analyzerConnected, serverConnected,
canScan, canPrint, msg, scanning, remaining, totalTime);
var bui = _ui.GetUi(uid, ArtifactAnalzyerUiKey.Key);
_ui.SetUiState(bui, state);
@@ -250,14 +246,27 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
{
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));
MetaData(report).EntityName = Loc.GetString("analysis-report-title", ("id", analyzer.LastAnalyzedNode.Id));
var msg = GetArtifactScanMessage(analyzer);
if (msg == null)
return;
_popup.PopupEntity(Loc.GetString("analysis-console-print-popup"), uid, Filter.Pvs(uid));
_paper.SetContent(report, msg.ToMarkup());
UpdateUserInterface(uid, component);
}
private FormattedMessage? GetArtifactScanMessage(ArtifactAnalyzerComponent component)
{
var msg = new FormattedMessage();
if (component.LastAnalyzedNode == null)
return null;
var n = component.LastAnalyzedNode;
msg.AddMarkup(Loc.GetString("analysis-console-info-id", ("id", n.Id)));
msg.PushNewline();
@@ -292,11 +301,10 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
msg.AddMarkup(Loc.GetString("analysis-console-info-edges", ("edges", n.Edges.Count)));
msg.PushNewline();
msg.AddMarkup(Loc.GetString("analysis-console-info-value", ("value", analyzer.LastAnalyzerPointValue)));
if (component.LastAnalyzerPointValue != null)
msg.AddMarkup(Loc.GetString("analysis-console-info-value", ("value", component.LastAnalyzerPointValue)));
_popup.PopupEntity(Loc.GetString("analysis-console-print-popup"), uid, Filter.Pvs(uid));
_paper.SetContent(report, msg.ToMarkup());
UpdateUserInterface(uid, component);
return msg;
}
/// <summary>

View File

@@ -1,6 +1,5 @@
using System.Linq;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Shared.Item;
using Content.Shared.Xenoarchaeology.XenoArtifacts;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
@@ -14,7 +13,7 @@ public sealed partial class ArtifactSystem
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly ISerializationManager _serialization = default!;
private const int MaxEdgesPerNode = 3;
private const int MaxEdgesPerNode = 4;
/// <summary>
/// Generate an Artifact tree with fully developed nodes.
@@ -162,16 +161,15 @@ public sealed partial class ArtifactSystem
}
component.CurrentNode = node;
node.Discovered = true;
var allComponents = node.Effect.Components.Concat(node.Effect.PermanentComponents).Concat(node.Trigger.Components);
foreach (var (name, entry) in allComponents)
{
var reg = _componentFactory.GetRegistration(name);
if (EntityManager.HasComponent(uid, reg.Type))
if (node.Discovered && EntityManager.HasComponent(uid, reg.Type))
{
// Don't re-add permanent components
// Don't re-add permanent components unless this is the first time you've entered this node
if (node.Effect.PermanentComponents.ContainsKey(name))
continue;
@@ -187,6 +185,7 @@ public sealed partial class ArtifactSystem
EntityManager.AddComponent(uid, (Component) temp!, true);
}
node.Discovered = true;
RaiseLocalEvent(uid, new ArtifactNodeEnteredEvent(component.CurrentNode.Id));
}

View File

@@ -11,4 +11,11 @@ public sealed class ArtifactMagnetTriggerComponent : Component
/// </summary>
[DataField("range")]
public float Range = 40f;
/// <summary>
/// How close do active magboots have to be?
/// This is smaller because they are weaker magnets
/// </summary>
[DataField("magbootRange")]
public float MagbootRange = 2f;
}

View File

@@ -1,5 +1,7 @@
using Content.Server.Salvage;
using System.Linq;
using Content.Server.Salvage;
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
using Content.Shared.Clothing;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems;
@@ -16,6 +18,42 @@ public sealed class ArtifactMagnetTriggerSystem : EntitySystem
SubscribeLocalEvent<SalvageMagnetActivatedEvent>(OnMagnetActivated);
}
public override void Update(float frameTime)
{
base.Update(frameTime);
var artifactQuery = EntityQuery<ArtifactMagnetTriggerComponent, TransformComponent>().ToHashSet();
if (!artifactQuery.Any())
return;
List<EntityUid> toActivate = new();
//assume that there's more instruments than artifacts
foreach (var magboot in EntityQuery<MagbootsComponent>())
{
if (!magboot.On)
continue;
var magXform = Transform(magboot.Owner);
foreach (var (trigger, xform) in artifactQuery)
{
if (!magXform.Coordinates.TryDistance(EntityManager, xform.Coordinates, out var distance))
continue;
if (distance > trigger.Range)
continue;
toActivate.Add(trigger.Owner);
}
}
foreach (var a in toActivate)
{
_artifact.TryActivateArtifact(a);
}
}
private void OnMagnetActivated(SalvageMagnetActivatedEvent ev)
{
var magXform = Transform(ev.Magnet);