[Feat&Fix] Система лежания (#288)

* лежать

* лучше так сделать

* - remove: Gravity is fine.

* - add: Hit moving lying targets.

* - tweak: Lie down insted of stun on FTL.

* - fix: Fix double component.

* - remove: Disable recoil.

---------

Co-authored-by: Aviu00 <aviu00@protonmail.com>
This commit is contained in:
Remuchi
2024-04-22 22:14:23 +07:00
committed by GitHub
parent 026ab3b445
commit 9565de0262
30 changed files with 237 additions and 139 deletions

View File

@@ -0,0 +1,9 @@
using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
namespace Content.Client.Standing;
public sealed class StandingStateSystem : SharedStandingStateSystem
{
}

View File

@@ -264,10 +264,11 @@ public sealed partial class GunSystem : SharedGunSystem
private void Recoil(EntityUid? user, Vector2 recoil, float recoilScalar) 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; 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) protected override void Popup(string message, EntityUid? uid, EntityUid? user)

View File

@@ -8,6 +8,7 @@ using Content.Shared.Buckle.Components;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems; using Content.Shared.Hands.EntitySystems;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.IntegrationTests.Tests.Buckle namespace Content.IntegrationTests.Tests.Buckle
@@ -58,7 +59,7 @@ namespace Content.IntegrationTests.Tests.Buckle
var entityManager = server.ResolveDependency<IEntityManager>(); var entityManager = server.ResolveDependency<IEntityManager>();
var actionBlocker = entityManager.System<ActionBlockerSystem>(); var actionBlocker = entityManager.System<ActionBlockerSystem>();
var buckleSystem = entityManager.System<SharedBuckleSystem>(); var buckleSystem = entityManager.System<SharedBuckleSystem>();
var standingState = entityManager.System<StandingStateSystem>(); var standingState = entityManager.System<SharedStandingStateSystem>();
var xformSystem = entityManager.System<SharedTransformSystem>(); var xformSystem = entityManager.System<SharedTransformSystem>();
EntityUid human = default; EntityUid human = default;

View File

@@ -48,6 +48,7 @@ using Content.Shared.Ninja.Components;
using Content.Shared.NPC.Components; using Content.Shared.NPC.Components;
using Content.Shared.NPC.Systems; using Content.Shared.NPC.Systems;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;
using Content.Shared.Tag; using Content.Shared.Tag;
using Robust.Server.Containers; using Robust.Server.Containers;
@@ -65,7 +66,7 @@ public sealed partial class ChangelingSystem
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!; [Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly DamageableSystem _damage = 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 HumanoidAppearanceSystem _humanoidAppearance = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!; [Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly IdentitySystem _identity = default!; [Dependency] private readonly IdentitySystem _identity = default!;

View File

@@ -10,6 +10,7 @@ using Content.Shared.Mind;
using Content.Shared.Morgue; using Content.Shared.Morgue;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Storage; using Content.Shared.Storage;
using Content.Shared.Storage.Components; using Content.Shared.Storage.Components;
using Content.Shared.Verbs; using Content.Shared.Verbs;
@@ -28,7 +29,7 @@ public sealed class CrematoriumSystem : EntitySystem
[Dependency] private readonly GameTicker _ticker = default!; [Dependency] private readonly GameTicker _ticker = default!;
[Dependency] private readonly EntityStorageSystem _entityStorage = default!; [Dependency] private readonly EntityStorageSystem _entityStorage = default!;
[Dependency] private readonly SharedPopupSystem _popup = 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 SharedMindSystem _minds = default!;
[Dependency] private readonly SharedContainerSystem _containers = default!; [Dependency] private readonly SharedContainerSystem _containers = default!;

View File

@@ -4,6 +4,7 @@ using Content.Shared.Interaction;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Events; using Content.Shared.Weapons.Ranged.Events;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
@@ -203,6 +204,7 @@ public sealed partial class NPCCombatSystem
return; return;
} }
SharedGunSystem.SetTarget(gun, comp.Target); // WD
_gun.AttemptShoot(uid, gunUid, gun, targetCordinates); _gun.AttemptShoot(uid, gunUid, gun, targetCordinates);
} }
} }

View File

@@ -586,10 +586,11 @@ public sealed partial class ShuttleSystem
{ {
foreach (var child in toKnock) foreach (var child in toKnock)
{ {
if (!_statusQuery.TryGetComponent(child, out var status)) /*if (!_statusQuery.TryGetComponent(child, out var status))
continue; 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 the guy we knocked down is on a spaced tile, throw them too
if (grid != null) if (grid != null)

View File

@@ -2,6 +2,7 @@ using Content.Server.Body.Systems;
using Content.Server.Doors.Systems; using Content.Server.Doors.Systems;
using Content.Server.Parallax; using Content.Server.Parallax;
using Content.Server.Shuttles.Components; using Content.Server.Shuttles.Components;
using Content.Server.Standing;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Server.Stunnable; using Content.Server.Stunnable;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
@@ -50,6 +51,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
[Dependency] private readonly ThrusterSystem _thruster = default!; [Dependency] private readonly ThrusterSystem _thruster = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!; [Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly InventorySystem _inventory = default!; // WD [Dependency] private readonly InventorySystem _inventory = default!; // WD
[Dependency] private readonly StandingStateSystem _standing = default!; // WD
public const float TileMassMultiplier = 0.5f; public const float TileMassMultiplier = 0.5f;

View File

@@ -4,46 +4,17 @@ using Content.Shared.Hands.EntitySystems;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Content.Shared._White.MagGloves; using Content.Shared._White.MagGloves;
using Content.Shared.Standing.Systems;
using Robust.Server.GameObjects;
using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Components;
using Robust.Shared.Random;
namespace Content.Server.Standing; 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 SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly ThrowingSystem _throwingSystem = default!; [Dependency] private readonly ThrowingSystem _throwingSystem = default!;
[Dependency] private readonly TransformSystem _transform = 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<TransformComponent>(uid).WorldRotation.ToVec();
foreach (var hand in handsComp.Hands.Values)
{
if (hand.HeldEntity is not EntityUid held)
continue;
if (!HasComp<KeepItemsOnFallComponent>(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);
}
}
public override void Initialize() public override void Initialize()
{ {
@@ -51,16 +22,43 @@ public sealed class StandingStateSystem : EntitySystem
SubscribeLocalEvent<StandingStateComponent, DropHandItemsEvent>(FallOver); SubscribeLocalEvent<StandingStateComponent, DropHandItemsEvent>(FallOver);
} }
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);
if (!TryComp(uid, out HandsComponent? handsComp))
return;
var worldRotation = _transform.GetWorldRotation(uid).ToVec();
foreach (var hand in handsComp.Hands.Values)
{
if (hand.HeldEntity is not { } held)
continue;
if (!HasComp<KeepItemsOnFallComponent>(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);
}
}
} }
/// <summary> /// <summary>
/// Raised after an entity falls down. /// Raised after an entity falls down.
/// </summary> /// </summary>
public sealed class FellDownEvent : EntityEventArgs public sealed class FellDownEvent(EntityUid uid) : EntityEventArgs
{ {
public EntityUid Uid { get; } public EntityUid Uid { get; } = uid;
public FellDownEvent(EntityUid uid) }
{
Uid = uid;
}
}

View File

@@ -20,7 +20,7 @@ using Content.Shared.Movement.Pulling.Components;
using Content.Shared.Movement.Pulling.Events; using Content.Shared.Movement.Pulling.Events;
using Content.Shared.Movement.Pulling.Systems; using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Content.Shared.Standing; using Content.Shared.Standing.Systems;
using Content.Shared.Stunnable; using Content.Shared.Stunnable;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Content.Shared.Verbs; using Content.Shared.Verbs;
@@ -34,7 +34,6 @@ public sealed class CarryingSystem : EntitySystem
[Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!; [Dependency] private readonly VirtualItemSystem _virtualItemSystem = default!;
[Dependency] private readonly CarryingSlowdownSystem _slowdown = default!; [Dependency] private readonly CarryingSlowdownSystem _slowdown = default!;
[Dependency] private readonly DoAfterSystem _doAfterSystem = default!; [Dependency] private readonly DoAfterSystem _doAfterSystem = default!;
[Dependency] private readonly StandingStateSystem _standingState = default!;
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly PullingSystem _pullingSystem = default!; [Dependency] private readonly PullingSystem _pullingSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!; [Dependency] private readonly MobStateSystem _mobStateSystem = default!;
@@ -272,7 +271,6 @@ public sealed class CarryingSystem : EntitySystem
_actionBlockerSystem.UpdateCanMove(carried); _actionBlockerSystem.UpdateCanMove(carried);
_virtualItemSystem.DeleteInHandsMatching(carrier, carried); _virtualItemSystem.DeleteInHandsMatching(carrier, carried);
_transform.AttachToGridOrMap(carried); _transform.AttachToGridOrMap(carried);
_standingState.Stand(carried);
_movementSpeed.RefreshMovementSpeedModifiers(carrier); _movementSpeed.RefreshMovementSpeedModifiers(carrier);
} }

View File

@@ -1,6 +1,7 @@
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -34,7 +35,7 @@ public abstract partial class SharedBodySystem : EntitySystem
[Dependency] protected readonly MovementSpeedModifierSystem Movement = default!; [Dependency] protected readonly MovementSpeedModifierSystem Movement = default!;
[Dependency] protected readonly SharedContainerSystem Containers = default!; [Dependency] protected readonly SharedContainerSystem Containers = default!;
[Dependency] protected readonly SharedTransformSystem SharedTransform = default!; [Dependency] protected readonly SharedTransformSystem SharedTransform = default!;
[Dependency] protected readonly StandingStateSystem Standing = default!; [Dependency] protected readonly SharedStandingStateSystem Standing = default!;
public override void Initialize() public override void Initialize()
{ {

View File

@@ -11,6 +11,7 @@ using Content.Shared.Mobs.Components;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Storage.Components; using Content.Shared.Storage.Components;
using Content.Shared.Stunnable; using Content.Shared.Stunnable;
using Content.Shared.Throwing; using Content.Shared.Throwing;

View File

@@ -7,6 +7,7 @@ using Content.Shared.Mobs.Systems;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Pulling; using Content.Shared.Pulling;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -38,7 +39,7 @@ public abstract partial class SharedBuckleSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly PullingSystem _pulling = default!; [Dependency] private readonly PullingSystem _pulling = default!;
[Dependency] private readonly SharedTransformSystem _transform = 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!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
/// <inheritdoc/> /// <inheritdoc/>

View File

@@ -9,6 +9,7 @@ using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems; using Content.Shared.Mobs.Systems;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Stunnable; using Content.Shared.Stunnable;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Containers; using Robust.Shared.Containers;
@@ -19,7 +20,7 @@ namespace Content.Shared.Medical.Cryogenics;
public abstract partial class SharedCryoPodSystem: EntitySystem public abstract partial class SharedCryoPodSystem: EntitySystem
{ {
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; [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 MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!;

View File

@@ -1,4 +1,5 @@
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Robust.Shared.Containers; using Robust.Shared.Containers;
namespace Content.Shared.Medical.Cryogenics; namespace Content.Shared.Medical.Cryogenics;

View File

@@ -13,6 +13,7 @@ using Content.Shared.Pointing;
using Content.Shared.Pulling.Events; using Content.Shared.Pulling.Events;
using Content.Shared.Speech; using Content.Shared.Speech;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Strip.Components; using Content.Shared.Strip.Components;
using Content.Shared.Throwing; using Content.Shared.Throwing;

View File

@@ -2,6 +2,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Administration.Logs; using Content.Shared.Administration.Logs;
using Content.Shared.Mobs.Components; using Content.Shared.Mobs.Components;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Physics.Systems; using Robust.Shared.Physics.Systems;
using Robust.Shared.Timing; using Robust.Shared.Timing;
@@ -14,7 +15,7 @@ public partial class MobStateSystem : EntitySystem
[Dependency] private readonly ActionBlockerSystem _blocker = default!; [Dependency] private readonly ActionBlockerSystem _blocker = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = 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 ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly ILogManager _logManager = default!; [Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IGameTiming _timing = default!; [Dependency] private readonly IGameTiming _timing = default!;

View File

@@ -1,13 +1,14 @@
using Content.Shared.Body.Components; using Content.Shared.Body.Components;
using Content.Shared.Morgue.Components; using Content.Shared.Morgue.Components;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Storage.Components; using Content.Shared.Storage.Components;
namespace Content.Shared.Morgue; namespace Content.Shared.Morgue;
public sealed class EntityStorageLayingDownOverrideSystem : EntitySystem public sealed class EntityStorageLayingDownOverrideSystem : EntitySystem
{ {
[Dependency] private readonly StandingStateSystem _standing = default!; [Dependency] private readonly SharedStandingStateSystem _standing = default!;
public override void Initialize() public override void Initialize()
{ {

View File

@@ -32,6 +32,9 @@ public sealed partial class ProjectileComponent : Component
[AutoNetworkedField] [AutoNetworkedField]
public EntityUid? Target; public EntityUid? Target;
[DataField, AutoNetworkedField]
public bool IgnoreTarget;
/// <summary> /// <summary>
/// The projectile spawns inside the shooter most of the time, this prevents entities from shooting themselves. /// The projectile spawns inside the shooter most of the time, this prevents entities from shooting themselves.
/// </summary> /// </summary>

View File

@@ -1,5 +1,6 @@
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Stunnable; using Content.Shared.Stunnable;
using Robust.Shared.Physics.Events; using Robust.Shared.Physics.Events;

View File

@@ -1,10 +1,11 @@
using Content.Shared.Standing.Systems;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
namespace Content.Shared.Standing namespace Content.Shared.Standing
{ {
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(StandingStateSystem))] [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, Access(typeof(SharedStandingStateSystem))]
public sealed partial class StandingStateComponent : Component public sealed partial class StandingStateComponent : Component
{ {
[ViewVariables(VVAccess.ReadWrite), DataField] [ViewVariables(VVAccess.ReadWrite), DataField]

View File

@@ -1,11 +1,12 @@
using Content.Shared.DoAfter; using Content.Shared.DoAfter;
using Content.Shared.Gravity;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Input; using Content.Shared.Input;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Projectiles;
using Content.Shared.Rotation; 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.Audio.Systems;
using Robust.Shared.Input.Binding; using Robust.Shared.Input.Binding;
using Robust.Shared.Physics; using Robust.Shared.Physics;
@@ -13,18 +14,19 @@ using Robust.Shared.Physics.Systems;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Serialization; 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 SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!; // WD EDIT [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; // WD EDIT
[Dependency] private readonly MovementSpeedModifierSystem _movement = 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. // 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 // WD EDIT START
@@ -33,61 +35,20 @@ public sealed class StandingStateSystem : EntitySystem
{ {
base.Initialize(); base.Initialize();
SubscribeLocalEvent<StandingStateComponent, StandingUpDoAfterEvent>(OnStandingUpDoAfter); CommandBinds.Builder
SubscribeLocalEvent<StandingStateComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed); .Bind(ContentKeyFunctions.LieDown, InputCmdHandler.FromDelegate(ChangeLyingState))
SubscribeLocalEvent<StandingStateComponent, ProjectileCollideAttemptEvent>(OnProjectileCollideAttempt); .Register<SharedStandingStateSystem>();
SubscribeLocalEvent<StandingStateComponent, HitscanHitAttemptEvent>(OnHitscanHitAttempt);
SubscribeNetworkEvent<ChangeStandingStateEvent>(OnChangeState); SubscribeNetworkEvent<ChangeStandingStateEvent>(OnChangeState);
CommandBinds.Builder SubscribeLocalEvent<StandingStateComponent, StandingUpDoAfterEvent>(OnStandingUpDoAfter);
.Bind(ContentKeyFunctions.LieDown, InputCmdHandler.FromDelegate(ChangeLyingState)) SubscribeLocalEvent<StandingStateComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed);
.Register<StandingStateSystem>(); SubscribeLocalEvent<StandingStateComponent, SlipAttemptEvent>(OnSlipAttempt);
InitializeColliding();
} }
#region Events
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);
}
private void OnChangeState(ChangeStandingStateEvent ev, EntitySessionEventArgs args) private void OnChangeState(ChangeStandingStateEvent ev, EntitySessionEventArgs args)
{ {
@@ -98,6 +59,11 @@ public sealed class StandingStateSystem : EntitySystem
var uid = args.SenderSession.AttachedEntity.Value; var uid = args.SenderSession.AttachedEntity.Value;
if (_stun.IsParalyzed(uid))
{
return;
}
if (IsDown(uid)) if (IsDown(uid))
{ {
TryStandUp(uid); TryStandUp(uid);
@@ -108,6 +74,32 @@ 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
/// <summary> /// <summary>
/// Send an update event when player pressed keybind. /// Send an update event when player pressed keybind.
/// </summary> /// </summary>
@@ -140,11 +132,14 @@ public sealed class StandingStateSystem : EntitySystem
BreakOnHandChange = false BreakOnHandChange = false
}; };
_doAfter.TryStartDoAfter(doargs); if (!_doAfter.TryStartDoAfter(doargs))
return false;
standingState.CurrentState = StandingState.GettingUp;
return true; 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)) if (!Resolve(uid, ref standingState, false))
return false; return false;
@@ -154,11 +149,9 @@ public sealed class StandingStateSystem : EntitySystem
return false; return false;
} }
Down(uid, true, false, standingState); Down(uid, true, dropHeldItems, standingState);
_movement.RefreshMovementSpeedModifiers(uid);
return true; return true;
} }
// WD EDIT END // WD EDIT END
public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null) public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null)
@@ -177,7 +170,6 @@ public sealed class StandingStateSystem : EntitySystem
AppearanceComponent? appearance = null, AppearanceComponent? appearance = null,
HandsComponent? hands = null) HandsComponent? hands = null)
{ {
// TODO: This should actually log missing comps...
if (!Resolve(uid, ref standingState, false)) if (!Resolve(uid, ref standingState, false))
return false; return false;
@@ -230,9 +222,10 @@ public sealed class StandingStateSystem : EntitySystem
if (playSound) if (playSound)
{ {
_audio.PlayPredicted(standingState.DownSound, uid, uid); _audio.PlayPredicted(standingState.DownSound, uid, null);
} }
_movement.RefreshMovementSpeedModifiers(uid);
return true; return true;
} }
@@ -242,7 +235,6 @@ public sealed class StandingStateSystem : EntitySystem
AppearanceComponent? appearance = null, AppearanceComponent? appearance = null,
bool force = false) bool force = false)
{ {
// TODO: This should actually log missing comps...
if (!Resolve(uid, ref standingState, false)) if (!Resolve(uid, ref standingState, false))
return false; return false;
@@ -280,9 +272,12 @@ public sealed class StandingStateSystem : EntitySystem
} }
standingState.ChangedFixtures.Clear(); standingState.ChangedFixtures.Clear();
_movement.RefreshMovementSpeedModifiers(uid);
return true; return true;
} }
#endregion
} }
public sealed class DropHandItemsEvent : EventArgs; public sealed class DropHandItemsEvent : EventArgs;

View File

@@ -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<StandingStateComponent, ProjectileCollideAttemptEvent>(OnProjectileCollideAttempt);
SubscribeLocalEvent<StandingStateComponent, HitscanHitAttemptEvent>(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;
}
}

View File

@@ -12,6 +12,7 @@ using Content.Shared.Mobs.Components;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;
using Content.Shared.Throwing; using Content.Shared.Throwing;
using Robust.Shared.Audio.Systems; using Robust.Shared.Audio.Systems;
@@ -24,7 +25,7 @@ public abstract class SharedStunSystem : EntitySystem
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!; [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifier = default!;
[Dependency] private readonly SharedAudioSystem _audio = 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!; [Dependency] private readonly StatusEffectsSystem _statusEffect = default!;
/// <summary> /// <summary>
@@ -36,7 +37,6 @@ public abstract class SharedStunSystem : EntitySystem
public override void Initialize() public override void Initialize()
{ {
SubscribeLocalEvent<KnockedDownComponent, ComponentInit>(OnKnockInit); SubscribeLocalEvent<KnockedDownComponent, ComponentInit>(OnKnockInit);
SubscribeLocalEvent<KnockedDownComponent, ComponentShutdown>(OnKnockShutdown);
SubscribeLocalEvent<KnockedDownComponent, StandAttemptEvent>(OnStandAttempt); SubscribeLocalEvent<KnockedDownComponent, StandAttemptEvent>(OnStandAttempt);
SubscribeLocalEvent<SlowedDownComponent, ComponentInit>(OnSlowInit); SubscribeLocalEvent<SlowedDownComponent, ComponentInit>(OnSlowInit);
@@ -106,11 +106,6 @@ public abstract class SharedStunSystem : EntitySystem
_standingState.Down(uid); _standingState.Down(uid);
} }
private void OnKnockShutdown(EntityUid uid, KnockedDownComponent component, ComponentShutdown args)
{
_standingState.Stand(uid);
}
private void OnStandAttempt(EntityUid uid, KnockedDownComponent component, StandAttemptEvent args) private void OnStandAttempt(EntityUid uid, KnockedDownComponent component, StandAttemptEvent args)
{ {
if (component.LifeStage <= ComponentLifeStage.Running) if (component.LifeStage <= ComponentLifeStage.Running)

View File

@@ -3,6 +3,7 @@ using Content.Shared.Buckle.Components;
using Content.Shared.Movement.Events; using Content.Shared.Movement.Events;
using Content.Shared.Movement.Systems; using Content.Shared.Movement.Systems;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Throwing; using Content.Shared.Throwing;
namespace Content.Shared.Traits.Assorted; namespace Content.Shared.Traits.Assorted;
@@ -10,7 +11,7 @@ namespace Content.Shared.Traits.Assorted;
public sealed class LegsParalyzedSystem : EntitySystem public sealed class LegsParalyzedSystem : EntitySystem
{ {
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!; [Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
[Dependency] private readonly StandingStateSystem _standingSystem = default!; [Dependency] private readonly SharedStandingStateSystem _standingSystem = default!;
[Dependency] private readonly SharedBodySystem _bodySystem = default!; [Dependency] private readonly SharedBodySystem _bodySystem = default!;
public override void Initialize() public override void Initialize()

View File

@@ -562,6 +562,11 @@ public abstract partial class SharedGunSystem : EntitySystem
RefreshModifiers(weapon); RefreshModifiers(weapon);
} }
public static void SetTarget(GunComponent gun, EntityUid? target)
{
gun.Target = target;
}
// WD EDIT END // WD EDIT END
protected abstract void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null); protected abstract void CreateEffect(EntityUid uid, MuzzleFlashEvent message, EntityUid? user = null);
/// <summary> /// <summary>

View File

@@ -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}"); _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.Shooter = user;
projectileComp.Weapon = user; projectileComp.Weapon = user;
Dirty(projectile, projectileComp); Dirty(projectile, projectileComp);

View File

@@ -5,6 +5,7 @@ using Content.Shared.Damage.Systems;
using Content.Shared.Drugs; using Content.Shared.Drugs;
using Content.Shared.Drunk; using Content.Shared.Drunk;
using Content.Shared.Standing; using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.StatusEffect; using Content.Shared.StatusEffect;
using Robust.Shared.Random; using Robust.Shared.Random;
using Timer = Robust.Shared.Timing.Timer; using Timer = Robust.Shared.Timing.Timer;
@@ -16,7 +17,7 @@ public sealed class NarcoticEffect : EntitySystem
[Dependency] private readonly IRobustRandom _robustRandom = default!; [Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!; [Dependency] private readonly StatusEffectsSystem _statusEffectsSystem = default!;
[Dependency] private readonly StaminaSystem _stamina = default!; [Dependency] private readonly StaminaSystem _stamina = default!;
[Dependency] private readonly StandingStateSystem _standingStateSystem = default!; [Dependency] private readonly SharedStandingStateSystem _standingStateSystem = default!;
/// <inheritdoc/> /// <inheritdoc/>
public override void Initialize() public override void Initialize()

View File

@@ -8,6 +8,7 @@
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
state: buckshot state: buckshot
- type: Projectile - type: Projectile
ignoreTarget: true
deleteOnCollide: false deleteOnCollide: false
damage: damage:
types: types:
@@ -28,6 +29,7 @@
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
state: buckshot state: buckshot
- type: Projectile - type: Projectile
ignoreTarget: true
deleteOnCollide: false deleteOnCollide: false
damage: damage:
types: types:
@@ -45,6 +47,7 @@
sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi sprite: Objects/Weapons/Guns/Projectiles/projectiles2.rsi
state: buckshot-flare state: buckshot-flare
- type: Projectile - type: Projectile
ignoreTarget: true
deleteOnCollide: false deleteOnCollide: false
damage: damage:
types: types:

View File

@@ -198,6 +198,7 @@
groups: groups:
Burn: 10 Burn: 10
Brute: 10 Brute: 10
ignoreTarget: true
- type: PointLight - type: PointLight
enabled: true enabled: true
color: "#ff4300" color: "#ff4300"