PowerCellDrawComponent.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using Content.Shared.Item.ItemToggle.Components;
  2. using Robust.Shared.GameStates;
  3. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  4. namespace Content.Shared.PowerCell;
  5. /// <summary>
  6. /// Indicates that the entity's ActivatableUI requires power or else it closes.
  7. /// </summary>
  8. /// <remarks>
  9. /// With ActivatableUI it will activate and deactivate when the ui is opened and closed, drawing power inbetween.
  10. /// </remarks>
  11. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
  12. public sealed partial class PowerCellDrawComponent : Component
  13. {
  14. #region Prediction
  15. /// <summary>
  16. /// Whether there is any charge available to draw.
  17. /// </summary>
  18. [ViewVariables(VVAccess.ReadWrite), DataField("canDraw"), AutoNetworkedField]
  19. public bool CanDraw;
  20. /// <summary>
  21. /// Whether there is sufficient charge to use.
  22. /// </summary>
  23. [ViewVariables(VVAccess.ReadWrite), DataField("canUse"), AutoNetworkedField]
  24. public bool CanUse;
  25. #endregion
  26. /// <summary>
  27. /// Whether drawing is enabled.
  28. /// Having no cell will still disable it.
  29. /// </summary>
  30. [DataField, AutoNetworkedField]
  31. public bool Enabled = true;
  32. /// <summary>
  33. /// How much the entity draws while the UI is open.
  34. /// Set to 0 if you just wish to check for power upon opening the UI.
  35. /// </summary>
  36. [ViewVariables(VVAccess.ReadWrite), DataField("drawRate")]
  37. public float DrawRate = 1f;
  38. /// <summary>
  39. /// How much power is used whenever the entity is "used".
  40. /// This is used to ensure the UI won't open again without a minimum use power.
  41. /// </summary>
  42. [ViewVariables(VVAccess.ReadWrite), DataField("useRate")]
  43. public float UseRate;
  44. /// <summary>
  45. /// When the next automatic power draw will occur
  46. /// </summary>
  47. [DataField("nextUpdate", customTypeSerializer: typeof(TimeOffsetSerializer))]
  48. [AutoPausedField]
  49. public TimeSpan NextUpdateTime;
  50. /// <summary>
  51. /// How long to wait between power drawing.
  52. /// </summary>
  53. [DataField]
  54. public TimeSpan Delay = TimeSpan.FromSeconds(1);
  55. }