mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
38 lines
1.2 KiB
C#
38 lines
1.2 KiB
C#
using Content.Server.Mind;
|
|
using Content.Server.Objectives.Components;
|
|
using Content.Shared.Delivery;
|
|
using Content.Shared.FingerprintReader;
|
|
|
|
namespace Content.Server.Objectives.Systems;
|
|
|
|
public sealed partial class MailFraudObjectiveSystem : EntitySystem
|
|
{
|
|
[Dependency] private MindSystem _mind = default!;
|
|
[Dependency] private FingerprintReaderSystem _fingerprintReader = default!;
|
|
[Dependency] private CounterConditionSystem _counterCondition = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
SubscribeLocalEvent<DeliveryComponent, DeliveryOpenedEvent>(OnDeliveryOpened);
|
|
}
|
|
|
|
private void OnDeliveryOpened(Entity<DeliveryComponent> ent, ref DeliveryOpenedEvent args)
|
|
{
|
|
if (!ent.Comp.WasPenalized)
|
|
return; //not fraud
|
|
|
|
if (_fingerprintReader.IsAllowed(ent.Owner, args.User, out var _, showPopup: false, checkGloves: false))
|
|
return; //cutting open your own letter
|
|
|
|
if (!_mind.TryGetMind(args.User, out _, out var mind))
|
|
return;
|
|
|
|
foreach (var obj in mind.Objectives)
|
|
{
|
|
if (HasComp<MailFraudConditionComponent>(obj))
|
|
{
|
|
_counterCondition.IncreaseCount(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|