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