2022-01-04 02:17:39 -07:00
|
|
|
|
using Content.Shared.Body.Events;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Body.Part;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 11:11:52 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
using Robust.Shared.Serialization;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2021-11-11 16:10:57 -07:00
|
|
|
|
namespace Content.Shared.Body.Components
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
2022-01-04 02:17:39 -07:00
|
|
|
|
[RegisterComponent]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class MechanismComponent : Component, ISerializationHooks
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
2021-12-08 17:32:32 +01:00
|
|
|
|
[Dependency] private readonly IEntityManager _entMan = default!;
|
2021-06-16 16:44:38 +02:00
|
|
|
|
private SharedBodyPartComponent? _part;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
|
2021-06-16 16:44:38 +02:00
|
|
|
|
public SharedBodyComponent? Body => Part?.Body;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2021-06-16 16:44:38 +02:00
|
|
|
|
public SharedBodyPartComponent? Part
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
|
|
|
|
|
get => _part;
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_part == value)
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var old = _part;
|
|
|
|
|
|
_part = value;
|
|
|
|
|
|
|
2020-10-16 14:42:33 +02:00
|
|
|
|
if (old != null)
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
2020-10-17 12:26:39 +02:00
|
|
|
|
if (old.Body == null)
|
|
|
|
|
|
{
|
2021-12-08 17:32:32 +01:00
|
|
|
|
_entMan.EventBus.RaiseLocalEvent(Owner, new RemovedFromPartEvent(old));
|
2020-10-17 12:26:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-12-08 17:32:32 +01:00
|
|
|
|
_entMan.EventBus.RaiseLocalEvent(Owner, new RemovedFromPartInBodyEvent(old.Body, old));
|
2020-10-17 12:26:39 +02:00
|
|
|
|
}
|
2020-10-10 15:25:13 +02:00
|
|
|
|
}
|
2020-10-16 14:42:33 +02:00
|
|
|
|
|
|
|
|
|
|
if (value != null)
|
2020-10-10 15:25:13 +02:00
|
|
|
|
{
|
2020-10-17 12:26:39 +02:00
|
|
|
|
if (value.Body == null)
|
|
|
|
|
|
{
|
2021-12-08 17:32:32 +01:00
|
|
|
|
_entMan.EventBus.RaiseLocalEvent(Owner, new AddedToPartEvent(value));
|
2020-10-17 12:26:39 +02:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-12-08 17:32:32 +01:00
|
|
|
|
_entMan.EventBus.RaiseLocalEvent(Owner, new AddedToPartInBodyEvent(value.Body, value));
|
2020-10-17 12:26:39 +02:00
|
|
|
|
}
|
2020-10-10 15:25:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("maxDurability")] public int MaxDurability { get; set; } = 10;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("currentDurability")] public int CurrentDurability { get; set; } = 10;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("destroyThreshold")] public int DestroyThreshold { get; set; } = -10;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2020-11-15 04:22:59 +01:00
|
|
|
|
// TODO BODY: Surgery description and adding a message to the examine tooltip of the entity that owns this mechanism
|
2020-10-10 15:25:13 +02:00
|
|
|
|
// TODO BODY
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("resistance")] public int Resistance { get; set; } = 0;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
|
|
|
|
|
// TODO BODY OnSizeChanged
|
2021-06-16 16:44:38 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Determines whether this
|
2022-01-04 02:17:39 -07:00
|
|
|
|
/// <see cref="MechanismComponent"/> can fit into a <see cref="SharedBodyPartComponent"/>.
|
2021-06-16 16:44:38 +02:00
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("size")] public int Size { get; set; } = 1;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
|
2021-06-16 16:44:38 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// What kind of <see cref="SharedBodyPartComponent"/> this
|
2022-01-04 02:17:39 -07:00
|
|
|
|
/// <see cref="MechanismComponent"/> can be easily installed into.
|
2021-06-16 16:44:38 +02:00
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("compatibility")]
|
|
|
|
|
|
public BodyPartCompatibility Compatibility { get; set; } = BodyPartCompatibility.Universal;
|
2020-10-10 15:25:13 +02:00
|
|
|
|
}
|
|
|
|
|
|
}
|