mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
* Decouple gibbing from the body system * allow gibs that don't drop giblets * pass through user * prediction gon * comment * destructible * playpvs * very very very very very very very minor cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
using Content.Shared.GameTicking;
|
|
using Content.Shared.Gibbing.Components;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Objectives.Systems;
|
|
using Content.Shared.Gibbing;
|
|
|
|
namespace Content.Server.Gibbing.Systems;
|
|
public sealed class GibOnRoundEndSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly GibbingSystem _gibbing = default!;
|
|
[Dependency] private readonly SharedMindSystem _mind = default!;
|
|
[Dependency] private readonly SharedObjectivesSystem _objectives = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
// this is raised after RoundEndTextAppendEvent, so they can successfully greentext before we gib them
|
|
SubscribeLocalEvent<RoundEndMessageEvent>(OnRoundEnd);
|
|
}
|
|
|
|
private void OnRoundEnd(RoundEndMessageEvent args)
|
|
{
|
|
var gibQuery = EntityQueryEnumerator<GibOnRoundEndComponent>();
|
|
|
|
// gib everyone with the component
|
|
while (gibQuery.MoveNext(out var uid, out var gibComp))
|
|
{
|
|
var gib = false;
|
|
// if they fulfill all objectives given in the component they are not gibbed
|
|
if (_mind.TryGetMind(uid, out var mindId, out var mindComp))
|
|
{
|
|
foreach (var objectiveId in gibComp.PreventGibbingObjectives)
|
|
{
|
|
if (!_mind.TryFindObjective((mindId, mindComp), objectiveId, out var objective)
|
|
|| !_objectives.IsCompleted(objective.Value, (mindId, mindComp)))
|
|
{
|
|
gib = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
gib = true;
|
|
|
|
if (!gib)
|
|
continue;
|
|
|
|
if (gibComp.SpawnProto != null)
|
|
SpawnAtPosition(gibComp.SpawnProto, Transform(uid).Coordinates);
|
|
|
|
_gibbing.Gib(uid);
|
|
}
|
|
}
|
|
}
|