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

Binary file not shown.

View File

@@ -472,25 +472,34 @@ namespace Game
//Console.PrintDebug("Executed '" + execute + "' with params: '" + value + "'");
if (consoleCommands.TryGetValue(executeLower, out ConsoleCommand cmd))
try
{
string[] values = strs.Skip(1).ToArray();
if (values.Length > 0)
cmd.Invoke(values);
else
cmd.Invoke();
//Console.Print("Command bound to '" + execute + "' is '" + cmd.method.Name + "'");
}
else if (consoleVariables.TryGetValue(executeLower, out ConsoleVariable cvar))
{
if (value != null)
cvar.SetValue(value);
if (consoleCommands.TryGetValue(executeLower, out ConsoleCommand cmd))
{
string[] values = strs.Skip(1).ToArray();
if (values.Length > 0)
cmd.Invoke(values);
else
cmd.Invoke();
//Console.Print("Command bound to '" + execute + "' is '" + cmd.method.Name + "'");
}
else if (consoleVariables.TryGetValue(executeLower, out ConsoleVariable cvar))
{
if (value != null)
cvar.SetValue(value);
Console.Print("'" + execute + "' is '" + cvar.GetValueString() + "'");
Console.Print("'" + execute + "' is '" + cvar.GetValueString() + "'");
}
else
{
Console.Print("Unknown command '" + execute + "'");
}
}
else
catch (Exception e)
{
Console.Print("Unknown command '" + execute + "'");
var message = e.InnerException != null ? e.InnerException.Message : e.Message;
Console.Print("Command failed: " + message);
throw;
}
}

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()
{

View File

@@ -63,14 +63,14 @@ namespace Game
ServerAddress = "localhost";
ConnectServer();
}
#if FLAX_EDITOR
//#if FLAX_EDITOR
else
{
StartServer();
ServerAddress = "localhost";
ConnectServer();
}
#endif
//#endif
initialized = true;
#if FLAX_EDITOR