Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port: Vulpkanin Update #2490

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 130 additions & 0 deletions Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
using Content.Server.Popups;
using Content.Shared.DoAfter;
using Content.Shared.Verbs;
using Content.Shared.Forensics;
using Content.Shared.Examine;
using Robust.Shared.Utility;
using Content.Shared.IdentityManagement;

namespace Content.Server.Forensics
{
public sealed class ScentTrackerSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfterSystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<ScentTrackerComponent, GetVerbsEvent<InnateVerb>>(AddVerbs);
SubscribeLocalEvent<ScentTrackerComponent, ScentTrackerDoAfterEvent>(TrackScentDoAfter);
SubscribeLocalEvent<ForensicsComponent, ExaminedEvent>((uid, _, args) => OnExamine(uid, args));
}

private void AddVerbs(EntityUid uid, ScentTrackerComponent component, GetVerbsEvent<InnateVerb> args)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 22 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)
{
TrackScentVerb(uid, component, args);
StopTrackScentVerb(uid, component, args);
}

private void TrackScentVerb(EntityUid uid, ScentTrackerComponent component, GetVerbsEvent<InnateVerb> args)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 28 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)
{
if (!args.CanInteract
|| !args.CanAccess
|| args.User == args.Target)
return;

InnateVerb verbTrackScent = new()
{
Act = () => AttemptTrackScent(uid, args.Target, component),
Text = Loc.GetString("track-scent"),
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/psionic_invisibility.png")),
Priority = 1
};
args.Verbs.Add(verbTrackScent);
}

private void AttemptTrackScent(EntityUid user, EntityUid target, ScentTrackerComponent component)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 45 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)
{
if (!HasComp<ScentTrackerComponent>(user))
return;

var doAfterEventArgs = new DoAfterArgs(EntityManager, user, component.SniffDelay, new ScentTrackerDoAfterEvent(), user, target: target)
{
BreakOnUserMove = true,
BreakOnDamage = true,
BreakOnTargetMove = true
};

_popupSystem.PopupEntity(Loc.GetString("start-tracking-scent", ("user", Identity.Name(user, EntityManager)), ("target", Identity.Name(target, EntityManager))), user);
_doAfterSystem.TryStartDoAfter(doAfterEventArgs);
}

private void TrackScentDoAfter(Entity<ScentTrackerComponent> entity, ref ScentTrackerDoAfterEvent args)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerDoAfterEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerDoAfterEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerDoAfterEvent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 61 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerDoAfterEvent' could not be found (are you missing a using directive or an assembly reference?)
{
if (args.Handled
|| args.Cancelled
|| args.Args.Target == null)
return;

TrackScent(args.Args.User, args.Args.Target.Value);

args.Handled = true;
}

private void StopTrackScentVerb(EntityUid uid, ScentTrackerComponent component, GetVerbsEvent<InnateVerb> args)

Check failure on line 73 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 73 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 73 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 73 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)
{
if (args.User != args.Target
|| component.Scent == string.Empty)
return;

InnateVerb verbStopTrackScent = new()
{
Act = () => StopTrackScent(uid, component),
Text = Loc.GetString("stop-track-scent"),
Icon = new SpriteSpecifier.Texture(new ResPath("/Textures/Interface/VerbIcons/psionic_invisibility.png")),
Priority = 2
};
args.Verbs.Add(verbStopTrackScent);
}

private void OnExamine(EntityUid uid, ExaminedEvent args)
{
if (!TryComp<ScentTrackerComponent>(args.Examiner, out var component)
|| !TryComp<ForensicsComponent>(args.Examined, out var forcomp))
return;

if (forcomp.Scent != string.Empty && component.Scent == forcomp.Scent)
args.PushMarkup(Loc.GetString("examined-scent"), -1);
}

#region Utilities
public void TrackScent(EntityUid uid, EntityUid target)
{
if (!TryComp<ScentTrackerComponent>(uid, out var component)
|| !TryComp<ForensicsComponent>(target, out var forcomp))
return;

if (forcomp.Scent != string.Empty)
{
component.Scent = forcomp.Scent;
_popupSystem.PopupEntity(Loc.GetString("tracking-scent", ("target", Identity.Name(target, EntityManager))), uid, uid);
}
else
_popupSystem.PopupEntity(Loc.GetString("no-scent"), uid, uid);

Dirty(uid, component);
}

public void StopTrackScent(EntityUid uid, ScentTrackerComponent component)

Check failure on line 117 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 117 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 117 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 117 in Content.Server/_EE/Forensics/Systems/ScentTrackerSystem.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The type or namespace name 'ScentTrackerComponent' could not be found (are you missing a using directive or an assembly reference?)
{
if (!HasComp<ScentTrackerComponent>(uid))
return;

component.Scent = string.Empty;
_popupSystem.PopupEntity(Loc.GetString("stopped-tracking-scent"), uid, uid);

Dirty(uid, component);
}

#endregion
}
}
Loading