2020-02-26 03:19:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using Unity.Jobs;
|
|
|
|
|
using RobocraftX.StateSync;
|
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Events
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Event emitter engine for switching to simulation mode.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class GameStateSimulationEmitterEngine : IEventEmitterEngine, IInitializeOnSimulationStart
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; } = "GamecraftModdingAPIGameStateSimulationEventEmitter" ;
|
|
|
|
|
|
2020-03-12 22:36:23 +00:00
|
|
|
|
public EntitiesDB entitiesDB { set; private get; }
|
2020-02-26 03:19:22 +00:00
|
|
|
|
|
2020-04-02 17:08:05 +00:00
|
|
|
|
public int type { get; } = (int)EventType.SimulationSwitchedTo;
|
2020-02-26 03:19:22 +00:00
|
|
|
|
|
|
|
|
|
public bool isRemovable { get; } = false;
|
|
|
|
|
|
|
|
|
|
public IEntityFactory Factory { set; private get; }
|
|
|
|
|
|
|
|
|
|
public void Dispose() { }
|
|
|
|
|
|
|
|
|
|
public void Emit()
|
|
|
|
|
{
|
|
|
|
|
Logging.Log("Dispatching Simulation Switched To event");
|
|
|
|
|
if (Factory == null) { return; }
|
|
|
|
|
Factory.BuildEntity<ModEventEntityDescriptor>(ApiExclusiveGroups.eventID++, ApiExclusiveGroups.eventsExclusiveGroup)
|
|
|
|
|
.Init(new ModEventEntityStruct { type = type });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public JobHandle OnInitializeSimulationMode()
|
|
|
|
|
{
|
|
|
|
|
Emit();
|
|
|
|
|
return default(JobHandle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Ready() { }
|
|
|
|
|
}
|
|
|
|
|
}
|