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.

66 lines
2.1KB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Svelto.ECS;
  7. using GamecraftModdingAPI.Utility;
  8. namespace GamecraftModdingAPI.Events
  9. {
  10. /// <summary>
  11. /// A simple implementation of IEventEmitterEngine sufficient for most uses
  12. /// </summary>
  13. public class SimpleEventEmitterEngine : IEventEmitterEngine
  14. {
  15. public string Name { get; set; }
  16. public object type { get; set; }
  17. public bool isRemovable { get; }
  18. public IEntityFactory Factory { private get; set; }
  19. public IEntitiesDB entitiesDB { set; private get; }
  20. public void Ready() { }
  21. /// <summary>
  22. /// Emit the event
  23. /// </summary>
  24. public void Emit()
  25. {
  26. Factory.BuildEntity<ModEventEntityDescriptor>(ApiExclusiveGroups.eventID++, ApiExclusiveGroups.eventsExclusiveGroup)
  27. .Init(new ModEventEntityStruct { type = type });
  28. }
  29. public void Dispose() { }
  30. /// <summary>
  31. /// Construct the engine
  32. /// </summary>
  33. /// <param name="type">The EventType to use for ModEventEntityStruct.type</param>
  34. /// <param name="name">The name of this engine</param>
  35. /// <param name="isRemovable">Will removing this engine not break your code?</param>
  36. public SimpleEventEmitterEngine(EventType type, string name, bool isRemovable = true)
  37. {
  38. this.type = type;
  39. this.Name = name;
  40. this.isRemovable = isRemovable;
  41. }
  42. /// <summary>
  43. /// Construct the engine
  44. /// </summary>
  45. /// <param name="type">The object to use for ModEventEntityStruct.type</param>
  46. /// <param name="name">The name of this engine</param>
  47. /// <param name="isRemovable">Will removing this engine not break your code?</param>
  48. public SimpleEventEmitterEngine(object type, string name, bool isRemovable = true)
  49. {
  50. this.type = type;
  51. this.Name = name;
  52. this.isRemovable = isRemovable;
  53. }
  54. }
  55. }