2020-02-26 03:19:22 +00:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
using Unity.Jobs;
|
2020-04-07 17:05:00 +00:00
|
|
|
|
using RobocraftX.SimulationModeState;
|
2020-02-26 03:19:22 +00:00
|
|
|
|
using RobocraftX.StateSync;
|
|
|
|
|
using Svelto.ECS;
|
|
|
|
|
|
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Events
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Event emitter engine for switching to to build mode.
|
|
|
|
|
/// </summary>
|
2020-08-03 02:39:26 +00:00
|
|
|
|
[Obsolete]
|
2020-05-14 15:42:34 +00:00
|
|
|
|
public class GameStateBuildEmitterEngine : IEventEmitterEngine, IUnorderedInitializeOnTimeStoppedModeEntered
|
2020-02-26 03:19:22 +00:00
|
|
|
|
{
|
|
|
|
|
public string Name { get; } = "GamecraftModdingAPIGameStateBuildEventEmitter" ;
|
|
|
|
|
|
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.BuildSwitchedTo;
|
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 Build Switched To event");
|
|
|
|
|
if (Factory == null) { return; }
|
|
|
|
|
Factory.BuildEntity<ModEventEntityDescriptor>(ApiExclusiveGroups.eventID++, ApiExclusiveGroups.eventsExclusiveGroup)
|
|
|
|
|
.Init(new ModEventEntityStruct { type = type });
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-07 17:05:00 +00:00
|
|
|
|
public void EmitIfBuildMode()
|
|
|
|
|
{
|
|
|
|
|
//Logging.MetaDebugLog($"nextSimulationMode: {entitiesDB.QueryUniqueEntity<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode}");
|
2020-05-14 15:42:34 +00:00
|
|
|
|
if (entitiesDB.QueryUniqueEntity<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode == SimulationMode.TimeStopped)
|
2020-04-07 17:05:00 +00:00
|
|
|
|
{
|
|
|
|
|
Emit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-14 15:42:34 +00:00
|
|
|
|
|
2020-07-10 22:30:58 +00:00
|
|
|
|
public JobHandle OnInitializeTimeStoppedMode(JobHandle inputDeps)
|
2020-02-26 03:19:22 +00:00
|
|
|
|
{
|
|
|
|
|
Emit();
|
2020-07-10 22:30:58 +00:00
|
|
|
|
return inputDeps;
|
2020-02-26 03:19:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Ready() { }
|
|
|
|
|
}
|
|
|
|
|
}
|