- using System;
-
- using RobocraftX.Blocks;
- using RobocraftX.Common;
- using Gamecraft.Blocks.TimerBlock;
- using Svelto.ECS;
- using Unity.Mathematics;
-
- using GamecraftModdingAPI;
- using GamecraftModdingAPI.Utility;
-
- namespace GamecraftModdingAPI.Blocks
- {
- public class Timer : Block
- {
- public Timer(EGID id) : base(id)
- {
- }
-
- public Timer(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TIMER_BLOCK_GROUP))
- {
- }
-
- // custom timer properties
-
- /// <summary>
- /// The player-specified start time.
- /// </summary>
- public float Start
- {
- get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.startTime);
-
- set
- {
- BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.startTime = val,
- value);
- }
- }
-
- /// <summary>
- /// The player-specified end time.
- /// </summary>
- public float End
- {
- get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.endTime);
-
- set
- {
- BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.endTime = val,
- value);
- }
- }
-
- /// <summary>
- /// Whether to display time with millisecond precision.
- /// </summary>
- public bool DisplayMilliseconds
- {
- get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.outputFormatHasMS);
-
- set
- {
- BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, bool val) => tbds.outputFormatHasMS = val,
- value);
- }
- }
-
- /// <summary>
- /// Current time (as of the last video frame), in milliseconds.
- /// </summary>
- public int CurrentTime
- {
- get => BlockEngine.GetBlockInfo(this, (TimerBlockLabelCacheEntityStruct st) => st.timeLastRenderFrameMS);
-
- set
- {
- BlockEngine.SetBlockInfo(this, (ref TimerBlockLabelCacheEntityStruct tbds, int val) => tbds.timeLastRenderFrameMS = val,
- value);
- }
- }
- }
- }
|