Skip to content

Commit

Permalink
Исправил отсутсвие целей на убийства у агентов.
Browse files Browse the repository at this point in the history
  • Loading branch information
VigersRay committed Jul 24, 2024
1 parent 5a4b9eb commit f4081b9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 16 deletions.
44 changes: 28 additions & 16 deletions Content.Server/Objectives/Systems/KillPersonConditionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
using Content.Server.Objectives.Components;
using Content.Server.Shuttles.Systems;
using Content.Shared.CCVar;
using Content.Shared.Humanoid;
using Content.Shared.Mind;
using Content.Shared.Mind.Components;
using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Objectives.Components;
using Content.Shared.Roles.Jobs;
using Robust.Shared.Configuration;
Expand All @@ -22,6 +26,7 @@ public sealed class KillPersonConditionSystem : EntitySystem
[Dependency] private readonly SharedJobSystem _job = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly TargetObjectiveSystem _target = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;

public override void Initialize()
{
Expand Down Expand Up @@ -56,15 +61,7 @@ private void OnPersonAssigned(EntityUid uid, PickRandomPersonComponent comp, ref
return;

// no other humans to kill
var allHumans = _mind.GetAliveHumansExcept(args.MindId);

// Sunrise-Start
foreach (var entityUid in allHumans.ToList())
{
if (!HasComp<AntagTargetComponent>(entityUid))
allHumans.Remove(entityUid);
}
// Sunrise-End
var allHumans = GetAliveTargetsExcept(args.MindId);

if (allHumans.Count == 0)
{
Expand All @@ -89,13 +86,7 @@ private void OnHeadAssigned(EntityUid uid, PickRandomHeadComponent comp, ref Obj
return;

// no other humans to kill
var allHumans = _mind.GetAliveHumansExcept(args.MindId);

foreach (var entityUid in allHumans.ToList())
{
if (!HasComp<AntagTargetComponent>(entityUid))
allHumans.Remove(entityUid);
}
var allHumans = GetAliveTargetsExcept(args.MindId);

if (allHumans.Count == 0)
{
Expand Down Expand Up @@ -146,4 +137,25 @@ private float GetProgress(EntityUid target, bool requireDead)
// if evac is still here and target hasn't boarded, show 50% to give you an indicator that you are doing good
return _emergencyShuttle.EmergencyShuttleArrived ? 0.5f : 0f;
}

public List<EntityUid> GetAliveTargetsExcept(EntityUid exclude)
{
var mindQuery = EntityQuery<MindComponent>();

var allTargets = new List<EntityUid>();
// HumanoidAppearanceComponent is used to prevent mice, pAIs, etc from being chosen
var query = EntityQueryEnumerator<MindContainerComponent, MobStateComponent, AntagTargetComponent, HumanoidAppearanceComponent>();
while (query.MoveNext(out var uid, out var mc, out var mobState, out _, out _))
{
// the player needs to have a mind and not be the excluded one
if (mc.Mind == null || mc.Mind == exclude)
continue;

// the player has to be alive
if (_mobState.IsAlive(uid, mobState))
allTargets.Add(mc.Mind.Value);
}

return allTargets;
}
}
9 changes: 9 additions & 0 deletions Resources/Changelog/ChangelogSunrise.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1936,3 +1936,12 @@
type: Fix
id: 145
time: '2024-07-24T18:45:34.906534+00:00'
- author: VigersRay
changes:
- message: "\u0418\u0441\u043F\u0440\u0430\u0432\u043B\u0435\u043D\u043E \u043E\u0442\
\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0446\u0435\u043B\u0435\u0439\
\ \u043D\u0430 \u0443\u0431\u0438\u0439\u0441\u0442\u0432\u043E \u0443 \u0430\
\u0433\u0435\u043D\u0442\u043E\u0432."
type: Fix
id: 146
time: '2024-07-24T21:47:55.955101+00:00'

0 comments on commit f4081b9

Please sign in to comment.