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

@@ -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);