NorbiPeti
5bbb54c0c5
And store delegates of dynamic methods invoking constructors Tested with the automated tests
69 lines
1.8 KiB
C#
69 lines
1.8 KiB
C#
using System;
|
|
|
|
using Gamecraft.Blocks.GUI;
|
|
using RobocraftX.Common;
|
|
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");
|
|
}
|
|
}
|
|
|
|
public TextBlock(uint id) : base(new EGID(id, CommonExclusiveGroups.BUILD_TEXT_BLOCK_GROUP))
|
|
{
|
|
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
|
|
{
|
|
return BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id).textCurrent;
|
|
}
|
|
|
|
set
|
|
{
|
|
ref TextBlockDataStruct tbds = ref BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id);
|
|
tbds.textCurrent.Set(value);
|
|
tbds.textStored.Set(value);
|
|
BlockEngine.GetBlockInfo<TextBlockNetworkDataStruct>(Id).newTextBlockStringContent.Set(value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The text block's current text block ID (used in ChangeTextBlockCommand).
|
|
/// </summary>
|
|
public string TextBlockId
|
|
{
|
|
get
|
|
{
|
|
return BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id).textBlockID;
|
|
}
|
|
|
|
set
|
|
{
|
|
BlockEngine.GetBlockInfo<TextBlockDataStruct>(Id).textBlockID.Set(value);
|
|
BlockEngine.GetBlockInfo<TextBlockNetworkDataStruct>(Id).newTextBlockID.Set(value);
|
|
}
|
|
}
|
|
}
|
|
}
|