* Cleanup warnings in DamageMarkerSystem * Cleanup warnings in CuffableSystem * Cleanup warnings in DeployableTurretSystem * Cleanup warnings in StorageContainerVisualsSystem * Cleanup warnings in ItemMapperSystem * Cleanup warnings in ItemCounterSystem * Cleanup warnings in RandomSpriteSystem * Cleanup warnings in PowerCellSystem * Cleanup warnings in ParticleAcceleratorPartVisualizerSystem * Cleanup warnings in PaperVisualizerSystem * Cleanup warnings in PoweredLightVisualizerSystem * Cleanup warnings in LightBulbSystem * Cleanup warnings in EmergencyLightSystem * Cleanup warnings in DoorSystem * Cleanup warnings in ClockSystem * Cleanup warnings in BuckleSystem * Cleanup warnings in JukeboxSystem
70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using Content.Shared.PowerCell;
|
|
using Content.Shared.PowerCell.Components;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.PowerCell;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class PowerCellSystem : SharedPowerCellSystem
|
|
{
|
|
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
|
[Dependency] private readonly SpriteSystem _sprite = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<PowerCellVisualsComponent, AppearanceChangeEvent>(OnPowerCellVisualsChange);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool HasActivatableCharge(EntityUid uid, PowerCellDrawComponent? battery = null, PowerCellSlotComponent? cell = null,
|
|
EntityUid? user = null)
|
|
{
|
|
if (!Resolve(uid, ref battery, ref cell, false))
|
|
return true;
|
|
|
|
return battery.CanUse;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public override bool HasDrawCharge(
|
|
EntityUid uid,
|
|
PowerCellDrawComponent? battery = null,
|
|
PowerCellSlotComponent? cell = null,
|
|
EntityUid? user = null)
|
|
{
|
|
if (!Resolve(uid, ref battery, ref cell, false))
|
|
return true;
|
|
|
|
return battery.CanDraw;
|
|
}
|
|
|
|
private void OnPowerCellVisualsChange(EntityUid uid, PowerCellVisualsComponent component, ref AppearanceChangeEvent args)
|
|
{
|
|
if (args.Sprite == null)
|
|
return;
|
|
|
|
if (!_sprite.LayerExists((uid, args.Sprite), PowerCellVisualLayers.Unshaded))
|
|
return;
|
|
|
|
if (_appearance.TryGetData<byte>(uid, PowerCellVisuals.ChargeLevel, out var level, args.Component))
|
|
{
|
|
if (level == 0)
|
|
{
|
|
_sprite.LayerSetVisible((uid, args.Sprite), PowerCellVisualLayers.Unshaded, false);
|
|
return;
|
|
}
|
|
|
|
_sprite.LayerSetVisible((uid, args.Sprite), PowerCellVisualLayers.Unshaded, false);
|
|
_sprite.LayerSetRsiState((uid, args.Sprite), PowerCellVisualLayers.Unshaded, $"o{level}");
|
|
}
|
|
}
|
|
|
|
private enum PowerCellVisualLayers : byte
|
|
{
|
|
Base,
|
|
Unshaded,
|
|
}
|
|
}
|