CivResearchComponent.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. using Robust.Shared.Prototypes;
  8. using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
  9. namespace Content.Shared.Civ14.CivResearch;
  10. [RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
  11. public sealed partial class CivResearchComponent : Component
  12. {
  13. /// <summary>
  14. /// Defines if research is currently active and progressing
  15. /// </summary>
  16. [ViewVariables(VVAccess.ReadWrite)]
  17. [DataField("researchEnabled"), AutoNetworkedField]
  18. public bool ResearchEnabled { get; set; } = true;
  19. /// <summary>
  20. /// The current research level. From 0 to 800.
  21. /// </summary>
  22. [DataField("researchLevel"), AutoNetworkedField]
  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 hour.
  27. /// </summary>
  28. [DataField("researchSpeed"), AutoNetworkedField]
  29. public float ResearchSpeed { get; set; } = 0.001368f;
  30. /// <summary>
  31. /// The maximum research level.
  32. /// Should probably stay below 900 as 9 is used as the research level for disabled and futuristic stuff.
  33. /// </summary>
  34. [DataField("maxResearch"), AutoNetworkedField]
  35. public float MaxResearch { get; set; } = 800;
  36. /// <summary>
  37. /// If the map is tdm or not. Crafting is restricted in TDM maps.
  38. /// </summary>
  39. [ViewVariables(VVAccess.ReadWrite)]
  40. [DataField("isTDM"), AutoNetworkedField]
  41. public bool IsTDM { get; set; } = false;
  42. /// <summary>
  43. /// Calculates the current age based on the ResearchLevel.
  44. /// Age is determined by flooring the division of ResearchLevel by 100.
  45. /// </summary>
  46. /// <returns>The current age as an integer.</returns>
  47. public int GetCurrentAge()
  48. {
  49. return (int)Math.Floor(ResearchLevel / 100f);
  50. }
  51. }