2020-05-18 03:19:16 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using RobocraftX.Blocks;
|
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 ConsoleBlock : Block
|
|
|
|
|
{
|
|
|
|
|
public static ConsoleBlock PlaceNew(float3 position,
|
|
|
|
|
float3 rotation = default, BlockColors color = BlockColors.Default, byte darkness = 0,
|
|
|
|
|
int uscale = 1, float3 scale = default, Player player = null)
|
|
|
|
|
{
|
2020-05-22 22:06:49 +00:00
|
|
|
|
if (PlacementEngine.IsInGame && GameState.IsBuildMode())
|
|
|
|
|
{
|
|
|
|
|
EGID id = PlacementEngine.PlaceBlock(BlockIDs.ConsoleBlock, color, darkness,
|
|
|
|
|
position, uscale, scale, player, rotation);
|
|
|
|
|
return new ConsoleBlock(id);
|
|
|
|
|
}
|
2020-05-18 03:19:16 +00:00
|
|
|
|
|
2020-05-22 22:06:49 +00:00
|
|
|
|
return null;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ConsoleBlock(EGID id): base(id)
|
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<ConsoleBlockEntityStruct>(this.Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-10 22:30:58 +00:00
|
|
|
|
public ConsoleBlock(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_CONSOLE_BLOCK_GROUP))
|
2020-05-18 03:19:16 +00:00
|
|
|
|
{
|
|
|
|
|
if (!BlockEngine.GetBlockInfoExists<ConsoleBlockEntityStruct>(this.Id))
|
|
|
|
|
{
|
|
|
|
|
throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// custom console block properties
|
|
|
|
|
|
|
|
|
|
public string Command
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
return BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName.Set(value);
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Arg1
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1.Set(value);
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Arg2
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2.Set(value);
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string Arg3
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3;
|
2020-05-18 03:19:16 +00:00
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
2020-05-19 22:08:02 +00:00
|
|
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3.Set(value);
|
2020-05-18 03:19:16 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|