Files
tbd-station-14/Content.Server/GameObjects/Components/Destructible/Thresholds/Behaviors/ChangeConstructionNodeBehavior.cs

33 lines
992 B
C#

#nullable enable
using System;
using Content.Server.GameObjects.Components.Construction;
using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Interfaces.Serialization;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Behaviors
{
[Serializable]
public class ChangeConstructionNodeBehavior : IThresholdBehavior
{
public string Node { get; private set; } = string.Empty;
void IExposeData.ExposeData(ObjectSerializer serializer)
{
serializer.DataField(this, x => x.Node, "node", string.Empty);
}
public void Execute(IEntity owner, DestructibleSystem system)
{
if (string.IsNullOrEmpty(Node) ||
!owner.TryGetComponent(out ConstructionComponent? construction))
{
return;
}
construction.ChangeNode(Node);
}
}
}