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.

44 lines
1.2KB

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