Skip to content

Commit

Permalink
VM if this breaks im coming to your home at 3am
Browse files Browse the repository at this point in the history
Co-authored-by: VMSolidus <[email protected]>
Signed-off-by: FoxxoTrystan <[email protected]>
  • Loading branch information
FoxxoTrystan and VMSolidus committed Aug 14, 2024
1 parent b151b48 commit 7d87320
Show file tree
Hide file tree
Showing 9 changed files with 42 additions and 55 deletions.
15 changes: 6 additions & 9 deletions Content.Client/Forensics/ScentTrackerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,14 @@ public override void Update(float frameTime)
var query = AllEntityQuery<ForensicsComponent>();
while (query.MoveNext(out var uid, out var comp))
{
if (TryComp<ScentTrackerComponent>(_playerManager.LocalEntity, out var scentcomp))
{
if (scentcomp.Scent != string.Empty && scentcomp.Scent == comp.Scent)
if (TryComp<ScentTrackerComponent>(_playerManager.LocalEntity, out var scentcomp)
&& scentcomp.Scent != string.Empty
&& scentcomp.Scent == comp.Scent
&& _timing.CurTime > comp.TargetTime)
{
if (_timing.CurTime > comp.TargetTime)
{
comp.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(1.0f);
Spawn("ScentTrackEffect", _transform.GetMapCoordinates(uid).Offset(_random.NextVector2(0.25f)));
}
comp.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(1.0f);
Spawn("ScentTrackEffect", _transform.GetMapCoordinates(uid).Offset(_random.NextVector2(0.25f)));
}
}
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions Content.Server/Flash/FlashSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,10 @@ public void Flash(EntityUid target,
flashable.Duration = flashDuration / 1000f; // TODO: Make this sane...
Dirty(target, flashable);

if (TryComp<BlindableComponent>(target, out var blindable))
{
if (!blindable.IsBlind && _random.Prob(flashable.EyeDamageChance))
{
if (TryComp<BlindableComponent>(target, out var blindable)
&& !blindable.IsBlind
&& _random.Prob(flashable.EyeDamageChance))
_blindingSystem.AdjustEyeDamage((target, blindable), flashable.EyeDamage);
}
}

_stun.TrySlowdown(target, TimeSpan.FromSeconds(flashDuration/1000f), true,
slowTo, slowTo);
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Forensics/Components/ScentComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace Content.Server.Forensics;
[RegisterComponent]
public sealed partial class ScentComponent : Component
{
[DataField("scent"), ViewVariables(VVAccess.ReadWrite)]
[DataField]
public string Scent = String.Empty;
}
16 changes: 6 additions & 10 deletions Content.Server/Forensics/Systems/ForensicsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,10 @@ private void OnAfterInteract(EntityUid uid, CleansForensicsComponent component,
if (args.Handled)
return;

if (TryComp<ForensicsComponent>(args.Target, out var forensicsComp))
{
if ((forensicsComp.DNAs.Count > 0 && forensicsComp.CanDnaBeCleaned) || (forensicsComp.Fingerprints.Count + forensicsComp.Fibers.Count > 0) || (forensicsComp.Scent != string.Empty))
if (TryComp<ForensicsComponent>(args.Target, out var forensicsComp)
&& (forensicsComp.DNAs.Count > 0 && forensicsComp.CanDnaBeCleaned)
|| (forensicsComp.Fingerprints.Count + forensicsComp.Fibers.Count > 0)

Check failure on line 139 in Content.Server/Forensics/Systems/ForensicsSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Dereference of a possibly null reference.

Check failure on line 139 in Content.Server/Forensics/Systems/ForensicsSystem.cs

View workflow job for this annotation

GitHub Actions / Test Packaging

Dereference of a possibly null reference.

Check failure on line 139 in Content.Server/Forensics/Systems/ForensicsSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check failure on line 139 in Content.Server/Forensics/Systems/ForensicsSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check failure on line 139 in Content.Server/Forensics/Systems/ForensicsSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check failure on line 139 in Content.Server/Forensics/Systems/ForensicsSystem.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.
|| (forensicsComp.Scent != string.Empty))
{
var cleanDelay = component.CleanDelay;
if (HasComp<ScentComponent>(args.Target))
Expand All @@ -158,7 +159,6 @@ private void OnAfterInteract(EntityUid uid, CleansForensicsComponent component,
args.Handled = true;
return;
}
}

if (TryComp<ScentComponent>(args.Target, out var scentComp))
{
Expand Down Expand Up @@ -209,10 +209,8 @@ private void OnCleanForensicsDoAfter(EntityUid uid, ForensicsComponent component
scentComp.Scent = generatedscent;
targetComp.Scent = generatedscent;

if (args.Target is { Valid: true } target)
{
if (_inventory.TryGetSlots(target, out var slotDefinitions))
{
if (args.Target is { Valid: true } target
&& _inventory.TryGetSlots(target, out var slotDefinitions))
foreach (var slot in slotDefinitions)
{
if (!_inventory.TryGetSlotEntity(target, slot.Name, out var slotEnt))
Expand All @@ -223,8 +221,6 @@ private void OnCleanForensicsDoAfter(EntityUid uid, ForensicsComponent component

Dirty(slotEnt.Value, recipientComp);
}
}
}
}

if (args.Target is { Valid: true } targetuid)
Expand Down
25 changes: 12 additions & 13 deletions Content.Server/Forensics/Systems/ScentTrackerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ private void AddVerbs(EntityUid uid, ScentTrackerComponent component, GetVerbsEv

private void TrackScentVerb(EntityUid uid, ScentTrackerComponent component, GetVerbsEvent<InnateVerb> args)
{
if (!args.CanInteract || !args.CanAccess || args.User == args.Target)
if (!args.CanInteract
|| !args.CanAccess
|| args.User == args.Target)
return;

InnateVerb verbTrackScent = new()
Expand Down Expand Up @@ -58,7 +60,9 @@ private void AttemptTrackScent(EntityUid user, EntityUid target, ScentTrackerCom

private void TrackScentDoAfter(Entity<ScentTrackerComponent> entity, ref ScentTrackerDoAfterEvent args)
{
if (args.Handled || args.Cancelled || args.Args.Target == null)
if (args.Handled
|| args.Cancelled
|| args.Args.Target == null)
return;

TrackScent(args.Args.User, args.Args.Target.Value);
Expand All @@ -68,7 +72,8 @@ private void TrackScentDoAfter(Entity<ScentTrackerComponent> entity, ref ScentTr

private void StopTrackScentVerb(EntityUid uid, ScentTrackerComponent component, GetVerbsEvent<InnateVerb> args)
{
if (args.User != args.Target || component.Scent == string.Empty)
if (args.User != args.Target
|| component.Scent == string.Empty)
return;

InnateVerb verbStopTrackScent = new()
Expand All @@ -83,10 +88,8 @@ private void StopTrackScentVerb(EntityUid uid, ScentTrackerComponent component,

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

if (!TryComp<ForensicsComponent>(args.Examined, out var forcomp))
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)
Expand All @@ -96,10 +99,8 @@ private void OnExamine(EntityUid uid, ExaminedEvent args)
#region Utilities
public void TrackScent(EntityUid uid, EntityUid target)
{
if (!TryComp<ScentTrackerComponent>(uid, out var component))
return;

if (!TryComp<ForensicsComponent>(target, out var forcomp))
if (!TryComp<ScentTrackerComponent>(uid, out var component)
|| !TryComp<ForensicsComponent>(target, out var forcomp))
return;

if (forcomp.Scent != string.Empty)
Expand All @@ -108,9 +109,7 @@ public void TrackScent(EntityUid uid, EntityUid target)
_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);
}
Expand Down
8 changes: 4 additions & 4 deletions Content.Shared/Flash/FlashableComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ public sealed partial class FlashableComponent : Component
// <summary>
// Chance to get EyeDamage on flash
// </summary>
[DataField("eyeDamageChance")]
public float EyeDamageChance = 0f;
[DataField]
public float EyeDamageChance;

// <summary>
// How many EyeDamage when flashed? (If EyeDamageChance check passed)
// </summary>
[DataField("eyeDamage")]
public int EyeDamage = 0;
[DataField]
public int EyeDamage;

[DataField]
public CollisionGroup CollisionGroup = CollisionGroup.Opaque;
Expand Down
4 changes: 1 addition & 3 deletions Content.Shared/Forensics/Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ public ForensicPadDoAfterEvent(string sample)
}

[Serializable, NetSerializable]
public sealed partial class ScentTrackerDoAfterEvent : SimpleDoAfterEvent
{
}
public sealed partial class ScentTrackerDoAfterEvent : SimpleDoAfterEvent { }

[Serializable, NetSerializable]
public sealed partial class CleanForensicsDoAfterEvent : SimpleDoAfterEvent
Expand Down
10 changes: 5 additions & 5 deletions Content.Shared/Forensics/ForensicsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ namespace Content.Shared.Forensics
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
public sealed partial class ForensicsComponent : Component
{
[DataField("fingerprints"), AutoNetworkedField]
[DataField, AutoNetworkedField]
public HashSet<string> Fingerprints = new();

[DataField("fibers"), AutoNetworkedField]
[DataField, AutoNetworkedField]
public HashSet<string> Fibers = new();

[DataField("dnas"), AutoNetworkedField]
[DataField, AutoNetworkedField]
public HashSet<string> DNAs = new();

[DataField("scent"), AutoNetworkedField]
[DataField, AutoNetworkedField]
public string Scent = String.Empty;

[DataField("residues"), AutoNetworkedField]
[DataField, AutoNetworkedField]
public HashSet<string> Residues = new();

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions Content.Shared/Forensics/ScentTrackerComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace Content.Shared.Forensics
public sealed partial class ScentTrackerComponent : Component
{
/// <summary>
/// The currently tracked scent.
/// The currently tracked scent.
/// </summary>
[DataField("scent"), AutoNetworkedField]
[DataField, AutoNetworkedField]
public string Scent = String.Empty;

/// <summary>
/// The time (in seconds) that it takes to sniff an entity.
/// The time (in seconds) that it takes to sniff an entity.
/// </summary>
[DataField("sniffDelay")]
[DataField]
public float SniffDelay = 5.0f;
}
}

0 comments on commit 7d87320

Please sign in to comment.