CivResearchComponent.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System;
  2. using Robust.Shared.GameObjects;
  3. using Robust.Shared.GameStates;
  4. using Robust.Shared.Serialization;
  5. using Robust.Shared.Serialization.Manager.Attributes;
  6. using Robust.Shared.ViewVariables;
  7. namespace Content.Shared.Civ14.CivResearch;
  8. [RegisterComponent]
  9. [NetworkedComponent]
  10. public sealed partial class CivResearchComponent : Component
  11. {
  12. /// <summary>
  13. /// Defines if research is currently active and progressing
  14. /// </summary>
  15. [ViewVariables(VVAccess.ReadWrite)]
  16. [DataField("researchEnabled")]
  17. public bool ResearchEnabled { get; set; } = true;
  18. /// <summary>
  19. /// The current research level. From 0 to 800.
  20. /// </summary>
  21. [ViewVariables(VVAccess.ReadWrite)]
  22. [DataField("researchLevel")]
  23. public float ResearchLevel { get; set; } = 0f;
  24. /// <summary>
  25. /// For autoresearch, how much research increases per tick.
  26. /// This defaults to 100 levels per day.
  27. /// </summary>
  28. [ViewVariables(VVAccess.ReadWrite)]
  29. [DataField("researchSpeed")]
  30. public float ResearchSpeed { get; set; } = 0.000057f;
  31. /// <summary>
  32. /// The maximum research level.
  33. /// Should probably stay below 900 as 9 is used as the research level for disabled and futuristic stuff.
  34. /// </summary>
  35. [ViewVariables(VVAccess.ReadWrite)]
  36. [DataField("maxResearch")]
  37. public float MaxResearch { get; set; } = 800;
  38. /// <summary>
  39. /// Calculates the current age based on the ResearchLevel.
  40. /// Age is determined by flooring the division of ResearchLevel by 100.
  41. /// </summary>
  42. /// <returns>The current age as an integer.</returns>
  43. public int GetCurrentAge()
  44. {
  45. return (int)Math.Floor(ResearchLevel / 100f);
  46. }
  47. }