|
1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Collections.Generic;
-
- using RobocraftX.Blocks;
- using RobocraftX.Common;
- using Svelto.DataStructures;
- using Svelto.ECS;
-
- using GamecraftModdingAPI.Engines;
-
- 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;
- }
-
- public ref T GetBlockInfo<T>(EGID blockID) where T : struct, IEntityComponent
- {
- return ref entitiesDB.QueryEntity<T>(blockID);
- }
- }
- }
|