diff --git a/GamecraftModdingAPI/Blocks/BlockColors.cs b/GamecraftModdingAPI/Blocks/BlockColors.cs
index 7e405b4..146bcbf 100644
--- a/GamecraftModdingAPI/Blocks/BlockColors.cs
+++ b/GamecraftModdingAPI/Blocks/BlockColors.cs
@@ -1,5 +1,8 @@
namespace GamecraftModdingAPI.Blocks
{
+ ///
+ /// Preset block colours
+ ///
public enum BlockColors
{
Default = byte.MaxValue,
diff --git a/GamecraftModdingAPI/Blocks/BlockIDs.cs b/GamecraftModdingAPI/Blocks/BlockIDs.cs
index 83dc735..cbe581d 100644
--- a/GamecraftModdingAPI/Blocks/BlockIDs.cs
+++ b/GamecraftModdingAPI/Blocks/BlockIDs.cs
@@ -1,5 +1,8 @@
namespace GamecraftModdingAPI.Blocks
{
+ ///
+ /// Possible block types
+ ///
public enum BlockIDs
{
AluminiumCube,
diff --git a/GamecraftModdingAPI/Blocks/Movement.cs b/GamecraftModdingAPI/Blocks/Movement.cs
index 1222b09..4f4a8ec 100644
--- a/GamecraftModdingAPI/Blocks/Movement.cs
+++ b/GamecraftModdingAPI/Blocks/Movement.cs
@@ -20,7 +20,7 @@ namespace GamecraftModdingAPI.Blocks
///
/// The block's id
/// The movement amount (x,y,z)
- ///
+ /// Whether the operation was successful
public static bool MoveBlock(uint id, float3 vector)
{
if (movementEngine.IsInGame && movementEngine.IsBuildMode())
@@ -36,7 +36,7 @@ namespace GamecraftModdingAPI.Blocks
///
/// The starting block's id
/// The movement amount (x,y,z)
- ///
+ /// Whether the operation was successful
public static bool MoveConnectedBlocks(uint id, float3 vector)
{
if (movementEngine.IsInGame && movementEngine.IsBuildMode())
diff --git a/GamecraftModdingAPI/Blocks/Placement.cs b/GamecraftModdingAPI/Blocks/Placement.cs
index 110f92c..f650312 100644
--- a/GamecraftModdingAPI/Blocks/Placement.cs
+++ b/GamecraftModdingAPI/Blocks/Placement.cs
@@ -1,12 +1,13 @@
using System;
-using GamecraftModdingAPI.Utility;
-using GCMC;
+
using Unity.Mathematics;
+using GamecraftModdingAPI.Utility;
+
namespace GamecraftModdingAPI.Blocks
{
///
- /// Common block movement operations
+ /// Common block placement operations
///
public static class Placement
{
@@ -24,17 +25,26 @@ namespace GamecraftModdingAPI.Blocks
/// The block's uniform scale - default scale is 1 (with 0.2 width)
/// The block's non-uniform scale - 0 means is used
/// The player who placed the block
- ///
+ /// Whether the operation was successful
public static bool PlaceBlock(BlockIDs block, float3 position,
quaternion rotation = new quaternion(), BlockColors color = BlockColors.Default, byte darkness = 0,
int uscale = 1, float3 scale = new float3(), uint playerId = 0)
{
if (placementEngine.IsInGame && GameState.IsBuildMode())
{
- placementEngine.PlaceBlock(block, color, darkness, position, uscale, scale, playerId, rotation);
+ try
+ {
+ placementEngine.PlaceBlock(block, color, darkness, position, uscale, scale, playerId, rotation);
+ }
+ catch (Exception e)
+ {
+#if DEBUG
+ Logging.LogException(e);
+#endif
+ return false;
+ }
return true;
}
-
return false;
}
diff --git a/GamecraftModdingAPI/Blocks/PlacementEngine.cs b/GamecraftModdingAPI/Blocks/PlacementEngine.cs
index 3171cd1..fbad336 100644
--- a/GamecraftModdingAPI/Blocks/PlacementEngine.cs
+++ b/GamecraftModdingAPI/Blocks/PlacementEngine.cs
@@ -1,10 +1,8 @@
using System;
using System.Reflection;
+
using DataLoader;
-using GamecraftModdingAPI.Blocks;
-using GamecraftModdingAPI.Utility;
using Harmony;
-using JetBrains.Annotations;
using RobocraftX.Blocks;
using RobocraftX.Blocks.Ghost;
using RobocraftX.Blocks.Scaling;
@@ -22,8 +20,13 @@ using Unity.Mathematics;
using UnityEngine;
using uREPL;
-namespace GCMC
+using GamecraftModdingAPI.Utility;
+
+namespace GamecraftModdingAPI.Blocks
{
+ ///
+ /// Engine which executes block placement actions
+ ///
public class PlacementEngine : IApiEngine
{
public bool IsInGame = false;
@@ -55,22 +58,14 @@ namespace GCMC
public void PlaceBlock(BlockIDs block, BlockColors color, byte darkness, float3 position, int uscale,
float3 scale, uint playerId, quaternion rotation)
{ //It appears that only the non-uniform scale has any visible effect, but if that's not given here it will be set to the uniform one
- try
- {
- if (darkness > 9)
- throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)");
- BuildBlock((ushort) block, (byte) (color + darkness * 10), position, uscale, scale, rotation).Init(
- new BlockPlacementInfoStruct()
- {
- loadedFromDisk = false,
- placedBy = playerId
- });
- }
- catch (Exception e)
- {
- Console.WriteLine(e);
- Log.Error(e.Message);
- }
+ if (darkness > 9)
+ throw new Exception("That is too dark. Make sure to use 0-9 as darkness. (0 is default.)");
+ BuildBlock((ushort) block, (byte) (color + darkness * 10), position, uscale, scale, rotation).Init(
+ new BlockPlacementInfoStruct()
+ {
+ loadedFromDisk = false,
+ placedBy = playerId
+ });
}
private EntityStructInitializer BuildBlock(ushort block, byte color, float3 position, int uscale, float3 scale, quaternion rot)
@@ -135,16 +130,15 @@ namespace GCMC
return structInitializer;
}
- public string Name { get; } = nameof(PlacementEngine);
+ public string Name { get; } = "GamecraftModdingAPIPlacementGameEngine";
[HarmonyPatch]
- [UsedImplicitly]
public class FactoryObtainerPatch
{
static void Postfix(BlockEntityFactory blockEntityFactory)
{
_blockEntityFactory = blockEntityFactory;
- Debug.Log("Block entity factory injected.");
+ Logging.MetaDebugLog("Block entity factory injected.");
}
static MethodBase TargetMethod(HarmonyInstance instance)
diff --git a/GamecraftModdingAPI/Blocks/Rotation.cs b/GamecraftModdingAPI/Blocks/Rotation.cs
index 5f13663..a8ccd5a 100644
--- a/GamecraftModdingAPI/Blocks/Rotation.cs
+++ b/GamecraftModdingAPI/Blocks/Rotation.cs
@@ -19,8 +19,8 @@ namespace GamecraftModdingAPI.Blocks
/// Rotate a single block by a specific amount in degrees
///
/// The block's id
- /// The rotation amount around the x,y,z-planes
- ///
+ /// The rotation amount around the x,y,z-axis
+ /// Whether the operation was successful
public static bool RotateBlock(uint id, float3 vector)
{
if (rotationEngine.IsInGame && rotationEngine.IsBuildMode())
@@ -35,8 +35,8 @@ namespace GamecraftModdingAPI.Blocks
/// Rotate all connected blocks by a specific amount in degrees
///
/// The starting block's id
- /// The rotation around the x,y,z-planes
- ///
+ /// The rotation around the x,y,z-axis
+ /// Whether the operation was successful
public static bool RotateConnectedBlocks(uint id, float3 vector)
{
if (rotationEngine.IsInGame && rotationEngine.IsBuildMode())
diff --git a/GamecraftModdingAPI/Blocks/SignalEngine.cs b/GamecraftModdingAPI/Blocks/SignalEngine.cs
index 41c9328..5dde022 100644
--- a/GamecraftModdingAPI/Blocks/SignalEngine.cs
+++ b/GamecraftModdingAPI/Blocks/SignalEngine.cs
@@ -24,7 +24,7 @@ using GamecraftModdingAPI.Utility;
namespace GamecraftModdingAPI.Blocks
{
///
- /// Engine which executes block movement actions
+ /// Engine which executes signal actions
///
public class SignalEngine : IApiEngine
{