From 1760ec1bf87d21529dcf3e7c1fe871a32fae9864 Mon Sep 17 00:00:00 2001 From: AngryHound Date: Wed, 17 Apr 2024 20:29:54 -0500 Subject: [PATCH] commit before branch change to latest --- .../Scripts/Sessions/HEU_SessionManager.cs | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Plugins/HoudiniEngineUnity/Scripts/Sessions/HEU_SessionManager.cs b/Plugins/HoudiniEngineUnity/Scripts/Sessions/HEU_SessionManager.cs index c479ec3d..c239df08 100644 --- a/Plugins/HoudiniEngineUnity/Scripts/Sessions/HEU_SessionManager.cs +++ b/Plugins/HoudiniEngineUnity/Scripts/Sessions/HEU_SessionManager.cs @@ -80,11 +80,11 @@ public static class HEU_SessionManager { /// /// A new session object public static HEU_SessionBase CreateSessionObject( ) { - HEU_SessionBase sessionBase = null ; #if HOUDINIENGINEUNITY_ENABLED - sessionBase = new HEU_SessionHAPI( ) ; + HEU_SessionHAPI sessionBase = new( ) ; #else - sessionBase = new HEU_SessionBase(); + + HEU_SessionBase sessionBase = new( ) ; #endif return sessionBase ; } @@ -206,11 +206,12 @@ static void InternalValidateSceneAssets( ) { // Go through each asset, and validate in session _assets = Object.FindObjectsByType< HEU_HoudiniAsset >( FindObjectsSortMode.None ) ; foreach ( HEU_HoudiniAsset asset in _assets ) { - if ( !asset || asset.SessionID == HEU_Defines.HEU_INVALID_NODE_ID ) continue ; + if ( asset is not { SessionID: not HEU_Defines.HEU_INVALID_NODE_ID } ) + continue ; if ( _sessionMap.TryGetValue( asset.SessionID, out HEU_SessionBase session ) ) session.RegisterAsset( asset ) ; - else + else asset.InvalidateAsset( ) ; } } @@ -463,15 +464,8 @@ public static bool RestartSession( ) { /// /// True if plugin is installed and session is valid. public static bool ValidatePluginSession( HEU_SessionBase session = null ) { - if ( session is null ) { - session = GetOrCreateDefaultSession( ) ; - } - - if ( session is null || !session.IsSessionValid( ) ) { - return false ; - } - - return true ; + session ??= GetOrCreateDefaultSession( ) ; + return session?.IsSessionValid( ) is true ; } /// Returns last session error. @@ -525,14 +519,14 @@ public static string GetConnectionError( bool clear ) { } public static bool IsHARSProcessRunning( int processID ) { - if ( processID <= 0 ) return false ; + if ( processID < 1 ) return false ; try { System.Diagnostics.Process serverProcess = System.Diagnostics.Process.GetProcessById( processID ) ; return serverProcess is { HasExited: false, ProcessName: "HARS" } ; //!serverProcess.HasExited && serverProcess.ProcessName.Equals( "HARS" ) ; } - catch ( System.Exception ) { return false ; } + catch ( Exception ) { return false ; } } // SESSION DEBUG ----------------------------------------------------------------------------------------------