A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.1KB

  1. using System;
  2. using RobocraftX.Blocks;
  3. using RobocraftX.Common;
  4. using Gamecraft.Blocks.TimerBlock;
  5. using Svelto.ECS;
  6. using Unity.Mathematics;
  7. using GamecraftModdingAPI;
  8. using GamecraftModdingAPI.Utility;
  9. namespace GamecraftModdingAPI.Blocks
  10. {
  11. public class Timer : SignalingBlock
  12. {
  13. public Timer(EGID id) : base(id)
  14. {
  15. }
  16. public Timer(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TIMER_BLOCK_GROUP))
  17. {
  18. }
  19. // custom timer properties
  20. /// <summary>
  21. /// The player-specified start time.
  22. /// </summary>
  23. public float Start
  24. {
  25. get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.startTime);
  26. set
  27. {
  28. BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.startTime = val,
  29. value);
  30. }
  31. }
  32. /// <summary>
  33. /// The player-specified end time.
  34. /// </summary>
  35. public float End
  36. {
  37. get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.endTime);
  38. set
  39. {
  40. BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.endTime = val,
  41. value);
  42. }
  43. }
  44. /// <summary>
  45. /// Whether to display time with millisecond precision.
  46. /// </summary>
  47. public bool DisplayMilliseconds
  48. {
  49. get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.outputFormatHasMS);
  50. set
  51. {
  52. BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, bool val) => tbds.outputFormatHasMS = val,
  53. value);
  54. }
  55. }
  56. /// <summary>
  57. /// Current time (as of the last video frame), in milliseconds.
  58. /// </summary>
  59. public int CurrentTime
  60. {
  61. get => BlockEngine.GetBlockInfo(this, (TimerBlockLabelCacheEntityStruct st) => st.timeLastRenderFrameMS);
  62. set
  63. {
  64. BlockEngine.SetBlockInfo(this, (ref TimerBlockLabelCacheEntityStruct tbds, int val) => tbds.timeLastRenderFrameMS = val,
  65. value);
  66. }
  67. }
  68. }
  69. }