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.

46 lines
1.3KB

  1. using Gamecraft.Blocks.BlockGroups;
  2. using GamecraftModdingAPI.Blocks;
  3. using GamecraftModdingAPI.Utility;
  4. namespace GamecraftModdingAPI
  5. {
  6. /// <summary>
  7. /// A group of blocks that can be selected together. The placed version of blueprints.
  8. /// </summary>
  9. public class BlockGroup
  10. {
  11. internal static BlueprintEngine _engine = new BlueprintEngine();
  12. public int Id { get; }
  13. private Block _sourceBlock;
  14. internal BlockGroup(int id, Block block)
  15. {
  16. if (id == BlockGroupUtility.GROUP_UNASSIGNED)
  17. throw new BlockException("Cannot create a block group for blocks without a group!");
  18. Id = id;
  19. _sourceBlock = block;
  20. }
  21. /// <summary>
  22. /// Collects each block that is a part of this group.
  23. /// </summary>
  24. /// <returns>An array of blocks</returns>
  25. public Block[] GetBlocks()
  26. {
  27. return _engine.GetBlocksFromGroup(_sourceBlock.Id);
  28. }
  29. /// <summary>
  30. /// Removes all of the blocks in this group from the world.
  31. /// </summary>
  32. public void Remove()
  33. {
  34. _engine.RemoveBlockGroup(Id);
  35. }
  36. public static void Init()
  37. {
  38. GameEngineManager.AddGameEngine(_engine);
  39. }
  40. }
  41. }