r_lighting and gameplay globals

This commit is contained in:
2022-05-22 21:28:37 +03:00
parent 99aa9ab6f8
commit 42f4840b09
6 changed files with 69 additions and 17 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.IO;
using FidelityFX;
using FlaxEngine;
@@ -189,6 +190,48 @@ namespace Game
}
}
[ConsoleVariable("r_lighting")]
public static string SceneLighting
{
get
{
string workDir = Directory.GetCurrentDirectory();
string matBasePath = Path.Combine(workDir, "Content");
string assetPath = Path.Combine(matBasePath, "GameplayGlobals.flax");
//40caea634c3e619b7c35588f1cbdb967
GameplayGlobals globals;
globals = Content.GetAsset(assetPath) as GameplayGlobals;
if (globals == null)
globals = Content.Load<GameplayGlobals>(assetPath);
//globals = Content.GetAsset(assetPath) as GameplayGlobals;
//GameplayGlobals globals = Content..GetAsset(new Guid("40caea634c3e619b7c35588f1cbdb967")) as GameplayGlobals;
return ((bool)globals.GetValue("Scene Lighting") ? "1" : "0");
}
set
{
string workDir = Directory.GetCurrentDirectory();
string matBasePath = Path.Combine(workDir, "Content");
string assetPath = Path.Combine(matBasePath, "GameplayGlobals.flax");
//GameplayGlobals globals = Content.GetAsset(assetPath) as GameplayGlobals;
//GameplayGlobals globals = Content.GetAsset(new Guid("40caea634c3e619b7c35588f1cbdb967")) as GameplayGlobals;
GameplayGlobals globals;
globals = Content.GetAsset(assetPath) as GameplayGlobals;
if (globals == null)
globals = Content.Load<GameplayGlobals>(assetPath);
bool boolValue = false;
if (int.TryParse(value, out int intValue))
boolValue = intValue != 0;
else if (float.TryParse(value, out float valueFloat))
boolValue = valueFloat != 0f;
globals.SetValue("Scene Lighting", boolValue);
}
}
[ConsoleSubsystemInitializer]
public static void Initialize()
{