More xeno artifacts effects (#6282)

This commit is contained in:
Alex Evgrashin
2022-02-07 05:26:10 +03:00
committed by GitHub
parent be7a770b78
commit 617f92df65
15 changed files with 299 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Atmos.EntitySystems;
using Content.Server.Xenoarchaeology.XenoArtifacts.Events;
using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
@@ -15,7 +16,16 @@ public class ArtifactGasTriggerSystem : EntitySystem
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<ArtifactGasTriggerComponent, ComponentInit>(OnInit);
SubscribeLocalEvent<ArtifactGasTriggerComponent, RandomizeTriggerEvent>(OnRandomizeTrigger);
}
private void OnRandomizeTrigger(EntityUid uid, ArtifactGasTriggerComponent component, RandomizeTriggerEvent args)
{
if (component.ActivationGas == null)
{
var gas = _random.Pick(component.PossibleGases);
component.ActivationGas = gas;
}
}
public override void Update(float frameTime)
@@ -25,27 +35,18 @@ public class ArtifactGasTriggerSystem : EntitySystem
foreach (var (trigger, transform) in query)
{
if (trigger.ActivationGas == null)
return;
continue;
var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates, true);
if (environment == null)
return;
continue;
// check if outside there is enough moles to activate artifact
var moles = environment.GetMoles(trigger.ActivationGas.Value);
if (moles < trigger.ActivationMoles)
return;
continue;
_artifactSystem.TryActivateArtifact(trigger.Owner);
}
}
private void OnInit(EntityUid uid, ArtifactGasTriggerComponent component, ComponentInit args)
{
if (component.ActivationGas == null)
{
var gas = _random.Pick(component.PossibleGases);
component.ActivationGas = gas;
}
}
}