Various improvements:
Framebuffer resize queued to next frame to fix flickering Wren VM init moved to on play event Added new Wren modules Added missing components to the editor Changed how the wren scripts gets initialized
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#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>
|
||||
|
||||
namespace ScriptAPI
|
||||
{
|
||||
@@ -30,6 +31,10 @@ namespace ScriptAPI
|
||||
RegisterMethod("EntityHasComponent(_,_)", (void*)EntityHasComponent);
|
||||
RegisterMethod("SetLightIntensity_(_,_)", (void*)SetLightIntensity);
|
||||
RegisterMethod("GetLightIntensity_(_)", (void*)GetLightIntensity);
|
||||
RegisterMethod("SetCameraDirection_(_,_,_,_)", (void*)SetCameraDirection);
|
||||
RegisterMethod("GetCameraDirection_(_)", (void*)GetCameraDirection);
|
||||
RegisterMethod("GetCameraRight_(_)", (void*)GetCameraRight);
|
||||
RegisterMethod("MoveAndSlide_(_,_,_,_)", (void*)MoveAndSlide);
|
||||
}
|
||||
|
||||
static void GetEntity(WrenVM* vm)
|
||||
@@ -99,7 +104,73 @@ namespace ScriptAPI
|
||||
|
||||
static void SetCameraDirection(WrenVM* vm)
|
||||
{
|
||||
int handle = wrenGetSlotDouble(vm, 1);
|
||||
float x = wrenGetSlotDouble(vm, 2);
|
||||
float y = wrenGetSlotDouble(vm, 3);
|
||||
float z = wrenGetSlotDouble(vm, 4);
|
||||
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
|
||||
|
||||
auto& cam = ent.GetComponent<CameraComponent>();
|
||||
cam.CameraInstance->SetDirection(Vector3(x, y, z));
|
||||
}
|
||||
|
||||
static void GetCameraDirection(WrenVM* vm)
|
||||
{
|
||||
int handle = wrenGetSlotDouble(vm, 1);
|
||||
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
|
||||
|
||||
auto& cam = ent.GetComponent<CameraComponent>();
|
||||
|
||||
Vector3 dir = cam.CameraInstance->GetDirection();
|
||||
|
||||
wrenEnsureSlots(vm, 4);
|
||||
|
||||
// set the slots
|
||||
// Fill the list
|
||||
wrenSetSlotNewList(vm, 0);
|
||||
wrenSetSlotDouble(vm, 1, dir.x);
|
||||
wrenSetSlotDouble(vm, 2, dir.y);
|
||||
wrenSetSlotDouble(vm, 3, dir.z);
|
||||
|
||||
wrenInsertInList(vm, 0, -1, 1);
|
||||
wrenInsertInList(vm, 0, -1, 2);
|
||||
wrenInsertInList(vm, 0, -1, 3);
|
||||
}
|
||||
|
||||
static void GetCameraRight(WrenVM* vm)
|
||||
{
|
||||
int handle = wrenGetSlotDouble(vm, 1);
|
||||
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
|
||||
|
||||
auto& cam = ent.GetComponent<CameraComponent>();
|
||||
|
||||
Vector3 right = cam.CameraInstance->cameraRight;
|
||||
|
||||
// set the slots
|
||||
wrenSetSlotDouble(vm, 1, right.x);
|
||||
wrenSetSlotDouble(vm, 2, right.y);
|
||||
wrenSetSlotDouble(vm, 3, right.z);
|
||||
|
||||
// Fill the list
|
||||
wrenSetSlotNewList(vm, 0);
|
||||
wrenInsertInList(vm, 0, 0, 1);
|
||||
wrenInsertInList(vm, 0, 1, 2);
|
||||
wrenInsertInList(vm, 0, 2, 3);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void MoveAndSlide(WrenVM* vm)
|
||||
{
|
||||
int handle = wrenGetSlotDouble(vm, 1);
|
||||
float x = wrenGetSlotDouble(vm, 2);
|
||||
float y = wrenGetSlotDouble(vm, 3);
|
||||
float z = wrenGetSlotDouble(vm, 4);
|
||||
|
||||
Entity ent = Entity((entt::entity)handle, Engine::GetCurrentScene().get());
|
||||
auto& characterController = ent.GetComponent<CharacterControllerComponent>();
|
||||
characterController.CharacterController->MoveAndSlide(Vector3(x, y, z));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user