From 7d873201a7b1789e5a94abd1b61acc6e97b63557 Mon Sep 17 00:00:00 2001 From: FoxxoTrystan <45297731+FoxxoTrystan@users.noreply.github.com> Date: Wed, 14 Aug 2024 05:53:36 +0200 Subject: [PATCH] VM if this breaks im coming to your home at 3am Co-authored-by: VMSolidus Signed-off-by: FoxxoTrystan <45297731+FoxxoTrystan@users.noreply.github.com> --- .../Forensics/ScentTrackerSystem.cs | 15 +++++------ Content.Server/Flash/FlashSystem.cs | 9 +++---- .../Forensics/Components/ScentComponent.cs | 2 +- .../Forensics/Systems/ForensicsSystem.cs | 16 +++++------- .../Forensics/Systems/ScentTrackerSystem.cs | 25 +++++++++---------- Content.Shared/Flash/FlashableComponent.cs | 8 +++--- Content.Shared/Forensics/Events.cs | 4 +-- .../Forensics/ForensicsComponent.cs | 10 ++++---- .../Forensics/ScentTrackerComponent.cs | 8 +++--- 9 files changed, 42 insertions(+), 55 deletions(-) diff --git a/Content.Client/Forensics/ScentTrackerSystem.cs b/Content.Client/Forensics/ScentTrackerSystem.cs index 2cb70773b33..4152fba7476 100644 --- a/Content.Client/Forensics/ScentTrackerSystem.cs +++ b/Content.Client/Forensics/ScentTrackerSystem.cs @@ -19,17 +19,14 @@ public override void Update(float frameTime) var query = AllEntityQuery(); while (query.MoveNext(out var uid, out var comp)) { - if (TryComp(_playerManager.LocalEntity, out var scentcomp)) - { - if (scentcomp.Scent != string.Empty && scentcomp.Scent == comp.Scent) + if (TryComp(_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))); } - } } } } diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index 935e255efb3..f1bb5661658 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -142,13 +142,10 @@ public void Flash(EntityUid target, flashable.Duration = flashDuration / 1000f; // TODO: Make this sane... Dirty(target, flashable); - if (TryComp(target, out var blindable)) - { - if (!blindable.IsBlind && _random.Prob(flashable.EyeDamageChance)) - { + if (TryComp(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); diff --git a/Content.Server/Forensics/Components/ScentComponent.cs b/Content.Server/Forensics/Components/ScentComponent.cs index b4fa69faa13..85331f36126 100644 --- a/Content.Server/Forensics/Components/ScentComponent.cs +++ b/Content.Server/Forensics/Components/ScentComponent.cs @@ -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; } diff --git a/Content.Server/Forensics/Systems/ForensicsSystem.cs b/Content.Server/Forensics/Systems/ForensicsSystem.cs index ed28da30a20..7b95ab23434 100644 --- a/Content.Server/Forensics/Systems/ForensicsSystem.cs +++ b/Content.Server/Forensics/Systems/ForensicsSystem.cs @@ -134,9 +134,10 @@ private void OnAfterInteract(EntityUid uid, CleansForensicsComponent component, if (args.Handled) return; - if (TryComp(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(args.Target, out var forensicsComp) + && (forensicsComp.DNAs.Count > 0 && forensicsComp.CanDnaBeCleaned) + || (forensicsComp.Fingerprints.Count + forensicsComp.Fibers.Count > 0) + || (forensicsComp.Scent != string.Empty)) { var cleanDelay = component.CleanDelay; if (HasComp(args.Target)) @@ -158,7 +159,6 @@ private void OnAfterInteract(EntityUid uid, CleansForensicsComponent component, args.Handled = true; return; } - } if (TryComp(args.Target, out var scentComp)) { @@ -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)) @@ -223,8 +221,6 @@ private void OnCleanForensicsDoAfter(EntityUid uid, ForensicsComponent component Dirty(slotEnt.Value, recipientComp); } - } - } } if (args.Target is { Valid: true } targetuid) diff --git a/Content.Server/Forensics/Systems/ScentTrackerSystem.cs b/Content.Server/Forensics/Systems/ScentTrackerSystem.cs index 67956c7510c..1fdc44162dc 100644 --- a/Content.Server/Forensics/Systems/ScentTrackerSystem.cs +++ b/Content.Server/Forensics/Systems/ScentTrackerSystem.cs @@ -27,7 +27,9 @@ private void AddVerbs(EntityUid uid, ScentTrackerComponent component, GetVerbsEv private void TrackScentVerb(EntityUid uid, ScentTrackerComponent component, GetVerbsEvent args) { - if (!args.CanInteract || !args.CanAccess || args.User == args.Target) + if (!args.CanInteract + || !args.CanAccess + || args.User == args.Target) return; InnateVerb verbTrackScent = new() @@ -58,7 +60,9 @@ private void AttemptTrackScent(EntityUid user, EntityUid target, ScentTrackerCom private void TrackScentDoAfter(Entity 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); @@ -68,7 +72,8 @@ private void TrackScentDoAfter(Entity entity, ref ScentTr private void StopTrackScentVerb(EntityUid uid, ScentTrackerComponent component, GetVerbsEvent args) { - if (args.User != args.Target || component.Scent == string.Empty) + if (args.User != args.Target + || component.Scent == string.Empty) return; InnateVerb verbStopTrackScent = new() @@ -83,10 +88,8 @@ private void StopTrackScentVerb(EntityUid uid, ScentTrackerComponent component, private void OnExamine(EntityUid uid, ExaminedEvent args) { - if (!TryComp(args.Examiner, out var component)) - return; - - if (!TryComp(args.Examined, out var forcomp)) + if (!TryComp(args.Examiner, out var component) + || !TryComp(args.Examined, out var forcomp)) return; if (forcomp.Scent != string.Empty && component.Scent == forcomp.Scent) @@ -96,10 +99,8 @@ private void OnExamine(EntityUid uid, ExaminedEvent args) #region Utilities public void TrackScent(EntityUid uid, EntityUid target) { - if (!TryComp(uid, out var component)) - return; - - if (!TryComp(target, out var forcomp)) + if (!TryComp(uid, out var component) + || !TryComp(target, out var forcomp)) return; if (forcomp.Scent != string.Empty) @@ -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); } diff --git a/Content.Shared/Flash/FlashableComponent.cs b/Content.Shared/Flash/FlashableComponent.cs index e6d8115cf35..1aa378c6986 100644 --- a/Content.Shared/Flash/FlashableComponent.cs +++ b/Content.Shared/Flash/FlashableComponent.cs @@ -13,14 +13,14 @@ public sealed partial class FlashableComponent : Component // // Chance to get EyeDamage on flash // - [DataField("eyeDamageChance")] - public float EyeDamageChance = 0f; + [DataField] + public float EyeDamageChance; // // How many EyeDamage when flashed? (If EyeDamageChance check passed) // - [DataField("eyeDamage")] - public int EyeDamage = 0; + [DataField] + public int EyeDamage; [DataField] public CollisionGroup CollisionGroup = CollisionGroup.Opaque; diff --git a/Content.Shared/Forensics/Events.cs b/Content.Shared/Forensics/Events.cs index c3e0713f861..7f85c35ad02 100644 --- a/Content.Shared/Forensics/Events.cs +++ b/Content.Shared/Forensics/Events.cs @@ -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 diff --git a/Content.Shared/Forensics/ForensicsComponent.cs b/Content.Shared/Forensics/ForensicsComponent.cs index fc578168cc3..8c5be03603e 100644 --- a/Content.Shared/Forensics/ForensicsComponent.cs +++ b/Content.Shared/Forensics/ForensicsComponent.cs @@ -5,19 +5,19 @@ namespace Content.Shared.Forensics [RegisterComponent, NetworkedComponent, AutoGenerateComponentState] public sealed partial class ForensicsComponent : Component { - [DataField("fingerprints"), AutoNetworkedField] + [DataField, AutoNetworkedField] public HashSet Fingerprints = new(); - [DataField("fibers"), AutoNetworkedField] + [DataField, AutoNetworkedField] public HashSet Fibers = new(); - [DataField("dnas"), AutoNetworkedField] + [DataField, AutoNetworkedField] public HashSet DNAs = new(); - [DataField("scent"), AutoNetworkedField] + [DataField, AutoNetworkedField] public string Scent = String.Empty; - [DataField("residues"), AutoNetworkedField] + [DataField, AutoNetworkedField] public HashSet Residues = new(); /// diff --git a/Content.Shared/Forensics/ScentTrackerComponent.cs b/Content.Shared/Forensics/ScentTrackerComponent.cs index a94172c5c71..789ec90adb2 100644 --- a/Content.Shared/Forensics/ScentTrackerComponent.cs +++ b/Content.Shared/Forensics/ScentTrackerComponent.cs @@ -6,15 +6,15 @@ namespace Content.Shared.Forensics public sealed partial class ScentTrackerComponent : Component { /// - /// The currently tracked scent. + /// The currently tracked scent. /// - [DataField("scent"), AutoNetworkedField] + [DataField, AutoNetworkedField] public string Scent = String.Empty; /// - /// The time (in seconds) that it takes to sniff an entity. + /// The time (in seconds) that it takes to sniff an entity. /// - [DataField("sniffDelay")] + [DataField] public float SniffDelay = 5.0f; } }