Power cell culling (#8814)

This commit is contained in:
metalgearsloth
2022-06-16 18:37:07 +10:00
committed by GitHub
parent 2ad62a01f1
commit a18ba5c2b5
136 changed files with 234 additions and 977 deletions

View File

@@ -1,7 +1,38 @@
using Content.Shared.PowerCell;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
namespace Content.Client.PowerCell;
[UsedImplicitly]
public sealed class PowerCellSystem : SharedPowerCellSystem { }
public sealed class PowerCellSystem : SharedPowerCellSystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PowerCellVisualsComponent, AppearanceChangeEvent>(OnPowerCellVisualsChange);
}
private void OnPowerCellVisualsChange(EntityUid uid, PowerCellVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null) return;
if (args.Component.TryGetData(PowerCellVisuals.ChargeLevel, out byte level))
{
if (level == 0)
{
args.Sprite.LayerSetVisible(PowerCellVisualLayers.Unshaded, false);
return;
}
args.Sprite.LayerSetVisible(PowerCellVisualLayers.Unshaded, true);
args.Sprite.LayerSetState(PowerCellVisualLayers.Unshaded, $"o{level}");
}
}
private enum PowerCellVisualLayers : byte
{
Base,
Unshaded,
}
}