TechbloxModdingAPI/GamecraftModdingAPI/Events/GameStateBuildEmitterEngine.cs

44 lines
1.1 KiB
C#

using System;
using Unity.Jobs;
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, IInitializeOnBuildStart
{
public string Name { get; } = "GamecraftModdingAPIGameStateBuildEventEmitter" ;
public IEntitiesDB entitiesDB { set; private get; }
public object type { get; } = 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 JobHandle OnInitializeBuildMode()
{
Emit();
return default(JobHandle);
}
public void Ready() { }
}
}