Add "Begin Deconstruction" verb, unfinished particle accelerator bits will tell you how to finish them (#2706)

* More Construction Pieces: Default construction targets

* More Construction Pieces: Unfinished particle accelerator will tell you how to finish it

* More Construction Pieces: Construction system actually pathfinds any-to-any

* More Construction Pieces: Verb to begin deconstruction of an object
This commit is contained in:
20kdc
2020-12-08 10:53:37 +00:00
committed by GitHub
parent f6d62ada65
commit d75c22d5e1
5 changed files with 89 additions and 7 deletions

View File

@@ -0,0 +1,52 @@
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Verbs;
using Content.Shared.Interfaces;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Components;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Log;
namespace Content.Server.GameObjects.Components.Construction
{
public partial class ConstructionComponent
{
[Verb]
public sealed class DeconstructibleVerb : Verb<ConstructionComponent>
{
protected override void GetData(IEntity user, ConstructionComponent component, VerbData data)
{
if (!ActionBlockerSystem.CanInteract(user))
{
data.Visibility = VerbVisibility.Invisible;
return;
}
if (((component.Target != null) && (component.Target.Name == component.DeconstructionNodeIdentifier)) ||
((component.Node != null) && (component.Node.Name == component.DeconstructionNodeIdentifier)))
{
data.Visibility = VerbVisibility.Invisible;
return;
}
data.CategoryData = VerbCategories.Construction;
data.Text = Loc.GetString("Begin deconstructing");
data.IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.96dpi.png";
}
protected override void Activate(IEntity user, ConstructionComponent component)
{
component.SetNewTarget(component.DeconstructionNodeIdentifier);
if (component.Target == null)
{
// Maybe check, but on the flip-side a better solution might be to not make it undeconstructible in the first place, no?
component.Owner.PopupMessage(user, Loc.GetString("There is no way to deconstruct this."));
}
else
{
component.Owner.PopupMessage(user, Loc.GetString("Examine to see instructions."));
}
}
}
}
}

View File

@@ -28,7 +28,7 @@ using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Construction
{
[RegisterComponent]
public class ConstructionComponent : Component, IExamine, IInteractUsing
public partial class ConstructionComponent : Component, IExamine, IInteractUsing
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
@@ -39,6 +39,7 @@ namespace Content.Server.GameObjects.Components.Construction
private TaskCompletionSource<object>? _handlingTask = null;
private string _graphIdentifier = string.Empty;
private string _startingNodeIdentifier = string.Empty;
private string _startingTargetNodeIdentifier = string.Empty;
[ViewVariables]
private HashSet<string> _containers = new();
@@ -79,6 +80,9 @@ namespace Content.Server.GameObjects.Components.Construction
[ViewVariables]
public int EdgeStep { get; private set; } = 0;
[ViewVariables]
public string DeconstructionNodeIdentifier { get; private set; } = "start";
/// <inheritdoc />
public override void ExposeData(ObjectSerializer serializer)
{
@@ -86,6 +90,8 @@ namespace Content.Server.GameObjects.Components.Construction
serializer.DataField(ref _graphIdentifier, "graph", string.Empty);
serializer.DataField(ref _startingNodeIdentifier, "node", string.Empty);
serializer.DataField(ref _startingTargetNodeIdentifier, "defaultTarget", string.Empty);
serializer.DataField(this, x => x.DeconstructionNodeIdentifier, "deconstructionTarget", "start");
}
/// <summary>
@@ -495,6 +501,9 @@ namespace Content.Server.GameObjects.Components.Construction
{
Logger.Error($"Couldn't find prototype {_graphIdentifier} in construction component!");
}
if (!string.IsNullOrEmpty(_startingTargetNodeIdentifier))
SetNewTarget(_startingTargetNodeIdentifier);
}
protected override void Startup()