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

@@ -14,6 +14,7 @@ namespace Content.Server.Climbing.Components
public class ClimbingComponent : SharedClimbingComponent
{
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
public override bool IsClimbing
{
@@ -73,7 +74,7 @@ namespace Content.Server.Climbing.Components
/// </summary>
public void TryMoveTo(Vector2 from, Vector2 to)
{
if (Body == null) return;
if (!_entityManager.TryGetComponent<PhysicsComponent>(Owner, out var physicsComponent)) return;
var velocity = (to - from).Length;
@@ -82,7 +83,7 @@ namespace Content.Server.Climbing.Components
// Since there are bodies with different masses:
// mass * 5 seems enough to move entity
// instead of launching cats like rockets against the walls with constant impulse value.
Body.ApplyLinearImpulse((to - from).Normalized * velocity * Body.Mass * 5);
physicsComponent.ApplyLinearImpulse((to - from).Normalized * velocity * physicsComponent.Mass * 5);
OwnerIsTransitioning = true;
EntitySystem.Get<ClimbSystem>().UnsetTransitionBoolAfterBufferTime(Owner, this);