More artifact effects (#13300)

This commit is contained in:
Kara
2023-01-03 17:13:10 -06:00
committed by GitHub
parent bd9d744682
commit b170b823eb
12 changed files with 168 additions and 4 deletions

View File

@@ -0,0 +1,55 @@
using Content.Server.Actions;
using Content.Server.Popups;
using Content.Shared.Actions;
using Content.Shared.Actions.ActionTypes;
using Content.Shared.Xenoarchaeology.XenoArtifacts;
using Robust.Shared.Prototypes;
namespace Content.Server.Xenoarchaeology.XenoArtifacts;
public partial class ArtifactSystem
{
[Dependency] private readonly ActionsSystem _actions = default!;
[Dependency] private readonly PopupSystem _popup = default!;
/// <summary>
/// Used to add the artifact activation action (hehe), which lets sentient artifacts activate themselves,
/// either through admemery or the sentience effect.
/// </summary>
public void InitializeActions()
{
SubscribeLocalEvent<ArtifactComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<ArtifactComponent, ComponentRemove>(OnRemove);
SubscribeLocalEvent<ArtifactComponent, ArtifactSelfActivateEvent>(OnSelfActivate);
}
private void OnStartup(EntityUid uid, ArtifactComponent component, ComponentStartup args)
{
if (_prototype.TryIndex<InstantActionPrototype>("ArtifactActivate", out var proto))
{
_actions.AddAction(uid, new InstantAction(proto), null);
}
}
private void OnRemove(EntityUid uid, ArtifactComponent component, ComponentRemove args)
{
if (_prototype.TryIndex<InstantActionPrototype>("ArtifactActivate", out var proto))
{
_actions.RemoveAction(uid, new InstantAction(proto));
}
}
private void OnSelfActivate(EntityUid uid, ArtifactComponent component, ArtifactSelfActivateEvent args)
{
if (component.CurrentNode == null)
return;
var curNode = component.CurrentNode.Id;
_popup.PopupEntity(Loc.GetString("activate-artifact-popup-self", ("node", curNode)), uid, uid);
TryActivateArtifact(uid, uid, component);
args.Handled = true;
}
}

View File

@@ -29,6 +29,7 @@ public sealed partial class ArtifactSystem : EntitySystem
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEnd);
InitializeCommands();
InitializeActions();
}
private void OnInit(EntityUid uid, ArtifactComponent component, MapInitEvent args)

View File

@@ -0,0 +1,10 @@
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
/// <summary>
/// Removes the masks/layers of hard fixtures from the artifact when added, allowing it to pass through walls
/// and such.
/// </summary>
[RegisterComponent]
public sealed class ClearFixturesArtifactComponent : Component
{
}

View File

@@ -0,0 +1,36 @@
using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Shared.Physics;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Dynamics;
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems;
/// <summary>
/// Handles allowing activated artifacts to phase through walls.
/// </summary>
public sealed class ClearFixturesArtifactSystem : EntitySystem
{
/// <inheritdoc/>
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ClearFixturesArtifactComponent, ArtifactActivatedEvent>(OnActivate);
}
private void OnActivate(EntityUid uid, ClearFixturesArtifactComponent component, ArtifactActivatedEvent args)
{
if (!TryComp<FixturesComponent>(uid, out var fixtures))
return;
foreach (var (_, fixture) in fixtures.Fixtures)
{
if (!fixture.Hard)
continue;
fixture.CollisionLayer = (int) CollisionGroup.None;
fixture.CollisionMask = (int) CollisionGroup.None;
}
}
}