using Content.Shared.Machines.EntitySystems;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Utility;
namespace Content.Shared.Machines.Components;
///
/// Marks an entity as being the owner of a multipart machine.
///
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(raiseAfterAutoHandleState: true)]
[Access(typeof(SharedMultipartMachineSystem))]
public sealed partial class MultipartMachineComponent : Component
{
///
/// Dictionary of Enum values to specific parts of this machine.
/// Each key can be specified as 'enum..` in Yaml.
///
[DataField, AutoNetworkedField]
public Dictionary Parts = [];
///
/// Whether this multipart machine is assembled or not.
/// Optional parts are not taken into account.
///
[DataField, AutoNetworkedField]
public bool IsAssembled = false;
///
/// Flag for whether the client side system is allowed to show
/// ghosts of missing machine parts.
/// Controlled/Used by the client side.
///
public List Ghosts = [];
}
[DataDefinition]
[Serializable, NetSerializable]
public sealed partial class MachinePart
{
///
/// Component type that is expected for this part to have
/// to be considered a "Part" of the machine.
///
[DataField(required: true, customTypeSerializer: typeof(ComponentNameSerializer))]
public string Component = "";
///
/// Expected offset to find this machine at.
///
[DataField(required: true)]
public Vector2i Offset;
///
/// Whether this part is required for the machine to be
/// considered "assembled", or is considered an optional extra.
///
[DataField]
public bool Optional = false;
///
/// ID of prototype, used to show sprite and description of part, when user examines the machine and there
/// is no matched entity. Can reference dummy entities to give more detailed descriptions.
///
[DataField]
public EntProtoId? GhostProto = null;
///
/// Expected rotation for this machine to have.
///
[DataField]
public Angle Rotation = Angle.Zero;
///
/// Network entity, used to inform clients and update their side of the component
/// locally.
/// Use the Entity attribute if you wish to get which entity is actually bound to this part.
///
public NetEntity? NetEntity = null;
///
/// Entity associated with this part.
/// Not null when an entity is successfully matched to the part and null otherwise.
///
[DataField, NonSerialized]
public EntityUid? Entity = null;
///
/// Expected graph for this part to use as part of its construction.
///
[DataField]
public EntProtoId Graph;
///
/// Expected node for this part to be in, on the graph.
/// Used to determine when a construct-able object has been
/// assembled or disassembled.
///
[DataField]
public string ExpectedNode;
}