_wipshit
This commit is contained in:
@@ -91,7 +91,7 @@ namespace Game
|
||||
|
||||
private int GetFontCharacterWidth()
|
||||
{
|
||||
Font font = Font.GetFont();
|
||||
Font font = Font?.GetFont();
|
||||
if (!font)
|
||||
return 0;
|
||||
return (int)font.MeasureText("a").X; // hacky, but works for fixed-size fonts...
|
||||
@@ -99,7 +99,7 @@ namespace Game
|
||||
|
||||
public int GetFontHeight()
|
||||
{
|
||||
Font font = Font.GetFont();
|
||||
Font font = Font?.GetFont();
|
||||
if (font == null)
|
||||
return (int)Height;
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace Game
|
||||
|
||||
private int GetHeightInLines()
|
||||
{
|
||||
Font font = Font.GetFont();
|
||||
Font font = Font?.GetFont();
|
||||
if (!font)
|
||||
return 0;
|
||||
return (int)(Height / (font.Height / Platform.DpiScale)); // number of fully visible lines
|
||||
@@ -323,7 +323,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Render2D.FillRectangle(selectionRect, selectionColor);
|
||||
|
||||
layout.Bounds.Y += lineHeight;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Game
|
||||
public string mapPath;// = @"C:\dev\Goake\maps\aerowalk\aerowalk.map";
|
||||
//private string mapPath = @"C:\dev\GoakeFlax\Assets\Maps\problematic.map";
|
||||
|
||||
public bool importLights = false;
|
||||
public bool importLights = true;
|
||||
private bool generateSdf = true;
|
||||
private bool childModelSdf = true;
|
||||
|
||||
@@ -116,6 +116,19 @@ namespace Game
|
||||
}
|
||||
}
|
||||
|
||||
public bool LoadCollidersOnly
|
||||
{
|
||||
get => collidersOnly;
|
||||
set
|
||||
{
|
||||
if (collidersOnly == value)
|
||||
return;
|
||||
collidersOnly = value;
|
||||
dirtyLights = true;
|
||||
dirtyMap = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void QuickHull(Float3[] points, out Float3[] outVertices)
|
||||
{
|
||||
@@ -333,6 +346,7 @@ namespace Game
|
||||
private bool sceneLighting = false;
|
||||
private bool sceneShadows = false;
|
||||
private bool staticBatching = false;
|
||||
private bool collidersOnly = false;
|
||||
private bool globalIllumination = false;
|
||||
public override void OnUpdate()
|
||||
{
|
||||
@@ -457,6 +471,9 @@ namespace Game
|
||||
|
||||
private void LoadMap(bool forceLoad)
|
||||
{
|
||||
if (string.IsNullOrEmpty(mapPath))
|
||||
return;
|
||||
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
|
||||
|
||||
@@ -492,9 +509,10 @@ namespace Game
|
||||
// FlaxEngine.Debug.Log("No WorldSpawn, loading map");
|
||||
|
||||
bool oneMesh = false;
|
||||
bool useStaticBatching = StaticBatching;
|
||||
bool useStaticBatching = StaticBatching && !LoadCollidersOnly;
|
||||
bool convexMesh = true;
|
||||
|
||||
|
||||
FlaxEngine.Debug.Log("Loading map, static batching: " + useStaticBatching);
|
||||
{
|
||||
string matBasePath = Path.Combine(AssetManager.ContentPath, "Materials");
|
||||
@@ -743,14 +761,24 @@ namespace Game
|
||||
brushIndex = 0;
|
||||
foreach (BrushGeometry geom in brushGeometries)
|
||||
{
|
||||
StaticModel childModel = worldSpawnActor.AddChild<StaticModel>();
|
||||
childModel.Name = "Brush_" + brushIndex;
|
||||
childModel.Model = geom.model;
|
||||
childModel.Position = geom.offset;
|
||||
//childModel.DrawModes = DrawPass.None;
|
||||
Actor childModel;
|
||||
if (LoadCollidersOnly)
|
||||
{
|
||||
childModel = worldSpawnActor.AddChild<EmptyActor>();
|
||||
}
|
||||
else
|
||||
{
|
||||
StaticModel staticModel = worldSpawnActor.AddChild<StaticModel>();
|
||||
staticModel.Model = geom.model;
|
||||
//staticModel.DrawModes = DrawPass.None;
|
||||
|
||||
for (int i = 0; i < geom.meshes.Length; i++)
|
||||
childModel.SetMaterial(i, geom.meshes[i].material);
|
||||
for (int i = 0; i < geom.meshes.Length; i++)
|
||||
staticModel.SetMaterial(i, geom.meshes[i].material);
|
||||
|
||||
childModel = staticModel;
|
||||
}
|
||||
childModel.Name = "Brush_" + brushIndex;
|
||||
childModel.Position = geom.offset;
|
||||
|
||||
BrushScript brushScript = childModel.AddScript<BrushScript>();
|
||||
|
||||
@@ -760,16 +788,17 @@ namespace Game
|
||||
|
||||
bool isClipMaterial = false;
|
||||
bool isMissingMaterial = false;
|
||||
if (geom.meshes.Length == 1)
|
||||
if (geom.meshes.Length == 1 && !LoadCollidersOnly)
|
||||
{
|
||||
MaterialParameter info = geom.meshes[0].material.GetParameter("IsClipMaterial");
|
||||
if (info != null && (bool)info.Value)
|
||||
{
|
||||
var entries = childModel.Entries;
|
||||
StaticModel staticModel = childModel.As<StaticModel>();
|
||||
var entries = staticModel.Entries;
|
||||
entries[0].Visible = false;
|
||||
entries[0].ShadowsMode = ShadowsCastingMode.None;
|
||||
entries[0].ReceiveDecals = false;
|
||||
childModel.Entries = entries;
|
||||
staticModel.Entries = entries;
|
||||
isClipMaterial = true;
|
||||
}
|
||||
|
||||
@@ -777,14 +806,17 @@ namespace Game
|
||||
isMissingMaterial = true;
|
||||
}
|
||||
|
||||
/*{
|
||||
var entries = childModel.Entries;
|
||||
/*
|
||||
if (!LoadCollidersOnly)
|
||||
{
|
||||
StaticModel staticModel = childModel.As<StaticModel>();
|
||||
var entries = staticModel.Entries;
|
||||
for (int i=0; i < entries.Length; i++)
|
||||
entries[i].Visible = false;
|
||||
childModel.Entries = entries;
|
||||
staticModel.Entries = entries;
|
||||
}*/
|
||||
|
||||
if (!isClipMaterial && !isMissingMaterial)
|
||||
if (!isClipMaterial && !isMissingMaterial && !LoadCollidersOnly)
|
||||
sdfModels.Add(geom.model);
|
||||
|
||||
CollisionData collisionData = Content.CreateVirtualAsset<CollisionData>();
|
||||
@@ -1286,11 +1318,9 @@ namespace Game
|
||||
|
||||
private void ParseLight(MapEntity entity, ref int lightIndex)
|
||||
{
|
||||
LightWithShadow light;
|
||||
Actor actor;
|
||||
Float3? lightTargetPosition = null;
|
||||
|
||||
|
||||
|
||||
if (entity.properties.TryGetValue("target", out string targetName))
|
||||
{
|
||||
var target = root.entities.FirstOrDefault(x =>
|
||||
@@ -1300,148 +1330,155 @@ namespace Game
|
||||
lightTargetPosition = ParseOrigin(target.properties["origin"]);
|
||||
}
|
||||
|
||||
if (!lightTargetPosition.HasValue)
|
||||
light = worldSpawnActor.AddChild<PointLight>();
|
||||
if (LoadCollidersOnly)
|
||||
actor = worldSpawnActor.AddChild<EmptyActor>();
|
||||
else if (!lightTargetPosition.HasValue)
|
||||
actor = worldSpawnActor.AddChild<PointLight>();
|
||||
else
|
||||
light = worldSpawnActor.AddChild<SpotLight>();
|
||||
actor = worldSpawnActor.AddChild<SpotLight>();
|
||||
|
||||
if (!lightTargetPosition.HasValue)
|
||||
actor.Name = "Light_" + lightIndex;
|
||||
else
|
||||
actor.Name = "SpotLight_" + lightIndex;
|
||||
|
||||
//Console.Print("light");
|
||||
//PointLight light = worldSpawnActor.AddChild<PointLight>();
|
||||
//LightWithShadow light = new PointLight();
|
||||
var pointLight = light as PointLight;
|
||||
var spotLight = light as SpotLight;
|
||||
//var light = actor as LightWithShadow;
|
||||
|
||||
if (spotLight != null)
|
||||
light.Name = "SpotLight_" + lightIndex;
|
||||
else
|
||||
light.Name = "Light_" + lightIndex;
|
||||
light.IsActive = sceneLighting;
|
||||
light.LocalPosition = ParseOrigin(entity.properties["origin"]);
|
||||
actor.IsActive = sceneLighting;
|
||||
actor.LocalPosition = ParseOrigin(entity.properties["origin"]);
|
||||
actor.Layer = 1;
|
||||
|
||||
if (lightTargetPosition.HasValue)
|
||||
light.Orientation = Quaternion.LookAt(light.LocalPosition, lightTargetPosition.Value);
|
||||
actor.Orientation = Quaternion.LookAt(actor.LocalPosition, lightTargetPosition.Value);
|
||||
|
||||
if (entity.properties.TryGetValue("_color", out string colorStr))
|
||||
light.Color = ParseColor(colorStr);
|
||||
|
||||
float lightamm = 300f;
|
||||
if (entity.properties.TryGetValue("light", out string lightStr))
|
||||
lightamm = float.Parse(lightStr);
|
||||
|
||||
float radamm = 64f;
|
||||
if (entity.properties.TryGetValue("radius", out string radStr))
|
||||
radamm = float.Parse(radStr);
|
||||
|
||||
bool castShadows = true;
|
||||
if (entity.properties.TryGetValue("castshadows", out string castShadowsStr))
|
||||
castShadows = int.Parse(castShadowsStr) != 0;
|
||||
|
||||
|
||||
light.Layer = 1;
|
||||
if (pointLight != null)
|
||||
if (actor is LightWithShadow light)
|
||||
{
|
||||
pointLight.UseInverseSquaredFalloff = false;
|
||||
pointLight.FallOffExponent = 8;
|
||||
pointLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
|
||||
}
|
||||
if (spotLight != null)
|
||||
{
|
||||
spotLight.UseInverseSquaredFalloff = false;
|
||||
spotLight.FallOffExponent = 8;
|
||||
spotLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
|
||||
spotLight.InnerConeAngle = 65f;
|
||||
spotLight.OuterConeAngle = 80f;
|
||||
}
|
||||
var pointLight = light as PointLight;
|
||||
var spotLight = light as SpotLight;
|
||||
|
||||
light.ShadowsDistance = 500f;
|
||||
light.ShadowsDepthBias = 0.027f;//0.005f;
|
||||
if (entity.properties.TryGetValue("_color", out string colorStr))
|
||||
light.Color = ParseColor(colorStr);
|
||||
|
||||
int preset = 3;
|
||||
if (preset == 0) // most accurate?, huge radius and low performance
|
||||
{
|
||||
light.Brightness = lightamm / 93f;
|
||||
float lightamm = 300f;
|
||||
if (entity.properties.TryGetValue("light", out string lightStr))
|
||||
lightamm = float.Parse(lightStr);
|
||||
|
||||
light.ShadowsDepthBias = 0.0565f;
|
||||
float radamm = 64f;
|
||||
if (entity.properties.TryGetValue("radius", out string radStr))
|
||||
radamm = float.Parse(radStr);
|
||||
|
||||
light.Brightness *= 0.7837f;
|
||||
bool castShadows = true;
|
||||
if (entity.properties.TryGetValue("castshadows", out string castShadowsStr))
|
||||
castShadows = int.Parse(castShadowsStr) != 0;
|
||||
|
||||
if (pointLight != null)
|
||||
{
|
||||
pointLight.Radius = radamm * 12.5f;
|
||||
pointLight.FallOffExponent = 3.33f;
|
||||
pointLight.Radius *= 0.83375f;
|
||||
pointLight.UseInverseSquaredFalloff = false;
|
||||
pointLight.FallOffExponent = 8;
|
||||
pointLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
|
||||
}
|
||||
|
||||
var hsv = light.Color.ToHSV();
|
||||
hsv.Y *= 0.8f;
|
||||
light.Color = Color.FromHSV(hsv);
|
||||
}
|
||||
else if (preset == 1) //
|
||||
{
|
||||
if (pointLight != null)
|
||||
if (spotLight != null)
|
||||
{
|
||||
pointLight.Radius = 250f;
|
||||
pointLight.FallOffExponent = 2f;
|
||||
spotLight.UseInverseSquaredFalloff = false;
|
||||
spotLight.FallOffExponent = 8;
|
||||
spotLight.ShadowsStrength = sceneShadows && castShadows ? 1.0f : 0.0f;
|
||||
spotLight.InnerConeAngle = 65f;
|
||||
spotLight.OuterConeAngle = 80f;
|
||||
}
|
||||
|
||||
light.Brightness = (lightamm / 128f) * 1.25f;
|
||||
}
|
||||
else if (preset == 2)
|
||||
{
|
||||
if (pointLight != null)
|
||||
{
|
||||
pointLight.Radius = 200f;
|
||||
pointLight.FallOffExponent = 2f;
|
||||
}
|
||||
|
||||
light.Brightness = (lightamm / 128f) * 1.6f;
|
||||
}
|
||||
else //if (preset == 3)
|
||||
{
|
||||
bool inverse = false;
|
||||
float finalRadius = radamm * LightRadiusMultiplier;
|
||||
|
||||
|
||||
light.Brightness = (lightamm / 128f) * BrightnessMultiplier;
|
||||
|
||||
light.ShadowsNormalOffsetScale = 10f;
|
||||
|
||||
light.ShadowsFadeDistance = 100f; // for debugging
|
||||
light.ShadowsDistance = 500f;
|
||||
light.ShadowsDepthBias = 0.027f;//0.005f;
|
||||
|
||||
var hsv = light.Color.ToHSV();
|
||||
hsv.Y *= SaturationMultiplier;
|
||||
light.Color = Color.FromHSV(hsv);
|
||||
|
||||
light.IndirectLightingIntensity = IndirectLightMultiplier;
|
||||
|
||||
light.ShadowsDepthBias = 0.0565f;
|
||||
// if low quality shadows
|
||||
//light.ShadowsDepthBias = 0.2492f;
|
||||
|
||||
if (spotLight != null)
|
||||
int preset = 3;
|
||||
if (preset == 0) // most accurate?, huge radius and low performance
|
||||
{
|
||||
// huge aliasing with spot lights for some reason?
|
||||
light.ShadowsDepthBias = 0.7f;
|
||||
light.Brightness = lightamm / 93f;
|
||||
|
||||
light.ShadowsDepthBias = 0.0565f;
|
||||
|
||||
light.Brightness *= 0.7837f;
|
||||
|
||||
if (pointLight != null)
|
||||
{
|
||||
pointLight.Radius = radamm * 12.5f;
|
||||
pointLight.FallOffExponent = 3.33f;
|
||||
pointLight.Radius *= 0.83375f;
|
||||
}
|
||||
|
||||
var hsv = light.Color.ToHSV();
|
||||
hsv.Y *= 0.8f;
|
||||
light.Color = Color.FromHSV(hsv);
|
||||
}
|
||||
else if (preset == 1) //
|
||||
{
|
||||
if (pointLight != null)
|
||||
{
|
||||
pointLight.Radius = 250f;
|
||||
pointLight.FallOffExponent = 2f;
|
||||
}
|
||||
|
||||
if (inverse)
|
||||
{
|
||||
light.Brightness *= 20000f;
|
||||
finalRadius *= 0.7f;
|
||||
light.Brightness = (lightamm / 128f) * 1.25f;
|
||||
}
|
||||
else if (preset == 2)
|
||||
{
|
||||
if (pointLight != null)
|
||||
{
|
||||
pointLight.Radius = 200f;
|
||||
pointLight.FallOffExponent = 2f;
|
||||
}
|
||||
|
||||
if (pointLight != null)
|
||||
{
|
||||
pointLight.UseInverseSquaredFalloff = inverse;
|
||||
pointLight.Radius = finalRadius;
|
||||
pointLight.FallOffExponent = FallOffExponent;
|
||||
light.Brightness = (lightamm / 128f) * 1.6f;
|
||||
}
|
||||
if (spotLight != null)
|
||||
else //if (preset == 3)
|
||||
{
|
||||
spotLight.UseInverseSquaredFalloff = inverse;
|
||||
spotLight.Radius = finalRadius;
|
||||
spotLight.FallOffExponent = FallOffExponent;
|
||||
bool inverse = false;
|
||||
float finalRadius = radamm * LightRadiusMultiplier;
|
||||
|
||||
|
||||
light.Brightness = (lightamm / 128f) * BrightnessMultiplier;
|
||||
|
||||
light.ShadowsNormalOffsetScale = 10f;
|
||||
|
||||
light.ShadowsFadeDistance = 100f; // for debugging
|
||||
light.ShadowsDistance = 500f;
|
||||
|
||||
var hsv = light.Color.ToHSV();
|
||||
hsv.Y *= SaturationMultiplier;
|
||||
light.Color = Color.FromHSV(hsv);
|
||||
|
||||
light.IndirectLightingIntensity = IndirectLightMultiplier;
|
||||
|
||||
light.ShadowsDepthBias = 0.0565f;
|
||||
// if low quality shadows
|
||||
//light.ShadowsDepthBias = 0.2492f;
|
||||
|
||||
if (spotLight != null)
|
||||
{
|
||||
// huge aliasing with spot lights for some reason?
|
||||
light.ShadowsDepthBias = 0.7f;
|
||||
}
|
||||
|
||||
if (inverse)
|
||||
{
|
||||
light.Brightness *= 20000f;
|
||||
finalRadius *= 0.7f;
|
||||
}
|
||||
|
||||
if (pointLight != null)
|
||||
{
|
||||
pointLight.UseInverseSquaredFalloff = inverse;
|
||||
pointLight.Radius = finalRadius;
|
||||
pointLight.FallOffExponent = FallOffExponent;
|
||||
}
|
||||
if (spotLight != null)
|
||||
{
|
||||
spotLight.UseInverseSquaredFalloff = inverse;
|
||||
spotLight.Radius = finalRadius;
|
||||
spotLight.FallOffExponent = FallOffExponent;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
40
Source/Game/MultiSceneScript.cs
Normal file
40
Source/Game/MultiSceneScript.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.Json;
|
||||
|
||||
namespace Game;
|
||||
|
||||
/// <summary>
|
||||
/// MultiSceneScript Script.
|
||||
/// </summary>
|
||||
public class MultiSceneScript : Script
|
||||
{
|
||||
private PhysicsScene phystest;
|
||||
private PhysicsScene phystest2;
|
||||
|
||||
public override void OnStart()
|
||||
{
|
||||
phystest = Physics.FindOrCreateScene("phystest");
|
||||
phystest2 = Physics.FindOrCreateScene("phystest2");
|
||||
|
||||
Level.SceneLoaded += OnSceneLoaded;
|
||||
Level.LoadScene(new SceneReference(JsonSerializer.ParseID("a916228c48fe3a0e89ff0985d4ad2fca")));
|
||||
Level.SceneLoaded -= OnSceneLoaded;
|
||||
|
||||
Level.SceneLoaded += OnSceneLoaded2;
|
||||
Level.LoadScene(new SceneReference(JsonSerializer.ParseID("f749e5d141e1384c05e49abe92a4fb90")));
|
||||
Level.SceneLoaded -= OnSceneLoaded2;
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(Scene scene, Guid id)
|
||||
{
|
||||
scene.PhysicsScene = phystest;
|
||||
}
|
||||
|
||||
private void OnSceneLoaded2(Scene scene, Guid id)
|
||||
{
|
||||
scene.PhysicsScene = phystest2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,154 +6,148 @@ using FlaxEditor.CustomEditors.Dedicated;
|
||||
using FlaxEditor.Scripting;
|
||||
#endif
|
||||
|
||||
namespace Game
|
||||
{
|
||||
namespace Game;
|
||||
|
||||
#if FLAX_EDITOR
|
||||
[CustomEditor(typeof(PlayerActor))]
|
||||
public class PlayerActorEditor : ActorEditor
|
||||
[CustomEditor(typeof(PlayerActor))]
|
||||
public class PlayerActorEditor : ActorEditor
|
||||
{
|
||||
protected override List<ItemInfo> GetItemsForType(ScriptType type)
|
||||
{
|
||||
protected override List<ItemInfo> GetItemsForType(ScriptType type)
|
||||
var items = GetItemsForType(type, type.IsClass, true);
|
||||
|
||||
// Remove all Rigid Body options
|
||||
items.RemoveAll(x => x.Display?.Group == "Rigid Body");
|
||||
|
||||
// Inject scripts editor
|
||||
ScriptMemberInfo scriptsMember = type.GetProperty("Scripts");
|
||||
if (scriptsMember != ScriptMemberInfo.Null)
|
||||
{
|
||||
var items = GetItemsForType(type, type.IsClass, true);
|
||||
|
||||
// Remove all Rigid Body options
|
||||
items.RemoveAll(x => x.Display?.Group == "Rigid Body");
|
||||
|
||||
// Inject scripts editor
|
||||
ScriptMemberInfo scriptsMember = type.GetProperty("Scripts");
|
||||
if (scriptsMember != ScriptMemberInfo.Null)
|
||||
ItemInfo item = new ItemInfo(scriptsMember)
|
||||
{
|
||||
ItemInfo item = new ItemInfo(scriptsMember)
|
||||
{
|
||||
CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor))
|
||||
};
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
return items;
|
||||
CustomEditor = new CustomEditorAttribute(typeof(ScriptsEditor))
|
||||
};
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
public class SomeActor : EmptyActor
|
||||
public class PlayerActor : RigidBody//, INetworkSerializable
|
||||
{
|
||||
private PlayerMovement playerMovement;
|
||||
public CapsuleCollider capsuleCollider;
|
||||
public BoxCollider boxCollider;
|
||||
public MeshCollider meshCollider;
|
||||
|
||||
//[NetworkReplicated]
|
||||
public uint PlayerId = uint.MaxValue;
|
||||
|
||||
/*public PlayerActor()
|
||||
{
|
||||
// Default internal values for RigidBody
|
||||
IsKinematic = true;
|
||||
EnableGravity = false;
|
||||
LinearDamping = 0f;
|
||||
AngularDamping = 0f;
|
||||
Constraints = RigidbodyConstraints.LockRotation;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
public class PlayerActor : RigidBody//, INetworkSerializable
|
||||
public override void OnBeginPlay()
|
||||
{
|
||||
private PlayerMovement playerMovement;
|
||||
public CapsuleCollider capsuleCollider;
|
||||
public BoxCollider boxCollider;
|
||||
public MeshCollider meshCollider;
|
||||
// Default internal values for RigidBody
|
||||
IsKinematic = true;
|
||||
EnableGravity = false;
|
||||
LinearDamping = 0f;
|
||||
AngularDamping = 0f;
|
||||
Constraints = RigidbodyConstraints.LockRotation;
|
||||
|
||||
//[NetworkReplicated]
|
||||
public uint PlayerId = uint.MaxValue;
|
||||
base.OnBeginPlay();
|
||||
|
||||
/*public PlayerActor()
|
||||
{
|
||||
// Default internal values for RigidBody
|
||||
IsKinematic = true;
|
||||
EnableGravity = false;
|
||||
LinearDamping = 0f;
|
||||
AngularDamping = 0f;
|
||||
Constraints = RigidbodyConstraints.LockRotation;
|
||||
}*/
|
||||
|
||||
public override void OnBeginPlay()
|
||||
{
|
||||
// Default internal values for RigidBody
|
||||
IsKinematic = true;
|
||||
EnableGravity = false;
|
||||
LinearDamping = 0f;
|
||||
AngularDamping = 0f;
|
||||
Constraints = RigidbodyConstraints.LockRotation;
|
||||
|
||||
base.OnBeginPlay();
|
||||
|
||||
playerMovement = FindScript<PlayerMovement>();
|
||||
capsuleCollider = GetChild<CapsuleCollider>();
|
||||
boxCollider = GetChild<BoxCollider>();
|
||||
meshCollider = GetChild<MeshCollider>();
|
||||
//playerRigidBody = FindActor<RigidBody>();
|
||||
playerMovement = FindScript<PlayerMovement>();
|
||||
capsuleCollider = GetChild<CapsuleCollider>();
|
||||
boxCollider = GetChild<BoxCollider>();
|
||||
meshCollider = GetChild<MeshCollider>();
|
||||
//playerRigidBody = FindActor<RigidBody>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Console.Print("OnBeginPlay playerid: " + PlayerId.ToString());
|
||||
//playerMovement.input = new PlayerInputNetwork();
|
||||
}
|
||||
//Console.Print("OnBeginPlay playerid: " + PlayerId.ToString());
|
||||
//playerMovement.input = new PlayerInputNetwork();
|
||||
}
|
||||
|
||||
public override void OnEnable()
|
||||
public override void OnEnable()
|
||||
{
|
||||
// Trigger OnEnable manually, does not seem to propagate when parent gets enabled/disabled
|
||||
playerMovement.Enabled = true;
|
||||
//NetworkReplicator.AddObject(this);
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
playerMovement.Enabled = false;
|
||||
//NetworkReplicator.RemoveObject(this);
|
||||
}
|
||||
|
||||
//[NetworkRpc(client: true)]
|
||||
public void Initialize(uint playerId, Float3 newPosition, Float3 eulerAngles)
|
||||
{
|
||||
if (PlayerId == playerId) // FIXME
|
||||
return;
|
||||
|
||||
FindActor("PlayerModel").IsActive = true;
|
||||
IsActive = true;
|
||||
|
||||
PlayerId = playerId;
|
||||
playerMovement.SetInput(playerId);
|
||||
if (playerId == NetworkManager.LocalPlayerClientId)
|
||||
{
|
||||
// Trigger OnEnable manually, does not seem to propagate when parent gets enabled/disabled
|
||||
playerMovement.Enabled = true;
|
||||
//NetworkReplicator.AddObject(this);
|
||||
FindActor("CameraHolder").IsActive = true;
|
||||
//FindActor("ViewModelHolder").IsActive = true;
|
||||
FindActor("PlayerModel").IsActive = false;
|
||||
}
|
||||
SetPosition(newPosition);
|
||||
SetRotation(eulerAngles);
|
||||
//else
|
||||
// FindActor("PlayerModel").IsActive = true;
|
||||
//IsActive = true;
|
||||
}
|
||||
|
||||
public override void OnDisable()
|
||||
{
|
||||
playerMovement.Enabled = false;
|
||||
//NetworkReplicator.RemoveObject(this);
|
||||
}
|
||||
//[NetworkRpc(server: true)]
|
||||
public void UpdateNetworkInput(PlayerInputState inputState/*, Float4 viewDeltaXYMoveForwardRight, bool attacking, bool jumping*/)
|
||||
{
|
||||
if (playerMovement.input is not PlayerInputNetwork playerInputNetwork)
|
||||
return;
|
||||
|
||||
//[NetworkRpc(client: true)]
|
||||
public void Initialize(uint playerId, Float3 newPosition, Float3 eulerAngles)
|
||||
{
|
||||
if (PlayerId == playerId) // FIXME
|
||||
return;
|
||||
//PlayerInputState inputState = new PlayerInputState(frame, viewDeltaXYMoveForwardRight.X, viewDeltaXYMoveForwardRight.Y, viewDeltaXYMoveForwardRight.Z, viewDeltaXYMoveForwardRight.W, attacking, jumping);
|
||||
//playerInputNetwork.currentState.input = inputState;
|
||||
playerInputNetwork.SetState(inputState.frame, inputState);
|
||||
}
|
||||
|
||||
FindActor("PlayerModel").IsActive = true;
|
||||
IsActive = true;
|
||||
public void SetPosition(Float3 newPosition)
|
||||
{
|
||||
Position = newPosition;
|
||||
playerMovement.movementState.position = newPosition;
|
||||
}
|
||||
|
||||
PlayerId = playerId;
|
||||
playerMovement.SetInput(playerId);
|
||||
if (playerId == NetworkManager.LocalPlayerClientId)
|
||||
{
|
||||
FindActor("CameraHolder").IsActive = true;
|
||||
//FindActor("ViewModelHolder").IsActive = true;
|
||||
FindActor("PlayerModel").IsActive = false;
|
||||
}
|
||||
SetPosition(newPosition);
|
||||
SetRotation(eulerAngles);
|
||||
//else
|
||||
// FindActor("PlayerModel").IsActive = true;
|
||||
//IsActive = true;
|
||||
}
|
||||
public void SetRotation(Float3 eulerAngles)
|
||||
{
|
||||
playerMovement.ResetRotation(eulerAngles);
|
||||
}
|
||||
|
||||
//[NetworkRpc(server: true)]
|
||||
public void UpdateNetworkInput(PlayerInputState inputState/*, Float4 viewDeltaXYMoveForwardRight, bool attacking, bool jumping*/)
|
||||
{
|
||||
if (playerMovement.input is not PlayerInputNetwork playerInputNetwork)
|
||||
return;
|
||||
public Float3 GetRotation()
|
||||
{
|
||||
return playerMovement.viewAngles;
|
||||
}
|
||||
|
||||
//PlayerInputState inputState = new PlayerInputState(frame, viewDeltaXYMoveForwardRight.X, viewDeltaXYMoveForwardRight.Y, viewDeltaXYMoveForwardRight.Z, viewDeltaXYMoveForwardRight.W, attacking, jumping);
|
||||
//playerInputNetwork.currentState.input = inputState;
|
||||
playerInputNetwork.SetState(inputState.frame, inputState);
|
||||
}
|
||||
|
||||
public void SetPosition(Float3 newPosition)
|
||||
{
|
||||
Position = newPosition;
|
||||
playerMovement.movementState.position = newPosition;
|
||||
}
|
||||
|
||||
public void SetRotation(Float3 eulerAngles)
|
||||
{
|
||||
playerMovement.ResetRotation(eulerAngles);
|
||||
}
|
||||
|
||||
public Float3 GetRotation()
|
||||
{
|
||||
return playerMovement.viewAngles;
|
||||
}
|
||||
|
||||
//[NetworkRpc(client: true)]
|
||||
public void Teleport(Float3 newPosition, Float3 eulerAngles)
|
||||
{
|
||||
SetPosition(newPosition);
|
||||
SetRotation(eulerAngles);
|
||||
}
|
||||
//[NetworkRpc(client: true)]
|
||||
public void Teleport(Float3 newPosition, Float3 eulerAngles)
|
||||
{
|
||||
SetPosition(newPosition);
|
||||
SetRotation(eulerAngles);
|
||||
}
|
||||
}
|
||||
@@ -1302,7 +1302,7 @@ namespace Game
|
||||
velocity.Y = jumpVel;
|
||||
}
|
||||
else
|
||||
velocity = Float3.Up * jumpVel;
|
||||
velocity = Float3.Up * jumpVel + new Float3(1, 0, 1) * velocity;
|
||||
|
||||
movementState.onGround = false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user