[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:
9
Content.Client/Standing/StandingStateSystem.cs
Normal file
9
Content.Client/Standing/StandingStateSystem.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Content.Shared.Standing;
|
||||
using Content.Shared.Standing.Systems;
|
||||
|
||||
namespace Content.Client.Standing;
|
||||
|
||||
public sealed class StandingStateSystem : SharedStandingStateSystem
|
||||
{
|
||||
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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<IEntityManager>();
|
||||
var actionBlocker = entityManager.System<ActionBlockerSystem>();
|
||||
var buckleSystem = entityManager.System<SharedBuckleSystem>();
|
||||
var standingState = entityManager.System<StandingStateSystem>();
|
||||
var standingState = entityManager.System<SharedStandingStateSystem>();
|
||||
var xformSystem = entityManager.System<SharedTransformSystem>();
|
||||
|
||||
EntityUid human = default;
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -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!;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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<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);
|
||||
}
|
||||
}
|
||||
[Dependency] private readonly TransformSystem _transform = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -51,16 +22,43 @@ public sealed class StandingStateSystem : EntitySystem
|
||||
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>
|
||||
/// Raised after an entity falls down.
|
||||
/// </summary>
|
||||
public sealed class FellDownEvent : EntityEventArgs
|
||||
public sealed class FellDownEvent(EntityUid uid) : EntityEventArgs
|
||||
{
|
||||
public EntityUid Uid { get; }
|
||||
public FellDownEvent(EntityUid uid)
|
||||
{
|
||||
Uid = uid;
|
||||
}
|
||||
public EntityUid Uid { get; } = uid;
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Standing;
|
||||
using Content.Shared.Standing.Systems;
|
||||
using Robust.Shared.Containers;
|
||||
|
||||
namespace Content.Shared.Medical.Cryogenics;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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!;
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -32,6 +32,9 @@ public sealed partial class ProjectileComponent : Component
|
||||
[AutoNetworkedField]
|
||||
public EntityUid? Target;
|
||||
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool IgnoreTarget;
|
||||
|
||||
/// <summary>
|
||||
/// The projectile spawns inside the shooter most of the time, this prevents entities from shooting themselves.
|
||||
/// </summary>
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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,15 +14,16 @@ 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;
|
||||
@@ -33,61 +35,20 @@ public sealed class StandingStateSystem : EntitySystem
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<StandingStateComponent, StandingUpDoAfterEvent>(OnStandingUpDoAfter);
|
||||
SubscribeLocalEvent<StandingStateComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed);
|
||||
SubscribeLocalEvent<StandingStateComponent, ProjectileCollideAttemptEvent>(OnProjectileCollideAttempt);
|
||||
SubscribeLocalEvent<StandingStateComponent, HitscanHitAttemptEvent>(OnHitscanHitAttempt);
|
||||
CommandBinds.Builder
|
||||
.Bind(ContentKeyFunctions.LieDown, InputCmdHandler.FromDelegate(ChangeLyingState))
|
||||
.Register<SharedStandingStateSystem>();
|
||||
|
||||
SubscribeNetworkEvent<ChangeStandingStateEvent>(OnChangeState);
|
||||
|
||||
CommandBinds.Builder
|
||||
.Bind(ContentKeyFunctions.LieDown, InputCmdHandler.FromDelegate(ChangeLyingState))
|
||||
.Register<StandingStateSystem>();
|
||||
SubscribeLocalEvent<StandingStateComponent, StandingUpDoAfterEvent>(OnStandingUpDoAfter);
|
||||
SubscribeLocalEvent<StandingStateComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed);
|
||||
SubscribeLocalEvent<StandingStateComponent, SlipAttemptEvent>(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,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>
|
||||
/// Send an update event when player pressed keybind.
|
||||
/// </summary>
|
||||
@@ -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,11 +149,9 @@ 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)
|
||||
@@ -177,7 +170,6 @@ 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;
|
||||
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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!;
|
||||
|
||||
/// <summary>
|
||||
@@ -36,7 +37,6 @@ public abstract class SharedStunSystem : EntitySystem
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<KnockedDownComponent, ComponentInit>(OnKnockInit);
|
||||
SubscribeLocalEvent<KnockedDownComponent, ComponentShutdown>(OnKnockShutdown);
|
||||
SubscribeLocalEvent<KnockedDownComponent, StandAttemptEvent>(OnStandAttempt);
|
||||
|
||||
SubscribeLocalEvent<SlowedDownComponent, ComponentInit>(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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
/// <summary>
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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!;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void Initialize()
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -198,6 +198,7 @@
|
||||
groups:
|
||||
Burn: 10
|
||||
Brute: 10
|
||||
ignoreTarget: true
|
||||
- type: PointLight
|
||||
enabled: true
|
||||
color: "#ff4300"
|
||||
|
||||
Reference in New Issue
Block a user