| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- using Content.Server.Atmos.Piping.Components;
- using Content.Shared.Atmos.Piping;
- using Robust.Server.GameObjects;
- namespace Content.Server.Atmos.Piping.EntitySystems
- {
- public sealed class AtmosPipeColorSystem : EntitySystem
- {
- [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
- public override void Initialize()
- {
- base.Initialize();
- SubscribeLocalEvent<AtmosPipeColorComponent, ComponentStartup>(OnStartup);
- SubscribeLocalEvent<AtmosPipeColorComponent, ComponentShutdown>(OnShutdown);
- }
- private void OnStartup(EntityUid uid, AtmosPipeColorComponent component, ComponentStartup args)
- {
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
- return;
- _appearance.SetData(uid, PipeColorVisuals.Color, component.Color, appearance);
- }
- private void OnShutdown(EntityUid uid, AtmosPipeColorComponent component, ComponentShutdown args)
- {
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
- return;
- _appearance.SetData(uid, PipeColorVisuals.Color, Color.White, appearance);
- }
- public void SetColor(EntityUid uid, AtmosPipeColorComponent component, Color color)
- {
- component.Color = color;
- if (!EntityManager.TryGetComponent(uid, out AppearanceComponent? appearance))
- return;
- _appearance.SetData(uid, PipeColorVisuals.Color, color, appearance);
- var ev = new AtmosPipeColorChangedEvent(color);
- RaiseLocalEvent(uid, ref ev);
- }
- }
- }
|