diff --git a/Content.Client/Entry/IgnoredComponents.cs b/Content.Client/Entry/IgnoredComponents.cs index 6ce07e6058..8f10608e6f 100644 --- a/Content.Client/Entry/IgnoredComponents.cs +++ b/Content.Client/Entry/IgnoredComponents.cs @@ -306,6 +306,9 @@ namespace Content.Client.Entry "TelepathicArtifact", "ArtifactGasTrigger", "ArtifactInteractionTrigger", + "ArtifactTimerTrigger", + "ArtifactHeatTrigger", + "ArtifactElectricityTrigger", "Artifact", "RandomArtifactSprite", "EnergySword", diff --git a/Content.Server/Administration/AdminVerbSystem.cs b/Content.Server/Administration/AdminVerbSystem.cs index 4e373e4381..4c975847ae 100644 --- a/Content.Server/Administration/AdminVerbSystem.cs +++ b/Content.Server/Administration/AdminVerbSystem.cs @@ -14,6 +14,8 @@ using Content.Server.Inventory; using Content.Server.Mind.Commands; using Content.Server.Mind.Components; using Content.Server.Players; +using Content.Server.Xenoarchaeology.XenoArtifacts; +using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; using Content.Shared.Administration; using Content.Shared.Body.Components; using Content.Shared.Database; @@ -47,6 +49,7 @@ namespace Content.Server.Administration [Dependency] private readonly EuiManager _euiManager = default!; [Dependency] private readonly ExplosionSystem _explosions = default!; [Dependency] private readonly GhostRoleSystem _ghostRoleSystem = default!; + [Dependency] private readonly ArtifactSystem _artifactSystem = default!; private readonly Dictionary _openSolutionUis = new(); @@ -100,6 +103,29 @@ namespace Content.Server.Administration }); } + // XenoArcheology + if (TryComp(args.Target, out var artifact)) + { + // make artifact always active (by adding timer trigger) + args.Verbs.Add(new Verb() + { + Text = Loc.GetString("artifact-verb-make-always-active"), + Category = VerbCategory.Admin, + Act = () => EntityManager.AddComponent(args.Target), + Disabled = EntityManager.HasComponent(args.Target), + Impact = LogImpact.High + }); + + // force to activate artifact ignoring timeout + args.Verbs.Add(new Verb() + { + Text = Loc.GetString("artifact-verb-activate"), + Category = VerbCategory.Admin, + Act = () => _artifactSystem.ForceActivateArtifact(args.Target, component: artifact), + Impact = LogImpact.High + }); + } + // TeleportTo args.Verbs.Add(new Verb { diff --git a/Content.Server/Power/Events/PowerPulseEvent.cs b/Content.Server/Power/Events/PowerPulseEvent.cs new file mode 100644 index 0000000000..23afc52dd1 --- /dev/null +++ b/Content.Server/Power/Events/PowerPulseEvent.cs @@ -0,0 +1,11 @@ +namespace Content.Server.Power.Events; + +/// +/// Invoked on a target entity, when it was pulsed with an energy. +/// For instance, interacted with an active stun baton. +/// +public sealed class PowerPulseEvent : EntityEventArgs +{ + public EntityUid? User; + public EntityUid? Used; +} diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index b7752211ae..24a69b9089 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using Content.Server.Power.Events; using Content.Server.PowerCell; using Content.Server.Speech.EntitySystems; using Content.Server.Stunnable.Components; @@ -56,6 +57,7 @@ namespace Content.Server.Stunnable foreach (EntityUid entity in args.HitEntities) { StunEntity(entity, comp); + SendPowerPulse(entity, args.User, uid); } } @@ -69,6 +71,7 @@ namespace Content.Server.Stunnable args.CanInteract = true; StunEntity(args.Entity, comp); + SendPowerPulse(args.Entity, args.User, uid); } private void OnUseInHand(EntityUid uid, StunbatonComponent comp, UseInHandEvent args) @@ -92,6 +95,7 @@ namespace Content.Server.Stunnable return; StunEntity(args.Target, comp); + SendPowerPulse(args.Target, args.User, uid); } private void OnPowerCellChanged(EntityUid uid, StunbatonComponent comp, PowerCellChangedEvent args) @@ -197,5 +201,14 @@ namespace Content.Server.Stunnable sprite.LayerSetState(0, "stunbaton_on"); comp.Activated = true; } + + private void SendPowerPulse(EntityUid target, EntityUid? user, EntityUid used) + { + RaiseLocalEvent(target, new PowerPulseEvent() + { + Used = used, + User = user + }, false); + } } } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactComponent.cs index 3d6bc321b4..06f1816326 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactComponent.cs @@ -1,8 +1,3 @@ -using System; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; - namespace Content.Server.Xenoarchaeology.XenoArtifacts; [RegisterComponent] @@ -21,7 +16,9 @@ public sealed class ArtifactComponent : Component [DataField("possibleTriggers")] public string[] PossibleTriggers = { "ArtifactInteractionTrigger", - "ArtifactGasTrigger" + "ArtifactGasTrigger", + "ArtifactHeatTrigger", + "ArtifactElectricityTrigger", }; /// diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs index c11fc65ad7..8164bdcece 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/ArtifactSystem.cs @@ -1,6 +1,4 @@ using Content.Server.Xenoarchaeology.XenoArtifacts.Events; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Random; using Robust.Shared.Timing; @@ -26,7 +24,7 @@ public sealed class ArtifactSystem : EntitySystem } } - public void AddRandomTrigger(EntityUid uid, ArtifactComponent? component = null) + private void AddRandomTrigger(EntityUid uid, ArtifactComponent? component = null) { if (!Resolve(uid, ref component)) return; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/GasArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/GasArtifactComponent.cs index 42e8cd31e4..d5d2304a5b 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/GasArtifactComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/GasArtifactComponent.cs @@ -1,7 +1,4 @@ using Content.Shared.Atmos; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/RadiateArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/RadiateArtifactComponent.cs index 2e4a3587ab..dd0f79a858 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/RadiateArtifactComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/RadiateArtifactComponent.cs @@ -1,7 +1,5 @@ using Content.Server.Radiation; -using Robust.Shared.GameObjects; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs index 58ac8cef61..e42f50d42f 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/SpawnArtifactComponent.cs @@ -1,10 +1,6 @@ -using System.Collections.Generic; -using Robust.Shared.GameObjects; using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List; -using Robust.Shared.ViewVariables; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TelepathicArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TelepathicArtifactComponent.cs index 3552569ce2..9595e75c0f 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TelepathicArtifactComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TelepathicArtifactComponent.cs @@ -1,7 +1,3 @@ -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; - namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; /// diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TemperatureArtifactComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TemperatureArtifactComponent.cs index 6b64788aec..c758e7d3c1 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TemperatureArtifactComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Components/TemperatureArtifactComponent.cs @@ -1,6 +1,4 @@ using Content.Shared.Atmos; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; @@ -20,4 +18,11 @@ public sealed class TemperatureArtifactComponent : Component [DataField("maxTempDif")] public float MaxTemperatureDifference = 1; + + /// + /// If true, artifact will heat/cool not only its current tile, but surrounding tiles too. + /// This will change room temperature much faster. + /// + [DataField("effectAdjacent")] + public bool EffectAdjacentTiles = true; } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/GasArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/GasArtifactSystem.cs index ea0bf936de..551911056d 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/GasArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/GasArtifactSystem.cs @@ -2,8 +2,6 @@ using Content.Server.Atmos.EntitySystems; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Random; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RadiateArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RadiateArtifactSystem.cs index 28579aaa6d..d235c50e2f 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RadiateArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/RadiateArtifactSystem.cs @@ -1,7 +1,6 @@ using Content.Server.Radiation; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; -using Robust.Shared.GameObjects; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs index a17e50fe68..29888fc7d4 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/SpawnArtifactSystem.cs @@ -2,9 +2,6 @@ using Content.Server.Clothing.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; using Content.Shared.Hands.Components; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Maths; using Robust.Shared.Random; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TelepathicArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TelepathicArtifactSystem.cs index 8c5a77efe9..7566075905 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TelepathicArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TelepathicArtifactSystem.cs @@ -2,9 +2,6 @@ using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; using Content.Shared.Popups; using Robust.Server.GameObjects; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; -using Robust.Shared.Localization; using Robust.Shared.Player; using Robust.Shared.Random; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TemperatureArtifactSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TemperatureArtifactSystem.cs index 6e4da2b522..5a2a71124a 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TemperatureArtifactSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Effects/Systems/TemperatureArtifactSystem.cs @@ -1,9 +1,7 @@ -using System; +using Content.Server.Atmos; using Content.Server.Atmos.EntitySystems; using Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Components; using Content.Server.Xenoarchaeology.XenoArtifacts.Events; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Effects.Systems; @@ -21,10 +19,23 @@ public sealed class TemperatureArtifactSystem : EntitySystem { var transform = Transform(uid); - var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates, true); - if (environment == null) + var center = _atmosphereSystem.GetTileMixture(transform.Coordinates, true); + if (center == null) return; + UpdateTileTemperature(component, center); + if (component.EffectAdjacentTiles) + { + var adjacent = _atmosphereSystem.GetAdjacentTileMixtures(transform.Coordinates, invalidate: true); + foreach (var mixture in adjacent) + { + UpdateTileTemperature(component, mixture); + } + } + } + + private void UpdateTileTemperature(TemperatureArtifactComponent component, GasMixture environment) + { var dif = component.TargetTemperature - environment.Temperature; var absDif = Math.Abs(dif); if (absDif < component.MaxTemperatureDifference) diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Events/ArtifactActivatedEvent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Events/ArtifactActivatedEvent.cs index 812e71f9f7..9757316427 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Events/ArtifactActivatedEvent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Events/ArtifactActivatedEvent.cs @@ -1,5 +1,3 @@ -using Robust.Shared.GameObjects; - namespace Content.Server.Xenoarchaeology.XenoArtifacts.Events; /// diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Events/RandomizeTriggerEvent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Events/RandomizeTriggerEvent.cs index c5ba79bb31..45ceae788b 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Events/RandomizeTriggerEvent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Events/RandomizeTriggerEvent.cs @@ -1,6 +1,4 @@ -using Robust.Shared.GameObjects; - -namespace Content.Server.Xenoarchaeology.XenoArtifacts.Events; +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Events; /// /// Force to randomize artifact triggers. diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteComponent.cs index 21ccf65595..3091cf8dd2 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteComponent.cs @@ -1,8 +1,4 @@ -using System; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; - -namespace Content.Server.Xenoarchaeology.XenoArtifacts; +namespace Content.Server.Xenoarchaeology.XenoArtifacts; [RegisterComponent] public sealed class RandomArtifactSpriteComponent : Component diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteSystem.cs index 688dd2e396..74a2ad94a5 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/RandomArtifactSpriteSystem.cs @@ -1,8 +1,5 @@ -using System; -using Content.Server.Xenoarchaeology.XenoArtifacts.Events; +using Content.Server.Xenoarchaeology.XenoArtifacts.Events; using Content.Shared.Xenoarchaeology.XenoArtifacts; -using Robust.Shared.GameObjects; -using Robust.Shared.IoC; using Robust.Shared.Random; using Robust.Shared.Timing; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactElectricityTriggerComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactElectricityTriggerComponent.cs new file mode 100644 index 0000000000..110a3ff4e5 --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactElectricityTriggerComponent.cs @@ -0,0 +1,15 @@ +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; + +/// +/// Activate artifact when it contacted with an electricity source. +/// It could be connected MV cables, stun baton or multi tool. +/// +[RegisterComponent] +public sealed class ArtifactElectricityTriggerComponent : Component +{ + /// + /// How much power should artifact receive to operate. + /// + [DataField("minPower")] + public float MinPower = 400; +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactGasTriggerComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactGasTriggerComponent.cs index 8cbb607215..d1bcea62b2 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactGasTriggerComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactGasTriggerComponent.cs @@ -1,7 +1,4 @@ using Content.Shared.Atmos; -using Robust.Shared.GameObjects; -using Robust.Shared.Serialization.Manager.Attributes; -using Robust.Shared.ViewVariables; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactHeatTriggerComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactHeatTriggerComponent.cs new file mode 100644 index 0000000000..fecbdd7ca3 --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactHeatTriggerComponent.cs @@ -0,0 +1,28 @@ +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; + +// TODO: This should probably be generalized for cold temperature too, +// but right now there is no sane way to make a freezer. + +/// +/// Triggers artifact if its in hot environment or +/// has contacted with a hot object (lit welder, lighter, etc). +/// +[RegisterComponent] +public sealed class ArtifactHeatTriggerComponent : Component +{ + /// + /// Minimal surrounding gas temperature to trigger artifact. + /// Around 100 degrees celsius by default. + /// Doesn't affect hot items temperature. + /// + [DataField("activationTemperature")] + [ViewVariables(VVAccess.ReadWrite)] + public float ActivationTemperature = 373; + + /// + /// Should artifact be activated by hot items (welders, lighter, etc)? + /// + [DataField("activateHot")] + [ViewVariables(VVAccess.ReadWrite)] + public bool ActivateHotItems = true; +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactInteractionTriggerComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactInteractionTriggerComponent.cs index 9ab33f6a22..b5c08cc4c4 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactInteractionTriggerComponent.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactInteractionTriggerComponent.cs @@ -1,11 +1,29 @@ -using Robust.Shared.GameObjects; - namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; /// -/// Activate artifact just by touching it. +/// Activate artifact by touching, attacking or pulling it. /// [RegisterComponent] public sealed class ArtifactInteractionTriggerComponent : Component { + /// + /// Should artifact be activated just by touching with empty hand? + /// + [DataField("emptyHandActivation")] + [ViewVariables(VVAccess.ReadWrite)] + public bool EmptyHandActivation = true; + + /// + /// Should artifact be activated by melee attacking? + /// + [DataField("attackActivation")] + [ViewVariables(VVAccess.ReadWrite)] + public bool AttackActivation = true; + + /// + /// Should artifact be activated by starting pulling it? + /// + [DataField("pullActivation")] + [ViewVariables(VVAccess.ReadWrite)] + public bool PullActivation = true; } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactTimerTriggerComponent.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactTimerTriggerComponent.cs new file mode 100644 index 0000000000..0bd94cb839 --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Components/ArtifactTimerTriggerComponent.cs @@ -0,0 +1,21 @@ +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; + +/// +/// Will try to activate artifact periodically. +/// Doesn't used for random artifacts, can be spawned by admins. +/// +[RegisterComponent] +public sealed class ArtifactTimerTriggerComponent : Component +{ + /// + /// Time between artifact activation attempts. + /// + [DataField("rate")] + [ViewVariables(VVAccess.ReadWrite)] + public TimeSpan ActivationRate = TimeSpan.FromSeconds(5.0f); + + /// + /// Last time when artifact was activated. + /// + public TimeSpan LastActivation; +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs new file mode 100644 index 0000000000..ff5774716e --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactElectricityTriggerSystem.cs @@ -0,0 +1,48 @@ +using Content.Server.Power.Components; +using Content.Server.Power.Events; +using Content.Server.Tools.Components; +using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; +using Content.Shared.Interaction; + +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems; + +public sealed class ArtifactElectricityTriggerSystem : EntitySystem +{ + [Dependency] private readonly ArtifactSystem _artifactSystem = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnInteractUsing); + SubscribeLocalEvent(OnPowerPulse); + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + var query = EntityManager.EntityQuery(); + foreach (var (trigger, power, artifact) in query) + { + if (power.ReceivedPower <= trigger.MinPower) + continue; + + _artifactSystem.TryActivateArtifact(trigger.Owner, component: artifact); + } + } + + private void OnInteractUsing(EntityUid uid, ArtifactElectricityTriggerComponent component, InteractUsingEvent args) + { + if (args.Handled) + return; + + if (!TryComp(args.Used, out ToolComponent? tool) || !tool.Qualities.ContainsAny("Pulsing")) + return; + + args.Handled = _artifactSystem.TryActivateArtifact(uid, args.User); + } + + private void OnPowerPulse(EntityUid uid, ArtifactElectricityTriggerComponent component, PowerPulseEvent args) + { + _artifactSystem.TryActivateArtifact(uid, args.User); + } +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactGasTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactGasTriggerSystem.cs index 7b39b0cf7c..3cd16bb503 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactGasTriggerSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactGasTriggerSystem.cs @@ -1,8 +1,6 @@ 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; using Robust.Shared.Random; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems; @@ -37,7 +35,7 @@ public sealed class ArtifactGasTriggerSystem : EntitySystem if (trigger.ActivationGas == null) continue; - var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates, true); + var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates); if (environment == null) continue; diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactHeatTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactHeatTriggerSystem.cs new file mode 100644 index 0000000000..0e3d3d65ce --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactHeatTriggerSystem.cs @@ -0,0 +1,62 @@ +using Content.Server.Atmos.EntitySystems; +using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; +using Content.Shared.Interaction; +using Content.Shared.Temperature; +using Content.Shared.Weapons.Melee; + +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems; + +public sealed class ArtifactHeatTriggerSystem : EntitySystem +{ + [Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!; + [Dependency] private readonly ArtifactSystem _artifactSystem = default!; + + public override void Initialize() + { + base.Initialize(); + SubscribeLocalEvent(OnAttacked); + SubscribeLocalEvent(OnUsing); + } + + public override void Update(float frameTime) + { + base.Update(frameTime); + + var query = EntityManager.EntityQuery(); + foreach (var (trigger, transform, artifact) in query) + { + var environment = _atmosphereSystem.GetTileMixture(transform.Coordinates); + if (environment == null) + continue; + + if (environment.Temperature < trigger.ActivationTemperature) + continue; + + _artifactSystem.TryActivateArtifact(trigger.Owner, component: artifact); + } + } + + private void OnAttacked(EntityUid uid, ArtifactHeatTriggerComponent component, AttackedEvent args) + { + if (!component.ActivateHotItems || !CheckHot(args.Used)) + return; + _artifactSystem.TryActivateArtifact(uid, args.User); + } + + private void OnUsing(EntityUid uid, ArtifactHeatTriggerComponent component, InteractUsingEvent args) + { + if (args.Handled) + return; + + if (!component.ActivateHotItems || !CheckHot(args.Used)) + return; + args.Handled = _artifactSystem.TryActivateArtifact(uid, args.User); + } + + private bool CheckHot(EntityUid usedUid) + { + var hotEvent = new IsHotEvent(); + RaiseLocalEvent(usedUid, hotEvent, false); + return hotEvent.IsHot; + } +} diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs index b640a9c9c6..c510446bed 100644 --- a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactInteractionTriggerSystem.cs @@ -1,5 +1,7 @@ using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; using Content.Shared.Interaction; +using Content.Shared.Physics.Pull; +using Content.Shared.Weapons.Melee; namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems; @@ -10,14 +12,35 @@ public sealed class ArtifactInteractionTriggerSystem : EntitySystem public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnPull); + SubscribeLocalEvent(OnAttack); SubscribeLocalEvent(OnInteract); } + private void OnPull(EntityUid uid, ArtifactInteractionTriggerComponent component, PullStartedMessage args) + { + if (!component.PullActivation) + return; + + _artifactSystem.TryActivateArtifact(uid, args.Puller.Owner); + } + + private void OnAttack(EntityUid uid, ArtifactInteractionTriggerComponent component, AttackedEvent args) + { + if (!component.AttackActivation) + return; + + _artifactSystem.TryActivateArtifact(uid, args.User); + } + private void OnInteract(EntityUid uid, ArtifactInteractionTriggerComponent component, InteractHandEvent args) { if (args.Handled) return; + if (!component.EmptyHandActivation) + return; + args.Handled = _artifactSystem.TryActivateArtifact(uid, args.User); } } diff --git a/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactTimerTriggerSystem.cs b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactTimerTriggerSystem.cs new file mode 100644 index 0000000000..8600dfbcd6 --- /dev/null +++ b/Content.Server/Xenoarchaeology/XenoArtifacts/Triggers/Systems/ArtifactTimerTriggerSystem.cs @@ -0,0 +1,26 @@ +using Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Components; +using Robust.Shared.Timing; + +namespace Content.Server.Xenoarchaeology.XenoArtifacts.Triggers.Systems; + +public sealed class ArtifactTimerTriggerSystem : EntitySystem +{ + [Dependency] private readonly IGameTiming _time = default!; + [Dependency] private readonly ArtifactSystem _artifactSystem = default!; + + public override void Update(float frameTime) + { + base.Update(frameTime); + + var query = EntityManager.EntityQuery(); + foreach (var (trigger, artifact) in query) + { + var timeDif = _time.CurTime - trigger.LastActivation; + if (timeDif <= trigger.ActivationRate) + continue; + + _artifactSystem.TryActivateArtifact(trigger.Owner, component: artifact); + trigger.LastActivation = _time.CurTime; + } + } +} diff --git a/Resources/Locale/en-US/xenoarchaeology/artifact-component.ftl b/Resources/Locale/en-US/xenoarchaeology/artifact-component.ftl new file mode 100644 index 0000000000..debb365304 --- /dev/null +++ b/Resources/Locale/en-US/xenoarchaeology/artifact-component.ftl @@ -0,0 +1,4 @@ +### Verbs + +artifact-verb-make-always-active = Make artifact always active +artifact-verb-activate = Activate artifact diff --git a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifacts.yml b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifacts.yml index 53c982dfd0..288cfb861b 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifacts.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Xenoarchaeology/artifacts.yml @@ -27,6 +27,21 @@ - type: Appearance visuals: - type: RandomArtifactVisualizer + - type: PowerConsumer + voltage: Medium + drawRate: 500 + - type: NodeContainer + nodes: + medium: + !type:CableDeviceNode + nodeGroupID: MVPower + # sadly, HVPower and Apc cables doesn't work right now + - type: Electrified + requirePower: true + noWindowInTile: true + highVoltageNode: high + mediumVoltageNode: medium + lowVoltageNode: low # Telepathic - type: entity