NorbiPeti
f403feb298
Removed BlockIdentifiers.OWNED_BLOCKS as the original got replaced with an array Added the correct group for each supported functional block Removed EntityFactory property from IEntitySerializer as it is provided on deserialization
90 lines
2.3 KiB
C#
90 lines
2.3 KiB
C#
using System;
|
|
|
|
using RobocraftX.Blocks;
|
|
using RobocraftX.Common;
|
|
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)
|
|
{
|
|
if (PlacementEngine.IsInGame && GameState.IsBuildMode())
|
|
{
|
|
EGID id = PlacementEngine.PlaceBlock(BlockIDs.ConsoleBlock, color, darkness,
|
|
position, uscale, scale, player, rotation);
|
|
return new ConsoleBlock(id);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public ConsoleBlock(EGID id): base(id)
|
|
{
|
|
if (!BlockEngine.GetBlockInfoExists<ConsoleBlockEntityStruct>(this.Id))
|
|
{
|
|
throw new BlockTypeException($"Block is not a {this.GetType().Name} block");
|
|
}
|
|
}
|
|
|
|
public ConsoleBlock(uint id): base(new EGID(id, CommonExclusiveGroups.BUILD_CONSOLE_BLOCK_GROUP))
|
|
{
|
|
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
|
|
{
|
|
return BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName;
|
|
}
|
|
|
|
set
|
|
{
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).commandName.Set(value);
|
|
}
|
|
}
|
|
|
|
public string Arg1
|
|
{
|
|
get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1;
|
|
|
|
set
|
|
{
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg1.Set(value);
|
|
}
|
|
}
|
|
|
|
public string Arg2
|
|
{
|
|
get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2;
|
|
|
|
set
|
|
{
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg2.Set(value);
|
|
}
|
|
}
|
|
|
|
public string Arg3
|
|
{
|
|
get => BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3;
|
|
|
|
set
|
|
{
|
|
BlockEngine.GetBlockInfo<ConsoleBlockEntityStruct>(Id).arg3.Set(value);
|
|
}
|
|
}
|
|
}
|
|
}
|