// SPDX-FileCopyrightText: 2025 GoobBot // SPDX-FileCopyrightText: 2025 deltanedas <@deltanedas:kde.org> // // SPDX-License-Identifier: AGPL-3.0-or-later using Content.Shared._Goobstation.Factory.Slots; using Content.Shared.Containers.ItemSlots; using Content.Shared.DeviceLinking; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Prototypes; using Robust.Shared.Serialization; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom; namespace Content.Shared._Goobstation.Factory; [RegisterComponent, NetworkedComponent, Access(typeof(RoboticArmSystem))] [AutoGenerateComponentState(true, fieldDeltas: true), AutoGenerateComponentPause] public sealed partial class RoboticArmComponent : Component { #region Linking /// /// Machine linked to the input port. /// Might not always exist. /// [DataField, AutoNetworkedField] public NetEntity? InputMachine; /// /// Sink port on this arm that machines link to. /// [DataField] public ProtoId InputPort = "RoboticArmInput"; /// /// The source port of the linked input machine. /// This controls which item slot etc gets pulled from. /// [DataField, AutoNetworkedField] public ProtoId? InputMachinePort; /// /// The resolved automation output slot of the input machine to take items from. /// [ViewVariables] public AutomationSlot? InputSlot; /// /// Machine linked to the output port. /// Might not always exist. /// [DataField, AutoNetworkedField] public NetEntity? OutputMachine; /// /// Source port on this arm that machines link from. /// [DataField] public ProtoId OutputPort = "RoboticArmOutput"; /// /// The sink port of the linked output machine. /// This controls which item slot etc gets inserted into. /// [DataField, AutoNetworkedField] public ProtoId? OutputMachinePort; /// /// The resolved automation input slot of the output machine to insert items into. /// [ViewVariables] public AutomationSlot? OutputSlot; /// /// Signal port invoked after an item gets moved. /// [DataField] public ProtoId MovedPort = "RoboticArmMoved"; #endregion #region Item Slot /// /// Item slot that stores the held item. /// [DataField] public string ItemSlotId = "robotic_arm_item"; /// /// The item slot cached on init. /// [ViewVariables] public ItemSlot ItemSlot = default!; /// /// The currently held item. /// [ViewVariables] public EntityUid? HeldItem => ItemSlot.Item; /// /// Whether an item is currently held. /// public bool HasItem => ItemSlot.HasItem; #endregion #region Input Items /// /// Fixture to look for input items with when no input machine is linked. /// [DataField] public string InputFixtureId = "robotic_arm_input"; /// /// Items currently colliding with and whether their CollisionWake was enabled. /// When items start to collide they get pushed to the end. /// When picking up items the last value is taken. /// This is essentially a FILO queue. /// [DataField, AutoNetworkedField] public List<(NetEntity, bool)> InputItems = new(); #endregion #region Arm Moving /// /// How long it takes to move an item. /// [DataField] public TimeSpan MoveDelay = TimeSpan.FromSeconds(0.6); /// /// When the arm will next move to the input or output. /// [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))] [AutoNetworkedField, AutoPausedField] public TimeSpan? NextMove; /// /// Sound played when moving an item. /// [DataField] public SoundSpecifier? MoveSound; #endregion #region Power /// /// Power used when idle. /// [DataField] public float IdlePowerDraw = 50f; /// /// Power used when moving items. /// [DataField] public float MovingPowerDraw = 200f; // DeltaV - was 3000f #endregion } [Serializable, NetSerializable] public enum RoboticArmVisuals : byte { HasItem } [Serializable, NetSerializable] public enum RoboticArmLayers : byte { Arm, Powered }