using System; using RobocraftX.Common; using Svelto.ECS; using RobocraftX.Blocks; using TechbloxModdingAPI.Engines; using TechbloxModdingAPI.Utility; namespace TechbloxModdingAPI.Blocks { public class BlockEventsEngine : IReactionaryEngine { public event EventHandler Placed; public event EventHandler Removed; public void Ready() { } public EntitiesDB entitiesDB { get; set; } public void Dispose() { } public string Name { get; } = "GamecraftModdingAPIBlockEventsEngine"; public bool isRemovable { get; } = false; private bool shouldAddRemove; public void Add(ref BlockTagEntityStruct entityComponent, EGID egid) { if (!(shouldAddRemove = !shouldAddRemove)) return; ExceptionUtil.InvokeEvent(Placed, this, new BlockPlacedRemovedEventArgs {ID = egid}); } public void Remove(ref BlockTagEntityStruct entityComponent, EGID egid) { if (!(shouldAddRemove = !shouldAddRemove)) return; ExceptionUtil.InvokeEvent(Removed, this, new BlockPlacedRemovedEventArgs {ID = egid}); } } public struct BlockPlacedRemovedEventArgs { public EGID ID; public BlockIDs Type; private Block block; public Block Block => block ?? (block = new Block(ID)); } }