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.

55 lines
1.5KB

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