Character controller working better
Moved ECS systems to separate folders better raycast normal result
This commit is contained in:
@@ -45,9 +45,9 @@ namespace ScriptAPI
|
||||
wrenSetSlotDouble(vm, 5, result.WorldPoint.y);
|
||||
wrenSetSlotDouble(vm, 6, result.WorldPoint.z);
|
||||
|
||||
wrenSetSlotDouble(vm, 7, result.Normal.x - result.WorldPoint.x);
|
||||
wrenSetSlotDouble(vm, 8, result.Normal.y - result.WorldPoint.y);
|
||||
wrenSetSlotDouble(vm, 9, result.Normal.z - result.WorldPoint.z);
|
||||
wrenSetSlotDouble(vm, 7, result.Normal.x);
|
||||
wrenSetSlotDouble(vm, 8, result.Normal.y);
|
||||
wrenSetSlotDouble(vm, 9, result.Normal.z);
|
||||
|
||||
wrenInsertInList(vm, 0, -1, 1);
|
||||
wrenInsertInList(vm, 0, -1, 2);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
@@ -27,6 +27,7 @@ WrenScript::WrenScript(const std::string& path, const std::string& mod, bool isE
|
||||
// Create handles to the instance methods.
|
||||
this->m_OnInitHandle = wrenMakeCallHandle(vm, "init()");
|
||||
this->m_OnUpdateHandle = wrenMakeCallHandle(vm, "update(_)");
|
||||
this->m_OnFixedUpdateHandle = wrenMakeCallHandle(vm, "fixedUpdate(_)");
|
||||
this->m_OnExitHandle = wrenMakeCallHandle(vm, "exit()");
|
||||
|
||||
if (isEntity)
|
||||
@@ -49,6 +50,15 @@ void WrenScript::CallUpdate(float timestep)
|
||||
WrenInterpretResult result = wrenCall(vm, this->m_OnUpdateHandle);
|
||||
}
|
||||
|
||||
void WrenScript::CallFixedUpdate(float timestep)
|
||||
{
|
||||
WrenVM* vm = ScriptingEngine::GetWrenVM();
|
||||
wrenEnsureSlots(vm, 2);
|
||||
wrenSetSlotHandle(vm, 0, this->m_Instance);
|
||||
wrenSetSlotDouble(vm, 1, timestep);
|
||||
WrenInterpretResult result = wrenCall(vm, this->m_OnFixedUpdateHandle);
|
||||
}
|
||||
|
||||
void WrenScript::CallExit()
|
||||
{
|
||||
WrenVM* vm = ScriptingEngine::GetWrenVM();
|
||||
|
||||
@@ -11,6 +11,7 @@ public:
|
||||
WrenHandle* m_Instance;
|
||||
WrenHandle* m_OnInitHandle;
|
||||
WrenHandle* m_OnUpdateHandle;
|
||||
WrenHandle* m_OnFixedUpdateHandle;
|
||||
WrenHandle* m_OnExitHandle;
|
||||
WrenHandle* m_SetEntityIDHandle;
|
||||
|
||||
@@ -18,6 +19,7 @@ public:
|
||||
|
||||
void CallInit();
|
||||
void CallUpdate(float timestep);
|
||||
void CallFixedUpdate(float timestep);
|
||||
void CallExit();
|
||||
|
||||
void RegisterMethod(const std::string& signature);
|
||||
|
||||
Reference in New Issue
Block a user