using SS14.Shared.GameObjects; using SS14.Shared.Interfaces.GameObjects; using SS14.Shared.Interfaces.Physics; using SS14.Shared.Interfaces.GameObjects.Components; using System; using System.Collections.Generic; using YamlDotNet.RepresentationModel; using SS14.Shared.Utility; namespace Content.Server.GameObjects.Components.Projectiles { public class ProjectileComponent : Component, ICollideSpecial, ICollideBehavior { public override string Name => "Projectile"; public bool IgnoreShooter = true; private EntityUid Shooter = EntityUid.Invalid; public Dictionary damages = new Dictionary(); /// /// Function that makes the collision of this object ignore a specific entity so we don't collide with ourselves /// /// public void IgnoreEntity(IEntity shooter) { Shooter = shooter.Uid; } /// /// Special collision override, can be used to give custom behaviors deciding when to collide /// /// /// bool ICollideSpecial.PreventCollide(ICollidable collidedwith) { if (IgnoreShooter && collidedwith.Owner.Uid == Shooter) return true; return false; } /// /// Applys the damage when our projectile collides with its victim /// /// void ICollideBehavior.CollideWith(List collidedwith) { foreach(var entity in collidedwith) { if(entity.TryGetComponent(out DamageableComponent damage)) { damage.TakeDamage(DamageType.Brute, 10); } } if (collidedwith.Count > 0) Owner.Delete(); } } }