Make pushing a toggle (#4330)

* Make pushing a toggle

* Review
This commit is contained in:
metalgearsloth
2021-07-25 16:58:11 +10:00
committed by GitHub
parent 29e335c54d
commit c9c6bd685b
2 changed files with 23 additions and 1 deletions

View File

@@ -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
*/

View File

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