xenoarch inhands + a few effects (#12655)

This commit is contained in:
Nemanja
2022-11-17 18:10:45 -05:00
committed by GitHub
parent 786a4d461c
commit 257a9db5c1
33 changed files with 229 additions and 2 deletions

View File

@@ -0,0 +1,17 @@
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
/// <summary>
/// Artifact that ignites surrounding entities when triggered.
/// </summary>
[RegisterComponent]
public sealed class IgniteArtifactComponent : Component
{
[DataField("range")]
public float Range = 2f;
[DataField("minFireStack")]
public int MinFireStack = 2;
[DataField("maxFireStack")]
public int MaxFireStack = 5;
}

View File

@@ -0,0 +1,7 @@
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
[RegisterComponent]
public sealed class RandomInstrumentArtifactComponent : Component
{
}

View File

@@ -0,0 +1,43 @@
using System.Linq;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Robust.Shared.Random;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
public sealed class IgniteArtifactSystem : EntitySystem
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly FlammableSystem _flammable = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<IgniteArtifactComponent, ArtifactActivatedEvent>(OnActivate);
}
private void OnActivate(EntityUid uid, IgniteArtifactComponent component, ArtifactActivatedEvent args)
{
var flammable = GetEntityQuery<FlammableComponent>();
var targets = new HashSet<EntityUid>();
if (args.Activator != null)
{
targets.Add(args.Activator.Value);
}
else
{
targets = _lookup.GetEntitiesInRange(uid, component.Range);
}
foreach (var target in targets)
{
if (!flammable.TryGetComponent(target, out var fl))
continue;
fl.FireStacks += _random.Next(component.MinFireStack, component.MaxFireStack);
_flammable.Ignite(target, fl);
}
}
}

View File

@@ -0,0 +1,25 @@
using Content.Server.Instruments;
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Shared.Instruments;
using Robust.Shared.Random;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
public sealed class RandomInstrumentArtifactSystem : EntitySystem
{
[Dependency] private readonly InstrumentSystem _instrument = default!;
[Dependency] private readonly IRobustRandom _random = default!;
/// <inheritdoc/>
public override void Initialize()
{
SubscribeLocalEvent<RandomInstrumentArtifactComponent, ComponentStartup>(OnStartup);
}
private void OnStartup(EntityUid uid, RandomInstrumentArtifactComponent component, ComponentStartup args)
{
if (!TryComp<SharedInstrumentComponent>(uid, out var instrument))
return;
_instrument.SetInstrumentProgram(instrument, (byte) _random.Next(0, 127), 0);
}
}

View File

@@ -1,4 +1,5 @@
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Shared.Item;
using Content.Shared.Xenoarchaeology.XenoArtifacts;
using Robust.Server.GameObjects;
using Robust.Shared.Random;
@@ -11,6 +12,7 @@ public sealed class RandomArtifactSpriteSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IGameTiming _time = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly SharedItemSystem _item = default!;
public override void Initialize()
{
@@ -41,6 +43,7 @@ public sealed class RandomArtifactSpriteSystem : EntitySystem
{
var randomSprite = _random.Next(component.MinSprite, component.MaxSprite + 1);
_appearance.SetData(uid, SharedArtifactsVisuals.SpriteIndex, randomSprite);
_item.SetHeldPrefix(uid, "ano" + randomSprite.ToString("D2")); //set item artifact inhands
}
private void OnActivated(EntityUid uid, RandomArtifactSpriteComponent component, ArtifactActivatedEvent args)