Merge physics rewrite

This commit is contained in:
Pieter-Jan Briers
2020-05-23 01:23:36 +02:00
parent b6b4482ca0
commit 18ce80a43c
20 changed files with 224 additions and 104 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Content.Server.GameObjects.Components.Access;
using Content.Server.GameObjects.EntitySystems;
using Content.Shared.GameObjects.Components.Doors;
@@ -17,7 +18,7 @@ namespace Content.Server.GameObjects
{
[RegisterComponent]
[ComponentReference(typeof(IActivate))]
public class ServerDoorComponent : Component, IActivate
public class ServerDoorComponent : Component, IActivate, ICollideBehavior
{
public override string Name => "Door";
@@ -85,26 +86,16 @@ namespace Content.Server.GameObjects
ActivateImpl(eventArgs);
}
public override void HandleMessage(ComponentMessage message, IComponent component)
void ICollideBehavior.CollideWith(IEntity entity)
{
base.HandleMessage(message, component);
switch (message)
if (State != DoorState.Closed)
{
case BumpedEntMsg msg:
if (State != DoorState.Closed)
{
return;
}
// Only open when bumped by mobs.
if (!msg.Entity.HasComponent(typeof(SpeciesComponent)))
{
return;
}
TryOpen(msg.Entity);
break;
return;
}
if (entity.HasComponent(typeof(SpeciesComponent)))
{
TryOpen(entity);
}
}
@@ -155,7 +146,7 @@ namespace Content.Server.GameObjects
Timer.Spawn(OpenTimeOne, async () =>
{
collidableComponent.IsHardCollidable = false;
collidableComponent.CanCollide = false;
await Timer.Delay(OpenTimeTwo, _cancellationTokenSource.Token);
@@ -191,14 +182,14 @@ namespace Content.Server.GameObjects
public bool Close()
{
if (collidableComponent.TryCollision(Vector2.Zero))
if (collidableComponent.IsColliding(Vector2.Zero))
{
// Do nothing, somebody's in the door.
return false;
}
State = DoorState.Closing;
collidableComponent.IsHardCollidable = true;
collidableComponent.CanCollide = true;
OpenTimeCounter = 0;
SetAppearance(DoorVisualState.Closing);