1
0

AmeShieldingSystem.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Content.Server.Ame.Components;
  2. using Content.Shared.Ame.Components;
  3. using Robust.Server.GameObjects;
  4. namespace Content.Server.Ame.EntitySystems;
  5. public sealed class AmeShieldingSystem : EntitySystem
  6. {
  7. [Dependency] private readonly AppearanceSystem _appearanceSystem = default!;
  8. [Dependency] private readonly PointLightSystem _pointLightSystem = default!;
  9. public void SetCore(EntityUid uid, bool value, AmeShieldComponent? shield = null)
  10. {
  11. if (!Resolve(uid, ref shield))
  12. return;
  13. if (value == shield.IsCore)
  14. return;
  15. shield.IsCore = value;
  16. _appearanceSystem.SetData(uid, AmeShieldVisuals.Core, value);
  17. if (!value)
  18. UpdateCoreVisuals(uid, 0, false, shield);
  19. }
  20. public void UpdateCoreVisuals(EntityUid uid, int injectionStrength, bool injecting, AmeShieldComponent? shield = null)
  21. {
  22. if (!Resolve(uid, ref shield))
  23. return;
  24. if (!injecting)
  25. {
  26. _appearanceSystem.SetData(uid, AmeShieldVisuals.CoreState, AmeCoreState.Off);
  27. _pointLightSystem.SetEnabled(uid, false);
  28. return;
  29. }
  30. _pointLightSystem.SetRadius(uid, Math.Clamp(injectionStrength, 1, 12));
  31. _pointLightSystem.SetEnabled(uid, true);
  32. _appearanceSystem.SetData(uid, AmeShieldVisuals.CoreState, injectionStrength > 2 ? AmeCoreState.Strong : AmeCoreState.Weak);
  33. }
  34. }