NorbiPeti
f403feb298
Removed BlockIdentifiers.OWNED_BLOCKS as the original got replaced with an array Added the correct group for each supported functional block Removed EntityFactory property from IEntitySerializer as it is provided on deserialization
54 lines
1.6 KiB
C#
54 lines
1.6 KiB
C#
using System;
|
|
|
|
using Unity.Jobs;
|
|
using RobocraftX.SimulationModeState;
|
|
using RobocraftX.StateSync;
|
|
using Svelto.ECS;
|
|
|
|
using GamecraftModdingAPI.Utility;
|
|
|
|
namespace GamecraftModdingAPI.Events
|
|
{
|
|
/// <summary>
|
|
/// Event emitter engine for switching to to build mode.
|
|
/// </summary>
|
|
public class GameStateBuildEmitterEngine : IEventEmitterEngine, IUnorderedInitializeOnTimeStoppedModeEntered
|
|
{
|
|
public string Name { get; } = "GamecraftModdingAPIGameStateBuildEventEmitter" ;
|
|
|
|
public EntitiesDB entitiesDB { set; private get; }
|
|
|
|
public int type { get; } = (int)EventType.BuildSwitchedTo;
|
|
|
|
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 });
|
|
}
|
|
|
|
public void EmitIfBuildMode()
|
|
{
|
|
//Logging.MetaDebugLog($"nextSimulationMode: {entitiesDB.QueryUniqueEntity<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode}");
|
|
if (entitiesDB.QueryUniqueEntity<SimulationModeStateEntityStruct>(SimulationModeStateExclusiveGroups.GAME_STATE_GROUP).nextSimulationMode == SimulationMode.TimeStopped)
|
|
{
|
|
Emit();
|
|
}
|
|
}
|
|
|
|
public JobHandle OnInitializeTimeStoppedMode(JobHandle inputDeps)
|
|
{
|
|
Emit();
|
|
return inputDeps;
|
|
}
|
|
|
|
public void Ready() { }
|
|
}
|
|
}
|