Added suicide for Crematorium and Recycler, soft fixed Recycled gibbing (#2610)

* Added suicide for Crematorium and Recycler, soft fixed Recycled gibbing

* Renamed _cancelToken to _cremateCancelToken, made _cremateCancelToken nullable

* Update Content.Server/GameObjects/Components/Morgue/CrematoriumEntityStorageComponent.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Added Ownder.Deleted check inside timer

* Added TODO gibbing comments

* Removed innecessary code and removed deleting entities when getting 'gibbed'

* Fix ghosting with gibbing.

Co-authored-by: Manel Navola <ManelNavola@users.noreply.github.com>
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
Manel Navola
2021-01-14 08:57:24 +01:00
committed by GitHub
parent ce096f9c51
commit f7ac546f39
3 changed files with 92 additions and 8 deletions

View File

@@ -1,5 +1,9 @@
#nullable enable
using Content.Server.GameObjects.Components.Items.Storage;
using Content.Server.Interfaces.Chat;
using Content.Server.Interfaces.GameObjects;
using Content.Server.Utility;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Morgue;
using Content.Shared.GameObjects.EntitySystems;
using Content.Shared.GameObjects.EntitySystems.ActionBlocker;
@@ -11,9 +15,14 @@ using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Timers;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
using System.Threading;
using Content.Server.Interfaces.GameTicking;
using Content.Server.Players;
using Robust.Server.Player;
using Robust.Shared.GameObjects.Components.Timers;
using Robust.Shared.IoC;
namespace Content.Server.GameObjects.Components.Morgue
{
@@ -22,7 +31,7 @@ namespace Content.Server.GameObjects.Components.Morgue
[ComponentReference(typeof(EntityStorageComponent))]
[ComponentReference(typeof(IActivate))]
[ComponentReference(typeof(IStorageComponent))]
public class CrematoriumEntityStorageComponent : MorgueEntityStorageComponent, IExamine
public class CrematoriumEntityStorageComponent : MorgueEntityStorageComponent, IExamine, ISuicideAct
{
public override string Name => "CrematoriumEntityStorage";
@@ -32,6 +41,8 @@ namespace Content.Server.GameObjects.Components.Morgue
[ViewVariables(VVAccess.ReadWrite)]
private int _burnMilis = 3000;
private CancellationTokenSource? _cremateCancelToken;
void IExamine.Examine(FormattedMessage message, bool inDetailsRange)
{
if (Appearance == null) return;
@@ -64,16 +75,30 @@ namespace Content.Server.GameObjects.Components.Morgue
return base.CanOpen(user, silent);
}
public void Cremate()
public void TryCremate()
{
if (Cooking) return;
if (Open) return;
Cremate();
}
public void Cremate()
{
if (Open)
CloseStorage();
Appearance?.SetData(CrematoriumVisuals.Burning, true);
Cooking = true;
Timer.Spawn(_burnMilis, () =>
_cremateCancelToken?.Cancel();
_cremateCancelToken = new CancellationTokenSource();
Owner.SpawnTimer(_burnMilis, () =>
{
if (Owner.Deleted)
return;
Appearance?.SetData(CrematoriumVisuals.Burning, false);
Cooking = false;
@@ -93,7 +118,34 @@ namespace Content.Server.GameObjects.Components.Morgue
TryOpenStorage(Owner);
EntitySystem.Get<AudioSystem>().PlayFromEntity("/Audio/Machines/ding.ogg", Owner);
});
}, _cremateCancelToken.Token);
}
public SuicideKind Suicide(IEntity victim, IChatManager chat)
{
var mind = victim.PlayerSession()?.ContentData()?.Mind;
if (mind != null)
{
IoCManager.Resolve<IGameTicker>().OnGhostAttempt(mind, false);
mind.OwnedEntity.PopupMessage(Loc.GetString("You cremate yourself!"));
}
victim.PopupMessageOtherClients(Loc.GetString("{0:theName} is cremating {0:themself}!", victim));
EntitySystem.Get<SharedStandingStateSystem>().Down(victim, false, false, true);
if (CanInsert(victim))
{
Insert(victim);
}
else
{
victim.Delete();
}
Cremate();
return SuicideKind.Heat;
}
[Verb]
@@ -113,7 +165,7 @@ namespace Content.Server.GameObjects.Components.Morgue
/// <inheritdoc />
protected override void Activate(IEntity user, CrematoriumEntityStorageComponent component)
{
component.Cremate();
component.TryCremate();
}
}
}