Artifact container (#7822)
Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
@@ -28,5 +28,12 @@ public sealed class ArtifactComponent : Component
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public double CooldownTime = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Is this artifact under some suppression device?
|
||||
/// If true, will ignore all trigger activations attempts.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool IsSuppressed;
|
||||
|
||||
public TimeSpan LastActivationTime;
|
||||
}
|
||||
|
||||
@@ -49,6 +49,10 @@ public sealed class ArtifactSystem : EntitySystem
|
||||
if (!Resolve(uid, ref component))
|
||||
return false;
|
||||
|
||||
// check if artifact is under suppression field
|
||||
if (component.IsSuppressed)
|
||||
return false;
|
||||
|
||||
// check if artifact isn't under cooldown
|
||||
var timeDif = _gameTiming.CurTime - component.LastActivationTime;
|
||||
if (timeDif.TotalSeconds < component.CooldownTime)
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Equipment.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Suppress artifact activation, when entity is placed inside this container.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class SuppressArtifactContainerComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Content.Server.Xenoarchaeology.XenoArtifacts.Equipment.Components;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Server.Xenoarchaeology.XenoArtifacts.Equipment.Systems;
|
||||
|
||||
public sealed class SuppressArtifactContainerSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<SuppressArtifactContainerComponent, EntInsertedIntoContainerMessage>(OnInserted);
|
||||
SubscribeLocalEvent<SuppressArtifactContainerComponent, EntRemovedFromContainerMessage>(OnRemoved);
|
||||
}
|
||||
|
||||
private void OnInserted(EntityUid uid, SuppressArtifactContainerComponent component, EntInsertedIntoContainerMessage args)
|
||||
{
|
||||
if (!TryComp(args.Entity, out ArtifactComponent? artifact))
|
||||
return;
|
||||
|
||||
artifact.IsSuppressed = true;
|
||||
}
|
||||
|
||||
private void OnRemoved(EntityUid uid, SuppressArtifactContainerComponent component, EntRemovedFromContainerMessage args)
|
||||
{
|
||||
if (!TryComp(args.Entity, out ArtifactComponent? artifact))
|
||||
return;
|
||||
|
||||
artifact.IsSuppressed = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user