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

@@ -62,36 +62,32 @@ namespace Content.Server.GameObjects.Components.Projectiles
}
/// <summary>
/// Applys the damage when our projectile collides with its victim
/// Applies the damage when our projectile collides with its victim
/// </summary>
/// <param name="collidedwith"></param>
void ICollideBehavior.CollideWith(List<IEntity> collidedwith)
/// <param name="entity"></param>
void ICollideBehavior.CollideWith(IEntity entity)
{
foreach (var entity in collidedwith)
if (entity.TryGetComponent(out DamageableComponent damage))
{
if (entity.TryGetComponent(out DamageableComponent damage))
Owner.EntityManager.TryGetEntity(Shooter, out var shooter);
foreach (var (damageType, amount) in _damages)
{
Owner.EntityManager.TryGetEntity(Shooter, out var shooter);
foreach (var (damageType, amount) in _damages)
{
damage.TakeDamage(damageType, amount, Owner, shooter);
}
}
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
&& Owner.TryGetComponent(out PhysicsComponent physicsComponent))
{
var direction = physicsComponent.LinearVelocity.Normalized;
recoilComponent.Kick(direction);
damage.TakeDamage(damageType, amount, Owner, shooter);
}
}
if (collidedwith.Count > 0)
if (!entity.Deleted && entity.TryGetComponent(out CameraRecoilComponent recoilComponent)
&& Owner.TryGetComponent(out PhysicsComponent physicsComponent))
{
Owner.Delete();
var direction = physicsComponent.LinearVelocity.Normalized;
recoilComponent.Kick(direction);
}
}
void ICollideBehavior.PostCollide(int collideCount)
{
if (collideCount > 0) Owner.Delete();
}
}
}