перенос общих файлов из папки White в _White

This commit is contained in:
Remuchi
2024-01-28 18:37:24 +07:00
parent 1e4ad59270
commit 3a08b81d53
370 changed files with 805 additions and 812 deletions

View File

@@ -0,0 +1,71 @@
using Content.Shared.Interaction.Events;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Serialization;
namespace Content.Shared._White.Crossbow;
public sealed class DrawableSystem : EntitySystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<DrawableComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<DrawableComponent, EntRemovedFromContainerMessage>(OnItemRemove);
SubscribeLocalEvent<DrawableComponent, AttemptShootEvent>(OnAttemptShoot);
SubscribeLocalEvent<DrawableComponent, UseInHandEvent>(OnUse);
}
private void OnUse(EntityUid uid, DrawableComponent component, UseInHandEvent args)
{
if (component.Drawn || component.Provider.Count == 0)
return;
args.Handled = true;
_audio.PlayPredicted(component.SoundDraw, uid, args.User);
component.Drawn = true;
UpdateDrawableAppearance(uid, component);
}
private void OnItemRemove(EntityUid uid, DrawableComponent component, EntRemovedFromContainerMessage args)
{
if (!component.Drawn || args.Container.ID != component.Provider.Container.ID)
return;
component.Drawn = false;
UpdateDrawableAppearance(uid, component);
}
private void OnStartup(EntityUid uid, DrawableComponent component, ComponentStartup args)
{
component.Provider = EnsureComp<BallisticAmmoProviderComponent>(uid);
}
private void OnAttemptShoot(EntityUid uid, DrawableComponent component, ref AttemptShootEvent args)
{
if (!component.Drawn)
args.Cancelled = true;
}
private void UpdateDrawableAppearance(EntityUid uid, DrawableComponent component)
{
if (!TryComp<AppearanceComponent>(uid, out var appearance))
return;
_appearance.SetData(uid, DrawableVisuals.Drawn, component.Drawn, appearance);
}
}
[Serializable, NetSerializable]
public enum DrawableVisuals : byte
{
Drawn
}