51 lines
1.7 KiB
C#
51 lines
1.7 KiB
C#
|
|
using Content.Shared.GameObjects.Components;
|
|||
|
|
using Robust.Shared.GameObjects;
|
|||
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|||
|
|
using Robust.Shared.IoC;
|
|||
|
|
using Robust.Shared.Log;
|
|||
|
|
using Robust.Shared.Serialization;
|
|||
|
|
|
|||
|
|
namespace Content.Server.GameObjects.Components.PA
|
|||
|
|
{
|
|||
|
|
[RegisterComponent]
|
|||
|
|
[ComponentReference(typeof(ParticleAcceleratorPartComponent))]
|
|||
|
|
public class ParticleAcceleratorEmitterComponent : ParticleAcceleratorPartComponent
|
|||
|
|
{
|
|||
|
|
[Dependency] private IEntityManager _entityManager = null!;
|
|||
|
|
|
|||
|
|
public override string Name => "ParticleAcceleratorEmitter";
|
|||
|
|
public ParticleAcceleratorEmitterType Type;
|
|||
|
|
|
|||
|
|
public override void ExposeData(ObjectSerializer serializer)
|
|||
|
|
{
|
|||
|
|
base.ExposeData(serializer);
|
|||
|
|
|
|||
|
|
serializer.DataField(ref Type, "emitterType", ParticleAcceleratorEmitterType.Center);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void Fire(ParticleAcceleratorPowerState strength)
|
|||
|
|
{
|
|||
|
|
var projectile = _entityManager.SpawnEntity("ParticlesProjectile", Owner.Transform.Coordinates);
|
|||
|
|
|
|||
|
|
if (!projectile.TryGetComponent<ParticleProjectileComponent>(out var particleProjectileComponent))
|
|||
|
|
{
|
|||
|
|
Logger.Error("ParticleAcceleratorEmitter tried firing particles, but they was spawned without a ParticleProjectileComponent");
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
particleProjectileComponent.Fire(strength, Owner.Transform.WorldRotation, Owner);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override string ToString()
|
|||
|
|
{
|
|||
|
|
return base.ToString() + $" EmitterType:{Type}";
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public enum ParticleAcceleratorEmitterType
|
|||
|
|
{
|
|||
|
|
Left,
|
|||
|
|
Center,
|
|||
|
|
Right
|
|||
|
|
}
|
|||
|
|
}
|