Character controller working better

Moved ECS systems to separate folders
better raycast normal result
This commit is contained in:
Antoine Pilote
2021-06-18 16:44:54 -04:00
parent 8f238cd4ca
commit 5b56e2ff9a
73 changed files with 1179 additions and 489 deletions

View File

@@ -7,12 +7,13 @@
#include <wren.h>
#include "Engine.h"
#include "../Scene/Entities/Entity.h"
#include <src/Scene/Entities/Components/TransformComponent.h>
#include <src/Scene/Entities/Components/LightComponent.h>
#include <src/Scene/Entities/Components/QuakeMap.h>
#include <src/Scene/Entities/Components/CameraComponent.h>
#include <src/Scene/Entities/Components/RigidbodyComponent.h>
#include <src/Scene/Entities/Components/CharacterControllerComponent.h>
#include <src/Scene/Components/TransformComponent.h>
#include <src/Scene/Components/LightComponent.h>
#include <src/Scene/Components/QuakeMap.h>
#include <src/Scene/Components/CameraComponent.h>
#include <src/Scene/Components/RigidbodyComponent.h>
#include <src/Scene/Components/CharacterControllerComponent.h>
#include <src/Scene/Components/WrenScriptComponent.h>
namespace ScriptAPI
{
@@ -30,8 +31,10 @@ namespace ScriptAPI
RegisterMethod("GetEntityID(_)", (void*)GetEntity);
RegisterMethod("EntityHasComponent(_,_)", (void*)EntityHasComponent);
RegisterMethod("GetTranslation_(_)", (void*)GetTranslation);
RegisterMethod("SetTranslation_(_,_,_,_)", (void*)SetTranslation);
RegisterMethod("SetLightIntensity_(_,_)", (void*)SetLightIntensity);
RegisterMethod("GetLightIntensity_(_)", (void*)GetLightIntensity);
RegisterMethod("GetScript_(_)", (void*)GetScript);
RegisterMethod("SetCameraDirection_(_,_,_,_)", (void*)SetCameraDirection);
RegisterMethod("GetCameraDirection_(_)", (void*)GetCameraDirection);
RegisterMethod("GetCameraRight_(_)", (void*)GetCameraRight);
@@ -82,6 +85,20 @@ namespace ScriptAPI
bool result = ent.HasComponent<RigidBodyComponent>();
wrenSetSlotBool(vm, 0, result);
}
if (name == "Script") {
bool result = ent.HasComponent<WrenScriptComponent>();
wrenSetSlotBool(vm, 0, result);
}
}
static void GetScript(WrenVM* vm) {
int handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
if (ent.HasComponent<WrenScriptComponent>())
{
wrenSetSlotHandle(vm, 0, ent.GetComponent<WrenScriptComponent>().WrenScript->m_Instance);
}
}
static void SetLightIntensity(WrenVM* vm)
@@ -198,5 +215,17 @@ namespace ScriptAPI
wrenInsertInList(vm, 0, 2, 3);
}
static void SetTranslation(WrenVM* vm)
{
int handle = wrenGetSlotDouble(vm, 1);
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
auto& transform = ent.GetComponent<TransformComponent>();
// set the slots
float x = wrenGetSlotDouble(vm, 2);
float y = wrenGetSlotDouble(vm, 3);
float z = wrenGetSlotDouble(vm, 4);
transform.Translation = Vector3(x, y, z);
}
};
}