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.

45 lines
1.1KB

  1. using System;
  2. using Unity.Jobs;
  3. using RobocraftX.StateSync;
  4. using Svelto.ECS;
  5. using GamecraftModdingAPI.Utility;
  6. namespace GamecraftModdingAPI.Events
  7. {
  8. /// <summary>
  9. /// Event emitter engine for switching to simulation mode.
  10. /// </summary>
  11. public class GameStateSimulationEmitterEngine : IEventEmitterEngine, IInitializeOnSimulationStart
  12. {
  13. public string Name { get; } = "GamecraftModdingAPIGameStateSimulationEventEmitter" ;
  14. public EntitiesDB entitiesDB { set; private get; }
  15. public int type { get; } = (int)EventType.SimulationSwitchedTo;
  16. public bool isRemovable { get; } = false;
  17. public IEntityFactory Factory { set; private get; }
  18. public void Dispose() { }
  19. public void Emit()
  20. {
  21. Logging.Log("Dispatching Simulation Switched To event");
  22. if (Factory == null) { return; }
  23. Factory.BuildEntity<ModEventEntityDescriptor>(ApiExclusiveGroups.eventID++, ApiExclusiveGroups.eventsExclusiveGroup)
  24. .Init(new ModEventEntityStruct { type = type });
  25. }
  26. public JobHandle OnInitializeSimulationMode()
  27. {
  28. Emit();
  29. return default(JobHandle);
  30. }
  31. public void Ready() { }
  32. }
  33. }