Convert suicide to ecs (#8091)

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
wrexbe
2022-05-12 05:05:16 -07:00
committed by GitHub
parent 6903209a31
commit 089e40a061
15 changed files with 362 additions and 282 deletions

View File

@@ -25,7 +25,7 @@ using Robust.Shared.Player;
namespace Content.Server.Kitchen.Components
{
[RegisterComponent]
public sealed class MicrowaveComponent : SharedMicrowaveComponent, ISuicideAct
public sealed class MicrowaveComponent : SharedMicrowaveComponent
{
[Dependency] private readonly IEntityManager _entities = default!;
@@ -98,6 +98,12 @@ namespace Content.Server.Kitchen.Components
}
}
public void SetCookTime(uint cookTime)
{
_currentCookTimerTime = cookTime;
UIDirty = true;
}
private void UserInterfaceOnReceiveMessage(ServerBoundUserInterfaceMessage message)
{
if (!Powered || _busy)
@@ -193,7 +199,7 @@ namespace Content.Server.Kitchen.Components
// ReSharper disable once InconsistentNaming
// ReSharper disable once IdentifierTypo
private void Wzhzhzh()
public void Wzhzhzh()
{
if (!HasContents)
{
@@ -439,60 +445,10 @@ namespace Content.Server.Kitchen.Components
return true;
}
private void ClickSound()
public void ClickSound()
{
SoundSystem.Play(Filter.Pvs(Owner), _clickSound.GetSound(), Owner, AudioParams.Default.WithVolume(-2f));
}
SuicideKind ISuicideAct.Suicide(EntityUid victim, IChatManager chat)
{
var headCount = 0;
if (_entities.TryGetComponent<SharedBodyComponent?>(victim, out var body))
{
var headSlots = body.GetSlotsOfType(BodyPartType.Head);
foreach (var slot in headSlots)
{
var part = slot.Part;
if (part == null ||
!body.TryDropPart(slot, out var dropped))
{
continue;
}
foreach (var droppedPart in dropped.Values)
{
if (droppedPart.PartType != BodyPartType.Head)
{
continue;
}
Storage.Insert(droppedPart.Owner);
headCount++;
}
}
}
var othersMessage = headCount > 1
? Loc.GetString("microwave-component-suicide-multi-head-others-message", ("victim", victim))
: Loc.GetString("microwave-component-suicide-others-message", ("victim", victim));
victim.PopupMessageOtherClients(othersMessage);
var selfMessage = headCount > 1
? Loc.GetString("microwave-component-suicide-multi-head-message")
: Loc.GetString("microwave-component-suicide-message");
victim.PopupMessage(selfMessage);
_currentCookTimerTime = 10;
ClickSound();
UIDirty = true;
Wzhzhzh();
return SuicideKind.Heat;
}
}
public sealed class BeingMicrowavedEvent : HandledEntityEventArgs