removes componentdependencies (#6160)

This commit is contained in:
Paul Ritter
2022-01-15 03:26:37 +01:00
committed by GitHub
parent 46405ec165
commit 9e1607722d
33 changed files with 257 additions and 274 deletions

View File

@@ -3,6 +3,7 @@ using Content.Shared.ActionBlocker;
using Content.Shared.Physics;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.IoC;
using Robust.Shared.Physics;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
@@ -12,15 +13,17 @@ namespace Content.Shared.Climbing
[NetworkedComponent()]
public abstract class SharedClimbingComponent : Component
{
[Dependency] private readonly IEntityManager _entMan = default!;
public sealed override string Name => "Climbing";
protected bool IsOnClimbableThisFrame
{
get
{
if (Body == null) return false;
if (!_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent)) return false;
foreach (var entity in Body.GetBodiesIntersecting())
foreach (var entity in physicsComponent.GetBodiesIntersecting())
{
if ((entity.CollisionLayer & (int) CollisionGroup.SmallImpassable) != 0) return true;
}
@@ -37,22 +40,20 @@ namespace Content.Shared.Climbing
{
if (_ownerIsTransitioning == value) return;
_ownerIsTransitioning = value;
if (Body == null) return;
if (!_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent)) return;
if (value)
{
Body.BodyType = BodyType.Dynamic;
physicsComponent.BodyType = BodyType.Dynamic;
}
else
{
Body.BodyType = BodyType.KinematicController;
physicsComponent.BodyType = BodyType.KinematicController;
}
}
}
private bool _ownerIsTransitioning = false;
[ComponentDependency] protected PhysicsComponent? Body;
protected TimeSpan StartClimbTime = TimeSpan.Zero;
/// <summary>
@@ -78,9 +79,9 @@ namespace Content.Shared.Climbing
private void ToggleSmallPassable(bool value)
{
// Hope the mob has one fixture
if (Body == null || Body.Deleted) return;
if (!_entMan.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent) || physicsComponent.Deleted) return;
foreach (var fixture in Body.Fixtures)
foreach (var fixture in physicsComponent.Fixtures)
{
if (value)
{