Artifact container (#7822)

Co-authored-by: Kara <lunarautomaton6@gmail.com>
This commit is contained in:
Alex Evgrashin
2022-04-29 01:03:39 +03:00
committed by GitHub
parent 6dbc37a690
commit 2d34ded94d
20 changed files with 226 additions and 42 deletions

View File

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

View File

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

View File

@@ -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
{
}

View File

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