@@ -181,6 +181,15 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<float> StopSpeed =
|
||||
CVarDef.Create("physics.stop_speed", 0.1f);
|
||||
|
||||
/// <summary>
|
||||
/// Whether mobs can push objects like lockers.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Technically client doesn't need to know about it but this may prevent a bug in the distant future so it stays.
|
||||
/// </remarks>
|
||||
public static readonly CVarDef<bool> MobPushing =
|
||||
CVarDef.Create("physics.mob_pushing", true, CVar.REPLICATED);
|
||||
|
||||
/*
|
||||
* Ambience
|
||||
*/
|
||||
|
||||
@@ -1,23 +1,34 @@
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Collision;
|
||||
using Robust.Shared.Physics.Dynamics;
|
||||
|
||||
namespace Content.Shared.Movement.EntitySystems
|
||||
{
|
||||
public sealed class SharedMobMoverSystem : EntitySystem
|
||||
{
|
||||
private bool _pushingEnabled;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
Get<SharedPhysicsSystem>().KinematicControllerCollision += HandleCollisionMessage;
|
||||
IoCManager.Resolve<IConfigurationManager>().OnValueChanged(CCVars.MobPushing, SetPushing, true);
|
||||
}
|
||||
|
||||
private void SetPushing(bool value)
|
||||
{
|
||||
_pushingEnabled = value;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
base.Shutdown();
|
||||
IoCManager.Resolve<IConfigurationManager>().UnsubValueChanged(CCVars.MobPushing, SetPushing);
|
||||
Get<SharedPhysicsSystem>().KinematicControllerCollision -= HandleCollisionMessage;
|
||||
}
|
||||
|
||||
@@ -26,6 +37,8 @@ namespace Content.Shared.Movement.EntitySystems
|
||||
/// </summary>
|
||||
private void HandleCollisionMessage(Fixture ourFixture, Fixture otherFixture, float frameTime, Vector2 worldNormal)
|
||||
{
|
||||
if (!_pushingEnabled) return;
|
||||
|
||||
var otherBody = otherFixture.Body;
|
||||
|
||||
if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return;
|
||||
|
||||
Reference in New Issue
Block a user