Files
tbd-station-14/Content.Server/GameObjects/Components/Projectiles/ProjectileComponent.cs
clusterfack 37df61113e Species Component (#130)
* Fix this
fug
oksure
Creates the initial species component, damage states, and threshold templates and hooks them into the damageable component

* More rebase fixes

* test

* Pre future rebase

* Please

* Lol

* Lol2

* SHADERS

* Update Engine

* yml file

* Fix an initialization issue, injects dependencies

* Fix error in loading shaders

* Makes a master character ui controller component added upon client attachment to entity and remove upon client detachment from entity

* Fixes just about everytrhing

* Address PJB's comments

* geeze

* Make overlays work in worldspace instead of screen space and not cover user interfaces

* update submodule
2018-12-13 14:47:18 +01:00

63 lines
2.0 KiB
C#

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;
using Content.Shared.GameObjects;
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<DamageType, int> damages = new Dictionary<DamageType, int>();
/// <summary>
/// Function that makes the collision of this object ignore a specific entity so we don't collide with ourselves
/// </summary>
/// <param name="shooter"></param>
public void IgnoreEntity(IEntity shooter)
{
Shooter = shooter.Uid;
}
/// <summary>
/// Special collision override, can be used to give custom behaviors deciding when to collide
/// </summary>
/// <param name="collidedwith"></param>
/// <returns></returns>
bool ICollideSpecial.PreventCollide(ICollidable collidedwith)
{
if (IgnoreShooter && collidedwith.Owner.Uid == Shooter)
return true;
return false;
}
/// <summary>
/// Applys the damage when our projectile collides with its victim
/// </summary>
/// <param name="collidedwith"></param>
void ICollideBehavior.CollideWith(List<IEntity> collidedwith)
{
foreach(var entity in collidedwith)
{
if(entity.TryGetComponent(out DamageableComponent damage))
{
damage.TakeDamage(DamageType.Brute, 10);
}
}
if (collidedwith.Count > 0)
Owner.Delete();
}
}
}