фиксы апстрима и активация колизии
This commit is contained in:
parent
e16e73d714
commit
3145968806
4 changed files with 54 additions and 35 deletions
|
|
@ -1,10 +1,10 @@
|
|||
using Content.Server.DeviceLinking.Events;
|
||||
using Content.Server.DeviceLinking.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Server.PowerCell;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.DeviceLinking.Events;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Popups;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using Content.Shared.Hands.Components;
|
|||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Movement.Systems;
|
||||
using Content.Shared.Standing;
|
||||
using Content.Shared.Throwing;
|
||||
using Robust.Shared.Physics.Components;
|
||||
|
|
@ -14,10 +15,6 @@ namespace Content.Server.Standing;
|
|||
|
||||
public sealed class StandingStateSystem : SharedStandingStateSystem
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly ThrowingSystem _throwingSystem = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
[Dependency] private readonly SharedGravitySystem _gravity = default!;
|
||||
|
||||
public override void Initialize()
|
||||
|
|
@ -25,7 +22,6 @@ public sealed class StandingStateSystem : SharedStandingStateSystem
|
|||
base.Initialize();
|
||||
|
||||
SubscribeNetworkEvent<ChangeLayingDownEvent>(OnChangeState);
|
||||
SubscribeLocalEvent<StandingStateComponent, DropHandItemsEvent>(FallOver);
|
||||
}
|
||||
|
||||
private void OnChangeState(ChangeLayingDownEvent msg, EntitySessionEventArgs args)
|
||||
|
|
@ -43,29 +39,4 @@ public sealed class StandingStateSystem : SharedStandingStateSystem
|
|||
Fall(uid);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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 (!_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ public sealed partial class CCVars
|
|||
/// </summary>
|
||||
[CVarControl(AdminFlags.VarEdit)]
|
||||
public static readonly CVarDef<bool> MovementMobPushing =
|
||||
CVarDef.Create("movement.mob_pushing", false, CVar.SERVER | CVar.REPLICATED);
|
||||
CVarDef.Create("movement.mob_pushing", true, CVar.SERVER | CVar.REPLICATED);
|
||||
|
||||
/// <summary>
|
||||
/// Can we push mobs not moving.
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System.Numerics;
|
||||
using Content.Shared._Sunrise.Jump;
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Buckle;
|
||||
|
|
@ -6,6 +7,7 @@ using Content.Shared.Damage.Systems;
|
|||
using Content.Shared.DoAfter;
|
||||
using Content.Shared.Emoting;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Mobs;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Movement.Events;
|
||||
|
|
@ -19,6 +21,7 @@ using Robust.Shared.Network;
|
|||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Shared.Standing;
|
||||
|
||||
|
|
@ -33,9 +36,10 @@ public abstract class SharedStandingStateSystem : EntitySystem
|
|||
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
|
||||
[Dependency] private readonly SharedRotationVisualsSystem _rotation = default!;
|
||||
[Dependency] private readonly SharedBuckleSystem _buckle = default!;
|
||||
[Dependency] private readonly StaminaSystem _stamina = default!;
|
||||
[Dependency] private readonly SharedStunSystem _stun = default!;
|
||||
[Dependency] private readonly ThrowingSystem _throwing = default!;
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||
|
||||
private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable;
|
||||
|
||||
|
|
@ -47,6 +51,50 @@ public abstract class SharedStandingStateSystem : EntitySystem
|
|||
SubscribeLocalEvent<StandingStateComponent, DownDoAfterEvent>(OnDownDoAfter);
|
||||
SubscribeLocalEvent<StandingStateComponent, MoveEvent>(OnMove);
|
||||
SubscribeLocalEvent<StandingStateComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed);
|
||||
SubscribeLocalEvent<StandingStateComponent, AttemptMobCollideEvent>(OnMobCollide);
|
||||
SubscribeLocalEvent<StandingStateComponent, AttemptMobTargetCollideEvent>(OnMobTargetCollide);
|
||||
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);
|
||||
|
||||
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 (!_handsSystem.TryDrop(uid, hand, checkActionBlocker: false, handsComp: handsComp))
|
||||
continue;
|
||||
|
||||
_throwing.TryThrow(
|
||||
held,
|
||||
_random.NextAngle().RotateVec(direction / dropAngle + worldRotation / 50),
|
||||
0.5f * dropAngle * _random.NextFloat(-0.9f, 1.1f),
|
||||
uid,
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMobTargetCollide(Entity<StandingStateComponent> ent, ref AttemptMobTargetCollideEvent args)
|
||||
{
|
||||
if (ent.Comp.CurrentState == StandingState.Laying)
|
||||
{
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMobCollide(Entity<StandingStateComponent> ent, ref AttemptMobCollideEvent args)
|
||||
{
|
||||
if (ent.Comp.CurrentState == StandingState.Laying)
|
||||
{
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
#region Implementation
|
||||
|
|
@ -146,7 +194,7 @@ public abstract class SharedStandingStateSystem : EntitySystem
|
|||
return _doAfter.TryStartDoAfter(args);
|
||||
}
|
||||
|
||||
public void Fall(EntityUid uid, float rollDistance = 3f, float rollSpeed = 6f)
|
||||
public void Fall(EntityUid uid, float rollDistance = 6f, float rollSpeed = 6f)
|
||||
{
|
||||
if (!TryComp<PhysicsComponent>(uid, out var physics))
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue