Thrown Item Physics (#120)
* Thrown object speed is now based on force. Fixed BoundingBox namespace. * 100% more throwing. CollisionGroup enum. * Update Engine.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
fc7493e149
commit
d186f18c20
@@ -0,0 +1,36 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.GameObjects.Components.Projectiles;
|
||||
using Content.Shared.Physics;
|
||||
using SS14.Shared.Interfaces.GameObjects;
|
||||
using SS14.Shared.Interfaces.GameObjects.Components;
|
||||
|
||||
namespace Content.Server.GameObjects.Components
|
||||
{
|
||||
class ThrownItemComponent : ProjectileComponent, ICollideBehavior
|
||||
{
|
||||
public override string Name => "ThrownItem";
|
||||
|
||||
void ICollideBehavior.CollideWith(List<IEntity> collidedwith)
|
||||
{
|
||||
foreach (var entity in collidedwith)
|
||||
{
|
||||
if (entity.TryGetComponent(out DamageableComponent damage))
|
||||
{
|
||||
damage.TakeDamage(DamageType.Brute, 10);
|
||||
}
|
||||
}
|
||||
|
||||
// Stop colliding with mobs, this mimics not having enough velocity to do damage
|
||||
// after impacting the first object.
|
||||
// For realism this should actually be changed when the velocity of the object is less than a threshold.
|
||||
// This would allow ricochets off walls, and weird gravity effects from slowing the object.
|
||||
if (collidedwith.Count > 0 && Owner.TryGetComponent(out ICollidableComponent body))
|
||||
{
|
||||
body.CollisionMask &= (int) ~CollisionGroup.Mob;
|
||||
|
||||
// KYS, your job is finished.
|
||||
Owner.RemoveComponent<ThrownItemComponent>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user