Files
tbd-station-14/Content.Shared/Item/ItemToggle/Components/ComponentTogglerComponent.cs
Samuka-C fbe05977d5 Fix the component toggler (#37309)
* Make the ComponentToggle remember what entity it gave components to

* fix the null problem by just ignoring the null problem

* Add documentation to the new datafield + removing the "= null" that is not necessary

* small fixes and cleaning the code

* whitespace my beloved

* wait, I dont need those lines, why did I add them?
2025-05-09 20:00:58 +02:00

39 lines
1.1 KiB
C#

using Content.Shared.Item.ItemToggle;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
namespace Content.Shared.Item.ItemToggle.Components;
/// <summary>
/// Adds or removes components when toggled.
/// Requires <see cref="ItemToggleComponent"/>.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(ComponentTogglerSystem))]
public sealed partial class ComponentTogglerComponent : Component
{
/// <summary>
/// The components to add when activated.
/// </summary>
[DataField(required: true)]
public ComponentRegistry Components = new();
/// <summary>
/// The components to remove when deactivated.
/// If this is null <see cref="Components"/> is reused.
/// </summary>
[DataField]
public ComponentRegistry? RemoveComponents;
/// <summary>
/// If true, adds components on the entity's parent instead of the entity itself.
/// </summary>
[DataField]
public bool Parent;
// <summary>
// It holds the entity that the component gave the component to, so it can remove from it even if it changes parent.
// </summary>
[DataField]
public EntityUid? Target;
}