From c9c6bd685b345cda5a0664f9a3ad1b2cb038f199 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 25 Jul 2021 16:58:11 +1000 Subject: [PATCH] Make pushing a toggle (#4330) * Make pushing a toggle * Review --- Content.Shared/CCVar/CCVars.cs | 9 +++++++++ .../EntitySystems/SharedMobMoverSystem.cs | 15 ++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 7d118440f5..3656505a4e 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -181,6 +181,15 @@ namespace Content.Shared.CCVar public static readonly CVarDef StopSpeed = CVarDef.Create("physics.stop_speed", 0.1f); + /// + /// Whether mobs can push objects like lockers. + /// + /// + /// Technically client doesn't need to know about it but this may prevent a bug in the distant future so it stays. + /// + public static readonly CVarDef MobPushing = + CVarDef.Create("physics.mob_pushing", true, CVar.REPLICATED); + /* * Ambience */ diff --git a/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs index 2bee98ca4f..ea7654ce99 100644 --- a/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs @@ -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().KinematicControllerCollision += HandleCollisionMessage; + IoCManager.Resolve().OnValueChanged(CCVars.MobPushing, SetPushing, true); + } + + private void SetPushing(bool value) + { + _pushingEnabled = value; } public override void Shutdown() { base.Shutdown(); + IoCManager.Resolve().UnsubValueChanged(CCVars.MobPushing, SetPushing); Get().KinematicControllerCollision -= HandleCollisionMessage; } @@ -26,6 +37,8 @@ namespace Content.Shared.Movement.EntitySystems /// 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;