+using Content.Shared.Actions;
using Content.Shared.Destructible.Thresholds;
using Content.Shared.EntityTable.EntitySelectors;
using Content.Shared.Xenoarchaeology.Artifact.Prototypes;
Variation = 0.1f
}
};
+
+ /// <summary>
+ /// Action that allows the artifact to self activate.
+ /// </summary>
+ [DataField]
+ public EntProtoId<InstantActionComponent> SelfActivateAction = "ActionArtifactActivate";
}
+
+/// <summary>
+/// Event raised by sentient artifact to activate itself at no durability cost.
+/// </summary>
+public sealed partial class ArtifactSelfActivateEvent : InstantActionEvent;
/// <param name="user">Character that attempted to activate artifact.</param>
/// <param name="target">Target, on which artifact activation attempt was used (for hand-held artifact - it can be 'clicked' over someone).</param>
/// <param name="coordinates">Coordinates of <paramref name="target"/> entity.</param>
+ /// <param name="consumeDurability">Whether this activation will deplete durability on the activated nodes.</param>
/// <returns>True, if activation was successful, false otherwise.</returns>
public bool TryActivateXenoArtifact(
Entity<XenoArtifactComponent> artifact,
EntityUid? user,
EntityUid? target,
- EntityCoordinates coordinates
+ EntityCoordinates coordinates,
+ bool consumeDurability = true
)
{
XenoArtifactComponent xenoArtifactComponent = artifact;
var success = false;
foreach (var node in GetActiveNodes(artifact))
{
- success |= ActivateNode(artifact, node, user, target, coordinates);
+ success |= ActivateNode(artifact, node, user, target, coordinates, consumeDurability: consumeDurability);
}
if (!success)
+using Content.Shared.Actions;
using Content.Shared.Popups;
using Content.Shared.Xenoarchaeology.Artifact.Components;
using Robust.Shared.Containers;
[Dependency] private readonly INetManager _net = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
[Dependency] protected readonly IRobustRandom RobustRandom = default!;
+ [Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
public override void Initialize()
{
SubscribeLocalEvent<XenoArtifactComponent, ComponentStartup>(OnStartup);
+ SubscribeLocalEvent<XenoArtifactComponent, ArtifactSelfActivateEvent>(OnSelfActivate);
InitializeNode();
InitializeUnlock();
/// <summary> As all artifacts have to contain nodes - we ensure that they are containers. </summary>
private void OnStartup(Entity<XenoArtifactComponent> ent, ref ComponentStartup args)
{
+ _actions.AddAction(ent, ent.Comp.SelfActivateAction);
ent.Comp.NodeContainer = _container.EnsureContainer<Container>(ent, XenoArtifactComponent.NodeContainerId);
}
+ private void OnSelfActivate(Entity<XenoArtifactComponent> ent, ref ArtifactSelfActivateEvent args)
+ {
+ args.Handled = TryActivateXenoArtifact(ent, ent, null, Transform(ent).Coordinates, false);
+ }
+
public void SetSuppressed(Entity<XenoArtifactComponent> ent, bool val)
{
if (ent.Comp.Suppressed == val)
- type: entity
id: BaseXenoArtifact
+ parent: BaseMob # we use this since it can technically get inhabited
name: artifact
description: A strange artifact from time unknown. Looks like a good time.
abstract: true
- type: Actions
- type: Physics
bodyType: Dynamic
+ - type: MovementSpeedModifier
+ baseWalkSpeed: 0.25
+ baseSprintSpeed: 0.5
- type: UseDelay
- type: StealTarget
stealGroup: XenoArtifact
# These components are needed for certain triggers to work.
- type: RadiationReceiver
- type: Reactive
+
+- type: entity
+ id: ActionArtifactActivate
+ name: Activate Artifact
+ description: Activate yourself, causing chaos to those near you.
+ components:
+ - type: InstantAction
+ icon:
+ sprite: Objects/Specific/Xenoarchaeology/xeno_artifacts.rsi
+ state: ano29
+ useDelay: 300
+ event: !type:ArtifactSelfActivateEvent
mindRoles:
- MindRoleGhostRoleFreeAgent
- type: GhostTakeoverAvailable
- - type: MovementSpeedModifier
- baseWalkSpeed: 0.25
- baseSprintSpeed: 0.5
- type: entity
id: XenoArtifactOmnitool