36 lines
831 B
C#
36 lines
831 B
C#
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Placement handler for brand-new blocks dragged from the menu.
|
|
/// </summary>
|
|
public class NewBlockPlacementHandler : IPlacementHandler
|
|
{
|
|
private readonly CommandHandler _commandHandler;
|
|
|
|
public NewBlockPlacementHandler(CommandHandler commandHandler)
|
|
{
|
|
_commandHandler = commandHandler;
|
|
Debug.Log("initialize the NewBlockPlacement");
|
|
|
|
}
|
|
|
|
public void Commit(BlockEditContext ctx)
|
|
{
|
|
if (ctx.Block == null) return;
|
|
_commandHandler.createBlock(
|
|
ctx.Block.getBlockData()?.blockName,
|
|
ctx.GhostTransform.position,
|
|
ctx.GhostTransform.rotation);
|
|
}
|
|
|
|
public void Cancel(BlockEditContext ctx)
|
|
{
|
|
// nothing for now
|
|
}
|
|
|
|
public void Debugln()
|
|
{
|
|
Debug.Log("Hi I'm New");
|
|
}
|
|
}
|