dotnet7 compat, DLSS, network manager rewrite and other fixes
This commit is contained in:
@@ -1,16 +1,48 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
//using FidelityFX;
|
||||
using FidelityFX;
|
||||
#if COMPILE_WITH_DLSS
|
||||
using NVIDIA;
|
||||
#endif
|
||||
using FlaxEditor.Content.Settings;
|
||||
using FlaxEngine;
|
||||
|
||||
namespace Game
|
||||
{
|
||||
public enum UpscalingMode
|
||||
{
|
||||
None,
|
||||
DLSS,
|
||||
FSR1,
|
||||
}
|
||||
|
||||
// Holds Console variables and commands to control engine behaviour
|
||||
public static class EngineSubsystem
|
||||
{
|
||||
//private static FSR _fsrPlugin;
|
||||
private static FSR _fsrPlugin;
|
||||
public static FSR FsrPlugin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_fsrPlugin == null)
|
||||
_fsrPlugin = PluginManager.GetPlugin<FSR>();
|
||||
return _fsrPlugin;
|
||||
}
|
||||
}
|
||||
|
||||
#if COMPILE_WITH_DLSS
|
||||
private static DLSS _dlssPlugin;
|
||||
public static DLSS DlssPlugin
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dlssPlugin == null)
|
||||
_dlssPlugin = PluginManager.GetPlugin<DLSS>();
|
||||
return _dlssPlugin;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: this should manually set all postprocessing values to 0 or disabled
|
||||
/*[ConsoleVariable("r_postprocessing")]
|
||||
@@ -98,30 +130,122 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
/*public static FSR FsrPlugin
|
||||
private static UpscalingMode GetUpscalingMode()
|
||||
{
|
||||
return (UpscalingMode)int.Parse(Upscaling);
|
||||
}
|
||||
|
||||
[ConsoleVariable("r_upscaling")]
|
||||
public static string Upscaling
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_fsrPlugin == null)
|
||||
_fsrPlugin = PluginManager.GetPlugin<FSR>();
|
||||
return _fsrPlugin;
|
||||
#if COMPILE_WITH_DLSS
|
||||
if (DlssPlugin.PostFx?.Enabled ?? false)
|
||||
return ((int)UpscalingMode.DLSS).ToString();
|
||||
#else
|
||||
if (false) { }
|
||||
#endif
|
||||
|
||||
else if (FsrPlugin.PostFx?.Enabled ?? false)
|
||||
return ((int)UpscalingMode.FSR1).ToString();
|
||||
else
|
||||
return ((int)UpscalingMode.None).ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (int.TryParse(value, out int intValue))
|
||||
{
|
||||
UpscalingMode upscaling = (UpscalingMode)intValue;
|
||||
|
||||
#if COMPILE_WITH_DLSS
|
||||
if (DlssPlugin.PostFx != null)
|
||||
{
|
||||
if (upscaling == UpscalingMode.DLSS)
|
||||
{
|
||||
if (DlssPlugin.Support == DLSSSupport.Supported)
|
||||
DlssPlugin.PostFx.Enabled = true;
|
||||
else
|
||||
{
|
||||
DlssPlugin.PostFx.Enabled = false;
|
||||
Console.Print("DLSS not supported");
|
||||
}
|
||||
}
|
||||
else
|
||||
DlssPlugin.PostFx.Enabled = false;
|
||||
}
|
||||
#else
|
||||
if (upscaling == UpscalingMode.DLSS)
|
||||
{
|
||||
Console.Print("DLSS not supported: compiled without COMPILE_WITH_DLSS");
|
||||
upscaling = UpscalingMode.None;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (FsrPlugin.PostFx != null)
|
||||
FsrPlugin.PostFx.Enabled = upscaling == UpscalingMode.FSR1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: r_upscaling
|
||||
[ConsoleVariable("r_fsr_enabled")]
|
||||
public static string FsrEnabled
|
||||
#if !COMPILE_WITH_DLSS
|
||||
private static float dummy_DlssSharpness;
|
||||
private static int dummy_DlssQuality;
|
||||
#endif
|
||||
|
||||
[ConsoleVariable("r_dlss_sharpness")]
|
||||
public static string DlssSharpness
|
||||
{
|
||||
get => FsrPlugin.PostFx.Enabled ? "1" : "0";
|
||||
get
|
||||
{
|
||||
#if COMPILE_WITH_DLSS
|
||||
return DlssPlugin.Sharpness.ToString();
|
||||
#else
|
||||
return dummy_DlssSharpness.ToString();
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
bool boolValue = false;
|
||||
if (int.TryParse(value, out int intValue))
|
||||
boolValue = intValue != 0;
|
||||
else if (float.TryParse(value, out float valueFloat))
|
||||
boolValue = valueFloat != 0f;
|
||||
if (float.TryParse(value, out float valueFloat))
|
||||
{
|
||||
valueFloat = Mathf.Clamp(valueFloat, -1f, 1f);
|
||||
#if COMPILE_WITH_DLSS
|
||||
DlssPlugin.Sharpness = valueFloat;
|
||||
#else
|
||||
dummy_DlssSharpness = valueFloat;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FsrPlugin.PostFx.Enabled = boolValue;
|
||||
[ConsoleVariable("r_dlss_quality")]
|
||||
public static string DlssQuality
|
||||
{
|
||||
get
|
||||
{
|
||||
#if COMPILE_WITH_DLSS
|
||||
return ((int)DlssPlugin.Quality).ToString();
|
||||
#else
|
||||
return dummy_DlssQuality.ToString();
|
||||
#endif
|
||||
}
|
||||
set
|
||||
{
|
||||
if (int.TryParse(value, out int intValue))
|
||||
{
|
||||
#if COMPILE_WITH_DLSS
|
||||
#if USE_NETCORE
|
||||
intValue = Math.Clamp(intValue, 0, (int)DLSSQuality.MAX-1);
|
||||
#else
|
||||
intValue = (intValue > (int)DLSSQuality.MAX-1) ? ((int)DLSSQuality.MAX-1) : (intValue < 0 ? 0 : intValue);
|
||||
#endif
|
||||
DlssPlugin.Quality = (DLSSQuality)intValue;
|
||||
#else
|
||||
//intValue = Math.Clamp(intValue, 0, 4);
|
||||
intValue = (intValue > 4) ? 4 : (intValue < 0 ? 0 : intValue);
|
||||
dummy_DlssQuality = intValue;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +267,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
[ConsoleVariable("cl_showweapon")]
|
||||
public static string ShowWeapon
|
||||
@@ -204,8 +327,8 @@ namespace Game
|
||||
boolValue = valueFloat != 0f;
|
||||
|
||||
AssetManager.Globals.SetValue("Scene Lighting", boolValue);
|
||||
AmbientOcclusion = value;
|
||||
GlobalIllumination = value;
|
||||
//AmbientOcclusion = value;
|
||||
//GlobalIllumination = value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -378,7 +501,7 @@ namespace Game
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((bool)AssetManager.Globals.GetValue("Scene Shadows") ? "1" : "0");
|
||||
return (bool)AssetManager.Globals.GetValue("Scene Shadows") ? "1" : "0";
|
||||
}
|
||||
set
|
||||
{
|
||||
@@ -392,6 +515,25 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleVariable("r_staticbatch")]
|
||||
public static string StaticBatch
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)AssetManager.Globals.GetValue("Static Batching") ? "1" : "0";
|
||||
}
|
||||
set
|
||||
{
|
||||
bool boolValue = false;
|
||||
if (int.TryParse(value, out int intValue))
|
||||
boolValue = intValue != 0;
|
||||
else if (float.TryParse(value, out float valueFloat))
|
||||
boolValue = valueFloat != 0f;
|
||||
|
||||
AssetManager.Globals.SetValue("Static Batching", boolValue);
|
||||
}
|
||||
}
|
||||
|
||||
[ConsoleCommand("playdemo")]
|
||||
public static void PlayDemoCommand(string[] text)
|
||||
{
|
||||
@@ -402,8 +544,8 @@ namespace Game
|
||||
if (!demoName.EndsWith(".gdem"))
|
||||
demoName += ".gdem";
|
||||
|
||||
PlayerActor playerActor = Level.GetActors<PlayerActor>().First(x =>
|
||||
x.GetScript<PlayerMovement>().PlayerId == NetworkManager.LocalPlayerClientId);
|
||||
PlayerActor playerActor = Level.GetActors<PlayerActor>().First(/*x =>
|
||||
x.GetScript<PlayerMovement>().PlayerId == NetworkManager.LocalPlayerClientId*/);
|
||||
|
||||
string demoPath = Path.Combine(AssetManager.DemoPath, demoName);
|
||||
if (File.Exists(demoPath))
|
||||
@@ -427,8 +569,8 @@ namespace Game
|
||||
if (!demoName.EndsWith(".gdem"))
|
||||
demoName += ".gdem";
|
||||
|
||||
PlayerActor playerActor = Level.GetActors<PlayerActor>().First(x =>
|
||||
x.GetScript<PlayerMovement>().PlayerId == NetworkManager.LocalPlayerClientId);
|
||||
PlayerActor playerActor = Level.GetActors<PlayerActor>().First(/*x =>
|
||||
x.GetScript<PlayerMovement>().PlayerId == NetworkManager.LocalPlayerClientId*/);
|
||||
|
||||
var playerMovement = playerActor.GetScript<PlayerMovement>();
|
||||
string demoPath = Path.Combine(AssetManager.DemoPath, demoName);
|
||||
@@ -465,6 +607,19 @@ namespace Game
|
||||
Scripting.Update += TimeDemoOnUpdate;
|
||||
}
|
||||
|
||||
[ConsoleCommand("map")]
|
||||
public static void MapCommand()
|
||||
{
|
||||
//NetworkManager.StartServer(true);
|
||||
GameMode.StartServer(true);
|
||||
}
|
||||
|
||||
[ConsoleCommand("connect")]
|
||||
public static void ConnectCommand()
|
||||
{
|
||||
GameMode.Connect();
|
||||
}
|
||||
|
||||
[ConsoleSubsystemInitializer]
|
||||
public static void Initialize()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user