Add pipe coloring (#4261)

This commit is contained in:
Vera Aguilera Puerto
2021-07-12 09:59:45 +02:00
committed by GitHub
parent 6bbcf305bd
commit 077f158dda
17 changed files with 163 additions and 35 deletions

View File

@@ -0,0 +1,45 @@
using Content.Server.Atmos.Piping.Components;
using Content.Shared.Atmos.Piping;
using Robust.Server.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.Maths;
namespace Content.Server.Atmos.Piping.EntitySystems
{
public class AtmosPipeColorSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AtmosPipeColorComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<AtmosPipeColorComponent, ComponentShutdown>(OnShutdown);
}
private void OnStartup(EntityUid uid, AtmosPipeColorComponent component, ComponentStartup args)
{
if (!ComponentManager.TryGetComponent(uid, out AppearanceComponent? appearance))
return;
appearance.SetData(PipeColorVisuals.Color, component.Color);
}
private void OnShutdown(EntityUid uid, AtmosPipeColorComponent component, ComponentShutdown args)
{
if (!ComponentManager.TryGetComponent(uid, out AppearanceComponent? appearance))
return;
appearance.SetData(PipeColorVisuals.Color, Color.White);
}
public void SetColor(EntityUid uid, AtmosPipeColorComponent component, Color color)
{
component.Color = color;
if (!ComponentManager.TryGetComponent(uid, out AppearanceComponent? appearance))
return;
appearance.SetData(PipeColorVisuals.Color, color);
}
}
}