diff --git a/Content.Client/Standing/StandingStateSystem.cs b/Content.Client/Standing/StandingStateSystem.cs new file mode 100644 index 0000000000..dcc4b97d2e --- /dev/null +++ b/Content.Client/Standing/StandingStateSystem.cs @@ -0,0 +1,9 @@ +using Content.Shared.Standing; +using Content.Shared.Standing.Systems; + +namespace Content.Client.Standing; + +public sealed class StandingStateSystem : SharedStandingStateSystem +{ + +} \ No newline at end of file diff --git a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs index b3a0cfd5b5..5099e488ae 100644 --- a/Content.Client/Weapons/Ranged/Systems/GunSystem.cs +++ b/Content.Client/Weapons/Ranged/Systems/GunSystem.cs @@ -191,7 +191,7 @@ public sealed partial class GunSystem : SharedGunSystem if (_state.CurrentState is GameplayStateBase screen) shootingTarget = screen.GetClickedEntity(mousePos); - + EntityManager.RaisePredictiveEvent(new RequestShootEvent { Target = GetNetEntity(shootingTarget), @@ -264,10 +264,11 @@ public sealed partial class GunSystem : SharedGunSystem private void Recoil(EntityUid? user, Vector2 recoil, float recoilScalar) { - if (!Timing.IsFirstTimePredicted || user == null || recoil == Vector2.Zero || recoilScalar == 0) + /*if (!Timing.IsFirstTimePredicted || user == null || recoil == Vector2.Zero || recoilScalar == 0) return; - _recoil.KickCamera(user.Value, recoil.Normalized() * 0.5f * recoilScalar); + _recoil.KickCamera(user.Value, recoil.Normalized() * 0.5f * recoilScalar);*/ + // WD EDIT, disabled this due to lying problems } protected override void Popup(string message, EntityUid? uid, EntityUid? user) diff --git a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs index 7c700d9fb8..900c41f0b5 100644 --- a/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs +++ b/Content.IntegrationTests/Tests/Buckle/BuckleTest.cs @@ -8,6 +8,7 @@ using Content.Shared.Buckle.Components; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Robust.Shared.GameObjects; namespace Content.IntegrationTests.Tests.Buckle @@ -58,7 +59,7 @@ namespace Content.IntegrationTests.Tests.Buckle var entityManager = server.ResolveDependency(); var actionBlocker = entityManager.System(); var buckleSystem = entityManager.System(); - var standingState = entityManager.System(); + var standingState = entityManager.System(); var xformSystem = entityManager.System(); EntityUid human = default; diff --git a/Content.Server/Changeling/ChangelingSystem.Abilities.cs b/Content.Server/Changeling/ChangelingSystem.Abilities.cs index 2f6eccd3fa..d05b0845c3 100644 --- a/Content.Server/Changeling/ChangelingSystem.Abilities.cs +++ b/Content.Server/Changeling/ChangelingSystem.Abilities.cs @@ -48,6 +48,7 @@ using Content.Shared.Ninja.Components; using Content.Shared.NPC.Components; using Content.Shared.NPC.Systems; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.StatusEffect; using Content.Shared.Tag; using Robust.Server.Containers; @@ -65,7 +66,7 @@ public sealed partial class ChangelingSystem [Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly DamageableSystem _damage = default!; - [Dependency] private readonly StandingStateSystem _stateSystem = default!; + [Dependency] private readonly SharedStandingStateSystem _stateSystem = default!; [Dependency] private readonly HumanoidAppearanceSystem _humanoidAppearance = default!; [Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly IdentitySystem _identity = default!; diff --git a/Content.Server/Morgue/CrematoriumSystem.cs b/Content.Server/Morgue/CrematoriumSystem.cs index 54b47cff84..0e64f63f78 100644 --- a/Content.Server/Morgue/CrematoriumSystem.cs +++ b/Content.Server/Morgue/CrematoriumSystem.cs @@ -10,6 +10,7 @@ using Content.Shared.Mind; using Content.Shared.Morgue; using Content.Shared.Popups; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Storage; using Content.Shared.Storage.Components; using Content.Shared.Verbs; @@ -28,7 +29,7 @@ public sealed class CrematoriumSystem : EntitySystem [Dependency] private readonly GameTicker _ticker = default!; [Dependency] private readonly EntityStorageSystem _entityStorage = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; - [Dependency] private readonly StandingStateSystem _standing = default!; + [Dependency] private readonly SharedStandingStateSystem _standing = default!; [Dependency] private readonly SharedMindSystem _minds = default!; [Dependency] private readonly SharedContainerSystem _containers = default!; diff --git a/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs b/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs index 10ec54c895..6753d0eca2 100644 --- a/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs +++ b/Content.Server/NPC/Systems/NPCCombatSystem.Ranged.cs @@ -4,6 +4,7 @@ using Content.Shared.Interaction; using Content.Shared.Physics; using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Events; +using Content.Shared.Weapons.Ranged.Systems; using Robust.Shared.Map; using Robust.Shared.Physics.Components; @@ -203,6 +204,7 @@ public sealed partial class NPCCombatSystem return; } + SharedGunSystem.SetTarget(gun, comp.Target); // WD _gun.AttemptShoot(uid, gunUid, gun, targetCordinates); } } diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index e4dbf20b4f..f41e4de3f8 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -586,10 +586,11 @@ public sealed partial class ShuttleSystem { foreach (var child in toKnock) { - if (!_statusQuery.TryGetComponent(child, out var status)) + /*if (!_statusQuery.TryGetComponent(child, out var status)) continue; - _stuns.TryParalyze(child, _hyperspaceKnockdownTime, true, status); + _stuns.TryParalyze(child, _hyperspaceKnockdownTime, true, status);*/ + _standing.TryLieDown(child, dropHeldItems: true); // If the guy we knocked down is on a spaced tile, throw them too if (grid != null) @@ -791,8 +792,8 @@ public sealed partial class ShuttleSystem spawnPos = _transform.GetWorldPosition(targetXform, xformQuery); } - angle = !HasComp(targetXform.GridUid) - ? _random.NextAngle() + angle = !HasComp(targetXform.GridUid) + ? _random.NextAngle() : Angle.Zero; coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos); diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.cs index e25fc7e862..a191d3fb50 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Body.Systems; using Content.Server.Doors.Systems; using Content.Server.Parallax; using Content.Server.Shuttles.Components; +using Content.Server.Standing; using Content.Server.Station.Systems; using Content.Server.Stunnable; using Content.Shared.GameTicking; @@ -50,6 +51,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem [Dependency] private readonly ThrusterSystem _thruster = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!; [Dependency] private readonly InventorySystem _inventory = default!; // WD + [Dependency] private readonly StandingStateSystem _standing = default!; // WD public const float TileMassMultiplier = 0.5f; diff --git a/Content.Server/Standing/StandingStateSystem.cs b/Content.Server/Standing/StandingStateSystem.cs index 903c88d0f3..19fecf4b83 100644 --- a/Content.Server/Standing/StandingStateSystem.cs +++ b/Content.Server/Standing/StandingStateSystem.cs @@ -4,46 +4,17 @@ using Content.Shared.Hands.EntitySystems; using Content.Shared.Standing; using Content.Shared.Throwing; using Content.Shared._White.MagGloves; +using Content.Shared.Standing.Systems; +using Robust.Server.GameObjects; using Robust.Shared.Physics.Components; -using Robust.Shared.Random; namespace Content.Server.Standing; -public sealed class StandingStateSystem : EntitySystem +public sealed class StandingStateSystem : SharedStandingStateSystem { - [Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; [Dependency] private readonly ThrowingSystem _throwingSystem = default!; - - private void FallOver(EntityUid uid, StandingStateComponent component, DropHandItemsEvent args) - { - var direction = EntityManager.TryGetComponent(uid, out PhysicsComponent? comp) ? comp.LinearVelocity / 50 : Vector2.Zero; - var dropAngle = _random.NextFloat(0.8f, 1.2f); - - var fellEvent = new FellDownEvent(uid); - RaiseLocalEvent(uid, fellEvent, false); - - if (!TryComp(uid, out HandsComponent? handsComp)) - return; - - var worldRotation = EntityManager.GetComponent(uid).WorldRotation.ToVec(); - foreach (var hand in handsComp.Hands.Values) - { - if (hand.HeldEntity is not EntityUid held) - continue; - - if (!HasComp(uid)) - { - if (!_handsSystem.TryDrop(uid, hand, null, checkActionBlocker: false, handsComp: handsComp)) - continue; - } - - _throwingSystem.TryThrow(held, - _random.NextAngle().RotateVec(direction / dropAngle + worldRotation / 50), - 0.5f * dropAngle * _random.NextFloat(-0.9f, 1.1f), - uid, 0); - } - } + [Dependency] private readonly TransformSystem _transform = default!; public override void Initialize() { @@ -51,16 +22,43 @@ public sealed class StandingStateSystem : EntitySystem SubscribeLocalEvent(FallOver); } -} - - /// - /// Raised after an entity falls down. - /// - public sealed class FellDownEvent : EntityEventArgs + private void FallOver(EntityUid uid, StandingStateComponent component, DropHandItemsEvent args) { - public EntityUid Uid { get; } - public FellDownEvent(EntityUid uid) + var direction = EntityManager.TryGetComponent(uid, out PhysicsComponent? comp) + ? comp.LinearVelocity / 50 + : Vector2.Zero; + var dropAngle = Random.NextFloat(0.8f, 1.2f); + + var fellEvent = new FellDownEvent(uid); + RaiseLocalEvent(uid, fellEvent); + + if (!TryComp(uid, out HandsComponent? handsComp)) + return; + + var worldRotation = _transform.GetWorldRotation(uid).ToVec(); + foreach (var hand in handsComp.Hands.Values) { - Uid = uid; + if (hand.HeldEntity is not { } held) + continue; + + if (!HasComp(uid)) + { + if (!_handsSystem.TryDrop(uid, hand, checkActionBlocker: false, handsComp: handsComp)) + continue; + } + + _throwingSystem.TryThrow(held, + Random.NextAngle().RotateVec(direction / dropAngle + worldRotation / 50), + 0.5f * dropAngle * Random.NextFloat(-0.9f, 1.1f), + uid, 0); } } +} + +/// +/// Raised after an entity falls down. +/// +public sealed class FellDownEvent(EntityUid uid) : EntityEventArgs +{ + public EntityUid Uid { get; } = uid; +} \ No newline at end of file diff --git a/Content.Server/_White/Carrying/CarryingSystem.cs b/Content.Server/_White/Carrying/CarryingSystem.cs index fc8a78247d..959e58f295 100644 --- a/Content.Server/_White/Carrying/CarryingSystem.cs +++ b/Content.Server/_White/Carrying/CarryingSystem.cs @@ -20,7 +20,7 @@ using Content.Shared.Movement.Pulling.Components; using Content.Shared.Movement.Pulling.Events; using Content.Shared.Movement.Pulling.Systems; using Content.Shared.Movement.Systems; -using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Stunnable; using Content.Shared.Throwing; using Content.Shared.Verbs; @@ -34,7 +34,6 @@ public sealed class CarryingSystem : EntitySystem [Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!; [Dependency] private readonly CarryingSlowdownSystem _slowdown = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!; - [Dependency] private readonly StandingStateSystem _standingState = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly PullingSystem _pullingSystem = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!; @@ -272,7 +271,6 @@ public sealed class CarryingSystem : EntitySystem _actionBlockerSystem.UpdateCanMove(carried); _virtualItemSystem.DeleteInHandsMatching(carrier, carried); _transform.AttachToGridOrMap(carried); - _standingState.Stand(carried); _movementSpeed.RefreshMovementSpeedModifiers(carrier); } diff --git a/Content.Shared/Body/Systems/SharedBodySystem.cs b/Content.Shared/Body/Systems/SharedBodySystem.cs index a45966fcc3..020d5b4be4 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.cs @@ -1,6 +1,7 @@ using Content.Shared.Damage; using Content.Shared.Movement.Systems; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Robust.Shared.Containers; using Robust.Shared.Prototypes; using Robust.Shared.Timing; @@ -34,7 +35,7 @@ public abstract partial class SharedBodySystem : EntitySystem [Dependency] protected readonly MovementSpeedModifierSystem Movement = default!; [Dependency] protected readonly SharedContainerSystem Containers = default!; [Dependency] protected readonly SharedTransformSystem SharedTransform = default!; - [Dependency] protected readonly StandingStateSystem Standing = default!; + [Dependency] protected readonly SharedStandingStateSystem Standing = default!; public override void Initialize() { diff --git a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs index 14bd4503d6..ec4693b3f4 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs @@ -11,6 +11,7 @@ using Content.Shared.Mobs.Components; using Content.Shared.Movement.Events; using Content.Shared.Popups; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Storage.Components; using Content.Shared.Stunnable; using Content.Shared.Throwing; diff --git a/Content.Shared/Buckle/SharedBuckleSystem.cs b/Content.Shared/Buckle/SharedBuckleSystem.cs index 67218657e5..c221de61d3 100644 --- a/Content.Shared/Buckle/SharedBuckleSystem.cs +++ b/Content.Shared/Buckle/SharedBuckleSystem.cs @@ -7,6 +7,7 @@ using Content.Shared.Mobs.Systems; using Content.Shared.Popups; using Content.Shared.Pulling; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; @@ -38,7 +39,7 @@ public abstract partial class SharedBuckleSystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly PullingSystem _pulling = default!; [Dependency] private readonly SharedTransformSystem _transform = default!; - [Dependency] private readonly StandingStateSystem _standing = default!; + [Dependency] private readonly SharedStandingStateSystem _standing = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; /// diff --git a/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs b/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs index f6ce235ff7..eed3ee2f2e 100644 --- a/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs +++ b/Content.Shared/Medical/Cryogenics/SharedCryoPodSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Systems; using Content.Shared.Popups; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Stunnable; using Content.Shared.Verbs; using Robust.Shared.Containers; @@ -19,7 +20,7 @@ namespace Content.Shared.Medical.Cryogenics; public abstract partial class SharedCryoPodSystem: EntitySystem { [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; - [Dependency] private readonly StandingStateSystem _standingStateSystem = default!; + [Dependency] private readonly SharedStandingStateSystem _standingStateSystem = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; diff --git a/Content.Shared/Medical/Cryogenics/SharedInsideCryoPodSystem.cs b/Content.Shared/Medical/Cryogenics/SharedInsideCryoPodSystem.cs index da3604e6e5..a17fc84f01 100644 --- a/Content.Shared/Medical/Cryogenics/SharedInsideCryoPodSystem.cs +++ b/Content.Shared/Medical/Cryogenics/SharedInsideCryoPodSystem.cs @@ -1,4 +1,5 @@ using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Robust.Shared.Containers; namespace Content.Shared.Medical.Cryogenics; diff --git a/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs b/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs index 03f6c8aff4..1f8e1567ab 100644 --- a/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs +++ b/Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs @@ -13,6 +13,7 @@ using Content.Shared.Pointing; using Content.Shared.Pulling.Events; using Content.Shared.Speech; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Strip.Components; using Content.Shared.Throwing; diff --git a/Content.Shared/Mobs/Systems/MobStateSystem.cs b/Content.Shared/Mobs/Systems/MobStateSystem.cs index ff54c30aaf..2234c5bbd6 100644 --- a/Content.Shared/Mobs/Systems/MobStateSystem.cs +++ b/Content.Shared/Mobs/Systems/MobStateSystem.cs @@ -2,6 +2,7 @@ using Content.Shared.ActionBlocker; using Content.Shared.Administration.Logs; using Content.Shared.Mobs.Components; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Robust.Shared.GameStates; using Robust.Shared.Physics.Systems; using Robust.Shared.Timing; @@ -14,7 +15,7 @@ public partial class MobStateSystem : EntitySystem [Dependency] private readonly ActionBlockerSystem _blocker = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; - [Dependency] private readonly StandingStateSystem _standing = default!; + [Dependency] private readonly SharedStandingStateSystem _standing = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ILogManager _logManager = default!; [Dependency] private readonly IGameTiming _timing = default!; diff --git a/Content.Shared/Morgue/EntityStorageLayingDownOverrideSystem.cs b/Content.Shared/Morgue/EntityStorageLayingDownOverrideSystem.cs index 9341168ba3..9e1f77ef0a 100644 --- a/Content.Shared/Morgue/EntityStorageLayingDownOverrideSystem.cs +++ b/Content.Shared/Morgue/EntityStorageLayingDownOverrideSystem.cs @@ -1,13 +1,14 @@ using Content.Shared.Body.Components; using Content.Shared.Morgue.Components; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Storage.Components; namespace Content.Shared.Morgue; public sealed class EntityStorageLayingDownOverrideSystem : EntitySystem { - [Dependency] private readonly StandingStateSystem _standing = default!; + [Dependency] private readonly SharedStandingStateSystem _standing = default!; public override void Initialize() { diff --git a/Content.Shared/Projectiles/ProjectileComponent.cs b/Content.Shared/Projectiles/ProjectileComponent.cs index ea5d35955f..8c156d24e1 100644 --- a/Content.Shared/Projectiles/ProjectileComponent.cs +++ b/Content.Shared/Projectiles/ProjectileComponent.cs @@ -32,6 +32,9 @@ public sealed partial class ProjectileComponent : Component [AutoNetworkedField] public EntityUid? Target; + [DataField, AutoNetworkedField] + public bool IgnoreTarget; + /// /// The projectile spawns inside the shooter most of the time, this prevents entities from shooting themselves. /// diff --git a/Content.Shared/Slippery/SlidingSystem.cs b/Content.Shared/Slippery/SlidingSystem.cs index d44ddc883b..66e94f94ca 100644 --- a/Content.Shared/Slippery/SlidingSystem.cs +++ b/Content.Shared/Slippery/SlidingSystem.cs @@ -1,5 +1,6 @@ using Content.Shared.Movement.Events; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Stunnable; using Robust.Shared.Physics.Events; diff --git a/Content.Shared/Standing/StandingStateComponent.cs b/Content.Shared/Standing/StandingStateComponent.cs index ed9918e235..3db3488084 100644 --- a/Content.Shared/Standing/StandingStateComponent.cs +++ b/Content.Shared/Standing/StandingStateComponent.cs @@ -1,10 +1,11 @@ +using Content.Shared.Standing.Systems; using Robust.Shared.Audio; using Robust.Shared.GameStates; using Robust.Shared.Serialization; namespace Content.Shared.Standing { - [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(StandingStateSystem))] + [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedStandingStateSystem))] public sealed partial class StandingStateComponent : Component { [ViewVariables(VVAccess.ReadWrite), DataField] diff --git a/Content.Shared/Standing/StandingStateSystem.cs b/Content.Shared/Standing/Systems/SharedStandingStateSystem.cs similarity index 83% rename from Content.Shared/Standing/StandingStateSystem.cs rename to Content.Shared/Standing/Systems/SharedStandingStateSystem.cs index 153944373f..26b1e499e2 100644 --- a/Content.Shared/Standing/StandingStateSystem.cs +++ b/Content.Shared/Standing/Systems/SharedStandingStateSystem.cs @@ -1,11 +1,12 @@ using Content.Shared.DoAfter; +using Content.Shared.Gravity; using Content.Shared.Hands.Components; using Content.Shared.Input; using Content.Shared.Movement.Systems; using Content.Shared.Physics; -using Content.Shared.Projectiles; using Content.Shared.Rotation; -using Content.Shared.Weapons.Ranged.Systems; +using Content.Shared.Slippery; +using Content.Shared.Stunnable; using Robust.Shared.Audio.Systems; using Robust.Shared.Input.Binding; using Robust.Shared.Physics; @@ -13,81 +14,41 @@ using Robust.Shared.Physics.Systems; using Robust.Shared.Player; using Robust.Shared.Serialization; -namespace Content.Shared.Standing; +namespace Content.Shared.Standing.Systems; -public sealed class StandingStateSystem : EntitySystem +public abstract partial class SharedStandingStateSystem : EntitySystem { [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; // WD EDIT [Dependency] private readonly MovementSpeedModifierSystem _movement = default!; // WD EDIT + [Dependency] private readonly SharedStunSystem _stun = default!; // WD EDIT // If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited. - private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable; + private const int StandingCollisionLayer = (int)CollisionGroup.MidImpassable; // WD EDIT START - + /// public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnStandingUpDoAfter); - SubscribeLocalEvent(OnRefreshMovementSpeed); - SubscribeLocalEvent(OnProjectileCollideAttempt); - SubscribeLocalEvent(OnHitscanHitAttempt); + CommandBinds.Builder + .Bind(ContentKeyFunctions.LieDown, InputCmdHandler.FromDelegate(ChangeLyingState)) + .Register(); SubscribeNetworkEvent(OnChangeState); - CommandBinds.Builder - .Bind(ContentKeyFunctions.LieDown, InputCmdHandler.FromDelegate(ChangeLyingState)) - .Register(); + SubscribeLocalEvent(OnStandingUpDoAfter); + SubscribeLocalEvent(OnRefreshMovementSpeed); + SubscribeLocalEvent(OnSlipAttempt); + + InitializeColliding(); } - - private void OnRefreshMovementSpeed( - EntityUid uid, - StandingStateComponent component, - RefreshMovementSpeedModifiersEvent args) - { - if (IsDown(uid)) - args.ModifySpeed(0.4f, 0.4f); - else - args.ModifySpeed(1f, 1f); - } - - private void OnProjectileCollideAttempt(EntityUid uid, StandingStateComponent component, ref ProjectileCollideAttemptEvent args) - { - if (component.CurrentState is StandingState.Standing) - { - return; - } - - if (!args.Component.Target.HasValue || args.Component.Target != uid) - { - args.Cancelled = true; - } - } - - private void OnHitscanHitAttempt(EntityUid uid, StandingStateComponent component, ref HitscanHitAttemptEvent args) - { - if (component.CurrentState is StandingState.Standing) - { - return; - } - - if (!args.Target.HasValue || args.Target != uid) - { - args.Cancelled = true; - } - } - - private void OnStandingUpDoAfter(EntityUid uid, StandingStateComponent component, StandingUpDoAfterEvent args) - { - Stand(uid); - _movement.RefreshMovementSpeedModifiers(uid); - } + #region Events private void OnChangeState(ChangeStandingStateEvent ev, EntitySessionEventArgs args) { @@ -98,6 +59,11 @@ public sealed class StandingStateSystem : EntitySystem var uid = args.SenderSession.AttachedEntity.Value; + if (_stun.IsParalyzed(uid)) + { + return; + } + if (IsDown(uid)) { TryStandUp(uid); @@ -108,12 +74,38 @@ public sealed class StandingStateSystem : EntitySystem } } + private void OnStandingUpDoAfter(EntityUid uid, StandingStateComponent component, StandingUpDoAfterEvent args) + { + Stand(uid); + } + + private void OnRefreshMovementSpeed(EntityUid uid, StandingStateComponent component, + RefreshMovementSpeedModifiersEvent args) + { + if (IsDown(uid)) + args.ModifySpeed(0.4f, 0.4f); + else + args.ModifySpeed(1f, 1f); + } + + private void OnSlipAttempt(EntityUid uid, StandingStateComponent component, SlipAttemptEvent args) + { + if (IsDown(uid)) + { + args.Cancel(); + } + } + + #endregion + + #region Methods + /// /// Send an update event when player pressed keybind. /// private void ChangeLyingState(ICommonSession? session) { - if (session?.AttachedEntity == null || + if (session?.AttachedEntity == null || !TryComp(session.AttachedEntity, out StandingStateComponent? standing) || !standing.CanLieDown) { @@ -122,7 +114,7 @@ public sealed class StandingStateSystem : EntitySystem RaiseNetworkEvent(new ChangeStandingStateEvent()); } - + public bool TryStandUp(EntityUid uid, StandingStateComponent? standingState = null) { if (!Resolve(uid, ref standingState, false)) @@ -140,11 +132,14 @@ public sealed class StandingStateSystem : EntitySystem BreakOnHandChange = false }; - _doAfter.TryStartDoAfter(doargs); + if (!_doAfter.TryStartDoAfter(doargs)) + return false; + + standingState.CurrentState = StandingState.GettingUp; return true; } - public bool TryLieDown(EntityUid uid, StandingStateComponent? standingState = null) + public bool TryLieDown(EntityUid uid, StandingStateComponent? standingState = null, bool dropHeldItems = false) { if (!Resolve(uid, ref standingState, false)) return false; @@ -154,13 +149,11 @@ public sealed class StandingStateSystem : EntitySystem return false; } - Down(uid, true, false, standingState); - _movement.RefreshMovementSpeedModifiers(uid); + Down(uid, true, dropHeldItems, standingState); return true; } - // WD EDIT END - + public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null) { if (!Resolve(uid, ref standingState, false)) @@ -177,14 +170,13 @@ public sealed class StandingStateSystem : EntitySystem AppearanceComponent? appearance = null, HandsComponent? hands = null) { - // TODO: This should actually log missing comps... if (!Resolve(uid, ref standingState, false)) return false; // Optional component. Resolve(uid, ref appearance, ref hands, false); - if (standingState.CurrentState is StandingState.Lying or StandingState.GettingUp) + if (standingState.CurrentState is StandingState.Lying or StandingState.GettingUp) return true; // This is just to avoid most callers doing this manually saving boilerplate @@ -230,9 +222,10 @@ public sealed class StandingStateSystem : EntitySystem if (playSound) { - _audio.PlayPredicted(standingState.DownSound, uid, uid); + _audio.PlayPredicted(standingState.DownSound, uid, null); } + _movement.RefreshMovementSpeedModifiers(uid); return true; } @@ -242,7 +235,6 @@ public sealed class StandingStateSystem : EntitySystem AppearanceComponent? appearance = null, bool force = false) { - // TODO: This should actually log missing comps... if (!Resolve(uid, ref standingState, false)) return false; @@ -280,9 +272,12 @@ public sealed class StandingStateSystem : EntitySystem } standingState.ChangedFixtures.Clear(); + _movement.RefreshMovementSpeedModifiers(uid); return true; } + + #endregion } public sealed class DropHandItemsEvent : EventArgs; @@ -309,4 +304,4 @@ public sealed class DownedEvent : EntityEventArgs; // WD EDIT [Serializable, NetSerializable] -public sealed partial class StandingUpDoAfterEvent : SimpleDoAfterEvent; \ No newline at end of file +public sealed partial class StandingUpDoAfterEvent : SimpleDoAfterEvent; diff --git a/Content.Shared/Standing/Systems/StandingStateSystem.Colliding.cs b/Content.Shared/Standing/Systems/StandingStateSystem.Colliding.cs new file mode 100644 index 0000000000..af9c07f2bb --- /dev/null +++ b/Content.Shared/Standing/Systems/StandingStateSystem.Colliding.cs @@ -0,0 +1,68 @@ +using Content.Shared.Mobs.Systems; +using Content.Shared.Movement.Pulling.Components; +using Content.Shared.Projectiles; +using Content.Shared.Weapons.Ranged.Systems; +using Robust.Shared.Physics.Components; +using Robust.Shared.Random; + +namespace Content.Shared.Standing.Systems; + +// WD ADDED +public abstract partial class SharedStandingStateSystem +{ + [Dependency] protected readonly IRobustRandom Random = default!; + [Dependency] private readonly MobStateSystem _mobState = default!; + + private void InitializeColliding() + { + SubscribeLocalEvent(OnProjectileCollideAttempt); + SubscribeLocalEvent(OnHitscanHitAttempt); + } + + private void OnProjectileCollideAttempt(EntityUid uid, StandingStateComponent component, + ref ProjectileCollideAttemptEvent args) + { + if (component.CurrentState is StandingState.Standing) + { + return; + } + + if (!TryHit(uid, args.Component.Target, args.Component.IgnoreTarget)) + { + args.Cancelled = true; + } + } + + private void OnHitscanHitAttempt(EntityUid uid, StandingStateComponent component, ref HitscanHitAttemptEvent args) + { + if (component.CurrentState is StandingState.Standing) + { + return; + } + + if (!TryHit(uid, args.Target)) + { + args.Cancelled = true; + } + } + + private bool TryHit(EntityUid uid, EntityUid? target, bool ignoreTarget = false) + { + // Lying and being pulled + if (!ignoreTarget && TryComp(uid, out PullableComponent? pullable) && pullable.BeingPulled) + return uid == target; + + if (!TryComp(uid, out PhysicsComponent? physics)) + return true; + + // If alive and moving + if (_mobState.IsAlive(uid) && (ignoreTarget || physics.LinearVelocity.LengthSquared() > 0.01f)) + { + // We should hit + return true; + } + + // Only hit if we're target + return uid == target; + } +} diff --git a/Content.Shared/Stunnable/SharedStunSystem.cs b/Content.Shared/Stunnable/SharedStunSystem.cs index e0c5c28318..01ca89ef21 100644 --- a/Content.Shared/Stunnable/SharedStunSystem.cs +++ b/Content.Shared/Stunnable/SharedStunSystem.cs @@ -12,6 +12,7 @@ using Content.Shared.Mobs.Components; using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.StatusEffect; using Content.Shared.Throwing; using Robust.Shared.Audio.Systems; @@ -24,7 +25,7 @@ public abstract class SharedStunSystem : EntitySystem [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; [Dependency] private readonly SharedAudioSystem _audio = default!; - [Dependency] private readonly StandingStateSystem _standingState = default!; + [Dependency] private readonly SharedStandingStateSystem _standingState = default!; [Dependency] private readonly StatusEffectsSystem _statusEffect = default!; /// @@ -36,7 +37,6 @@ public abstract class SharedStunSystem : EntitySystem public override void Initialize() { SubscribeLocalEvent(OnKnockInit); - SubscribeLocalEvent(OnKnockShutdown); SubscribeLocalEvent(OnStandAttempt); SubscribeLocalEvent(OnSlowInit); @@ -106,11 +106,6 @@ public abstract class SharedStunSystem : EntitySystem _standingState.Down(uid); } - private void OnKnockShutdown(EntityUid uid, KnockedDownComponent component, ComponentShutdown args) - { - _standingState.Stand(uid); - } - private void OnStandAttempt(EntityUid uid, KnockedDownComponent component, StandAttemptEvent args) { if (component.LifeStage <= ComponentLifeStage.Running) diff --git a/Content.Shared/Traits/Assorted/LegsParalyzedSystem.cs b/Content.Shared/Traits/Assorted/LegsParalyzedSystem.cs index 7c91366937..4707511cb2 100644 --- a/Content.Shared/Traits/Assorted/LegsParalyzedSystem.cs +++ b/Content.Shared/Traits/Assorted/LegsParalyzedSystem.cs @@ -3,6 +3,7 @@ using Content.Shared.Buckle.Components; using Content.Shared.Movement.Events; using Content.Shared.Movement.Systems; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.Throwing; namespace Content.Shared.Traits.Assorted; @@ -10,7 +11,7 @@ namespace Content.Shared.Traits.Assorted; public sealed class LegsParalyzedSystem : EntitySystem { [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!; - [Dependency] private readonly StandingStateSystem _standingSystem = default!; + [Dependency] private readonly SharedStandingStateSystem _standingSystem = default!; [Dependency] private readonly SharedBodySystem _bodySystem = default!; public override void Initialize() diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index e5b91e876f..ca5db48c8d 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -562,6 +562,11 @@ public abstract partial class SharedGunSystem : EntitySystem RefreshModifiers(weapon); } + + public static void SetTarget(GunComponent gun, EntityUid? target) + { + gun.Target = target; + } // WD EDIT END protected abstract void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null); /// diff --git a/Content.Shared/Weapons/Reflect/ReflectSystem.cs b/Content.Shared/Weapons/Reflect/ReflectSystem.cs index f26cf1d182..6aa6aeb66b 100644 --- a/Content.Shared/Weapons/Reflect/ReflectSystem.cs +++ b/Content.Shared/Weapons/Reflect/ReflectSystem.cs @@ -132,6 +132,8 @@ public sealed class ReflectSystem : EntitySystem _adminLogger.Add(LogType.BulletHit, LogImpact.Medium, $"{ToPrettyString(user)} reflected {ToPrettyString(projectile)} from {ToPrettyString(projectileComp.Weapon)} shot by {projectileComp.Shooter}"); + projectileComp.IgnoreTarget = true; // WD + projectileComp.Shooter = user; projectileComp.Weapon = user; Dirty(projectile, projectileComp); diff --git a/Content.Shared/_White/Chemistry/NarcoticEffect.cs b/Content.Shared/_White/Chemistry/NarcoticEffect.cs index c106f57d1e..620094507c 100644 --- a/Content.Shared/_White/Chemistry/NarcoticEffect.cs +++ b/Content.Shared/_White/Chemistry/NarcoticEffect.cs @@ -5,6 +5,7 @@ using Content.Shared.Damage.Systems; using Content.Shared.Drugs; using Content.Shared.Drunk; using Content.Shared.Standing; +using Content.Shared.Standing.Systems; using Content.Shared.StatusEffect; using Robust.Shared.Random; using Timer = Robust.Shared.Timing.Timer; @@ -16,7 +17,7 @@ public sealed class NarcoticEffect : EntitySystem [Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!; [Dependency] private readonly StaminaSystem _stamina = default!; - [Dependency] private readonly StandingStateSystem _standingStateSystem = default!; + [Dependency] private readonly SharedStandingStateSystem _standingStateSystem = default!; /// public override void Initialize() diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/grenade.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/grenade.yml index a2f96c07f5..47064b955c 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/grenade.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Ammunition/Projectiles/grenade.yml @@ -8,6 +8,7 @@ sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi state: buckshot - type: Projectile + ignoreTarget: true deleteOnCollide: false damage: types: @@ -28,6 +29,7 @@ sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi state: buckshot - type: Projectile + ignoreTarget: true deleteOnCollide: false damage: types: @@ -45,6 +47,7 @@ sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi state: buckshot-flare - type: Projectile + ignoreTarget: true deleteOnCollide: false damage: types: diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml index 097d7703e8..e91a4d0ede 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Projectiles/magic.yml @@ -198,6 +198,7 @@ groups: Burn: 10 Brute: 10 + ignoreTarget: true - type: PointLight enabled: true color: "#ff4300"