|
|
@@ -1,11 +1,12 @@ |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using GamecraftModdingAPI.Blocks; |
|
|
|
using GamecraftModdingAPI.Utility; |
|
|
|
using RobocraftX.Common; |
|
|
|
|
|
|
|
using Svelto.ECS; |
|
|
|
using RobocraftX.Common; |
|
|
|
using Unity.Mathematics; |
|
|
|
|
|
|
|
using GamecraftModdingAPI.Blocks; |
|
|
|
using GamecraftModdingAPI.Utility; |
|
|
|
|
|
|
|
namespace GamecraftModdingAPI |
|
|
|
{ |
|
|
|
public class Block |
|
|
@@ -80,11 +81,6 @@ namespace GamecraftModdingAPI |
|
|
|
set => MovementEngine.MoveBlock(Id.entityID, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// Returns an array of blocks that are connected to this one. |
|
|
|
/// </summary> |
|
|
|
public Block[] ConnectedCubes => BlockEngine.GetConnectedBlocks(Id.entityID); |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// The block's current rotation in degrees. |
|
|
|
/// </summary> |
|
|
@@ -94,13 +90,57 @@ namespace GamecraftModdingAPI |
|
|
|
set => RotationEngine.RotateBlock(Id.entityID, value); |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// The block's type (ID). Changing from or to a functional part may crash the game. |
|
|
|
/// </summary> |
|
|
|
public BlockIDs Type |
|
|
|
{ |
|
|
|
get => (BlockIDs) BlockEngine.GetBlockInfo<DBEntityStruct>(Id).DBID; |
|
|
|
set |
|
|
|
{ |
|
|
|
BlockEngine.GetBlockInfo<DBEntityStruct>(Id).DBID = (uint) value; |
|
|
|
uint prefabId = PrefabsID.GetPrefabId((uint) value, 0); |
|
|
|
BlockEngine.GetBlockInfo<GFXPrefabEntityStructGPUI>(Id).prefabID = prefabId; |
|
|
|
BlockEngine.GetBlockInfo<PhysicsPrefabEntityStruct>(Id) = new PhysicsPrefabEntityStruct(prefabId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public BlockColors Color |
|
|
|
{ |
|
|
|
get => (BlockColors) (BlockEngine.GetBlockInfo<ColourParameterEntityStruct>(Id).indexInPalette % 10); |
|
|
|
set |
|
|
|
{ |
|
|
|
ref var color = ref BlockEngine.GetBlockInfo<ColourParameterEntityStruct>(Id); |
|
|
|
color.indexInPalette = (byte) (color.indexInPalette / 10 * 10 + value); |
|
|
|
color.needsUpdate = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public byte ColorDarkness |
|
|
|
{ |
|
|
|
get => (byte) (BlockEngine.GetBlockInfo<ColourParameterEntityStruct>(Id).indexInPalette / 10); |
|
|
|
set |
|
|
|
{ |
|
|
|
ref var color = ref BlockEngine.GetBlockInfo<ColourParameterEntityStruct>(Id); |
|
|
|
color.indexInPalette = (byte) (10 * (byte) value + color.indexInPalette % 10); |
|
|
|
color.needsUpdate = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// Returns an array of blocks that are connected to this one. |
|
|
|
/// </summary> |
|
|
|
public Block[] GetConnectedCubes() => BlockEngine.GetConnectedBlocks(Id.entityID); |
|
|
|
|
|
|
|
/// <summary> |
|
|
|
/// Removes this block. |
|
|
|
/// </summary> |
|
|
|
/// <returns>True if the block exists and could be removed.</returns> |
|
|
|
public bool Remove() |
|
|
|
public bool Remove() => RemovalEngine.RemoveBlock(Id); |
|
|
|
|
|
|
|
public override string ToString() |
|
|
|
{ |
|
|
|
return RemovalEngine.RemoveBlock(Id); |
|
|
|
return $"{nameof(Id)}: {Id}, {nameof(Position)}: {Position}, {nameof(Rotation)}: {Rotation}"; |
|
|
|
} |
|
|
|
|
|
|
|
public static void Init() |
|
|
|