2019-12-17 01:55:52 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
using Unity.Mathematics;
|
|
|
|
|
|
|
|
|
|
namespace GamecraftModdingAPI.Blocks
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2020-02-25 23:05:13 +00:00
|
|
|
|
/// Common block rotation operations.
|
|
|
|
|
/// The functionality in this class is not completely implemented and will only work in build mode.
|
2019-12-17 01:55:52 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
public static class Rotation
|
|
|
|
|
{
|
|
|
|
|
private static RotationEngine rotationEngine = new RotationEngine();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-02-25 23:05:13 +00:00
|
|
|
|
/// Rotate a single block by a specific amount in degrees.
|
|
|
|
|
/// This not destroy inter-block connections, so neighbouring blocks will remain attached despite appearances.
|
|
|
|
|
/// The cube placement grid and collision are also rotated.
|
2019-12-17 01:55:52 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">The block's id</param>
|
2020-01-04 00:54:35 +00:00
|
|
|
|
/// <param name="vector">The rotation amount around the x,y,z-axis</param>
|
|
|
|
|
/// <returns>Whether the operation was successful</returns>
|
2019-12-25 19:25:53 +00:00
|
|
|
|
public static bool RotateBlock(uint id, float3 vector)
|
2019-12-17 01:55:52 +00:00
|
|
|
|
{
|
2020-04-13 00:03:23 +00:00
|
|
|
|
if (rotationEngine.IsInGame && GamecraftModdingAPI.Utility.GameState.IsBuildMode())
|
2019-12-17 01:55:52 +00:00
|
|
|
|
{
|
|
|
|
|
rotationEngine.RotateBlock(id, vector);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-02-25 23:05:13 +00:00
|
|
|
|
/// Rotate all connected blocks by a specific amount in degrees.
|
|
|
|
|
/// This does not do anything because it has not been implemented.
|
2019-12-17 01:55:52 +00:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="id">The starting block's id</param>
|
2020-01-04 00:54:35 +00:00
|
|
|
|
/// <param name="vector">The rotation around the x,y,z-axis</param>
|
|
|
|
|
/// <returns>Whether the operation was successful</returns>
|
2019-12-25 19:25:53 +00:00
|
|
|
|
public static bool RotateConnectedBlocks(uint id, float3 vector)
|
2019-12-17 01:55:52 +00:00
|
|
|
|
{
|
2020-04-13 00:03:23 +00:00
|
|
|
|
if (rotationEngine.IsInGame && GamecraftModdingAPI.Utility.GameState.IsBuildMode())
|
2019-12-17 01:55:52 +00:00
|
|
|
|
{
|
2019-12-25 19:25:53 +00:00
|
|
|
|
rotationEngine.RotateConnectedBlocks(id, vector);
|
2019-12-17 01:55:52 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Init()
|
|
|
|
|
{
|
|
|
|
|
GamecraftModdingAPI.Utility.GameEngineManager.AddGameEngine(rotationEngine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|