From 663983bfc3ff8e13c21ac5957b33a8599524d758 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Thu, 4 Jan 2024 23:11:26 -0500 Subject: [PATCH] NetSyncEnabled fixes (#23553) NetSyncEnabled fixes --- .../Effects/ColorFlashEffectSystem.cs | 20 +++++++++++++++---- .../Weapons/Ranged/Systems/GunSystem.cs | 11 ++++++++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/Content.Client/Effects/ColorFlashEffectSystem.cs b/Content.Client/Effects/ColorFlashEffectSystem.cs index 9a84401948..af0bd4b600 100644 --- a/Content.Client/Effects/ColorFlashEffectSystem.cs +++ b/Content.Client/Effects/ColorFlashEffectSystem.cs @@ -11,6 +11,7 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem { [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly AnimationPlayerSystem _animation = default!; + [Dependency] private readonly IComponentFactory _factory = default!; /// /// It's a little on the long side but given we use multiple colours denoting what happened it makes it easier to register. @@ -86,8 +87,13 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem continue; } - var player = EnsureComp(ent); - player.NetSyncEnabled = false; + if (!TryComp(ent, out AnimationPlayerComponent? player)) + { + player = (AnimationPlayerComponent) _factory.GetComponent(typeof(AnimationPlayerComponent)); + player.Owner = ent; + player.NetSyncEnabled = false; + AddComp(ent, player); + } // Need to stop the existing animation first to ensure the sprite color is fixed. // Otherwise we might lerp to a red colour instead. @@ -111,8 +117,14 @@ public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem if (animation == null) continue; - var comp = EnsureComp(ent); - comp.NetSyncEnabled = false; + if (!TryComp(ent, out ColorFlashEffectComponent? comp)) + { + comp = (ColorFlashEffectComponent) _factory.GetComponent(typeof(ColorFlashEffectComponent)); + comp.Owner = ent; + comp.NetSyncEnabled = false; + AddComp(ent, comp); + } + comp.Color = sprite.Color; _animation.Play((ent, player), animation, AnimationKey); } diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index 72f0c2130b..e4a95ac2c5 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -31,6 +31,7 @@ public sealed partial class GunSystem : SharedGunSystem [Dependency] private readonly AnimationPlayerSystem _animPlayer = default!; [Dependency] private readonly InputSystem _inputSystem = default!; [Dependency] private readonly SharedCameraRecoilSystem _recoil = default!; + [Dependency] private readonly IComponentFactory _factory = default!; [ValidatePrototypeId] public const string HitscanProto = "HitscanEffect"; @@ -309,8 +310,14 @@ public sealed partial class GunSystem : SharedGunSystem }; _animPlayer.Play(ent, anim, "muzzle-flash"); - var light = EnsureComp(uid); - light.NetSyncEnabled = false; + if (!TryComp(uid, out PointLightComponent? light)) + { + light = (PointLightComponent) _factory.GetComponent(typeof(PointLightComponent)); + light.Owner = uid; + light.NetSyncEnabled = false; + AddComp(uid, light); + } + Lights.SetEnabled(uid, true, light); Lights.SetRadius(uid, 2f, light); Lights.SetColor(uid, Color.FromHex("#cc8e2b"), light); -- 2.51.2