Converted everything to use collision and physics component interfaces.

This commit is contained in:
Acruid
2020-07-19 00:33:02 -07:00
parent ea94f4a182
commit c9374992a6
29 changed files with 75 additions and 75 deletions

View File

@@ -36,7 +36,7 @@ namespace Content.Server.GameObjects
protected const float AutoCloseDelay = 5;
protected float CloseSpeed = AutoCloseDelay;
private CollidableComponent collidableComponent;
private ICollidableComponent _collidableComponent;
private AppearanceComponent _appearance;
private CancellationTokenSource _cancellationTokenSource;
@@ -64,7 +64,7 @@ namespace Content.Server.GameObjects
{
base.Initialize();
collidableComponent = Owner.GetComponent<CollidableComponent>();
_collidableComponent = Owner.GetComponent<ICollidableComponent>();
_appearance = Owner.GetComponent<AppearanceComponent>();
_cancellationTokenSource = new CancellationTokenSource();
}
@@ -72,7 +72,7 @@ namespace Content.Server.GameObjects
public override void OnRemove()
{
_cancellationTokenSource.Cancel();
collidableComponent = null;
_collidableComponent = null;
_appearance = null;
base.OnRemove();
@@ -164,7 +164,7 @@ namespace Content.Server.GameObjects
Timer.Spawn(OpenTimeOne, async () =>
{
collidableComponent.Hard = false;
_collidableComponent.Hard = false;
await Timer.Delay(OpenTimeTwo, _cancellationTokenSource.Token);
@@ -203,7 +203,7 @@ namespace Content.Server.GameObjects
private void CheckCrush()
{
// Check if collides with something
var collidesWith = collidableComponent.GetCollidingEntities(Vector2.Zero, false);
var collidesWith = _collidableComponent.GetCollidingEntities(Vector2.Zero, false);
if (collidesWith.Count() != 0)
{
// Crush
@@ -236,7 +236,7 @@ namespace Content.Server.GameObjects
public bool Close()
{
bool shouldCheckCrush = false;
if (collidableComponent.IsColliding(Vector2.Zero, false))
if (_collidableComponent.IsColliding(Vector2.Zero, false))
{
if (Safety)
return false;
@@ -260,7 +260,7 @@ namespace Content.Server.GameObjects
CheckCrush();
}
collidableComponent.Hard = true;
_collidableComponent.Hard = true;
await Timer.Delay(CloseTimeTwo, _cancellationTokenSource.Token);