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.

56 lines
1.6KB

  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 to build mode.
  11. /// </summary>
  12. [Obsolete]
  13. public class GameStateBuildEmitterEngine : IEventEmitterEngine, IUnorderedInitializeOnTimeStoppedModeEntered
  14. {
  15. public string Name { get; } = "GamecraftModdingAPIGameStateBuildEventEmitter" ;
  16. public EntitiesDB entitiesDB { set; private get; }
  17. public int type { get; } = (int)EventType.BuildSwitchedTo;
  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 Build 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 EmitIfBuildMode()
  29. {
  30. //Logging.MetaDebugLog($"nextSimulationMode: {entitiesDB.QueryUniqueEntity<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode}");
  31. if (entitiesDB.QueryUniqueEntity<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode == SimulationMode.TimeStopped)
  32. {
  33. Emit();
  34. }
  35. }
  36. public JobHandle OnInitializeTimeStoppedMode(JobHandle inputDeps)
  37. {
  38. Emit();
  39. return inputDeps;
  40. }
  41. public void Ready() { }
  42. }
  43. }