2020-12-01 17:05:19 +01:00
|
|
|
|
using System.Linq;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Server.Mind.Components;
|
2020-12-01 17:05:19 +01:00
|
|
|
|
using Content.Server.Objectives.Interfaces;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.MobState;
|
2020-12-01 17:05:19 +01:00
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-12-01 17:05:19 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
using Robust.Shared.Random;
|
2021-03-05 01:08:38 +01:00
|
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-12-01 17:05:19 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Objectives.Conditions
|
|
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataDefinition]
|
2020-12-01 17:05:19 +01:00
|
|
|
|
public class KillRandomPersonCondition : KillPersonCondition
|
|
|
|
|
|
{
|
2021-06-09 22:19:39 +02:00
|
|
|
|
public override IObjectiveCondition GetAssigned(Mind.Mind mind)
|
2020-12-01 17:05:19 +01:00
|
|
|
|
{
|
|
|
|
|
|
var entityMgr = IoCManager.Resolve<IEntityManager>();
|
2021-09-28 13:35:29 +02:00
|
|
|
|
var allHumans = entityMgr.EntityQuery<MindComponent>(true).Where(mc =>
|
2020-12-01 17:05:19 +01:00
|
|
|
|
{
|
|
|
|
|
|
var entity = mc.Mind?.OwnedEntity;
|
2020-12-07 14:52:55 +01:00
|
|
|
|
return (entity?.GetComponentOrNull<IMobStateComponent>()?.IsAlive() ?? false) && mc.Mind != mind;
|
2020-12-01 17:05:19 +01:00
|
|
|
|
}).Select(mc => mc.Mind).ToList();
|
|
|
|
|
|
return new KillRandomPersonCondition {Target = IoCManager.Resolve<IRobustRandom>().Pick(allHumans)};
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|