This commit is contained in:
2024-03-27 22:38:48 +02:00
parent a5aed4266d
commit 88fd764928
14 changed files with 813 additions and 341 deletions

View File

@@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using FlaxEngine;
using FlaxEngine.Assertions;
using FlaxEngine.Json;
@@ -98,40 +99,70 @@ namespace Game
else
NetworkManager.RegisterClientMessageCallback(OnMessage);
if (IsLocalClient)
PhysicsScene localPhysicsScene = Physics.FindOrCreateScene(IsLocalClient ? "ClientPhysicsScene" : "ServerPhysicsScene");
Guid sceneGuid = JsonSerializer.ParseID(IsLocalClient ? "c095f9ac4989a46afd7fe3821f086e2e" : "59dd37cc444d5d7015759389c6153c4c");
string sceneData = $@"
{{
""ID"": ""{JsonSerializer.GetStringID(sceneGuid)}"",
""TypeName"": ""FlaxEngine.SceneAsset"",
""EngineBuild"": 65046,
""Data"": [
{{
""ID"": ""{JsonSerializer.GetStringID(sceneGuid)}"",
""TypeName"": ""FlaxEngine.Scene"",
""LightmapSettings"": {{
""IndirectLightingIntensity"": 1.0,
""GlobalObjectsScale"": 1.0,
""ChartsPadding"": 3,
""AtlasSize"": 1024,
""BounceCount"": 1,
""CompressLightmaps"": true,
""UseGeometryWithNoMaterials"": true,
""Quality"": 10
}}
}}
]
}}";
{
PhysicsScene localPhysicsScene = Physics.FindOrCreateScene("LocalPhysicsScene");
Guid localClientSceneGuid = JsonSerializer.ParseID("c095f9ac4989a46afd7fe3821f086e2e");
var onSceneLoaded = (Scene loadedScene, Guid id) =>
{
if (localClientSceneGuid == id)
if (sceneGuid == id)
{
loadedScene.PhysicsScene = localPhysicsScene;
scene = loadedScene;
//scene = loadedScene;
}
};
try
{
Level.SceneLoaded += onSceneLoaded;
Level.LoadScene(new SceneReference(localClientSceneGuid));
//Level.LoadScene(new SceneReference(sceneGuid));
scene = Level.LoadSceneFromBytes(Encoding.ASCII.GetBytes(sceneData));
}
finally
{
Level.SceneLoaded -= onSceneLoaded;
}
}
else
scene = Level.GetScene(0);
Assert.IsTrue(scene);
scene.Name = IsLocalClient ? "ClientScene" : "ServerScene";
Level.SceneLoaded += OnLevelLoaded;
//Scripting.LateUpdate += OnLateUpdatePre;
Scripting.LateFixedUpdate += OnLateUpdatePre;
worldSpawn = scene.FindActor("WorldSpawn") ?? Level.FindActor("WorldSpawn");
var importer = FlaxEngine.Object.New<Q3MapImporter>();
importer.mapPath = @"C:\dev\GoakeFlax\Assets\Maps\aerowalk.map";
importer.LoadCollidersOnly = false;//IsServer;
importer.Parent = scene;
//importer.Enabled = true;
worldSpawn = scene.FindActor("WorldSpawn");// ?? Level.FindActor("WorldSpawn");
Assert.IsTrue(worldSpawn);
}