[Feat] Внешний вид и название канистр можно изменить прямо в игре (#317)

* feat: Теперь можно менять внешний вид канистр газов

* fix: русский язык (я его не знаю)
This commit is contained in:
Remuchi
2024-05-30 21:28:53 +07:00
committed by GitHub
parent 26c7788d9b
commit d4be4d3445
10 changed files with 353 additions and 1 deletions

View File

@@ -0,0 +1,36 @@
using Content.Shared._White.PolymorphableCanister;
using Robust.Client.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.Client._White.PolymorphableCanister;
public sealed class PolymorphableCanisterSystem : SharedPolymorphableCanisterSystem
{
[Dependency] private readonly IComponentFactory _componentFactory = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PolymorphableCanisterComponent, AfterAutoHandleStateEvent>(HandleState);
}
private void HandleState(EntityUid uid,
PolymorphableCanisterComponent component,
ref AfterAutoHandleStateEvent args)
{
UpdateAppearance(uid, component.CurrentPrototype);
}
protected override void UpdateSprite(EntityUid uid, EntityPrototype proto)
{
base.UpdateSprite(uid, proto);
if (!TryComp(uid, out SpriteComponent? sprite) ||
!proto.TryGetComponent(out SpriteComponent? otherSprite, _componentFactory))
{
return;
}
sprite.CopyFrom(otherSprite);
}
}