A stable modding interface between Techblox and mods https://mod.exmods.org/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1KB

  1. using System.Collections.Generic;
  2. using GamecraftModdingAPI.Engines;
  3. using RobocraftX.Blocks;
  4. using RobocraftX.Common;
  5. using Svelto.DataStructures;
  6. using Svelto.ECS;
  7. using Svelto.ECS.EntityStructs;
  8. using Unity.Mathematics;
  9. namespace GamecraftModdingAPI.Blocks
  10. {
  11. public class BlockEngine : IApiEngine
  12. {
  13. public string Name { get; } = "GamecraftModdingAPIBlockGameEngine";
  14. public EntitiesDB entitiesDB { set; private get; }
  15. public bool isRemovable => false;
  16. public void Dispose()
  17. {
  18. }
  19. public void Ready()
  20. {
  21. }
  22. public Block[] GetConnectedBlocks(uint blockID)
  23. {
  24. Stack<uint> cubeStack = new Stack<uint>();
  25. FasterList<uint> cubesToProcess = new FasterList<uint>();
  26. ConnectedCubesUtility.TreeTraversal.GetConnectedCubes(entitiesDB, blockID, cubeStack, cubesToProcess, (in GridConnectionsEntityStruct g) => { return false; });
  27. var ret = new Block[cubesToProcess.count];
  28. for (int i = 0; i < cubesToProcess.count; i++)
  29. ret[i] = new Block(cubesToProcess[i]);
  30. return ret;
  31. }
  32. }
  33. }