void on_scene_exit( ref Scene scene ) { if ( scene == null ) return; #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " on_scene_exit " + scene.DebugInfo() ); #endif // #if DEBUG_SCENE_TRANSITIONS scene.OnExit(); }
void replace_scene( Scene new_scene ) { #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( "" ); System.Console.WriteLine( Common.FrameCount + " replace_scene " + get_top_scene().DebugInfo() + " -> " + new_scene.DebugInfo() ); #endif // #if DEBUG_SCENE_TRANSITIONS if ( m_canceled_replace_scene.Contains( new_scene ) ) { #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " => replace_scene cancelled because this scene has been interrupted by an other transition during this frame" ); #endif // #if DEBUG_SCENE_TRANSITIONS return; } Common.Assert( m_scenes_stack.Count > 0, "Can't ReplaceScene: scene stack is empty" ); Scene previous_scene = get_top_scene(); m_scenes_stack[ m_scenes_stack.Count - 1 ] = new_scene; Common.Assert( previous_scene != new_scene ); on_scene_change( previous_scene, new_scene ); }
// this function is called everytime scene changes void on_scene_change( Scene previous_scene, Scene next_scene ) { // if ( previous_scene!=null ) System.Console.WriteLine( "previous_scene " + previous_scene.DebugInfo() ); // if ( next_scene!=null ) System.Console.WriteLine( "next_scene " + next_scene.DebugInfo() ); Common.Assert( previous_scene != next_scene ); bool prev_is_transition = previous_scene != null && previous_scene.IsTransitionScene(); bool next_is_transition = next_scene != null && next_scene.IsTransitionScene(); if ( !prev_is_transition && !next_is_transition ) { #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " 1 [ scene -> scene ]" ); #endif // #if DEBUG_SCENE_TRANSITIONS on_scene_exit( ref previous_scene ); on_scene_enter( ref next_scene ); } else if ( !prev_is_transition && next_is_transition ) { #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " 2 [ scene -> transition ]" ); System.Console.WriteLine( Common.FrameCount + " >>>>>>>>>>>>>> start transition" ); #endif // #if DEBUG_SCENE_TRANSITIONS // initialize PreviousScene (TransitionScene sets it to null) ((TransitionScene)next_scene).PreviousScene = previous_scene; // on_scene_exit( ref previous_scene ); // no! this will be called at the end of the transition, in case 3 on_scene_enter( ref next_scene );// entering a transition scene on_scene_enter( ref ((TransitionScene)next_scene).NextScene ); } else if ( prev_is_transition && !next_is_transition ) { #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " 3 [ transition -> scene ]" ); if ( next_scene == null ) System.Console.WriteLine( Common.FrameCount + " next_scene is null" ); #endif // #if DEBUG_SCENE_TRANSITIONS // assume we are replacing the current transition by its own NextScene, ie: #if DEBUG_SCENE_TRANSITIONS if ( next_scene != ((TransitionScene)previous_scene).NextScene ) { System.Console.WriteLine( Common.FrameCount + " ((TransitionScene)previous_scene).NextScene = " + ((TransitionScene)previous_scene).NextScene.DebugInfo() ); System.Console.WriteLine( Common.FrameCount + " -> next_scene = " + next_scene.DebugInfo() ); } #endif // #if DEBUG_SCENE_TRANSITIONS Common.Assert( next_scene == ((TransitionScene)previous_scene).NextScene ); // https://npdev-ext.scei.co.jp/pssuite/bugzilla/process_bug.cgi on_scene_exit( ref ((TransitionScene)previous_scene).PreviousScene ); on_scene_exit( ref previous_scene ); // leaving a transition scene // on_scene_enter( ref next_scene ); // no! has already been called at the beginning of the transition, in case 2 pr 4 #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " <<<<<<<<<<<<<< end transition" ); #endif // #if DEBUG_SCENE_TRANSITIONS } else if ( prev_is_transition && next_is_transition ) { // interrupting a transition by an other transition: #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " 4 [ transition -> transition ]" ); #endif // #if DEBUG_SCENE_TRANSITIONS ((TransitionScene)next_scene).PreviousScene = ((TransitionScene)previous_scene).NextScene; // this transition scene is "cancelled", remove its ReplaceScene action from action manager ((TransitionScene)previous_scene).cancel_replace_scene(); // also remember that this scene has been cancelled in case the ReplaceScene was added to the event list we are executing *in this frame* m_canceled_replace_scene.Add( ((TransitionScene)previous_scene).NextScene ); on_scene_exit( ref ((TransitionScene)previous_scene).PreviousScene ); on_scene_exit( ref previous_scene ); // leaving a transition scene #if DEBUG_SCENE_TRANSITIONS System.Console.WriteLine( Common.FrameCount + " >>>>>>>>>>>>>> start *new* transition (" + ((TransitionScene)previous_scene).PreviousScene.DebugInfo() + " interrupted)" ); #endif // #if DEBUG_SCENE_TRANSITIONS on_scene_enter( ref next_scene );// entering a transition scene on_scene_enter( ref ((TransitionScene)next_scene).NextScene ); } }