diff --git a/Hazard/src/Hazard/Scripting/Bindings/EntityBindings.h b/Hazard/src/Hazard/Scripting/Bindings/EntityBindings.h index e9547e6db..ec89928ca 100644 --- a/Hazard/src/Hazard/Scripting/Bindings/EntityBindings.h +++ b/Hazard/src/Hazard/Scripting/Bindings/EntityBindings.h @@ -7,12 +7,13 @@ #include "Mono/Core/Mono.h" #define GET_ENTITY(id) handler->GetCurrentWorld()->GetEntityFromUID(id) + #define RegisterComponent(Type, Image) { \ MonoType* monoType = Mono::MonoTypeFromReflectionName("Hazard." #Type, Image); \ if (monoType) \ { \ hasComponentFuncs[monoType] = [](uint64_t entityID) { return GET_ENTITY(entityID).HasComponent(); }; \ - getComponentFuncs[monoType] = [](uint64_t entityID) -> ComponentBase& { return GET_ENTITY(entityID).GetComponent(); }; \ + getComponentFuncs[monoType] = [](uint64_t entityID) -> ComponentBase& { return GET_ENTITY(entityID).GetComponent(); }; \ createComponentFuncs[monoType] = [](uint64_t entityID) { GET_ENTITY(entityID).AddComponent(); }; \ } \ } diff --git a/Hazard/src/Hazard/Scripting/Bindings/TagComponentBindings.h b/Hazard/src/Hazard/Scripting/Bindings/TagComponentBindings.h index fa61c01ff..f0392e11b 100644 --- a/Hazard/src/Hazard/Scripting/Bindings/TagComponentBindings.h +++ b/Hazard/src/Hazard/Scripting/Bindings/TagComponentBindings.h @@ -9,7 +9,8 @@ namespace Hazard { using namespace HazardScript; - static MonoString* TagComponent_GetName_Native(uint64_t id) { + static MonoString* TagComponent_GetName_Native(uint64_t id) + { auto& tag = GET_ENTITY(id).GetComponent(); return Mono::StringToMonoString(tag.Tag); } diff --git a/Hazard/src/Hazard/Scripting/MonoUtils.cpp b/Hazard/src/Hazard/Scripting/MonoUtils.cpp index a0420004a..c2e3c301c 100644 --- a/Hazard/src/Hazard/Scripting/MonoUtils.cpp +++ b/Hazard/src/Hazard/Scripting/MonoUtils.cpp @@ -115,7 +115,8 @@ namespace HazardScript { ObjectReference stored = GetStoredValue(); ObjectReference ref = {}; - if (!m_Field->GetType().IsArray()) { + if (!m_Field->GetType().IsArray()) + { ref.MonoObject = MonoFieldUtils::GetFieldValue(object, m_Field->GetMonoField()); ref.MonoObjectHandle = stored.MonoObject == ref.MonoObject ? stored.MonoObjectHandle : 0; @@ -146,21 +147,17 @@ namespace HazardScript template<> void FieldValueStorage::SetLiveValue(MonoObject* object, ObjectReference value) { - if (value.MonoObject == nullptr) { + if (value.MonoObject == nullptr) + { value.MonoObjectHandle = Mono::InstantiateHandle(m_Field->GetType().TypeClass->Class); value.MonoObject = mono_gchandle_get_target(value.MonoObjectHandle); SetStoredValue(value); } if (!m_Field->GetType().IsArray()) - { MonoFieldUtils::SetFieldValue(object, m_Field->GetMonoField(), value.MonoObject); - } else - { - MonoArray* arr = (MonoArray*)object; - MonoArrayUtils::SetElementValue(arr, m_Index, value.MonoObject); - } + MonoArrayUtils::SetElementValue((MonoArray*)object, m_Index, value.MonoObject); MonoMethod* method = mono_class_get_method_from_name(m_Field->GetType().TypeClass->Class, ".ctor", 1); diff --git a/HazardEditor/imgui.ini b/HazardEditor/imgui.ini index fc8769400..613e7a54c 100644 --- a/HazardEditor/imgui.ini +++ b/HazardEditor/imgui.ini @@ -110,8 +110,8 @@ Size=430,450 Collapsed=0 [Window][RenderCommandList] -Pos=2076,937 -Size=484,432 +Pos=2076,788 +Size=484,581 Collapsed=0 DockId=0x0000000A,0 @@ -133,7 +133,7 @@ DockId=0x00000009,0 [Window][Properties] Pos=2076,32 -Size=484,903 +Size=484,754 Collapsed=0 DockId=0x00000002,0 @@ -165,8 +165,8 @@ Size=436,331 Collapsed=0 [Window][Console] -Pos=1313,904 -Size=761,465 +Pos=1368,904 +Size=706,465 Collapsed=0 DockId=0x0000000C,0 @@ -192,7 +192,7 @@ Collapsed=0 [Window][Asset panel] Pos=0,904 -Size=1311,465 +Size=1366,465 Collapsed=0 DockId=0x0000000B,0 @@ -336,10 +336,10 @@ DockSpace ID=0x1E88EA41 Window=0x4BF99D5A Pos=0,32 Size=2560,1337 Split= DockNode ID=0x00000001 Parent=0x00000007 SizeRef=394,929 Selected=0x788BAA0D DockNode ID=0x00000009 Parent=0x00000007 SizeRef=1678,929 CentralNode=1 Selected=0x995B0CF8 DockNode ID=0x00000008 Parent=0x00000003 SizeRef=1661,465 Split=X Selected=0x4B1ECD8B - DockNode ID=0x0000000B Parent=0x00000008 SizeRef=1311,364 Selected=0x4B1ECD8B - DockNode ID=0x0000000C Parent=0x00000008 SizeRef=761,364 Selected=0xF9BEF62A + DockNode ID=0x0000000B Parent=0x00000008 SizeRef=1366,364 Selected=0x4B1ECD8B + DockNode ID=0x0000000C Parent=0x00000008 SizeRef=706,364 Selected=0xF9BEF62A DockNode ID=0x00000004 Parent=0x00000005 SizeRef=338,1048 Selected=0xCAFA65A6 DockNode ID=0x00000006 Parent=0x1E88EA41 SizeRef=484,1345 Split=Y Selected=0xC89E3217 - DockNode ID=0x00000002 Parent=0x00000006 SizeRef=571,903 Selected=0xC89E3217 - DockNode ID=0x0000000A Parent=0x00000006 SizeRef=571,432 Selected=0xCAFA65A6 + DockNode ID=0x00000002 Parent=0x00000006 SizeRef=571,754 Selected=0xC89E3217 + DockNode ID=0x0000000A Parent=0x00000006 SizeRef=571,581 Selected=0xCAFA65A6 diff --git a/HazardEditor/src/GUI/Properties/ScriptFieldUI.h b/HazardEditor/src/GUI/Properties/ScriptFieldUI.h index 7b756f815..725582056 100644 --- a/HazardEditor/src/GUI/Properties/ScriptFieldUI.h +++ b/HazardEditor/src/GUI/Properties/ScriptFieldUI.h @@ -255,8 +255,9 @@ namespace UI std::string typeName = field.GetType().IsArray() ? field.GetType().GetElementType().GetTypeName() : field.GetType().GetTypeName(); Entity referenced = world->GetEntityFromUID(value.ObjectUID); + std::string& tag = referenced.IsValid() ? referenced.GetTag().Tag : ""; - std::string text = (value.ObjectUID != 0 ? (referenced.IsValid() ? referenced.GetTag().Tag : "") : "None") + " (" + typeName + ")"; + std::string text = (value.ObjectUID != 0 ? tag : "None") + " (" + typeName + ")"; ImGui::Text(text.c_str()); bool modified = false; diff --git a/img/editor.PNG b/img/editor.PNG index f93fa521f..424e31093 100644 Binary files a/img/editor.PNG and b/img/editor.PNG differ diff --git a/readme.md b/readme.md index 0ac68ea00..d1f720034 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # Hazard -The Game Engine +The Game Engine you don't want to use. Hazard is a new Game Engine being developed. @@ -8,15 +8,15 @@ Supported systems | Description Application stack | Include only the modules what you need Input events | Basic input system 2D batch renderer | Render 2D quads in a single draw call by batching -3D renderer | HDR environment map, PBR work in progress +3D renderer | Basic meshes done. Scripting | Supports C# scripting with Mono, Visual scripting coming later -Audio system | Supports audio to an extent, can be used for 2D games already -Runtime system | Exists but can barely do anything +Audio system | Not implemented +Runtime system | Coming soon Supported platforms | Status --------- | --------- Windows | All systems running, OpenGL backend has issues -MacOS | Compiles and runs, no rendering backend implemented +MacOS | Compiles, likely to be unusable in any form Linux | Currently not supported in any form ![Hazard Editor](https://raw.githubusercontent.com/ToniPlays/Hazard/master/img/editor.PNG)