Basic gibbing (#2973)

* Adds gibbing

* Adds adminbused absurd-damage foamblade

* Sane parts

* BaseOrgan -> BaseMechanism

* Do not do random offset on shared, fix killing oneself with click attacks

* BaseMechanism -> BaseHumanOrgan -> *stuff*

* Account for prediction, again

* Add gibbing sound
This commit is contained in:
Vera Aguilera Puerto
2021-01-10 20:12:34 +01:00
committed by GitHub
parent 8def38aed4
commit 12c733654c
18 changed files with 172 additions and 29 deletions

View File

@@ -1,15 +1,20 @@
#nullable enable
using System;
using Content.Server.Commands.Observer;
using Content.Shared.Audio;
using Content.Shared.GameObjects.Components.Body;
using Content.Shared.GameObjects.Components.Body.Part;
using Content.Shared.GameObjects.Components.Damage;
using Content.Shared.GameObjects.Components.Mobs.State;
using Content.Shared.GameObjects.Components.Movement;
using Content.Shared.Utility;
using Robust.Server.GameObjects.Components.Container;
using Robust.Server.GameObjects.EntitySystems;
using Robust.Server.Interfaces.Console;
using Robust.Server.Interfaces.Player;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.IoC;
using Robust.Shared.Log;
using Robust.Shared.Players;
@@ -41,6 +46,7 @@ namespace Content.Server.GameObjects.Components.Body
base.OnRemovePart(slot, part);
_partContainer.ForceRemove(part.Owner);
part.Owner.RandomOffset(0.25f);
}
public override void Initialize()
@@ -88,5 +94,29 @@ namespace Content.Server.GameObjects.Components.Body
new Ghost().Execute(shell, (IPlayerSession) session, Array.Empty<string>());
}
}
public override void Gib(bool gibParts = false)
{
base.Gib(gibParts);
EntitySystem.Get<AudioSystem>()
.PlayAtCoords(AudioHelpers.GetRandomFileFromSoundCollection("gib"), Owner.Transform.Coordinates,
AudioHelpers.WithVariation(0.025f));
if (Owner.TryGetComponent(out ContainerManagerComponent? container))
{
foreach (var cont in container.GetAllContainers())
{
foreach (var ent in cont.ContainedEntities)
{
cont.ForceRemove(ent);
ent.Transform.Coordinates = Owner.Transform.Coordinates;
ent.RandomOffset(0.25f);
}
}
}
Owner.Delete();
}
}
}

View File

@@ -11,6 +11,7 @@ using Content.Shared.GameObjects.Components.Body.Surgery;
using Content.Shared.GameObjects.Verbs;
using Content.Shared.Interfaces;
using Content.Shared.Interfaces.GameObjects.Components;
using Content.Shared.Utility;
using Robust.Server.Console;
using Robust.Server.GameObjects;
using Robust.Server.GameObjects.Components.Container;
@@ -57,6 +58,7 @@ namespace Content.Server.GameObjects.Components.Body.Part
base.OnRemoveMechanism(mechanism);
_mechanismContainer.Remove(mechanism.Owner);
mechanism.Owner.RandomOffset(0.25f);
}
public override void Initialize()

View File

@@ -0,0 +1,27 @@
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Body;
using JetBrains.Annotations;
using Robust.Shared.Interfaces.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Destructible.Thresholds.Behavior
{
[UsedImplicitly]
public class GibBehavior : IThresholdBehavior
{
private bool _recursive = true;
public void ExposeData(ObjectSerializer serializer)
{
serializer.DataField(ref _recursive, "recursive", true);
}
public void Trigger(IEntity owner, DestructibleSystem system)
{
if (owner.TryGetComponent(out IBody body))
{
body.Gib(_recursive);
}
}
}
}

View File

@@ -79,7 +79,7 @@ namespace Content.Server.GameObjects.Components.Recycling
// Mobs are a special case!
if (CanGib(entity))
{
entity.Delete(); // TODO: Gib
entity.GetComponent<IBody>().Gib(true);
Bloodstain();
return;
}