From 10dc201704ec788c042a6e0ede4a61d188f2297f Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Wed, 28 Oct 2020 10:12:46 +0100 Subject: [PATCH] Make pulled mobs not collide with other mobs (#2406) --- .../Pulling/SharedPullableComponent.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs index aa566e7dfd..5683665358 100644 --- a/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs +++ b/Content.Shared/GameObjects/Components/Pulling/SharedPullableComponent.cs @@ -1,21 +1,26 @@ #nullable enable using System; using Content.Shared.GameObjects.Components.Mobs; +using Content.Shared.Physics; using Content.Shared.Physics.Pull; using Robust.Shared.Containers; using Robust.Shared.GameObjects; +using Robust.Shared.GameObjects.ComponentDependencies; using Robust.Shared.GameObjects.Components; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Map; +using Robust.Shared.Physics; using Robust.Shared.Serialization; namespace Content.Shared.GameObjects.Components.Pulling { - public abstract class SharedPullableComponent : Component + public abstract class SharedPullableComponent : Component, ICollideSpecial { public override string Name => "Pullable"; public override uint? NetID => ContentNetIDs.PULLABLE; + [ComponentDependency] private IPhysicsComponent? _physics = default!; + private IEntity? _puller; public virtual IEntity? Puller @@ -231,6 +236,16 @@ namespace Content.Shared.GameObjects.Components.Pulling base.OnRemove(); } + + public bool PreventCollide(IPhysBody collidedWith) + { + if (_puller == null || _physics == null) + { + return false; + } + + return (_physics.CollisionLayer & collidedWith.CollisionMask) == (int) CollisionGroup.MobImpassable; + } } [Serializable, NetSerializable]