Fixed Coral crash with base type classes, temp fix for logs crash + added light color param to C# api

This commit is contained in:
Antoine Pilote
2024-09-05 00:52:55 -04:00
parent 732e94899c
commit 5e3472c256
5 changed files with 35 additions and 7 deletions

View File

@@ -334,6 +334,17 @@ namespace Nuake {
Logger::Log("Set light intensity with id: " + std::to_string(intensity));
}
void LightSetColor(int entityId, float r, float g, float b)
{
Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() };
if (entity.IsValid() && entity.HasComponent<LightComponent>())
{
auto& component = entity.GetComponent<LightComponent>();
component.Color = Color(r / 255.0f, g / 255.0f, b / 255.0f, 1.0f);
}
}
Coral::Array<float> CameraGetDirection(int entityId)
{
Entity entity = { (entt::entity)(entityId), Engine::GetCurrentScene().get() };
@@ -557,6 +568,7 @@ namespace Nuake {
// Lights
RegisterMethod("LightComponent.GetLightIntensityIcall", &LightGetIntensity);
RegisterMethod("LightComponent.SetLightIntensityIcall", &LightSetIntensity);
RegisterMethod("LightComponent.SetLightColorIcall", &LightSetColor);
// Camera
RegisterMethod("CameraComponent.GetDirectionIcall", &CameraGetDirection);
@@ -568,6 +580,7 @@ namespace Nuake {
RegisterMethod("CharacterControllerComponent.IsOnGroundIcall", &IsOnGround);
RegisterMethod("CharacterControllerComponent.GetGroundVelocityIcall", &GetGroundVelocity);
RegisterMethod("CharacterControllerComponent.GetGroundNormalIcall", &GetGroundNormal);
// Skinned
RegisterMethod("SkinnedModelComponent.PlayIcall", &Play);