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.

41 lines
1.1KB

  1. using Svelto.ECS;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace GamecraftModdingAPI.Events
  8. {
  9. class SimpleEventHandlerEngine : IEventHandlerEngine
  10. {
  11. public object type { get; set; }
  12. public string Name { get; set; }
  13. private readonly Action<IEntitiesDB> onEvent;
  14. public IEntitiesDB entitiesDB { set; private get; }
  15. public void Add(ref ModEventEntityStruct entityView, EGID egid)
  16. {
  17. if (entityView.type.Equals(this.type))
  18. {
  19. onEvent.Invoke(entitiesDB);
  20. }
  21. }
  22. public void Ready() { }
  23. public void Remove(ref ModEventEntityStruct entityView, EGID egid) { }
  24. public SimpleEventHandlerEngine(Action handleEvent, object type, string name) : this((IEntitiesDB db) => { handleEvent.Invoke(); }, type, name) { }
  25. public SimpleEventHandlerEngine(Action<IEntitiesDB> handleEvent, object type, string name)
  26. {
  27. this.type = type;
  28. this.Name = name;
  29. this.onEvent = handleEvent;
  30. }
  31. }
  32. }