From d643fe66b0b17beaebea32fe525f6953f1850c6a Mon Sep 17 00:00:00 2001 From: Kah Wei Date: Tue, 13 Sep 2022 17:16:36 +0800 Subject: [PATCH] Fixed errors in SHADE_Managed --- SHADE_Managed/src/Engine/ECS.cxx | 4 ++-- SHADE_Managed/src/Engine/Entity.cxx | 2 +- SHADE_Managed/src/Math/Vector2.hxx | 12 +++++++----- SHADE_Managed/src/Math/Vector3.hxx | 2 +- SHADE_Managed/src/Scripts/ScriptStore.cxx | 11 ++++++++++- SHADE_Managed/src/Scripts/ScriptStore.hxx | 2 +- SHADE_Managed/src/Utility/Convert.cxx | 2 +- 7 files changed, 23 insertions(+), 12 deletions(-) diff --git a/SHADE_Managed/src/Engine/ECS.cxx b/SHADE_Managed/src/Engine/ECS.cxx index a6ea0b96..5aceceee 100644 --- a/SHADE_Managed/src/Engine/ECS.cxx +++ b/SHADE_Managed/src/Engine/ECS.cxx @@ -244,8 +244,8 @@ namespace SHADE { using namespace System::Reflection; - array^ params = gcnew array{ Convert::ToCLI(entity) }; - return safe_cast(Activator::CreateInstance + array^ params = gcnew array{ static_cast(entity) }; + return safe_cast(System::Activator::CreateInstance ( T::typeid, BindingFlags::Instance | BindingFlags::NonPublic | BindingFlags::CreateInstance, diff --git a/SHADE_Managed/src/Engine/Entity.cxx b/SHADE_Managed/src/Engine/Entity.cxx index bd915c42..ba1a31c6 100644 --- a/SHADE_Managed/src/Engine/Entity.cxx +++ b/SHADE_Managed/src/Engine/Entity.cxx @@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited. // Primary Header #include "Entity.hxx" // External Dependencies -#include "Engine/ECS_Base/System/SHEntityManager.h" +#include "ECS_Base/System/SHEntityManager.h" namespace SHADE { diff --git a/SHADE_Managed/src/Math/Vector2.hxx b/SHADE_Managed/src/Math/Vector2.hxx index c52cdc72..c19828f4 100644 --- a/SHADE_Managed/src/Math/Vector2.hxx +++ b/SHADE_Managed/src/Math/Vector2.hxx @@ -16,13 +16,17 @@ of DigiPen Institute of Technology is prohibited. // Standard Libraries #include +// Undefine +#undef min +#undef max + namespace SHADE { /// /// CLR version of the the PlushieEngine's Vector2 class that represents a /// 2-Dimensional Vector. Designed to closely match Unity's Vector2 struct. /// - [StructLayout(LayoutKind::Sequential)] + [System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)] public value struct Vector2 : public System::IEquatable { public: @@ -42,8 +46,7 @@ namespace SHADE /// Shorthand for writing Vector2(double.NegativeInfinity, /// double.NegativeInfinity). /// - static const Vector2 NegativeInfinity = Vector2(std::numeric_limits::lowest(), - std::numeric_limits::lowest()); + static const Vector2 NegativeInfinity = Vector2(std::numeric_limits::lowest(), std::numeric_limits::lowest()); /// /// Shorthand for writing Vector2(1, 1). /// @@ -52,8 +55,7 @@ namespace SHADE /// Shorthand for writing Vector2(double.PositiveInfinity, /// double.PositiveInfinity). /// - static const Vector2 PositiveInfinity = Vector2(std::numeric_limits::max(), - std::numeric_limits::max()); + static const Vector2 PositiveInfinity = Vector2(std::numeric_limits::max(), std::numeric_limits::max()); /// /// Shorthand for writing Vector2(1, 0). /// diff --git a/SHADE_Managed/src/Math/Vector3.hxx b/SHADE_Managed/src/Math/Vector3.hxx index ab05ddc9..fb2fe8fc 100644 --- a/SHADE_Managed/src/Math/Vector3.hxx +++ b/SHADE_Managed/src/Math/Vector3.hxx @@ -24,7 +24,7 @@ namespace SHADE /// CLR version of the the PlushieEngine's Vector3 class that represents a /// 3-Dimensional Vector. Designed to closely match Unity's Vector3 struct. /// - [StructLayout(LayoutKind::Sequential)] + [System::Runtime::InteropServices::StructLayout(System::Runtime::InteropServices::LayoutKind::Sequential)] public value struct Vector3 : public System::IEquatable { public: diff --git a/SHADE_Managed/src/Scripts/ScriptStore.cxx b/SHADE_Managed/src/Scripts/ScriptStore.cxx index 8a574084..79a75bda 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.cxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.cxx @@ -18,6 +18,8 @@ of DigiPen Institute of Technology is prohibited. #include "ScriptStore.hxx" // Standard Libraries #include +// External Dependencies +#include "ECS_Base/System/SHEntityManager.h" // Project Headers #include "Utility/Debug.hxx" #include "Utility/Convert.hxx" @@ -658,7 +660,14 @@ namespace SHADE bool ScriptStore::isEntityActive(Entity entity) { + // Get native Entity + SHEntity* nativeEntity = SHEntityManager::GetEntityByID(entity); + + // Entity Validity Check + if (nativeEntity == nullptr) + throw gcnew System::InvalidOperationException("Attempted to get native Component to an invalid Entity."); + // Check active state - return Convert::ToNative(entity).isActive; + return nativeEntity->isActive; } } diff --git a/SHADE_Managed/src/Scripts/ScriptStore.hxx b/SHADE_Managed/src/Scripts/ScriptStore.hxx index 91c98ce9..798c4cb6 100644 --- a/SHADE_Managed/src/Scripts/ScriptStore.hxx +++ b/SHADE_Managed/src/Scripts/ScriptStore.hxx @@ -73,7 +73,7 @@ namespace SHADE /// True if successfully added. False otherwise with the error logged to the /// console. /// - static bool AddScriptViaNameWithRef(Entity entity, System::String^ scriptName, [Out] Script^% createdScript); + static bool AddScriptViaNameWithRef(Entity entity, System::String^ scriptName, [System::Runtime::InteropServices::Out] Script^% createdScript); /// /// Retrieves the first Script from the specified Entity that matches the /// specified type. diff --git a/SHADE_Managed/src/Utility/Convert.cxx b/SHADE_Managed/src/Utility/Convert.cxx index 2c0b7e65..8a8aff70 100644 --- a/SHADE_Managed/src/Utility/Convert.cxx +++ b/SHADE_Managed/src/Utility/Convert.cxx @@ -17,7 +17,7 @@ of DigiPen Institute of Technology is prohibited. // Primary Header #include "Convert.hxx" // External Dependencies -#include "Engine/ECS_Base/System//SHEntityManager.h" +#include "ECS_Base/System//SHEntityManager.h" #include namespace SHADE