|
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- using Svelto.ECS;
- using GamecraftModdingAPI.Utility;
-
- namespace GamecraftModdingAPI.Events
- {
- /// <summary>
- /// A simple implementation of IEventEmitterEngine sufficient for most uses
- /// </summary>
- public class SimpleEventEmitterEngine : IEventEmitterEngine
- {
- public string Name { get; set; }
- public int type { get; set; }
-
- public bool isRemovable { get; }
-
- public IEntityFactory Factory { private get; set; }
-
- public EntitiesDB entitiesDB { set; private get; }
-
- public void Ready() { }
-
- /// <summary>
- /// Emit the event
- /// </summary>
- public void Emit()
- {
- Factory.BuildEntity<ModEventEntityDescriptor>(ApiExclusiveGroups.eventID++, ApiExclusiveGroups.eventsExclusiveGroup)
- .Init(new ModEventEntityStruct { type = type });
- }
-
- public void Dispose() { }
-
- /// <summary>
- /// Construct the engine
- /// </summary>
- /// <param name="type">The EventType to use for ModEventEntityStruct.type</param>
- /// <param name="name">The name of this engine</param>
- /// <param name="isRemovable">Will removing this engine not break your code?</param>
- public SimpleEventEmitterEngine(EventType type, string name, bool isRemovable = true)
- {
- this.type = (int)type;
- this.Name = name;
- this.isRemovable = isRemovable;
- }
-
- /// <summary>
- /// Construct the engine
- /// </summary>
- /// <param name="type">The object to use for ModEventEntityStruct.type</param>
- /// <param name="name">The name of this engine</param>
- /// <param name="isRemovable">Will removing this engine not break your code?</param>
- public SimpleEventEmitterEngine(int type, string name, bool isRemovable = true)
- {
- this.type = type;
- this.Name = name;
- this.isRemovable = isRemovable;
- }
- }
- }
|