TechbloxModdingAPI/GamecraftModdingAPI/Blocks/Rotation.cs
2019-12-16 20:55:52 -05:00

55 lines
1.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Unity.Mathematics;
namespace GamecraftModdingAPI.Blocks
{
/// <summary>
/// Common block movement operations
/// </summary>
public static class Rotation
{
private static RotationEngine rotationEngine = new RotationEngine();
/// <summary>
/// Rotate a single block by a specific amount in degrees
/// </summary>
/// <param name="id">The block's id</param>
/// <param name="vector">The rotation amount around the x,y,z-planes</param>
/// <returns></returns>
public static bool MoveBlock(uint id, float3 vector)
{
if (rotationEngine.IsInGame && rotationEngine.IsBuildMode())
{
rotationEngine.RotateBlock(id, vector);
return true;
}
return false;
}
/// <summary>
/// Rotate all connected blocks by a specific amount in degrees
/// </summary>
/// <param name="id">The starting block's id</param>
/// <param name="vector">The rotation around the x,y,z-planes</param>
/// <returns></returns>
public static bool MoveRotateBlocks(uint id, float3 vector)
{
if (rotationEngine.IsInGame && rotationEngine.IsBuildMode())
{
rotationEngine.MoveConnectedBlocks(id, vector);
return true;
}
return false;
}
public static void Init()
{
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(rotationEngine);
}
}
}