A stable modding interface between Techblox and mods https://mod.exmods.org/
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

54 строки
1.5KB

  1. using System;
  2. using RobocraftX.Blocks;
  3. using Svelto.ECS;
  4. using TechbloxModdingAPI.Engines;
  5. using TechbloxModdingAPI.Utility;
  6. namespace TechbloxModdingAPI.Blocks.Engines
  7. {
  8. public class BlockEventsEngine : IReactionaryEngine<BlockTagEntityStruct>
  9. {
  10. public event EventHandler<BlockPlacedRemovedEventArgs> Placed;
  11. public event EventHandler<BlockPlacedRemovedEventArgs> Removed;
  12. public void Ready()
  13. {
  14. }
  15. public EntitiesDB entitiesDB { get; set; }
  16. public void Dispose()
  17. {
  18. }
  19. public string Name { get; } = "TechbloxModdingAPIBlockEventsEngine";
  20. public bool isRemovable { get; } = false;
  21. private bool shouldAddRemove;
  22. public void Add(ref BlockTagEntityStruct entityComponent, EGID egid)
  23. {
  24. if (!(shouldAddRemove = !shouldAddRemove))
  25. return;
  26. ExceptionUtil.InvokeEvent(Placed, this,
  27. new BlockPlacedRemovedEventArgs {ID = egid});
  28. }
  29. public void Remove(ref BlockTagEntityStruct entityComponent, EGID egid)
  30. {
  31. if (!(shouldAddRemove = !shouldAddRemove))
  32. return;
  33. ExceptionUtil.InvokeEvent(Removed, this,
  34. new BlockPlacedRemovedEventArgs {ID = egid});
  35. }
  36. }
  37. public struct BlockPlacedRemovedEventArgs
  38. {
  39. public EGID ID;
  40. private Block block;
  41. public Block Block => block ?? (block = Block.New(ID));
  42. }
  43. }