2020-05-21 00:42:02 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using RobocraftX.Blocks;
|
2020-07-10 22:30:58 +00:00
|
|
|
|
using RobocraftX.Common;
|
2020-05-21 00:42:02 +00:00
|
|
|
|
using Gamecraft.Blocks.TimerBlock;
|
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
|
|
|
|
using GamecraftModdingAPI;
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
|
|
|
{
|
2020-08-23 13:59:13 +00:00
|
|
|
|
public class Timer : SignalingBlock
|
2020-05-21 00:42:02 +00:00
|
|
|
|
{
|
|
|
|
|
public Timer(EGID id) : base(id)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-09 21:18:25 +00:00
|
|
|
|
public Timer(uint id) : base(new EGID(id, CommonExclusiveGroups.TIMER_BLOCK_GROUP))
|
2020-05-21 00:42:02 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom timer properties
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The player-specified start time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float Start
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.startTime);
|
2020-05-21 00:42:02 +00:00
|
|
|
|
|
2020-07-15 19:58:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.startTime = val,
|
|
|
|
|
value);
|
|
|
|
|
}
|
2020-05-21 00:42:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The player-specified end time.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public float End
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.endTime);
|
2020-05-21 00:42:02 +00:00
|
|
|
|
|
2020-07-15 19:58:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, float val) => tbds.endTime = val,
|
|
|
|
|
value);
|
|
|
|
|
}
|
2020-05-21 00:42:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Whether to display time with millisecond precision.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool DisplayMilliseconds
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (TimerBlockDataStruct st) => st.outputFormatHasMS);
|
2020-05-21 00:42:02 +00:00
|
|
|
|
|
2020-07-15 19:58:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref TimerBlockDataStruct tbds, bool val) => tbds.outputFormatHasMS = val,
|
|
|
|
|
value);
|
|
|
|
|
}
|
2020-05-21 00:42:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Current time (as of the last video frame), in milliseconds.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public int CurrentTime
|
|
|
|
|
{
|
2020-07-15 19:58:24 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo(this, (TimerBlockLabelCacheEntityStruct st) => st.timeLastRenderFrameMS);
|
2020-05-21 00:42:02 +00:00
|
|
|
|
|
2020-07-15 19:58:24 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
BlockEngine.SetBlockInfo(this, (ref TimerBlockLabelCacheEntityStruct tbds, int val) => tbds.timeLastRenderFrameMS = val,
|
|
|
|
|
value);
|
|
|
|
|
}
|
2020-05-21 00:42:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|