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 : SignalingBlock { public Timer(EGID id) : base(id) { } public Timer(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TIMER_BLOCK_GROUP)) { } // custom timer properties /// /// The player-specified start time. /// public float Start { get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.startTime); set { BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.startTime = val, value); } } /// /// The player-specified end time. /// public float End { get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.endTime); set { BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.endTime = val, value); } } /// /// Whether to display time with millisecond precision. /// public bool DisplayMilliseconds { get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.outputFormatHasMS); set { BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, bool val) => tbds.outputFormatHasMS = val, value); } } /// /// Current time (as of the last video frame), in milliseconds. /// public int CurrentTime { get => BlockEngine.GetBlockInfo(this, (TimerBlockLabelCacheEntityStruct st) => st.timeLastRenderFrameMS); set { BlockEngine.SetBlockInfo(this, (ref TimerBlockLabelCacheEntityStruct tbds, int val) => tbds.timeLastRenderFrameMS = val, value); } } } }