[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

@@ -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!;

View File

@@ -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!;

View File

@@ -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);
}
}

View File

@@ -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<MapComponent>(targetXform.GridUid)
? _random.NextAngle()
angle = !HasComp<MapComponent>(targetXform.GridUid)
? _random.NextAngle()
: Angle.Zero;
coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos);

View File

@@ -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;

View File

@@ -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);
}
}
/// <summary>
/// Raised after an entity falls down.
/// </summary>
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<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(EntityUid uid) : EntityEventArgs
{
public EntityUid Uid { get; } = uid;
}

View File

@@ -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);
}