Skip to content

Commit

Permalink
Small changes, updated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ToniPlays committed Aug 19, 2022
1 parent d6cc41a commit 1350cd5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Hazard/src/Hazard/Scripting/Bindings/EntityBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Type>(); }; \
getComponentFuncs[monoType] = [](uint64_t entityID) -> ComponentBase& { return GET_ENTITY(entityID).GetComponent<Type>(); }; \
getComponentFuncs[monoType] = [](uint64_t entityID) -> ComponentBase& { return GET_ENTITY(entityID).GetComponent<Type>(); }; \
createComponentFuncs[monoType] = [](uint64_t entityID) { GET_ENTITY(entityID).AddComponent<Type>(); }; \
} \
}
Expand Down
3 changes: 2 additions & 1 deletion Hazard/src/Hazard/Scripting/Bindings/TagComponentBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<TagComponent>();
return Mono::StringToMonoString(tag.Tag);
}
Expand Down
13 changes: 5 additions & 8 deletions Hazard/src/Hazard/Scripting/MonoUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ namespace HazardScript
{
ObjectReference stored = GetStoredValue<ObjectReference>();
ObjectReference ref = {};
if (!m_Field->GetType().IsArray()) {
if (!m_Field->GetType().IsArray())
{

ref.MonoObject = MonoFieldUtils::GetFieldValue<MonoObject*>(object, m_Field->GetMonoField());
ref.MonoObjectHandle = stored.MonoObject == ref.MonoObject ? stored.MonoObjectHandle : 0;
Expand Down Expand Up @@ -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);

Expand Down
20 changes: 10 additions & 10 deletions HazardEditor/imgui.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -133,7 +133,7 @@ DockId=0x00000009,0

[Window][Properties]
Pos=2076,32
Size=484,903
Size=484,754
Collapsed=0
DockId=0x00000002,0

Expand Down Expand Up @@ -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

Expand All @@ -192,7 +192,7 @@ Collapsed=0

[Window][Asset panel]
Pos=0,904
Size=1311,465
Size=1366,465
Collapsed=0
DockId=0x0000000B,0

Expand Down Expand Up @@ -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

3 changes: 2 additions & 1 deletion HazardEditor/src/GUI/Properties/ScriptFieldUI.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Binary file modified img/editor.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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)

0 comments on commit 1350cd5

Please sign in to comment.