Fixed Coral crash with base type classes, temp fix for logs crash + added light color param to C# api
This commit is contained in:
@@ -42,6 +42,12 @@ namespace NuakeEditor
|
||||
{
|
||||
const std::string& cleanProjectName = String::Sanitize(mProject->Name);
|
||||
const std::string& gameConfigFolderPath = mProject->TrenchbroomPath + "/../games/" + cleanProjectName + "/";
|
||||
|
||||
if (!FileSystem::DirectoryExists(gameConfigFolderPath))
|
||||
{
|
||||
FileSystem::MakeDirectory(gameConfigFolderPath);
|
||||
}
|
||||
|
||||
const std::string& gameConfigFilePath = gameConfigFolderPath + "GameConfig.cfg";
|
||||
FileSystem::BeginWriteFile(gameConfigFilePath, true);
|
||||
|
||||
|
||||
@@ -3055,10 +3055,10 @@ namespace Nuake {
|
||||
DrawMenuBars();
|
||||
|
||||
int i = 0;
|
||||
if (Logger::GetLogCount() > 0 && Logger::GetLogs()[Logger::GetLogCount() - 1].type == COMPILATION)
|
||||
{
|
||||
SetStatusMessage(std::string(ICON_FA_EXCLAMATION_TRIANGLE) + " An unhandled exception occured in your script. See logs for more details.", Color(1.0f, 0.1f, 0.1f, 1.0f));
|
||||
}
|
||||
//if (Logger::GetLogCount() > 0 && Logger::GetLogs()[Logger::GetLogCount() - 1].type == COMPILATION)
|
||||
//{
|
||||
// SetStatusMessage(std::string(ICON_FA_EXCLAMATION_TRIANGLE) + " An unhandled exception occured in your script. See logs for more details.", Color(1.0f, 0.1f, 0.1f, 1.0f));
|
||||
//}
|
||||
|
||||
DrawStatusBar();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -311,6 +311,7 @@ namespace Nuake
|
||||
m_GameAssembly = m_LoadContext.LoadAssembly(absoluteAssemblyPath);
|
||||
|
||||
m_PrefabType = m_GameAssembly.GetType("Nuake.Net.Prefab");
|
||||
auto entityScriptType = m_GameAssembly.GetType("Nuake.Net.Entity");
|
||||
auto& exposedFieldAttributeType = m_GameAssembly.GetType("Nuake.Net.ExposedAttribute");
|
||||
auto& brushScriptAttributeType = m_GameAssembly.GetType("Nuake.Net.BrushScript");
|
||||
auto& pointScriptAttributeType = m_GameAssembly.GetType("Nuake.Net.PointScript");
|
||||
@@ -343,7 +344,7 @@ namespace Nuake
|
||||
}
|
||||
}
|
||||
|
||||
if (type->GetBaseType())
|
||||
if (type->IsSubclassOf(entityScriptType))
|
||||
{
|
||||
const std::string baseTypeName = std::string(type->GetBaseType().GetFullName());
|
||||
if (baseTypeName != "Nuake.Net.Entity")
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Nuake.Net
|
||||
{
|
||||
internal static unsafe delegate*<int, float> GetLightIntensityIcall;
|
||||
internal static unsafe delegate*<int, float, void> SetLightIntensityIcall;
|
||||
|
||||
internal static unsafe delegate*<int, float, float, float, void> SetLightColorIcall;
|
||||
public enum LightType
|
||||
{
|
||||
Directional,
|
||||
@@ -148,7 +148,15 @@ namespace Nuake.Net
|
||||
}
|
||||
}
|
||||
|
||||
public Color Color { get; set; }
|
||||
public Color Color
|
||||
{
|
||||
get { return Color; }
|
||||
set
|
||||
{
|
||||
unsafe { SetLightColorIcall(EntityID, (float)value.R, (float)value.G, (float)value.B); }
|
||||
}
|
||||
}
|
||||
|
||||
public bool CastShadows { get; set; }
|
||||
public bool Volumetric { get; set; }
|
||||
public bool SyncWithSky { get; set; }
|
||||
|
||||
Reference in New Issue
Block a user