diff --git a/Content.Client/Effects/ColorFlashEffectSystem.cs b/Content.Client/Effects/ColorFlashEffectSystem.cs index b14c11a39e..dca675b8df 100644 --- a/Content.Client/Effects/ColorFlashEffectSystem.cs +++ b/Content.Client/Effects/ColorFlashEffectSystem.cs @@ -2,11 +2,14 @@ using Content.Shared.Effects; using Robust.Client.Animations; using Robust.Client.GameObjects; using Robust.Shared.Animations; +using Robust.Shared.Player; +using Robust.Shared.Timing; namespace Content.Client.Effects; -public sealed class ColorFlashEffectSystem : EntitySystem +public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem { + [Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly AnimationPlayerSystem _animation = default!; /// @@ -23,6 +26,14 @@ public sealed class ColorFlashEffectSystem : EntitySystem SubscribeLocalEvent(OnEffectAnimationCompleted); } + public override void RaiseEffect(Color color, List entities, Filter filter) + { + if (!_timing.IsFirstTimePredicted) + return; + + OnColorFlashEffect(new ColorFlashEffectEvent(color, entities)); + } + private void OnEffectAnimationCompleted(EntityUid uid, ColorFlashEffectComponent component, AnimationCompletedEvent args) { if (args.Key != AnimationKey) diff --git a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs index 40b7a4768b..fba9655791 100644 --- a/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Client/Weapons/Melee/MeleeWeaponSystem.cs @@ -15,6 +15,7 @@ using Robust.Client.Player; using Robust.Client.State; using Robust.Shared.Input; using Robust.Shared.Map; +using Robust.Shared.Player; using Robust.Shared.Players; using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -30,6 +31,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem [Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly AnimationPlayerSystem _animation = default!; [Dependency] private readonly InputSystem _inputSystem = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; private EntityQuery _xformQuery; @@ -167,8 +169,7 @@ public sealed partial class MeleeWeaponSystem : SharedMeleeWeaponSystem protected override void DoDamageEffect(List targets, EntityUid? user, TransformComponent targetXform) { // Server never sends the event to us for predictiveeevent. - if (_timing.IsFirstTimePredicted) - RaiseLocalEvent(new ColorFlashEffectEvent(Color.Red, targets)); + _color.RaiseEffect(Color.Red, targets, Filter.Local()); } protected override bool DoDisarm(EntityUid user, DisarmAttackEvent ev, EntityUid meleeUid, MeleeWeaponComponent component, ICommonSession? session) diff --git a/Content.Server/Damage/Systems/DamageOnHighSpeedImpactSystem.cs b/Content.Server/Damage/Systems/DamageOnHighSpeedImpactSystem.cs index 47797582e4..bcd1e0423a 100644 --- a/Content.Server/Damage/Systems/DamageOnHighSpeedImpactSystem.cs +++ b/Content.Server/Damage/Systems/DamageOnHighSpeedImpactSystem.cs @@ -12,11 +12,12 @@ namespace Content.Server.Damage.Systems; public sealed class DamageOnHighSpeedImpactSystem : EntitySystem { - [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IGameTiming _gameTiming = default!; + [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly DamageableSystem _damageable = default!; - [Dependency] private readonly StunSystem _stun = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; + [Dependency] private readonly StunSystem _stun = default!; public override void Initialize() { @@ -50,6 +51,6 @@ public sealed class DamageOnHighSpeedImpactSystem : EntitySystem _damageable.TryChangeDamage(uid, component.Damage * damageScale); _audio.PlayPvs(component.SoundHit, uid, AudioParams.Default.WithVariation(0.125f).WithVolume(-0.125f)); - RaiseNetworkEvent(new ColorFlashEffectEvent(Color.Red, new List { uid }), Filter.Pvs(uid, entityManager: EntityManager)); + _color.RaiseEffect(Color.Red, new List() { uid }, Filter.Pvs(uid, entityManager: EntityManager)); } } diff --git a/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs b/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs index 615caed2d8..6e2f0a23ad 100644 --- a/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs +++ b/Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs @@ -19,11 +19,12 @@ namespace Content.Server.Damage.Systems { [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly GunSystem _guns = default!; - [Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!; - [Dependency] private readonly ThrownItemSystem _thrownItem = default!; - [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly DamageableSystem _damageable = default!; [Dependency] private readonly DamageExamineSystem _damageExamine = default!; + [Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; + [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly ThrownItemSystem _thrownItem = default!; public override void Initialize() { @@ -39,7 +40,7 @@ namespace Content.Server.Damage.Systems if (dmg != null && HasComp(args.Target)) _adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.Total:damage} damage from collision"); - RaiseNetworkEvent(new ColorFlashEffectEvent(Color.Red, new List { args.Target }), Filter.Pvs(args.Target, entityManager: EntityManager)); + _color.RaiseEffect(Color.Red, new List() { args.Target }, Filter.Pvs(args.Target, entityManager: EntityManager)); _guns.PlayImpactSound(args.Target, dmg, null, false); if (TryComp(uid, out var body) && body.LinearVelocity.LengthSquared() > 0f) { diff --git a/Content.Server/Effects/ColorFlashEffectSystem.cs b/Content.Server/Effects/ColorFlashEffectSystem.cs new file mode 100644 index 0000000000..b3cc66a441 --- /dev/null +++ b/Content.Server/Effects/ColorFlashEffectSystem.cs @@ -0,0 +1,12 @@ +using Content.Shared.Effects; +using Robust.Shared.Player; + +namespace Content.Server.Effects; + +public sealed class ColorFlashEffectSystem : SharedColorFlashEffectSystem +{ + public override void RaiseEffect(Color color, List entities, Filter filter) + { + RaiseNetworkEvent(new ColorFlashEffectEvent(color, entities), filter); + } +} diff --git a/Content.Server/Fluids/EntitySystems/PuddleSystem.cs b/Content.Server/Fluids/EntitySystems/PuddleSystem.cs index 387997927c..991bbac6de 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleSystem.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleSystem.cs @@ -43,17 +43,18 @@ public sealed partial class PuddleSystem : SharedPuddleSystem [Dependency] private readonly IMapManager _mapManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly IRobustRandom _random = default!; + [Dependency] private readonly ITileDefinitionManager _tileDefMan = default!; [Dependency] private readonly AudioSystem _audio = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly ReactiveSystem _reactive = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; [Dependency] private readonly SharedPopupSystem _popups = default!; - [Dependency] private readonly StepTriggerSystem _stepTrigger = default!; [Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!; - [Dependency] private readonly TileFrictionController _tile = default!; + [Dependency] private readonly StepTriggerSystem _stepTrigger = default!; [Dependency] private readonly SlowContactsSystem _slowContacts = default!; - [Dependency] private readonly ITileDefinitionManager _tileDefMan = default!; + [Dependency] private readonly TileFrictionController _tile = default!; public static float PuddleVolume = 1000; @@ -518,7 +519,7 @@ public sealed partial class PuddleSystem : SharedPuddleSystem _popups.PopupEntity(Loc.GetString("spill-land-spilled-on-other", ("spillable", uid), ("target", Identity.Entity(owner, EntityManager))), owner, PopupType.SmallCaution); } - RaiseNetworkEvent(new ColorFlashEffectEvent(solution.GetColor(_prototypeManager), targets), Filter.Pvs(uid, entityManager: EntityManager)); + _color.RaiseEffect(solution.GetColor(_prototypeManager), targets, Filter.Pvs(uid, entityManager: EntityManager)); return TrySpillAt(coordinates, solution, out puddleUid, sound); } diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 345f10e852..34aa822a6c 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -1,4 +1,5 @@ using Content.Server.Administration.Logs; +using Content.Server.Effects; using Content.Server.Weapons.Ranged.Systems; using Content.Shared.Camera; using Content.Shared.Damage; @@ -15,6 +16,7 @@ namespace Content.Server.Projectiles; public sealed class ProjectileSystem : SharedProjectileSystem { [Dependency] private readonly IAdminLogManager _adminLogger = default!; + [Dependency] private readonly ColorFlashEffectSystem _color = default!; [Dependency] private readonly DamageableSystem _damageableSystem = default!; [Dependency] private readonly GunSystem _guns = default!; [Dependency] private readonly SharedCameraRecoilSystem _sharedCameraRecoil = default!; @@ -53,7 +55,7 @@ public sealed class ProjectileSystem : SharedProjectileSystem { if (modifiedDamage.Total > FixedPoint2.Zero && !deleted) { - RaiseNetworkEvent(new ColorFlashEffectEvent(Color.Red, new List { target }), Filter.Pvs(target, entityManager: EntityManager)); + _color.RaiseEffect(Color.Red, new List { target }, Filter.Pvs(target, entityManager: EntityManager)); } _adminLogger.Add(LogType.BulletHit, diff --git a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs index 767846fb2d..c8f894ea19 100644 --- a/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapons/Melee/MeleeWeaponSystem.cs @@ -38,13 +38,14 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem { [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly BloodstreamSystem _bloodstream = default!; + [Dependency] private readonly ChatSystem _chat = default!; [Dependency] private readonly ContestsSystem _contests = default!; + [Dependency] private readonly DamageExamineSystem _damageExamine = default!; [Dependency] private readonly InventorySystem _inventory = default!; [Dependency] private readonly LagCompensationSystem _lag = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; [Dependency] private readonly SolutionContainerSystem _solutions = default!; [Dependency] private readonly TagSystem _tag = default!; - [Dependency] private readonly ChatSystem _chat = default!; - [Dependency] private readonly DamageExamineSystem _damageExamine = default!; public override void Initialize() { @@ -191,7 +192,7 @@ public sealed class MeleeWeaponSystem : SharedMeleeWeaponSystem protected override void DoDamageEffect(List targets, EntityUid? user, TransformComponent targetXform) { var filter = Filter.Pvs(targetXform.Coordinates, entityMan: EntityManager).RemoveWhereAttachedEntity(o => o == user); - RaiseNetworkEvent(new ColorFlashEffectEvent(Color.Red, targets), filter); + _color.RaiseEffect(Color.Red, targets, filter); } private float CalculateDisarmChance(EntityUid disarmer, EntityUid disarmed, EntityUid? inTargetHand, CombatModeComponent disarmerComp) diff --git a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs index 43c9f09464..55fd7b5f8d 100644 --- a/Content.Server/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Server/Weapons/Ranged/Systems/GunSystem.cs @@ -34,13 +34,14 @@ public sealed partial class GunSystem : SharedGunSystem { [Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IComponentFactory _factory = default!; - [Dependency] private readonly InteractionSystem _interaction = default!; - [Dependency] private readonly PricingSystem _pricing = default!; - [Dependency] private readonly StaminaSystem _stamina = default!; - [Dependency] private readonly StunSystem _stun = default!; - [Dependency] private readonly SharedTransformSystem _transform = default!; [Dependency] private readonly BatterySystem _battery = default!; [Dependency] private readonly DamageExamineSystem _damageExamine = default!; + [Dependency] private readonly InteractionSystem _interaction = default!; + [Dependency] private readonly PricingSystem _pricing = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; + [Dependency] private readonly StaminaSystem _stamina = default!; + [Dependency] private readonly StunSystem _stun = default!; public const float DamagePitchVariation = SharedMeleeWeaponSystem.DamagePitchVariation; public const float GunClumsyChance = 0.5f; @@ -239,7 +240,9 @@ public sealed partial class GunSystem : SharedGunSystem if (!Deleted(hitEntity)) { if (dmg.Total > FixedPoint2.Zero) - RaiseNetworkEvent(new ColorFlashEffectEvent(Color.Red, new List { hitEntity }), Filter.Pvs(hitEntity, entityManager: EntityManager)); + { + _color.RaiseEffect(Color.Red, new List() { hitEntity }, Filter.Pvs(hitEntity, entityManager: EntityManager)); + } // TODO get fallback position for playing hit sound. PlayImpactSound(hitEntity, dmg, hitscan.Sound, hitscan.ForceSound); diff --git a/Content.Shared/Cuffs/SharedCuffableSystem.cs b/Content.Shared/Cuffs/SharedCuffableSystem.cs index 8de24c3c1f..57b4b19af0 100644 --- a/Content.Shared/Cuffs/SharedCuffableSystem.cs +++ b/Content.Shared/Cuffs/SharedCuffableSystem.cs @@ -43,6 +43,7 @@ namespace Content.Shared.Cuffs [Dependency] private readonly ISharedAdminLogManager _adminLog = default!; [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; [Dependency] private readonly AlertsSystem _alerts = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; [Dependency] private readonly DamageableSystem _damageSystem = default!; [Dependency] private readonly MobStateSystem _mobState = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; @@ -592,7 +593,7 @@ namespace Content.Shared.Cuffs if (target == user) { - RaiseNetworkEvent(new ColorFlashEffectEvent(Color.Red, new List() { user })); + _color.RaiseEffect(Color.Red, new List() { user }, Filter.Pvs(user, entityManager: EntityManager)); _popup.PopupEntity(Loc.GetString("cuffable-component-start-uncuffing-self"), user, user); } else diff --git a/Content.Shared/Damage/Systems/StaminaSystem.cs b/Content.Shared/Damage/Systems/StaminaSystem.cs index eaa041d6d2..d862064f44 100644 --- a/Content.Shared/Damage/Systems/StaminaSystem.cs +++ b/Content.Shared/Damage/Systems/StaminaSystem.cs @@ -28,14 +28,15 @@ namespace Content.Shared.Damage.Systems; public sealed partial class StaminaSystem : EntitySystem { [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly INetManager _net = default!; [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly AlertsSystem _alerts = default!; [Dependency] private readonly MetaDataSystem _metadata = default!; + [Dependency] private readonly SharedColorFlashEffectSystem _color = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedStunSystem _stunSystem = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly INetManager _net = default!; /// /// How much of a buffer is there between the stun duration and when stuns can be re-applied. @@ -328,7 +329,7 @@ public sealed partial class StaminaSystem : EntitySystem if (visual) { - RaiseNetworkEvent(new ColorFlashEffectEvent(Color.Aqua, new List() { uid })); + _color.RaiseEffect(Color.Aqua, new List() { uid }, Filter.Pvs(uid, entityManager: EntityManager)); } if (_net.IsServer) diff --git a/Content.Shared/Effects/ColorFlashEffectEvent.cs b/Content.Shared/Effects/ColorFlashEffectEvent.cs index 7dca9c5f41..0396d39547 100644 --- a/Content.Shared/Effects/ColorFlashEffectEvent.cs +++ b/Content.Shared/Effects/ColorFlashEffectEvent.cs @@ -20,4 +20,4 @@ public sealed class ColorFlashEffectEvent : EntityEventArgs Color = color; Entities = entities; } -} \ No newline at end of file +} diff --git a/Content.Shared/Effects/SharedColorFlashEffectSystem.cs b/Content.Shared/Effects/SharedColorFlashEffectSystem.cs new file mode 100644 index 0000000000..e1d5735550 --- /dev/null +++ b/Content.Shared/Effects/SharedColorFlashEffectSystem.cs @@ -0,0 +1,8 @@ +using Robust.Shared.Player; + +namespace Content.Shared.Effects; + +public abstract class SharedColorFlashEffectSystem : EntitySystem +{ + public abstract void RaiseEffect(Color color, List entities, Filter filter); +} diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index 853e43bb76..3e4b562d8a 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -515,7 +515,7 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem // If the target has stamina and is taking blunt damage, they should also take stamina damage based on their blunt to stamina factor if (damageResult.DamageDict.TryGetValue("Blunt", out var bluntDamage)) { - _stamina.TakeStaminaDamage(ev.Target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float(), source:user, with:meleeUid == user ? null : meleeUid); + _stamina.TakeStaminaDamage(ev.Target.Value, (bluntDamage * component.BluntStaminaDamageFactor).Float(), visual: false, source: user, with: meleeUid == user ? null : meleeUid); } if (meleeUid == user)