Browse Source

Refactor to make GlobalTransformation static.

Dominique Louis 2 tuần trước cách đây
mục cha
commit
14c83af4f1

+ 2 - 2
NetRumble/Core/BloomPostprocess/BloomComponent.cs

@@ -183,7 +183,7 @@ namespace NetRumble
                                bloomCombineEffect,
                                IntermediateBuffer.FinalResult);
 //            DrawFullscreenQuad(sceneRenderTarget,
-//                               viewport.Width, viewport.Height,
+//                               ScreenManager.BASE_BUFFER_WIDTH, ScreenManager.BASE_BUFFER_HEIGHT,
 //                               bloomCombineEffect,
 //                               IntermediateBuffer.FinalResult);
         }
@@ -219,7 +219,7 @@ namespace NetRumble
                 effect = null;
             }
 			effect = null;
-            spriteBatch.Begin(0, BlendState.Opaque, null, null, null, effect);
+            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, effect, ScreenManager.GlobalTransformation);
             spriteBatch.Draw(texture, new Rectangle(0, 0, width, height), Color.White);
             spriteBatch.End();
         }

+ 10 - 3
NetRumble/Core/Gameplay/World.cs

@@ -491,6 +491,15 @@ namespace NetRumble
             }
         }
 
+        /// <summary>
+        /// Reset per-round game state flags (shared by Initialize and host GenerateWorld).
+        /// </summary>
+        private void ResetGameState()
+        {
+            gameWon = false;
+            winnerIndex = -1;
+            gameExited = false;
+        }
 
         /// <summary>
         /// Initialize the world with the data from the WorldSetup packet.
@@ -499,9 +508,7 @@ namespace NetRumble
         public void Initialize()
         {
             // reset the game status
-            gameWon = false;
-            winnerIndex = -1;
-            gameExited = false;
+            ResetGameState();
 
             // initialize the ships with the data from the packet
             for (int i = 0; i < MaximumPlayers; i++)

+ 2 - 2
NetRumble/Core/ScreenManager/ScreenManager.cs

@@ -60,9 +60,9 @@ namespace NetRumble
         /// <summary>Gets or sets the base screen size used for scaling calculations.</summary>
         public Vector2 BaseScreenSize { get => baseScreenSize; set => baseScreenSize = value; }
 
-        private Matrix globalTransformation;
+        private static Matrix globalTransformation = Matrix.Identity;
         /// <summary>Gets or sets the global transformation matrix for scaling and positioning.</summary>
-        public Matrix GlobalTransformation { get => globalTransformation; set => globalTransformation = value; }
+        public static Matrix GlobalTransformation { get => globalTransformation; set => globalTransformation = value; }
 
         /// <summary>
         /// Expose access to our Game instance (this is protected in the