mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 02:41:18 +03:00
* doorjack to counter condition * howd i do that * partial * enumrate the * cleanup --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
35 lines
1.2 KiB
C#
35 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 var mindUid, out var mind))
|
|
return;
|
|
|
|
foreach (var obj in _mind.EnumerateObjectives<MailFraudConditionComponent>((mindUid, mind)))
|
|
{
|
|
_counterCondition.IncreaseCount(obj);
|
|
}
|
|
}
|
|
}
|