* Cleanup warnings in ClickableSystem * Cleanup warnings in FultonSystem * Cleanup warning in HolidaySystem * Cleanup warning in DoAfterOverlay * Cleanup warning in EntityHealthBarOverlay * Cleanup warning in SmokeVisualizerSystem * Cleanup warning in VaporVisualizerSystem * Cleanup warning in ColorFlashEffectSystem * Cleanup warnings in StealthSystem * Cleanup warnings in TrayScannerSystem * Cleanup warnings in InventoryUIController * Cleanup warnings in HideMechanismsCommand * Cleanup warning in ShowMechanismsCommand * Cleanup warnings in EntityPickupAnimationSystem * Cleanup warnings in PointingSystem * Cleanup warning in StickyVisualizerSystem * Cleanup warnings in TabletopSystem * Cleanup warnings in PillSystem * Cleanup warnings in DiceSystem * Cleanup warnings in ProjectileSystem
59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using Content.Shared.Projectiles;
|
|
using Content.Shared.Weapons.Ranged.Systems;
|
|
using Robust.Client.Animations;
|
|
using Robust.Client.GameObjects;
|
|
using TimedDespawnComponent = Robust.Shared.Spawners.TimedDespawnComponent;
|
|
|
|
namespace Content.Client.Projectiles;
|
|
|
|
public sealed class ProjectileSystem : SharedProjectileSystem
|
|
{
|
|
[Dependency] private readonly AnimationPlayerSystem _player = default!;
|
|
[Dependency] private readonly SpriteSystem _sprite = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeNetworkEvent<ImpactEffectEvent>(OnProjectileImpact);
|
|
}
|
|
|
|
private void OnProjectileImpact(ImpactEffectEvent ev)
|
|
{
|
|
var coords = GetCoordinates(ev.Coordinates);
|
|
|
|
if (Deleted(coords.EntityId))
|
|
return;
|
|
|
|
var ent = Spawn(ev.Prototype, coords);
|
|
|
|
if (TryComp<SpriteComponent>(ent, out var sprite))
|
|
{
|
|
sprite[EffectLayers.Unshaded].AutoAnimated = false;
|
|
_sprite.LayerMapTryGet((ent, sprite), EffectLayers.Unshaded, out var layer, false);
|
|
var state = _sprite.LayerGetRsiState((ent, sprite), layer);
|
|
var lifetime = 0.5f;
|
|
|
|
if (TryComp<TimedDespawnComponent>(ent, out var despawn))
|
|
lifetime = despawn.Lifetime;
|
|
|
|
var anim = new Animation()
|
|
{
|
|
Length = TimeSpan.FromSeconds(lifetime),
|
|
AnimationTracks =
|
|
{
|
|
new AnimationTrackSpriteFlick()
|
|
{
|
|
LayerKey = EffectLayers.Unshaded,
|
|
KeyFrames =
|
|
{
|
|
new AnimationTrackSpriteFlick.KeyFrame(state.Name, 0f),
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
_player.Play(ent, anim, "impact-effect");
|
|
}
|
|
}
|
|
}
|