Files
tbd-station-14/Content.Server/GameObjects/Components/Projectiles/FlashProjectileComponent.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

51 lines
1.5 KiB
C#

using Content.Server.GameObjects.Components.Weapon;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Server.GameObjects.Components.Projectiles
{
/// <summary>
/// Upon colliding with an object this will flash in an area around it
/// </summary>
[RegisterComponent]
public class FlashProjectileComponent : Component, ICollideBehavior
{
public override string Name => "FlashProjectile";
private float _range;
private float _duration;
private bool _flashed;
public override void ExposeData(ObjectSerializer serializer)
{
base.ExposeData(serializer);
serializer.DataField(ref _range, "range", 1.0f);
serializer.DataField(ref _duration, "duration", 8.0f);
}
public override void Initialize()
{
base.Initialize();
// Shouldn't be using this without a ProjectileComponent because it will just immediately collide with thrower
Owner.EnsureComponent<ProjectileComponent>();
}
void ICollideBehavior.CollideWith(IEntity entity)
{
if (_flashed)
{
return;
}
FlashableComponent.FlashAreaHelper(Owner, _range, _duration);
_flashed = true;
}
// Projectile should handle the deleting
void ICollideBehavior.PostCollide(int collisionCount)
{
return;
}
}
}