NorbiPeti
d744aaab79
Added a way to store block groups as blueprints Blocks can be added/removed from block groups, although it doesn't work well atm Added some patches to the test class in an attempt to debug an unrelated issue Added a command to test placing a block group Added a SelectedBlueprint property to the Player class
56 lines
No EOL
1.5 KiB
C#
56 lines
No EOL
1.5 KiB
C#
using System;
|
|
|
|
using RobocraftX.Common;
|
|
using Svelto.ECS;
|
|
|
|
using GamecraftModdingAPI.Engines;
|
|
using GamecraftModdingAPI.Utility;
|
|
using RobocraftX.Blocks;
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
{
|
|
public class BlockEventsEngine : IReactionaryEngine<BlockTagEntityStruct>
|
|
{
|
|
public event EventHandler<BlockPlacedRemovedEventArgs> Placed;
|
|
public event EventHandler<BlockPlacedRemovedEventArgs> 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));
|
|
}
|
|
} |