Fixed ECS references in various files in SHADE_Managed

This commit is contained in:
Kah Wei 2022-09-13 15:18:56 +08:00
parent 04cae0fad9
commit 0ed5cecbf3
19 changed files with 100 additions and 109 deletions

View File

@ -34,6 +34,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SHADE_Managed", "SHADE_Mana
{88F1A057-74BE-FB62-9DD7-E90A890331F1} = {88F1A057-74BE-FB62-9DD7-E90A890331F1}
{C0FF640D-2C14-8DBE-F595-301E616989EF} = {C0FF640D-2C14-8DBE-F595-301E616989EF}
{8EAD431C-7A4F-6EF2-630A-82464F4BF542} = {8EAD431C-7A4F-6EF2-630A-82464F4BF542}
{3F92E998-2BF5-783D-D47A-B1F3C0BC44C0} = {3F92E998-2BF5-783D-D47A-B1F3C0BC44C0}
EndProjectSection
EndProject
Global

View File

@ -64,7 +64,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
@ -86,7 +86,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
@ -114,6 +114,9 @@
<ProjectReference Include="..\SHADE_Engine\SHADE_Engine.vcxproj">
<Project>{3F92E998-2BF5-783D-D47A-B1F3C0BC44C0}</Project>
</ProjectReference>
<ProjectReference Include="..\SHADE_Managed\SHADE_Managed.vcxproj">
<Project>{16DB1400-829B-9036-4BD6-D9B3B755D512}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -7,7 +7,7 @@ project "SHADE_Application"
systemversion "latest"
pchheader "SBpch.h"
pchsource "%{prj.location}/src/SBpch.cpp"
staticruntime "on"
staticruntime "off"
entrypoint "wWinMainCRTStartup"
system ("windows")
@ -33,7 +33,8 @@ project "SHADE_Application"
links
{
"SHADE_Engine"
"SHADE_Engine",
"SHADE_Managed"
}
postbuildcommands

View File

@ -64,7 +64,7 @@
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>
@ -91,7 +91,7 @@
<IntrinsicFunctions>true</IntrinsicFunctions>
<MinimalRebuild>false</MinimalRebuild>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard>stdcpplatest</LanguageStandard>
</ClCompile>

View File

@ -7,7 +7,7 @@ project "SHADE_Engine"
systemversion "latest"
pchheader "SHpch.h"
pchsource "%{prj.location}/src/SHpch.cpp"
staticruntime "on"
staticruntime "off"
files
{

View File

@ -16,8 +16,8 @@ of DigiPen Institute of Technology is prohibited.
// Project Headers
#include "SHDotNetRuntime.h"
#include "Engine/ECS_Base/SHECSMacros.h"
#include "Engine/ECS_Base/Entity/SHEntity.h"
#include "ECS_Base/SHECSMacros.h"
#include "ECS_Base/Entity/SHEntity.h"
namespace SHADE
{

View File

@ -9,7 +9,7 @@ project "SHADE_Managed"
systemversion "latest"
pchheader "SHpch.h"
pchsource "%{prj.location}/src/SHpch.cpp"
staticruntime "on"
staticruntime "off"
files
{
@ -51,6 +51,7 @@ project "SHADE_Managed"
"yaml-cpp",
"imgui",
"spdlog",
"SHADE_Engine"
}
warnings 'Extra'

View File

@ -28,17 +28,17 @@ namespace SHADE
generic <typename T>
T BaseComponent::AddComponent()
{
return ECS::AddComponent<T>(owner.GetNativeEntity());
return ECS::AddComponent<T>(owner.GetEntity());
}
generic <typename T>
T BaseComponent::GetComponent()
{
return ECS::GetComponent<T>(owner.GetNativeEntity());
return ECS::GetComponent<T>(owner.GetEntity());
}
generic <typename T>
void BaseComponent::RemoveComponent()
{
ECS::RemoveComponent<T>(owner.GetNativeEntity());
ECS::RemoveComponent<T>(owner.GetEntity());
}
/*---------------------------------------------------------------------------------*/

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#pragma once
// External Dependencies
#include "Engine/ECS_Base/Components/SHComponent.h"
#include "ECS_Base/Components/SHComponent.h"
// Project Includes
#include "Engine/Entity.hxx"
#include "Scripts/Script.hxx"
@ -71,34 +71,34 @@ namespace SHADE
/* Script Access Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Adds a PlushieScript of the specified type to this GameObject.
/// Adds a Script of the specified type to this GameObject.
/// </summary>
/// <typeparam name="T">Type of PlushieScript to add.</typeparam>
/// <returns>Reference to the created PlushieScript.</returns>
generic<typename T> where T : ref class, PlushieScript
/// <typeparam name="T">Type of Script to add.</typeparam>
/// <returns>Reference to the created Script.</returns>
generic<typename T> where T : ref class, Script
T AddScript();
/// <summary>
/// Retrieves a PlushieScript of the specified type from this GameObject.
/// If multiple PlushieScripts of the same specified type are added on the same
/// Retrieves a Script of the specified type from this GameObject.
/// If multiple Scripts of the same specified type are added on the same
/// GameObject, this will retrieve the first one added.
/// </summary>
/// <typeparam name="T">Type of PlushieScript to add.</typeparam>
/// <returns>Reference to the PlushieScript to retrieve.</returns>
generic<typename T> where T : ref class, PlushieScript
/// <typeparam name="T">Type of Script to add.</typeparam>
/// <returns>Reference to the Script to retrieve.</returns>
generic<typename T> where T : ref class, Script
T GetScript();
/// <summary>
/// Retrieves a immutable list of PlushieScripts of the specified type from this
/// Retrieves a immutable list of Scripts of the specified type from this
/// GameObject.
/// </summary>
/// <typeparam name="T">Type of PlushieScripts to Get.</typeparam>
/// <returns>Immutable list of PlushieScripts of the specified type.</returns>
generic<typename T> where T : ref class, PlushieScript
/// <typeparam name="T">Type of Scripts to Get.</typeparam>
/// <returns>Immutable list of Scripts of the specified type.</returns>
generic<typename T> where T : ref class, Script
System::Collections::Generic::IEnumerable<T>^ GetScripts();
/// <summary>
/// Removes all PlushieScripts of the specified type from this GameObject.
/// Removes all Scripts of the specified type from this GameObject.
/// </summary>
/// <typeparam name="T">Type of PLushieScripts to remove.</typeparam>
generic<typename T> where T : ref class, PlushieScript
generic<typename T> where T : ref class, Script
void RemoveScript();
protected:

View File

@ -20,7 +20,7 @@ of DigiPen Institute of Technology is prohibited.
#include <sstream>
#include <msclr\marshal_cppstd.h>
// External Dependencies
#include "Engine/ECS_Base/System/SHEntityManager.h"
#include "ECS_Base/System/SHEntityManager.h"
// Project Headers
#include "Utility/Convert.hxx"
#include "Utility/Debug.hxx"

View File

@ -17,8 +17,8 @@ of DigiPen Institute of Technology is prohibited.
// Primary Include
#include "ECS.hxx"
// External Dependencies
#include "Engine/ECS_Base/System/SHComponentManager.h"
#include "Engine/ECS_Base/System/SHEntityManager.h"
#include "ECS_Base/System/SHComponentManager.h"
#include "ECS_Base/System/SHEntityManager.h"
namespace SHADE
{

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#pragma once
// External Dependencies
#include "Engine/ECS_Base/System/SHComponentManager.h"
#include "ECS_Base/System/SHComponentManager.h"
// Project Includes
#include "Components/Component.hxx"

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#pragma once
// External Dependencies
#include "Engine/ECS_Base/Entity/SHEntity.h"
#include "ECS_Base/Entity/SHEntity.h"
namespace SHADE
{

View File

@ -16,8 +16,10 @@ of DigiPen Institute of Technology is prohibited.
// Primary Header
#include "GameObject.hxx"
// External Dependencies
#include "Engine/ECS_Base/System/SHEntityManager.h"
#include "ECS_Base/System/SHEntityManager.h"
// Project Headers
#include "ECS.hxx"
#include "Scripts/ScriptStore.hxx"
namespace SHADE
{
@ -74,36 +76,31 @@ namespace SHADE
generic <typename T>
T GameObject::AddComponent()
{
throw gcnew System::NotImplementedException();
//return ECS::AddComponent<T>(GetNativeEntity());
return ECS::AddComponent<T>(entity);
}
generic <typename T>
T GameObject::GetComponent()
{
throw gcnew System::NotImplementedException();
//return ECS::GetComponent<T>(GetNativeEntity());
return ECS::GetComponent<T>(entity);
}
generic <typename T>
T GameObject::GetComponentInChildren()
{
throw gcnew System::NotImplementedException();
//return ECS::GetComponentInChildren<T>(GetNativeEntity());
return ECS::GetComponentInChildren<T>(entity);
}
generic <typename T>
T GameObject::EnsureComponent()
{
throw gcnew System::NotImplementedException();
//return ECS::EnsureComponent<T>(GetNativeEntity());
return ECS::EnsureComponent<T>(entity);
}
generic <typename T>
void GameObject::RemoveComponent()
{
throw gcnew System::NotImplementedException();
//ECS::RemoveComponent<T>(GetNativeEntity());
ECS::RemoveComponent<T>(entity);
}
/*---------------------------------------------------------------------------------*/
@ -112,36 +109,31 @@ namespace SHADE
generic <typename T>
T GameObject::AddScript()
{
throw gcnew System::NotImplementedException();
//return ScriptStore::AddScript<T>(entity);
return ScriptStore::AddScript<T>(entity);
}
generic <typename T>
T GameObject::GetScript()
{
throw gcnew System::NotImplementedException();
//return ScriptStore::GetScript<T>(entity);
return ScriptStore::GetScript<T>(entity);
}
generic <typename T>
T GameObject::GetScriptInChildren()
{
throw gcnew System::NotImplementedException();
//return ScriptStore::GetScriptInChildren<T>(entity);
return ScriptStore::GetScriptInChildren<T>(entity);
}
generic <typename T>
System::Collections::Generic::IEnumerable<T>^ GameObject::GetScripts()
{
throw gcnew System::NotImplementedException();
//return ScriptStore::GetScripts<T>(entity);
return ScriptStore::GetScripts<T>(entity);
}
generic <typename T>
void GameObject::RemoveScript()
{
throw gcnew System::NotImplementedException();
//ScriptStore::RemoveScript<T>(entity);
ScriptStore::RemoveScript<T>(entity);
}
/*---------------------------------------------------------------------------------*/
@ -158,10 +150,13 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Getters */
/*---------------------------------------------------------------------------------*/
SHEntity GameObject::GetNativeEntity()
SHEntity& GameObject::GetNativeEntity()
{
throw gcnew System::NotImplementedException();
//return Convert::ToNative(entity);
SHEntity* nativeEntity = SHEntityManager::GetEntityByID(entity);
if (nativeEntity == nullptr)
throw gcnew System::InvalidOperationException("[GameObject] Unable to obtain native Entity for GameObject.");
return *nativeEntity;
}
/*---------------------------------------------------------------------------------*/

View File

@ -22,7 +22,7 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* Forward Declarations */
/*---------------------------------------------------------------------------------*/
ref class PlushieScript;
ref class Script;
ref class BaseComponent;
/*---------------------------------------------------------------------------------*/
@ -158,43 +158,43 @@ namespace SHADE
/* Script Access Functions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Adds a PlushieScript of the specified type to this GameObject.
/// Adds a Script of the specified type to this GameObject.
/// </summary>
/// <typeparam name="T">Type of PlushieScript to add.</typeparam>
/// <returns>Reference to the created PlushieScript.</returns>
generic<typename T> where T : ref class, PlushieScript
/// <typeparam name="T">Type of Script to add.</typeparam>
/// <returns>Reference to the created Script.</returns>
generic<typename T> where T : ref class, Script
T AddScript();
/// <summary>
/// Retrieves a PlushieScript of the specified type from this GameObject.
/// If multiple PlushieScripts of the same specified type are added on the same
/// Retrieves a Script of the specified type from this GameObject.
/// If multiple Scripts of the same specified type are added on the same
/// GameObject, this will retrieve the first one added.
/// </summary>
/// <typeparam name="T">Type of PlushieScript to retrieve.</typeparam>
/// <returns>Reference to the PlushieScript to retrieve.</returns>
generic<typename T> where T : ref class, PlushieScript
/// <typeparam name="T">Type of Script to retrieve.</typeparam>
/// <returns>Reference to the Script to retrieve.</returns>
generic<typename T> where T : ref class, Script
T GetScript();
/// <summary>
/// Retrieves a PlushieScript of the specified type from child GameObjects.
/// If multiple PlushieScripts of the same specified type are added on the same
/// Retrieves a Script of the specified type from child GameObjects.
/// If multiple Scripts of the same specified type are added on the same
/// child GameObject, this will retrieve the first one added.
/// </summary>
/// <typeparam name="T">Type of PlushieScript to retrieve.</typeparam>
/// <returns>Reference to the PlushieScript to retrieve.</returns>
generic<typename T> where T : ref class, PlushieScript
/// <typeparam name="T">Type of Script to retrieve.</typeparam>
/// <returns>Reference to the Script to retrieve.</returns>
generic<typename T> where T : ref class, Script
T GetScriptInChildren();
/// <summary>
/// Retrieves a immutable list of PlushieScripts of the specified type from this
/// Retrieves a immutable list of Scripts of the specified type from this
/// GameObject.
/// </summary>
/// <typeparam name="T">Type of PlushieScripts to retrieve.</typeparam>
/// <returns>Immutable list of PlushieScripts of the specified type.</returns>
generic<typename T> where T : ref class, PlushieScript
/// <typeparam name="T">Type of Scripts to retrieve.</typeparam>
/// <returns>Immutable list of Scripts of the specified type.</returns>
generic<typename T> where T : ref class, Script
System::Collections::Generic::IEnumerable<T>^ GetScripts();
/// <summary>
/// Removes all PlushieScripts of the specified type from this GameObject.
/// Removes all Scripts of the specified type from this GameObject.
/// </summary>
/// <typeparam name="T">Type of PLushieScripts to remove.</typeparam>
generic<typename T> where T : ref class, PlushieScript
generic<typename T> where T : ref class, Script
void RemoveScript();
internal:
@ -229,7 +229,7 @@ namespace SHADE
/// Retrieves the native Entity object that this GameObject represents.
/// </summary>
/// <returns>Native Entity object that this GameObject represents.</returns>
SHEntity GetNativeEntity();
SHEntity& GetNativeEntity();
private:
/*-----------------------------------------------------------------------------*/

View File

@ -21,7 +21,6 @@ of DigiPen Institute of Technology is prohibited.
// Project Headers
#include "Utility/Debug.hxx"
#include "Utility/Convert.hxx"
#include "Tools/SHLogger.h"
#include "Script.hxx"
#include "Engine/Entity.hxx"
@ -88,7 +87,7 @@ namespace SHADE
oss << "[ScriptStore] No Script named "
<< Convert::ToNative(scriptName)
<< " found!";
SHLOG_ERROR(oss.str());
Debug::LogError(oss.str());
return false;
}
@ -104,7 +103,7 @@ namespace SHADE
std::ostringstream oss;
oss << "[ScriptStore] Failed to add Script named \"" << Convert::ToNative(scriptName)
<< "\" to Entity #" << entity << "! (" << Convert::ToNative(e->GetType()->Name) << ")";
SHLOG_ERROR(oss.str());
Debug::LogError(oss.str());
return false;
}
return true;
@ -593,7 +592,7 @@ namespace SHADE
/* Where */
bool predicateFunc(Pair^ pair)
{
return pair->type->IsSubclassOf(PlushieScript::typeid) && !pair->type->IsAbstract;
return pair->type->IsSubclassOf(Script::typeid) && !pair->type->IsAbstract;
}
/* Select */
@ -616,7 +615,7 @@ namespace SHADE
Func<Assembly^, Type^, Pair^>^ resultSelector = gcnew Func<Assembly^, Type^, Pair^>(resultSelectorFunc);
IEnumerable<Pair^>^ selectManyResult = Enumerable::SelectMany(assemblies, collectionSelector, resultSelector);
/* Where: Are concrete PlushieScripts */
/* Where: Are concrete Scripts */
Func<Pair^, bool>^ predicate = gcnew Func<Pair^, bool>(predicateFunc);
IEnumerable<Pair^>^ whereResult = Enumerable::Where(selectManyResult, predicate);
@ -628,7 +627,7 @@ namespace SHADE
std::ostringstream oss;
oss << "[ScriptStore] Successfully retrieved references to " << Enumerable::Count(scriptTypeList)
<< " Script(s) from currently loaded assemblies.";
SHLOG_INFO(oss.str());
Debug::Log(oss.str());
}
void ScriptStore::getGenericMethods()
@ -636,7 +635,7 @@ namespace SHADE
addScriptMethod = ScriptStore::typeid->GetMethod("AddScript");
if (addScriptMethod == nullptr)
{
SHLOG_ERROR("[ScriptStore] Failed to get MethodInfo of \"AddScript<T>()\". Adding of scripts from native code will fail.");
Debug::LogError("[ScriptStore] Failed to get MethodInfo of \"AddScript<T>()\". Adding of scripts from native code will fail.");
}
}

View File

@ -25,10 +25,6 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
/* ECS Conversions */
/*---------------------------------------------------------------------------------*/
SHEntity Convert::ToNative(Entity rawId)
{
return *SHEntityManager::GetEntityByID(rawId);
}
Entity Convert::ToCLI(SHEntity entity)
{
return static_cast<Entity>(entity.GetEID());

View File

@ -15,7 +15,7 @@ of DigiPen Institute of Technology is prohibited.
#pragma once
// External Dependencies
#include "Engine/ECS_Base/Entity/SHEntity.h"
#include "ECS_Base/Entity/SHEntity.h"
// Project Includes
#include "Engine/Entity.hxx"
@ -37,12 +37,6 @@ namespace SHADE
/* ECS Conversions */
/*-----------------------------------------------------------------------------*/
/// <summary>
/// Converts from a managed Entity (UInt32) to a native Entity.
/// </summary>
/// <param name="rawId">Raw ID of an Entity.</param>
/// <returns>Native representation of the specified Entity.</returns>
static SHEntity ToNative(Entity rawId);
/// <summary>
/// Converts from a native Entity to a managed Entity (UInt32).
/// </summary>
/// <param name="entity">Native Entity to convert from.</param>

View File

@ -22,6 +22,7 @@ of DigiPen Institute of Technology is prohibited.
#include "Tools/SHLogger.h"
// Project Headers
#include "Convert.hxx"
#include "SHLog.h"
namespace SHADE
{
@ -30,11 +31,11 @@ namespace SHADE
/*---------------------------------------------------------------------------------*/
void Debug::Log(const std::string& str)
{
SHLOG_INFO(str);
SHLog::Info(str);
}
void Debug::Log(System::String^ str)
{
SHLOG_INFO(Convert::ToNative(str));
SHLog::Info(Convert::ToNative(str));
}
void Debug::Log(System::String^ str, Object^ owner)
@ -49,15 +50,15 @@ namespace SHADE
{
std::ostringstream oss;
oss << "[" << throwerName << "] " << Convert::ToNative(str);
SHLOG_INFO(oss.str());
SHLog::Info(oss.str());
}
void Debug::LogWarning(const std::string& str)
{
SHLOG_WARNING(str);
SHLog::Warning(str);
}
void Debug::LogWarning(System::String^ str)
{
SHLOG_WARNING(Convert::ToNative(str));
SHLog::Warning(Convert::ToNative(str));
}
void Debug::LogWarning(System::String^ str, Object^ thrower)
{
@ -72,15 +73,15 @@ namespace SHADE
{
std::ostringstream oss;
oss << "[" << throwerName << "] " << Convert::ToNative(str);
SHLOG_WARNING(oss.str());
SHLog::Warning(oss.str());
}
void Debug::LogError(const std::string& str)
{
SHLOG_ERROR(str);
SHLog::Error(str);
}
void Debug::LogError(System::String^ str)
{
SHLOG_ERROR(Convert::ToNative(str));
SHLog::Error(Convert::ToNative(str));
}
void Debug::LogError(System::String^ str, Object^ thrower)
{
@ -90,7 +91,7 @@ namespace SHADE
{
std::ostringstream oss;
oss << "[" << throwerName << "] -> " << Convert::ToNative(str);
SHLOG_ERROR(oss.str());
SHLog::Error(oss.str());
}
void Debug::LogError(System::String^ str, System::String^ throwerName)
{
@ -113,12 +114,12 @@ namespace SHADE
{
std::ostringstream oss;
oss << "[" << throwerName << "] Unhandled exception: " << Convert::ToNative(exception->ToString());
SHLOG_ERROR(oss.str());
SHLog::Error(oss.str());
}
void Debug::LogExceptionNative(const std::exception& exception, const std::string& throwerName)
{
std::ostringstream oss;
oss << "[" << throwerName << "] Unhandled exception: " << exception.what();
SHLOG_ERROR(oss.str());
SHLog::Error(oss.str());
}
}