2020-05-18 03:19:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using Gamecraft.Blocks.GUI;
|
2020-07-10 22:30:58 +00:00
|
|
|
|
using RobocraftX.Common;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
|
|
|
|
using GamecraftModdingAPI;
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
|
|
|
{
|
|
|
|
|
public class TextBlock : Block
|
|
|
|
|
{
|
|
|
|
|
public TextBlock(EGID id) : base(id)
|
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<TextBlockDataStruct>(this.Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 22:30:58 +00:00
|
|
|
|
public TextBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TEXT_BLOCK_GROUP))
|
2020-05-18 03:19:16 +00:00
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<TextBlockDataStruct>(this.Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom text block properties
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The text block's current text.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Text
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
return BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id).textCurrent;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
ref TextBlockDataStruct tbds = ref BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id);
|
2020-05-18 03:19:16 +00:00
|
|
|
|
tbds.textCurrent.Set(value);
|
|
|
|
|
tbds.textStored.Set(value);
|
2020-05-19 22:08:02 +00:00
|
|
|
|
BlockEngine.GetBlockInfo<TextBlockNetworkDataStruct>(Id).newTextBlockStringContent.Set(value);
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The text block's current text block ID (used in ChangeTextBlockCommand).
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string TextBlockId
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
return BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id).textBlockID;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id).textBlockID.Set(value);
|
|
|
|
|
BlockEngine.GetBlockInfo<TextBlockNetworkDataStruct>(Id).newTextBlockID.Set(value);
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|