Files
tbd-station-14/Content.Shared/Implants/Components/ImplanterComponent.cs
Leon Friedrich 19277a2276 More DoAfter Changes (#14609)
* DoAfters

* Compact Clone()

* Fix mice and cuffables

* Try generalize attempt events

* moves climbabledoafter event to shared, fixes issue with climbable target

* Fix merge (cuffing)

* Make all events netserializable

* handful of doafter events moved

* moves the rest of the events to their respective shared folders

* Changes all mentions of server doafter to shared

* stop stripping cancellation

* fix merge errors

* draw paused doafters

* handle unpausing

* missing netserializable ref

* removes break on stun reference

* removes cuffing state reference

* Fix tools

* Fix door prying.

* Fix construction

* Fix dumping

* Fix wielding assert

* fix rev

* Fix test

* more test fixes

---------

Co-authored-by: keronshb <keronshb@live.com>
2023-04-02 21:13:48 -04:00

107 lines
2.9 KiB
C#

using System.Threading;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.DoAfter;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.Implants.Components;
/// <summary>
/// Implanters are used to implant or extract implants from an entity
/// Some can be single use (implant only) or some can draw out an implant
/// </summary>
//TODO: Rework drawing to work with implant cases when surgery is in
[RegisterComponent, NetworkedComponent]
public sealed class ImplanterComponent : Component
{
public const string ImplanterSlotId = "implanter_slot";
public const string ImplantSlotId = "implant";
/// <summary>
/// Used for implanters that start with specific implants
/// </summary>
[ViewVariables]
[DataField("implant", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string? Implant;
/// <summary>
/// The time it takes to implant someone else
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("implantTime")]
public float ImplantTime = 5f;
//TODO: Remove when surgery is a thing
/// <summary>
/// The time it takes to extract an implant from someone
/// It's excessively long to deter from implant checking any antag
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("drawTime")]
public float DrawTime = 300f;
/// <summary>
/// Good for single-use injectors
/// </summary>
[ViewVariables]
[DataField("implantOnly")]
public bool ImplantOnly = false;
/// <summary>
/// The current mode of the implanter
/// Mode is changed automatically depending if it implants or draws
/// </summary>
[ViewVariables]
[DataField("currentMode")]
public ImplanterToggleMode CurrentMode;
/// <summary>
/// The name and description of the implant to show on the implanter
/// </summary>
[ViewVariables]
[DataField("implantData")]
public (string, string) ImplantData;
/// <summary>
/// The <see cref="ItemSlot"/> for this implanter
/// </summary>
[ViewVariables]
[DataField("implanterSlot")]
public ItemSlot ImplanterSlot = new();
public bool UiUpdateNeeded;
}
[Serializable, NetSerializable]
public sealed class ImplanterComponentState : ComponentState
{
public ImplanterToggleMode CurrentMode;
public bool ImplantOnly;
public ImplanterComponentState(ImplanterToggleMode currentMode, bool implantOnly)
{
CurrentMode = currentMode;
ImplantOnly = implantOnly;
}
}
[Serializable, NetSerializable]
public enum ImplanterToggleMode : byte
{
Inject,
Draw
}
[Serializable, NetSerializable]
public enum ImplanterVisuals : byte
{
Full
}
[Serializable, NetSerializable]
public enum ImplanterImplantOnlyVisuals : byte
{
ImplantOnly
}