2020-05-13 12:02:36 +00:00
|
|
|
using System.Collections.Generic;
|
2020-05-13 14:52:21 +00:00
|
|
|
|
2020-05-13 12:02:36 +00:00
|
|
|
using RobocraftX.Blocks;
|
|
|
|
using RobocraftX.Common;
|
|
|
|
using Svelto.DataStructures;
|
|
|
|
using Svelto.ECS;
|
2020-05-13 14:52:21 +00:00
|
|
|
|
|
|
|
using GamecraftModdingAPI.Engines;
|
2020-05-13 12:02:36 +00:00
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
|
|
{
|
|
|
|
public class BlockEngine : IApiEngine
|
|
|
|
{
|
|
|
|
public string Name { get; } = "GamecraftModdingAPIBlockGameEngine";
|
|
|
|
|
|
|
|
public EntitiesDB entitiesDB { set; private get; }
|
|
|
|
|
|
|
|
public bool isRemovable => false;
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Ready()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
public Block[] GetConnectedBlocks(uint blockID)
|
|
|
|
{
|
|
|
|
Stack<uint> cubeStack = new Stack<uint>();
|
|
|
|
FasterList<uint> cubesToProcess = new FasterList<uint>();
|
|
|
|
ConnectedCubesUtility.TreeTraversal.GetConnectedCubes(entitiesDB, blockID, cubeStack, cubesToProcess, (in GridConnectionsEntityStruct g) => { return false; });
|
|
|
|
var ret = new Block[cubesToProcess.count];
|
|
|
|
for (int i = 0; i < cubesToProcess.count; i++)
|
|
|
|
ret[i] = new Block(cubesToProcess[i]);
|
|
|
|
return ret;
|
|
|
|
}
|
2020-05-13 14:52:21 +00:00
|
|
|
|
|
|
|
public ref T GetBlockInfo<T>(EGID blockID) where T : struct, IEntityComponent
|
|
|
|
{
|
|
|
|
return ref entitiesDB.QueryEntity<T>(blockID);
|
|
|
|
}
|
2020-05-13 12:02:36 +00:00
|
|
|
}
|
|
|
|
}
|