|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- 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 object type { get; set; }
-
- public bool isRemovable { get; }
-
- public IEntityFactory Factory { private get; set; }
-
- public IEntitiesDB 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 = 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(object type, string name, bool isRemovable = true)
- {
- this.type = type;
- this.Name = name;
- this.isRemovable = isRemovable;
- }
- }
- }
|