diff --git a/Editor/Background.meta b/Editor/Background.meta new file mode 100644 index 0000000..a00b40c --- /dev/null +++ b/Editor/Background.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 94ddf6c8713749dda84e4de934d39bf0 +timeCreated: 1752350242 \ No newline at end of file diff --git a/Editor/Background/EnsureUniqueActorID.cs b/Editor/Background/EnsureUniqueActorID.cs new file mode 100644 index 0000000..e075383 --- /dev/null +++ b/Editor/Background/EnsureUniqueActorID.cs @@ -0,0 +1,34 @@ +using RebootKit.Engine.Foundation; +using RebootKit.Engine.Simulation; +using UnityEditor; +using UnityEngine; + +namespace RebootKit.Editor.Background { + [InitializeOnLoad] + public class EnsureUniqueActorID { + static EnsureUniqueActorID() { + ObjectChangeEvents.changesPublished += OnObjectChange; + } + + static void OnObjectChange(ref ObjectChangeEventStream stream) { + + for (int i = 0; i < stream.length; ++i) { + switch (stream.GetEventType(i)) { + case ObjectChangeKind.CreateGameObjectHierarchy: + stream.GetCreateGameObjectHierarchyEvent(i, out CreateGameObjectHierarchyEventArgs createEvent); + + GameObject gameObjectChanged = + EditorUtility.InstanceIDToObject(createEvent.instanceId) as GameObject; + + if (gameObjectChanged != null && gameObjectChanged.TryGetComponent(out Actor actor)) { + actor.ActorID = UniqueID.NewULongFromGuid(); + EditorUtility.SetDirty(actor); + } + + break; + } + } + + } + } +} \ No newline at end of file diff --git a/Editor/Background/EnsureUniqueActorID.cs.meta b/Editor/Background/EnsureUniqueActorID.cs.meta new file mode 100644 index 0000000..9e12bdb --- /dev/null +++ b/Editor/Background/EnsureUniqueActorID.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: bccf1b1891f9486e85330d8c7be3ea52 +timeCreated: 1752350253 \ No newline at end of file diff --git a/Editor/RebootKitEditor.asmdef b/Editor/RebootKit.Editor.asmdef old mode 100755 new mode 100644 similarity index 86% rename from Editor/RebootKitEditor.asmdef rename to Editor/RebootKit.Editor.asmdef index df38dfc..5f33f14 --- a/Editor/RebootKitEditor.asmdef +++ b/Editor/RebootKit.Editor.asmdef @@ -1,6 +1,6 @@ { - "name": "SzafaKitEditor", - "rootNamespace": "RebootKitEditor", + "name": "RebootKit.Editor", + "rootNamespace": "RebootKit.Editor", "references": [ "GUID:284059c7949783646b281a1b815580e6", "GUID:9e24947de15b9834991c9d8411ea37cf", diff --git a/Editor/RebootKitEditor.asmdef.meta b/Editor/RebootKit.Editor.asmdef.meta old mode 100755 new mode 100644 similarity index 100% rename from Editor/RebootKitEditor.asmdef.meta rename to Editor/RebootKit.Editor.asmdef.meta diff --git a/Runtime/Engine/Code/Components/CopyTransform.cs b/Runtime/Engine/Code/Components/CopyTransform.cs index 359e436..b89a2fe 100755 --- a/Runtime/Engine/Code/Components/CopyTransform.cs +++ b/Runtime/Engine/Code/Components/CopyTransform.cs @@ -48,15 +48,15 @@ namespace RebootKit.Engine.Components { } void CopyTransformComponents() { - if (m_Components.HasFlag(TransformComponents.Position)) { + if ((m_Components & TransformComponents.Position) != 0) { m_Transform.position = m_Source.position; } - if (m_Components.HasFlag(TransformComponents.Rotation)) { + if ((m_Components & TransformComponents.Rotation) != 0) { m_Transform.rotation = m_Source.rotation; } - if (m_Components.HasFlag(TransformComponents.Scale)) { + if ((m_Components & TransformComponents.Scale) != 0) { m_Transform.localScale = m_Source.localScale; } } diff --git a/Runtime/Engine/Code/Console/ConsoleService.cs b/Runtime/Engine/Code/Console/ConsoleService.cs index 89bd02b..dc3cea8 100644 --- a/Runtime/Engine/Code/Console/ConsoleService.cs +++ b/Runtime/Engine/Code/Console/ConsoleService.cs @@ -86,7 +86,7 @@ namespace RebootKit.Engine.Console { return; } - if (!cvar.flags.HasFlag(CVarFlags.ReadOnly)) { + if ((cvar.flags & CVarFlags.ReadOnly) == 0) { Save(); } } @@ -158,8 +158,8 @@ namespace RebootKit.Engine.Console { IEnumerable methods = AppDomain.CurrentDomain.GetAssemblies() .SelectMany(assembly => assembly.GetTypes()) .SelectMany(type => type.GetMethods(BindingFlags.NonPublic | - BindingFlags.Public | - BindingFlags.Static)) + BindingFlags.Public | + BindingFlags.Static)) .Where(method => method.GetCustomAttributes(typeof(RCCMD), false) .Length > 0); @@ -256,7 +256,7 @@ namespace RebootKit.Engine.Console { StringBuilder sb = new StringBuilder(); foreach (ConfigVar cvar in ConfigVarsContainer.All()) { - if (!cvar.flags.HasFlag(CVarFlags.ReadOnly)) { + if ((cvar.flags & CVarFlags.ReadOnly) == 0) { sb.AppendFormat("{0} {1}\n", cvar.name, cvar); } } diff --git a/Runtime/Engine/Code/Development/DebugOverlayView.cs b/Runtime/Engine/Code/Development/DebugOverlayView.cs index 67903c2..50166fd 100644 --- a/Runtime/Engine/Code/Development/DebugOverlayView.cs +++ b/Runtime/Engine/Code/Development/DebugOverlayView.cs @@ -26,9 +26,9 @@ namespace RebootKit.Engine.Development { StringBuilder sb = new StringBuilder(); sb.Append("Network: "); - sb.Append($"IsServer: {nm.IsServer}"); - sb.Append($" | IsClient: {nm.IsClient}"); - sb.Append($" | IsHost: {nm.IsHost}"); + sb.Append($"IsServer: {nm.IsServer.ToString()}"); + sb.Append($" | IsClient: {nm.IsClient.ToString()}"); + sb.Append($" | IsHost: {nm.IsHost.ToString()}"); m_NetworkStatsLabel.text = sb.ToString(); } @@ -37,7 +37,7 @@ namespace RebootKit.Engine.Development { m_RootElement = new VisualElement(); CreateLabel($"Toggle Overlay [F3] | RebootKit | game: {Application.productName}, version: {Application.version}"); - m_FPSLabel = CreateLabel($"FPS: {Application.targetFrameRate}"); + m_FPSLabel = CreateLabel($"FPS: {Application.targetFrameRate.ToString()}"); m_NetworkStatsLabel = CreateLabel("Network Stats"); diff --git a/Runtime/Engine/Code/Development/DevToolsService.cs b/Runtime/Engine/Code/Development/DevToolsService.cs index 3501016..599a78b 100644 --- a/Runtime/Engine/Code/Development/DevToolsService.cs +++ b/Runtime/Engine/Code/Development/DevToolsService.cs @@ -4,18 +4,29 @@ using UnityEngine; using UnityEngine.InputSystem; namespace RebootKit.Engine.Development { - static class DebugConfig { - [ConfigVar("debug.overlay", 0, "Controls overlay visibility. 0 - hidden, 1 - visible")] public static ConfigVar s_OverlayMode; + static class DebugCVars { + [ConfigVar("debug.overlay", 0, "Controls overlay visibility. 0 - hidden, 1 - visible")] + public static ConfigVar OverlayMode; + + [ConfigVar("debug.game_version", 1, "Controls game version overlay visibility. 0 - hidden, 1 - visible")] + public static ConfigVar ShowGameVersion; + + [ConfigVar("debug.network_stats", 1, "Controls network stats overlay visibility. 0 - hidden, 1 - visible")] + public static ConfigVar ShowNetworkStats; } public class DevToolsService : ServiceMonoBehaviour { [SerializeField] DebugOverlayView m_DebugOverlayView; + [SerializeField] GameVersionOverlay m_GameVersionOverlay; + [SerializeField] GameObject m_NetworkStatsOverlay; IDisposable m_CVarChangedListener; void Start() { ConfigVar.StateChanged += OnCVarChanged; - OnCVarChanged(DebugConfig.s_OverlayMode); + OnCVarChanged(DebugCVars.OverlayMode); + OnCVarChanged(DebugCVars.ShowGameVersion); + OnCVarChanged(DebugCVars.ShowNetworkStats); } void OnDisable() { @@ -28,7 +39,7 @@ namespace RebootKit.Engine.Development { void Update() { if (InputSystem.GetDevice().f3Key.wasReleasedThisFrame) { - DebugConfig.s_OverlayMode.Set(DebugConfig.s_OverlayMode.IndexValue == 1 ? 0 : 1); + DebugCVars.OverlayMode.Set(DebugCVars.OverlayMode.IndexValue == 1 ? 0 : 1); } } @@ -41,8 +52,12 @@ namespace RebootKit.Engine.Development { } void OnCVarChanged(ConfigVar cvar) { - if (cvar == DebugConfig.s_OverlayMode) { + if (cvar == DebugCVars.OverlayMode) { OnOverlayModeChanged(cvar.IndexValue); + } else if (cvar == DebugCVars.ShowGameVersion) { + m_GameVersionOverlay.gameObject.SetActive(cvar.IndexValue > 0); + } else if (cvar == DebugCVars.ShowNetworkStats) { + m_NetworkStatsOverlay.SetActive(cvar.IndexValue > 0); } } } diff --git a/Runtime/Engine/Code/Development/GameVersionOverlay.cs b/Runtime/Engine/Code/Development/GameVersionOverlay.cs new file mode 100644 index 0000000..b516d49 --- /dev/null +++ b/Runtime/Engine/Code/Development/GameVersionOverlay.cs @@ -0,0 +1,34 @@ +using System; +using System.Text; +using RebootKit.Engine.Foundation; +using UnityEngine; +using UnityEngine.UIElements; + +namespace RebootKit.Engine.Development { + public class GameVersionOverlay : MonoBehaviour { + const string k_VersionLabelName = "rr-dev__version_label"; + + [SerializeField] UIDocument m_Document; + + void OnEnable() { + Label versionLabel = m_Document.rootVisualElement.Q