From fec20133d9d6e3b78fc614db0923d417e2bdab8f Mon Sep 17 00:00:00 2001 From: Profane McBane Date: Fri, 7 Feb 2020 23:15:06 +0000 Subject: [PATCH] disable collisions between mobs (#625) --- .../Movement/PlayerInputMoverComponent.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs b/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs index ad4e10921e..1d80e1c9d5 100644 --- a/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs +++ b/Content.Server/GameObjects/Components/Movement/PlayerInputMoverComponent.cs @@ -1,9 +1,11 @@ using Content.Server.Interfaces.GameObjects.Components.Movement; using Robust.Server.GameObjects; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.Components; using Robust.Shared.Log; using Robust.Shared.Map; using Robust.Shared.Maths; +using Robust.Shared.Physics; using Robust.Shared.Serialization; using Robust.Shared.ViewVariables; @@ -14,7 +16,7 @@ namespace Content.Server.GameObjects.Components.Movement /// [RegisterComponent] [ComponentReference(typeof(IMoverComponent))] - public class PlayerInputMoverComponent : Component, IMoverComponent + public class PlayerInputMoverComponent : Component, IMoverComponent, ICollideSpecial { private bool _movingUp; private bool _movingDown; @@ -117,5 +119,21 @@ namespace Content.Server.GameObjects.Components.Movement if (VelocityDir.LengthSquared > 1.0e-6) VelocityDir = VelocityDir.Normalized; } + + /// + /// Special collision override, can be used to give custom behaviors deciding when to collide + /// + /// + /// + bool ICollideSpecial.PreventCollide(IPhysBody collidedwith) + { + // Don't collid with other mobs + if (collidedwith.Owner.TryGetComponent(out var collidedSpeciesComponent)) + { + return true; + } + return false; + } + } }