diff options
-rw-r--r-- | StardewModdingAPI/Inheritance/SGame.cs | 1282 |
1 files changed, 656 insertions, 626 deletions
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs index 8eb7ad62..c346157c 100644 --- a/StardewModdingAPI/Inheritance/SGame.cs +++ b/StardewModdingAPI/Inheritance/SGame.cs @@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Reflection;
+using System.Runtime.CompilerServices;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
@@ -418,6 +419,7 @@ namespace StardewModdingAPI.Inheritance public static MethodInfo UpdateTitleScreen = typeof(Game1).GetMethod("UpdateTitleScreen", BindingFlags.NonPublic | BindingFlags.Instance);
+ public delegate void BaseBaseDraw();
/// <summary>
/// Whether or not the game's zoom level is 1.0f
@@ -458,11 +460,11 @@ namespace StardewModdingAPI.Inheritance QueueDebugMessage("FPS: " + FramesPerSecond);
UpdateEventCalls();
- /*if (ZoomLevelIsOne)
+ if (ZoomLevelIsOne)
{
options.zoomLevel = 0.99f;
InvokeBasePrivateInstancedMethod("Window_ClientSizeChanged", null, null);
- }*/
+ }
if (FramePressedKeys.Contains(Keys.F3))
{
@@ -479,163 +481,185 @@ namespace StardewModdingAPI.Inheritance {
#region Overridden Update Call
- if (Program.BuildType == 0)
- SteamHelper.update();
- if ((paused /*|| !this.IsActive*/) && (options == null || options.pauseWhenOutOfFocus || paused))
- return;
- if (quit)
- Exit();
- currentGameTime = gameTime;
- if (gameMode != 11)
+ try
{
- if (IsMultiplayer && gameMode == 3)
+ if (Program.BuildType == 0)
+ SteamHelper.update();
+ if ((paused /*|| !this.IsActive*/) && (options == null || options.pauseWhenOutOfFocus || paused))
+ return;
+ if (quit)
+ Exit();
+ currentGameTime = gameTime;
+ if (gameMode != 11)
{
- if (multiplayerMode == 2)
- server.receiveMessages();
- else
- client.receiveMessages();
- }
- if (IsActive)
- InvokeMethodInfo(CheckForEscapeKeys);
+ if (IsMultiplayer && gameMode == 3)
+ {
+ if (multiplayerMode == 2)
+ server.receiveMessages();
+ else
+ client.receiveMessages();
+ }
+ if (IsActive)
+ InvokeMethodInfo(CheckForEscapeKeys);
//InvokeBasePrivateInstancedMethod("checkForEscapeKeys");
-
+
//this.checkForEscapeKeys();
- updateMusic();
- updateRaindropPosition();
- if (bloom != null)
- bloom.tick(gameTime);
- if (globalFade)
- {
- if (!dialogueUp)
+ updateMusic();
+ updateRaindropPosition();
+ if (bloom != null)
+ bloom.tick(gameTime);
+ if (globalFade)
{
- if (fadeIn)
+ if (!dialogueUp)
{
- fadeToBlackAlpha = Math.Max(0.0f, fadeToBlackAlpha - globalFadeSpeed);
- if (fadeToBlackAlpha <= 0.0)
+ if (fadeIn)
{
- globalFade = false;
- if (afterFade != null)
+ fadeToBlackAlpha = Math.Max(0.0f, fadeToBlackAlpha - globalFadeSpeed);
+ if (fadeToBlackAlpha <= 0.0)
{
- afterFadeFunction afterFadeFunction = afterFade;
- afterFade();
- if (afterFade != null && afterFade.Equals(afterFadeFunction))
- afterFade = null;
- if (nonWarpFade)
- fadeToBlack = false;
+ globalFade = false;
+ if (afterFade != null)
+ {
+ afterFadeFunction afterFadeFunction = afterFade;
+ afterFade();
+ if (afterFade != null && afterFade.Equals(afterFadeFunction))
+ afterFade = null;
+ if (nonWarpFade)
+ fadeToBlack = false;
+ }
}
}
- }
- else
- {
- fadeToBlackAlpha = Math.Min(1f, fadeToBlackAlpha + globalFadeSpeed);
- if (fadeToBlackAlpha >= 1.0)
+ else
{
- globalFade = false;
- if (afterFade != null)
+ fadeToBlackAlpha = Math.Min(1f, fadeToBlackAlpha + globalFadeSpeed);
+ if (fadeToBlackAlpha >= 1.0)
{
- afterFadeFunction afterFadeFunction = afterFade;
- afterFade();
- if (afterFade != null && afterFade.Equals(afterFadeFunction))
- afterFade = null;
- if (nonWarpFade)
- fadeToBlack = false;
+ globalFade = false;
+ if (afterFade != null)
+ {
+ afterFadeFunction afterFadeFunction = afterFade;
+ afterFade();
+ if (afterFade != null && afterFade.Equals(afterFadeFunction))
+ afterFade = null;
+ if (nonWarpFade)
+ fadeToBlack = false;
+ }
}
}
}
+ else
+ InvokeMethodInfo(UpdateControlInput, gameTime);
+ //InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
+ //this.UpdateControlInput(gameTime);
}
- else
- InvokeMethodInfo(UpdateControlInput, gameTime);
- //InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
- //this.UpdateControlInput(gameTime);
- }
- else if (pauseThenDoFunctionTimer > 0)
- {
- freezeControls = true;
- pauseThenDoFunctionTimer -= gameTime.ElapsedGameTime.Milliseconds;
- if (pauseThenDoFunctionTimer <= 0)
- {
- freezeControls = false;
- if (afterPause != null)
- afterPause();
- }
- }
- if (gameMode == 3 || gameMode == 2)
- {
- player.millisecondsPlayed += (uint)gameTime.ElapsedGameTime.Milliseconds;
- bool flag = true;
- if (currentMinigame != null)
+ else if (pauseThenDoFunctionTimer > 0)
{
- if (pauseTime > 0.0)
- updatePause(gameTime);
- if (fadeToBlack)
+ freezeControls = true;
+ pauseThenDoFunctionTimer -= gameTime.ElapsedGameTime.Milliseconds;
+ if (pauseThenDoFunctionTimer <= 0)
{
- updateScreenFade(gameTime);
- if (fadeToBlackAlpha >= 1.0)
- fadeToBlack = false;
+ freezeControls = false;
+ if (afterPause != null)
+ afterPause();
}
- else
+ }
+ if (gameMode == 3 || gameMode == 2)
+ {
+ player.millisecondsPlayed += (uint) gameTime.ElapsedGameTime.Milliseconds;
+ bool flag = true;
+ if (currentMinigame != null)
{
- if (ThumbstickMotionMargin > 0)
- ThumbstickMotionMargin -= gameTime.ElapsedGameTime.Milliseconds;
- if (IsActive)
+ if (pauseTime > 0.0)
+ updatePause(gameTime);
+ if (fadeToBlack)
{
- KeyboardState state1 = Keyboard.GetState();
- MouseState state2 = Mouse.GetState();
- GamePadState state3 = GamePad.GetState(PlayerIndex.One);
- foreach (Keys keys in state1.GetPressedKeys())
- {
- if (!oldKBState.IsKeyDown(keys))
- currentMinigame.receiveKeyPress(keys);
- }
- if (options.gamepadControls)
+ updateScreenFade(gameTime);
+ if (fadeToBlackAlpha >= 1.0)
+ fadeToBlack = false;
+ }
+ else
+ {
+ if (ThumbstickMotionMargin > 0)
+ ThumbstickMotionMargin -= gameTime.ElapsedGameTime.Milliseconds;
+ if (IsActive)
{
- if (currentMinigame == null)
+ KeyboardState state1 = Keyboard.GetState();
+ MouseState state2 = Mouse.GetState();
+ GamePadState state3 = GamePad.GetState(PlayerIndex.One);
+ foreach (Keys keys in state1.GetPressedKeys())
{
- oldMouseState = state2;
- oldKBState = state1;
- oldPadState = state3;
- return;
+ if (!oldKBState.IsKeyDown(keys))
+ currentMinigame.receiveKeyPress(keys);
}
- foreach (Buttons b in Utility.getPressedButtons(state3, oldPadState))
- currentMinigame.receiveKeyPress(Utility.mapGamePadButtonToKey(b));
- if (currentMinigame == null)
+ if (options.gamepadControls)
{
- oldMouseState = state2;
- oldKBState = state1;
- oldPadState = state3;
- return;
+ if (currentMinigame == null)
+ {
+ oldMouseState = state2;
+ oldKBState = state1;
+ oldPadState = state3;
+ return;
+ }
+ foreach (Buttons b in Utility.getPressedButtons(state3, oldPadState))
+ currentMinigame.receiveKeyPress(Utility.mapGamePadButtonToKey(b));
+ if (currentMinigame == null)
+ {
+ oldMouseState = state2;
+ oldKBState = state1;
+ oldPadState = state3;
+ return;
+ }
+ if (state3.ThumbSticks.Right.Y < -0.200000002980232 && oldPadState.ThumbSticks.Right.Y >= -0.200000002980232)
+ currentMinigame.receiveKeyPress(Keys.Down);
+ if (state3.ThumbSticks.Right.Y > 0.200000002980232 && oldPadState.ThumbSticks.Right.Y <= 0.200000002980232)
+ currentMinigame.receiveKeyPress(Keys.Up);
+ if (state3.ThumbSticks.Right.X < -0.200000002980232 && oldPadState.ThumbSticks.Right.X >= -0.200000002980232)
+ currentMinigame.receiveKeyPress(Keys.Left);
+ if (state3.ThumbSticks.Right.X > 0.200000002980232 && oldPadState.ThumbSticks.Right.X <= 0.200000002980232)
+ currentMinigame.receiveKeyPress(Keys.Right);
+ if (oldPadState.ThumbSticks.Right.Y < -0.200000002980232 && state3.ThumbSticks.Right.Y >= -0.200000002980232)
+ currentMinigame.receiveKeyRelease(Keys.Down);
+ if (oldPadState.ThumbSticks.Right.Y > 0.200000002980232 && state3.ThumbSticks.Right.Y <= 0.200000002980232)
+ currentMinigame.receiveKeyRelease(Keys.Up);
+ if (oldPadState.ThumbSticks.Right.X < -0.200000002980232 && state3.ThumbSticks.Right.X >= -0.200000002980232)
+ currentMinigame.receiveKeyRelease(Keys.Left);
+ if (oldPadState.ThumbSticks.Right.X > 0.200000002980232 && state3.ThumbSticks.Right.X <= 0.200000002980232)
+ currentMinigame.receiveKeyRelease(Keys.Right);
+ if (isGamePadThumbstickInMotion())
+ {
+ setMousePosition(getMouseX() + (int) (state3.ThumbSticks.Left.X * 16.0), getMouseY() - (int) (state3.ThumbSticks.Left.Y * 16.0));
+ lastCursorMotionWasMouse = false;
+ }
+ else if (getMousePosition().X != getOldMouseX() || getMousePosition().Y != getOldMouseY())
+ lastCursorMotionWasMouse = true;
}
- if (state3.ThumbSticks.Right.Y < -0.200000002980232 && oldPadState.ThumbSticks.Right.Y >= -0.200000002980232)
- currentMinigame.receiveKeyPress(Keys.Down);
- if (state3.ThumbSticks.Right.Y > 0.200000002980232 && oldPadState.ThumbSticks.Right.Y <= 0.200000002980232)
- currentMinigame.receiveKeyPress(Keys.Up);
- if (state3.ThumbSticks.Right.X < -0.200000002980232 && oldPadState.ThumbSticks.Right.X >= -0.200000002980232)
- currentMinigame.receiveKeyPress(Keys.Left);
- if (state3.ThumbSticks.Right.X > 0.200000002980232 && oldPadState.ThumbSticks.Right.X <= 0.200000002980232)
- currentMinigame.receiveKeyPress(Keys.Right);
- if (oldPadState.ThumbSticks.Right.Y < -0.200000002980232 && state3.ThumbSticks.Right.Y >= -0.200000002980232)
- currentMinigame.receiveKeyRelease(Keys.Down);
- if (oldPadState.ThumbSticks.Right.Y > 0.200000002980232 && state3.ThumbSticks.Right.Y <= 0.200000002980232)
- currentMinigame.receiveKeyRelease(Keys.Up);
- if (oldPadState.ThumbSticks.Right.X < -0.200000002980232 && state3.ThumbSticks.Right.X >= -0.200000002980232)
- currentMinigame.receiveKeyRelease(Keys.Left);
- if (oldPadState.ThumbSticks.Right.X > 0.200000002980232 && state3.ThumbSticks.Right.X <= 0.200000002980232)
- currentMinigame.receiveKeyRelease(Keys.Right);
- if (isGamePadThumbstickInMotion())
+ foreach (Keys keys in oldKBState.GetPressedKeys())
{
- setMousePosition(getMouseX() + (int)(state3.ThumbSticks.Left.X * 16.0), getMouseY() - (int)(state3.ThumbSticks.Left.Y * 16.0));
- lastCursorMotionWasMouse = false;
+ if (!state1.IsKeyDown(keys))
+ currentMinigame.receiveKeyRelease(keys);
+ }
+ if (options.gamepadControls)
+ {
+ if (currentMinigame == null)
+ {
+ oldMouseState = state2;
+ oldKBState = state1;
+ oldPadState = state3;
+ return;
+ }
+ if (state3.IsConnected && state3.IsButtonDown(Buttons.X) && !oldPadState.IsButtonDown(Buttons.X))
+ currentMinigame.receiveRightClick(getMouseX(), getMouseY(), true);
+ else if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && !oldPadState.IsButtonDown(Buttons.A))
+ currentMinigame.receiveLeftClick(getMouseX(), getMouseY(), true);
+ else if (state3.IsConnected && !state3.IsButtonDown(Buttons.X) && oldPadState.IsButtonDown(Buttons.X))
+ currentMinigame.releaseRightClick(getMouseX(), getMouseY());
+ else if (state3.IsConnected && !state3.IsButtonDown(Buttons.A) && oldPadState.IsButtonDown(Buttons.A))
+ currentMinigame.releaseLeftClick(getMouseX(), getMouseY());
+ foreach (Buttons b in Utility.getPressedButtons(oldPadState, state3))
+ currentMinigame.receiveKeyRelease(Utility.mapGamePadButtonToKey(b));
+ if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && currentMinigame != null)
+ currentMinigame.leftClickHeld(0, 0);
}
- else if (getMousePosition().X != getOldMouseX() || getMousePosition().Y != getOldMouseY())
- lastCursorMotionWasMouse = true;
- }
- foreach (Keys keys in oldKBState.GetPressedKeys())
- {
- if (!state1.IsKeyDown(keys))
- currentMinigame.receiveKeyRelease(keys);
- }
- if (options.gamepadControls)
- {
if (currentMinigame == null)
{
oldMouseState = state2;
@@ -643,137 +667,122 @@ namespace StardewModdingAPI.Inheritance oldPadState = state3;
return;
}
- if (state3.IsConnected && state3.IsButtonDown(Buttons.X) && !oldPadState.IsButtonDown(Buttons.X))
- currentMinigame.receiveRightClick(getMouseX(), getMouseY(), true);
- else if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && !oldPadState.IsButtonDown(Buttons.A))
+ if (state2.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton != ButtonState.Pressed)
currentMinigame.receiveLeftClick(getMouseX(), getMouseY(), true);
- else if (state3.IsConnected && !state3.IsButtonDown(Buttons.X) && oldPadState.IsButtonDown(Buttons.X))
- currentMinigame.releaseRightClick(getMouseX(), getMouseY());
- else if (state3.IsConnected && !state3.IsButtonDown(Buttons.A) && oldPadState.IsButtonDown(Buttons.A))
+ if (state2.RightButton == ButtonState.Pressed && oldMouseState.RightButton != ButtonState.Pressed)
+ currentMinigame.receiveRightClick(getMouseX(), getMouseY(), true);
+ if (state2.LeftButton == ButtonState.Released && oldMouseState.LeftButton == ButtonState.Pressed)
currentMinigame.releaseLeftClick(getMouseX(), getMouseY());
- foreach (Buttons b in Utility.getPressedButtons(oldPadState, state3))
- currentMinigame.receiveKeyRelease(Utility.mapGamePadButtonToKey(b));
- if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && currentMinigame != null)
- currentMinigame.leftClickHeld(0, 0);
- }
- if (currentMinigame == null)
- {
+ if (state2.RightButton == ButtonState.Released && oldMouseState.RightButton == ButtonState.Pressed)
+ currentMinigame.releaseLeftClick(getMouseX(), getMouseY());
+ if (state2.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Pressed)
+ currentMinigame.leftClickHeld(getMouseX(), getMouseY());
oldMouseState = state2;
oldKBState = state1;
oldPadState = state3;
+ }
+ if (currentMinigame != null && currentMinigame.tick(gameTime))
+ {
+ currentMinigame.unload();
+ currentMinigame = null;
+ fadeIn = true;
+ fadeToBlackAlpha = 1f;
return;
}
- if (state2.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton != ButtonState.Pressed)
- currentMinigame.receiveLeftClick(getMouseX(), getMouseY(), true);
- if (state2.RightButton == ButtonState.Pressed && oldMouseState.RightButton != ButtonState.Pressed)
- currentMinigame.receiveRightClick(getMouseX(), getMouseY(), true);
- if (state2.LeftButton == ButtonState.Released && oldMouseState.LeftButton == ButtonState.Pressed)
- currentMinigame.releaseLeftClick(getMouseX(), getMouseY());
- if (state2.RightButton == ButtonState.Released && oldMouseState.RightButton == ButtonState.Pressed)
- currentMinigame.releaseLeftClick(getMouseX(), getMouseY());
- if (state2.LeftButton == ButtonState.Pressed && oldMouseState.LeftButton == ButtonState.Pressed)
- currentMinigame.leftClickHeld(getMouseX(), getMouseY());
- oldMouseState = state2;
- oldKBState = state1;
- oldPadState = state3;
}
- if (currentMinigame != null && currentMinigame.tick(gameTime))
+ flag = IsMultiplayer;
+ }
+ else if (farmEvent != null && farmEvent.tickUpdate(gameTime))
+ {
+ farmEvent.makeChangesToLocation();
+ timeOfDay = 600;
+ UpdateOther(gameTime);
+ displayHUD = true;
+ farmEvent = null;
+ currentLocation = getLocationFromName("FarmHouse");
+ player.position = Utility.PointToVector2(Utility.getHomeOfFarmer(player).getBedSpot()) * tileSize;
+ player.position.X -= tileSize;
+ changeMusicTrack("none");
+ currentLocation.resetForPlayerEntry();
+ player.forceCanMove();
+ freezeControls = false;
+ displayFarmer = true;
+ outdoorLight = Color.White;
+ viewportFreeze = false;
+ fadeToBlackAlpha = 0.0f;
+ fadeToBlack = false;
+ globalFadeToClear(null, 0.02f);
+ player.mailForTomorrow.Clear();
+ showEndOfNightStuff();
+ }
+ if (flag)
+ {
+ if (endOfNightMenus.Count() > 0 && activeClickableMenu == null)
+ activeClickableMenu = endOfNightMenus.Pop();
+ if (activeClickableMenu != null)
+ {
+ updateActiveMenu(gameTime);
+ }
+ else
+ {
+ if (pauseTime > 0.0)
+ updatePause(gameTime);
+ if (!globalFade && !freezeControls && (activeClickableMenu == null && IsActive))
+ InvokeMethodInfo(UpdateControlInput, gameTime);
+ //InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
+ //this.UpdateControlInput(gameTime);
+ }
+ if (showingEndOfNightStuff && endOfNightMenus.Count() == 0 && activeClickableMenu == null)
+ {
+ showingEndOfNightStuff = false;
+ globalFadeToClear(playMorningSong, 0.02f);
+ }
+ if (!showingEndOfNightStuff)
+ {
+ if (IsMultiplayer || activeClickableMenu == null && currentMinigame == null)
+ UpdateGameClock(gameTime);
+ //this.UpdateCharacters(gameTime);
+ //this.UpdateLocations(gameTime);
+ //InvokeBasePrivateInstancedMethod("UpdateCharacters", gameTime);
+ //InvokeBasePrivateInstancedMethod("UpdateLocations", gameTime);
+ //UpdateViewPort(false, (Point)InvokeBasePrivateInstancedMethod("getViewportCenter"));
+
+ InvokeMethodInfo(UpdateCharacters, gameTime);
+ InvokeMethodInfo(UpdateLocations, gameTime);
+ UpdateViewPort(false, (Point) InvokeMethodInfo(getViewportCenter));
+ }
+ UpdateOther(gameTime);
+ if (messagePause)
{
- currentMinigame.unload();
- currentMinigame = null;
- fadeIn = true;
- fadeToBlackAlpha = 1f;
- return;
+ KeyboardState state1 = Keyboard.GetState();
+ MouseState state2 = Mouse.GetState();
+ GamePadState state3 = GamePad.GetState(PlayerIndex.One);
+ if (isOneOfTheseKeysDown(state1, options.actionButton) && !isOneOfTheseKeysDown(oldKBState, options.actionButton))
+ pressActionButton(state1, state2, state3);
+ oldKBState = state1;
+ oldPadState = state3;
}
}
- flag = IsMultiplayer;
}
- else if (farmEvent != null && farmEvent.tickUpdate(gameTime))
- {
- farmEvent.makeChangesToLocation();
- timeOfDay = 600;
- UpdateOther(gameTime);
- displayHUD = true;
- farmEvent = null;
- currentLocation = getLocationFromName("FarmHouse");
- player.position = Utility.PointToVector2(Utility.getHomeOfFarmer(player).getBedSpot()) * tileSize;
- player.position.X -= tileSize;
- changeMusicTrack("none");
- currentLocation.resetForPlayerEntry();
- player.forceCanMove();
- freezeControls = false;
- displayFarmer = true;
- outdoorLight = Color.White;
- viewportFreeze = false;
- fadeToBlackAlpha = 0.0f;
- fadeToBlack = false;
- globalFadeToClear(null, 0.02f);
- player.mailForTomorrow.Clear();
- showEndOfNightStuff();
- }
- if (flag)
+ else
{
- if (endOfNightMenus.Count() > 0 && activeClickableMenu == null)
- activeClickableMenu = endOfNightMenus.Pop();
+ //InvokeBasePrivateInstancedMethod("UpdateTitleScreen", gameTime);
+ InvokeMethodInfo(UpdateTitleScreen, gameTime);
+ //this.UpdateTitleScreen(gameTime);
if (activeClickableMenu != null)
- {
updateActiveMenu(gameTime);
- }
- else
- {
- if (pauseTime > 0.0)
- updatePause(gameTime);
- if (!globalFade && !freezeControls && (activeClickableMenu == null && IsActive))
- InvokeMethodInfo(UpdateControlInput, gameTime);
- //InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
- //this.UpdateControlInput(gameTime);
- }
- if (showingEndOfNightStuff && endOfNightMenus.Count() == 0 && activeClickableMenu == null)
- {
- showingEndOfNightStuff = false;
- globalFadeToClear(playMorningSong, 0.02f);
- }
- if (!showingEndOfNightStuff)
- {
- if (IsMultiplayer || activeClickableMenu == null && currentMinigame == null)
- UpdateGameClock(gameTime);
- //this.UpdateCharacters(gameTime);
- //this.UpdateLocations(gameTime);
- //InvokeBasePrivateInstancedMethod("UpdateCharacters", gameTime);
- //InvokeBasePrivateInstancedMethod("UpdateLocations", gameTime);
- //UpdateViewPort(false, (Point)InvokeBasePrivateInstancedMethod("getViewportCenter"));
-
- InvokeMethodInfo(UpdateCharacters, gameTime);
- InvokeMethodInfo(UpdateLocations, gameTime);
- UpdateViewPort(false, (Point)InvokeMethodInfo(getViewportCenter));
- }
- UpdateOther(gameTime);
- if (messagePause)
- {
- KeyboardState state1 = Keyboard.GetState();
- MouseState state2 = Mouse.GetState();
- GamePadState state3 = GamePad.GetState(PlayerIndex.One);
- if (isOneOfTheseKeysDown(state1, options.actionButton) && !isOneOfTheseKeysDown(oldKBState, options.actionButton))
- pressActionButton(state1, state2, state3);
- oldKBState = state1;
- oldPadState = state3;
- }
+ if (gameMode == 10)
+ UpdateOther(gameTime);
}
+ if (audioEngine != null)
+ audioEngine.Update();
+ if (multiplayerMode == 2 && gameMode == 3)
+ server.sendMessages(gameTime);
}
- else
- {
- //InvokeBasePrivateInstancedMethod("UpdateTitleScreen", gameTime);
- InvokeMethodInfo(UpdateTitleScreen, gameTime);
- //this.UpdateTitleScreen(gameTime);
- if (activeClickableMenu != null)
- updateActiveMenu(gameTime);
- if (gameMode == 10)
- UpdateOther(gameTime);
- }
- if (audioEngine != null)
- audioEngine.Update();
- if (multiplayerMode == 2 && gameMode == 3)
- server.sendMessages(gameTime);
+ }
+ catch (Exception ex)
+ {
+ Log.Error("An error occurred in the overridden update loop: " + ex);
}
//typeof (Game).GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(this, new object[] {gameTime});
@@ -844,467 +853,488 @@ namespace StardewModdingAPI.Inheritance {
#region Overridden Draw
- if (!ZoomLevelIsOne)
- {
- GraphicsDevice.SetRenderTarget(Screen);
- }
-
- GraphicsDevice.Clear(BgColour);
- if (options.showMenuBackground && activeClickableMenu != null && activeClickableMenu.showWithoutTransparencyIfOptionIsSet())
+ try
{
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- activeClickableMenu.drawBackground(spriteBatch);
- activeClickableMenu.draw(spriteBatch);
- spriteBatch.End();
if (!ZoomLevelIsOne)
{
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
- spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
- spriteBatch.End();
+ GraphicsDevice.SetRenderTarget(Screen);
}
- return;
- }
- if (gameMode == 11)
- {
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- spriteBatch.DrawString(smoothFont, "Stardew Valley has crashed...", new Vector2(16f, 16f), Color.HotPink);
- spriteBatch.DrawString(smoothFont, "Please send the error report or a screenshot of this message to @ConcernedApe. (http://stardewvalley.net/contact/)", new Vector2(16f, 32f), new Color(0, 255, 0));
- spriteBatch.DrawString(smoothFont, parseText(errorMessage, smoothFont, graphics.GraphicsDevice.Viewport.Width), new Vector2(16f, 48f), Color.White);
- spriteBatch.End();
- return;
- }
- if (currentMinigame != null)
- {
- currentMinigame.draw(spriteBatch);
- if (globalFade && !menuUp && (!nameSelectUp || messagePause))
+
+ GraphicsDevice.Clear(BgColour);
+ if (options.showMenuBackground && activeClickableMenu != null && activeClickableMenu.showWithoutTransparencyIfOptionIsSet())
{
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * ((gameMode == 0) ? (1f - fadeToBlackAlpha) : fadeToBlackAlpha));
- spriteBatch.End();
- }
- if (!ZoomLevelIsOne)
- {
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
- spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ activeClickableMenu.drawBackground(spriteBatch);
+ activeClickableMenu.draw(spriteBatch);
spriteBatch.End();
+ if (!ZoomLevelIsOne)
+ {
+ GraphicsDevice.SetRenderTarget(null);
+ GraphicsDevice.Clear(BgColour);
+ spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
+ spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ spriteBatch.End();
+ }
+ return;
}
- return;
- }
- if (showingEndOfNightStuff)
- {
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- activeClickableMenu?.draw(spriteBatch);
- spriteBatch.End();
- if (!ZoomLevelIsOne)
+ if (gameMode == 11)
{
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
- spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ spriteBatch.DrawString(smoothFont, "Stardew Valley has crashed...", new Vector2(16f, 16f), Color.HotPink);
+ spriteBatch.DrawString(smoothFont, "Please send the error report or a screenshot of this message to @ConcernedApe. (http://stardewvalley.net/contact/)", new Vector2(16f, 32f), new Color(0, 255, 0));
+ spriteBatch.DrawString(smoothFont, parseText(errorMessage, smoothFont, graphics.GraphicsDevice.Viewport.Width), new Vector2(16f, 48f), Color.White);
spriteBatch.End();
+ return;
}
- return;
- }
- if (gameMode == 6)
- {
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- string text = "";
- int num = 0;
- while (num < gameTime.TotalGameTime.TotalMilliseconds % 999.0 / 333.0)
+ if (currentMinigame != null)
{
- text += ".";
- num++;
+ currentMinigame.draw(spriteBatch);
+ if (globalFade && !menuUp && (!nameSelectUp || messagePause))
+ {
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * ((gameMode == 0) ? (1f - fadeToBlackAlpha) : fadeToBlackAlpha));
+ spriteBatch.End();
+ }
+ if (!ZoomLevelIsOne)
+ {
+ GraphicsDevice.SetRenderTarget(null);
+ GraphicsDevice.Clear(BgColour);
+ spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
+ spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ spriteBatch.End();
+ }
+ return;
}
- SpriteText.drawString(spriteBatch, "Loading" + text, 64, graphics.GraphicsDevice.Viewport.Height - 64, 999, -1, 999, 1f, 1f, false, 0, "Loading...");
- spriteBatch.End();
- if (!ZoomLevelIsOne)
+ if (showingEndOfNightStuff)
{
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
- spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ activeClickableMenu?.draw(spriteBatch);
spriteBatch.End();
+ if (!ZoomLevelIsOne)
+ {
+ GraphicsDevice.SetRenderTarget(null);
+ GraphicsDevice.Clear(BgColour);
+ spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
+ spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ spriteBatch.End();
+ }
+ return;
}
- return;
- }
- if (gameMode == 0)
- {
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- }
- else
- {
- if (drawLighting)
+ if (gameMode == 6)
{
- GraphicsDevice.SetRenderTarget(lightmap);
- GraphicsDevice.Clear(Color.White * 0f);
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null);
- spriteBatch.Draw(staminaRect, lightmap.Bounds, currentLocation.name.Equals("UndergroundMine") ? mine.getLightingColor(gameTime) : ((!ambientLight.Equals(Color.White) && (!isRaining || !currentLocation.isOutdoors)) ? ambientLight : outdoorLight));
- for (int i = 0; i < currentLightSources.Count; i++)
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ string text = "";
+ int num = 0;
+ while (num < gameTime.TotalGameTime.TotalMilliseconds % 999.0 / 333.0)
{
- if (Utility.isOnScreen(currentLightSources.ElementAt(i).position, (int) (currentLightSources.ElementAt(i).radius * tileSize * 4f)))
- {
- spriteBatch.Draw(currentLightSources.ElementAt(i).lightTexture, GlobalToLocal(viewport, currentLightSources.ElementAt(i).position) / options.lightingQuality, currentLightSources.ElementAt(i).lightTexture.Bounds, currentLightSources.ElementAt(i).color, 0f, new Vector2(currentLightSources.ElementAt(i).lightTexture.Bounds.Center.X, currentLightSources.ElementAt(i).lightTexture.Bounds.Center.Y), currentLightSources.ElementAt(i).radius / options.lightingQuality, SpriteEffects.None, 0.9f);
- }
+ text += ".";
+ num++;
}
+ SpriteText.drawString(spriteBatch, "Loading" + text, 64, graphics.GraphicsDevice.Viewport.Height - 64, 999, -1, 999, 1f, 1f, false, 0, "Loading...");
spriteBatch.End();
- GraphicsDevice.SetRenderTarget(!ZoomLevelIsOne ? null : Screen);
+ if (!ZoomLevelIsOne)
+ {
+ GraphicsDevice.SetRenderTarget(null);
+ GraphicsDevice.Clear(BgColour);
+ spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
+ spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ spriteBatch.End();
+ }
+ return;
}
- if (bloomDay)
+ if (gameMode == 0)
{
- bloom?.BeginDraw();
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
}
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- GraphicsEvents.InvokeOnPreRenderEvent(null, EventArgs.Empty);
- background?.draw(spriteBatch);
- mapDisplayDevice.BeginScene(spriteBatch);
- currentLocation.Map.GetLayer("Back").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
- currentLocation.drawWater(spriteBatch);
- if (CurrentEvent == null)
+ else
{
- using (List<NPC>.Enumerator enumerator = currentLocation.characters.GetEnumerator())
+ if (drawLighting)
{
- while (enumerator.MoveNext())
+ GraphicsDevice.SetRenderTarget(lightmap);
+ GraphicsDevice.Clear(Color.White * 0f);
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, null, null);
+ spriteBatch.Draw(staminaRect, lightmap.Bounds, currentLocation.name.Equals("UndergroundMine") ? mine.getLightingColor(gameTime) : ((!ambientLight.Equals(Color.White) && (!isRaining || !currentLocation.isOutdoors)) ? ambientLight : outdoorLight));
+ for (int i = 0; i < currentLightSources.Count; i++)
{
- NPC current = enumerator.Current;
- if (current != null && !current.swimming && !current.hideShadow && !current.IsMonster && !currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current.getTileLocation()))
+ if (Utility.isOnScreen(currentLightSources.ElementAt(i).position, (int) (currentLightSources.ElementAt(i).radius * tileSize * 4f)))
{
- spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current.position + new Vector2(current.sprite.spriteWidth * pixelZoom / 2f, current.GetBoundingBox().Height + (current.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current.yJumpOffset / 40f) * current.scale, SpriteEffects.None, Math.Max(0f, current.getStandingY() / 10000f) - 1E-06f);
+ spriteBatch.Draw(currentLightSources.ElementAt(i).lightTexture, GlobalToLocal(viewport, currentLightSources.ElementAt(i).position) / options.lightingQuality, currentLightSources.ElementAt(i).lightTexture.Bounds, currentLightSources.ElementAt(i).color, 0f, new Vector2(currentLightSources.ElementAt(i).lightTexture.Bounds.Center.X, currentLightSources.ElementAt(i).lightTexture.Bounds.Center.Y), currentLightSources.ElementAt(i).radius / options.lightingQuality, SpriteEffects.None, 0.9f);
}
}
- goto IL_B30;
+ spriteBatch.End();
+ GraphicsDevice.SetRenderTarget(!ZoomLevelIsOne ? null : Screen);
}
- }
- foreach (NPC current2 in CurrentEvent.actors)
- {
- if (!current2.swimming && !current2.hideShadow && !currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current2.getTileLocation()))
+ if (bloomDay)
{
- spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current2.position + new Vector2(current2.sprite.spriteWidth * pixelZoom / 2f, current2.GetBoundingBox().Height + (current2.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current2.yJumpOffset / 40f) * current2.scale, SpriteEffects.None, Math.Max(0f, current2.getStandingY() / 10000f) - 1E-06f);
+ bloom?.BeginDraw();
}
- }
- IL_B30:
- if (!player.swimming && !player.isRidingHorse() && !currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(player.getTileLocation()))
- {
- spriteBatch.Draw(shadowTexture, GlobalToLocal(player.position + new Vector2(32f, 24f)), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), 4f - (((player.running || player.usingTool) && player.FarmerSprite.indexInCurrentAnimation > 1) ? (Math.Abs(FarmerRenderer.featureYOffsetPerFrame[player.FarmerSprite.CurrentFrame]) * 0.5f) : 0f), SpriteEffects.None, 0f);
- }
- currentLocation.Map.GetLayer("Buildings").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
- mapDisplayDevice.EndScene();
- spriteBatch.End();
- spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- if (CurrentEvent == null)
- {
- using (List<NPC>.Enumerator enumerator3 = currentLocation.characters.GetEnumerator())
+ GraphicsDevice.Clear(BgColour);
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ GraphicsEvents.InvokeOnPreRenderEvent(null, EventArgs.Empty);
+ background?.draw(spriteBatch);
+ mapDisplayDevice.BeginScene(spriteBatch);
+ currentLocation.Map.GetLayer("Back").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
+ currentLocation.drawWater(spriteBatch);
+ if (CurrentEvent == null)
{
- while (enumerator3.MoveNext())
+ using (List<NPC>.Enumerator enumerator = currentLocation.characters.GetEnumerator())
{
- NPC current3 = enumerator3.Current;
- if (current3 != null && !current3.swimming && !current3.hideShadow && currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current3.getTileLocation()))
+ while (enumerator.MoveNext())
{
- spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current3.position + new Vector2(current3.sprite.spriteWidth * pixelZoom / 2f, current3.GetBoundingBox().Height + (current3.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current3.yJumpOffset / 40f) * current3.scale, SpriteEffects.None, Math.Max(0f, current3.getStandingY() / 10000f) - 1E-06f);
+ NPC current = enumerator.Current;
+ if (current != null && !current.swimming && !current.hideShadow && !current.IsMonster && !currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current.getTileLocation()))
+ {
+ spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current.position + new Vector2(current.sprite.spriteWidth * pixelZoom / 2f, current.GetBoundingBox().Height + (current.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current.yJumpOffset / 40f) * current.scale, SpriteEffects.None, Math.Max(0f, current.getStandingY() / 10000f) - 1E-06f);
+ }
}
+ goto IL_B30;
}
- goto IL_F5F;
}
- }
- foreach (NPC current4 in CurrentEvent.actors)
- {
- if (!current4.swimming && !current4.hideShadow && currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current4.getTileLocation()))
+ foreach (NPC current2 in CurrentEvent.actors)
{
- spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current4.position + new Vector2(current4.sprite.spriteWidth * pixelZoom / 2f, current4.GetBoundingBox().Height + (current4.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current4.yJumpOffset / 40f) * current4.scale, SpriteEffects.None, Math.Max(0f, current4.getStandingY() / 10000f) - 1E-06f);
+ if (!current2.swimming && !current2.hideShadow && !currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current2.getTileLocation()))
+ {
+ spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current2.position + new Vector2(current2.sprite.spriteWidth * pixelZoom / 2f, current2.GetBoundingBox().Height + (current2.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current2.yJumpOffset / 40f) * current2.scale, SpriteEffects.None, Math.Max(0f, current2.getStandingY() / 10000f) - 1E-06f);
+ }
}
- }
- IL_F5F:
- if (!player.swimming && !player.isRidingHorse() && currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(player.getTileLocation()))
- {
- spriteBatch.Draw(shadowTexture, GlobalToLocal(player.position + new Vector2(32f, 24f)), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), 4f - (((player.running || player.usingTool) && player.FarmerSprite.indexInCurrentAnimation > 1) ? (Math.Abs(FarmerRenderer.featureYOffsetPerFrame[player.FarmerSprite.CurrentFrame]) * 0.5f) : 0f), SpriteEffects.None, Math.Max(0.0001f, player.getStandingY() / 10000f + 0.00011f) - 0.0001f);
- }
- if (displayFarmer)
- {
- player.draw(spriteBatch);
- }
- if ((eventUp || killScreen) && !killScreen)
- {
- currentLocation.currentEvent?.draw(spriteBatch);
- }
- if (player.currentUpgrade != null && player.currentUpgrade.daysLeftTillUpgradeDone <= 3 && currentLocation.Name.Equals("Farm"))
- {
- spriteBatch.Draw(player.currentUpgrade.workerTexture, GlobalToLocal(viewport, player.currentUpgrade.positionOfCarpenter), player.currentUpgrade.getSourceRectangle(), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, (player.currentUpgrade.positionOfCarpenter.Y + tileSize * 3 / 4) / 10000f);
- }
- currentLocation.draw(spriteBatch);
- if (eventUp && currentLocation.currentEvent?.messageToScreen != null)
- {
- drawWithBorder(currentLocation.currentEvent.messageToScreen, Color.Black, Color.White, new Vector2(graphics.GraphicsDevice.Viewport.TitleSafeArea.Width / 2 - borderFont.MeasureString(currentLocation.currentEvent.messageToScreen).X / 2f, graphics.GraphicsDevice.Viewport.TitleSafeArea.Height - tileSize), 0f, 1f, 0.999f);
- }
- if (player.ActiveObject == null && (player.UsingTool || pickingTool) && player.CurrentTool != null && (!player.CurrentTool.Name.Equals("Seeds") || pickingTool))
- {
- drawTool(player);
- }
- if (currentLocation.Name.Equals("Farm"))
- {
- //typeof (Game1).GetMethod("drawFarmBuildings", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
- DrawFarmBuildings.Invoke(Program.gamePtr, null);
- //this.drawFarmBuildings();
- }
- if (tvStation >= 0)
- {
- spriteBatch.Draw(tvStationTexture, GlobalToLocal(viewport, new Vector2(6 * tileSize + tileSize / 4, 2 * tileSize + tileSize / 2)), new Rectangle(tvStation * 24, 0, 24, 15), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 1E-08f);
- }
- if (panMode)
- {
- spriteBatch.Draw(fadeToBlackRect, new Rectangle((int) Math.Floor((getOldMouseX() + viewport.X) / (double) tileSize) * tileSize - viewport.X, (int) Math.Floor((getOldMouseY() + viewport.Y) / (double) tileSize) * tileSize - viewport.Y, tileSize, tileSize), Color.Lime * 0.75f);
- foreach (Warp current5 in currentLocation.warps)
+ IL_B30:
+ if (!player.swimming && !player.isRidingHorse() && !currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(player.getTileLocation()))
{
- spriteBatch.Draw(fadeToBlackRect, new Rectangle(current5.X * tileSize - viewport.X, current5.Y * tileSize - viewport.Y, tileSize, tileSize), Color.Red * 0.75f);
+ spriteBatch.Draw(shadowTexture, GlobalToLocal(player.position + new Vector2(32f, 24f)), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), 4f - (((player.running || player.usingTool) && player.FarmerSprite.indexInCurrentAnimation > 1) ? (Math.Abs(FarmerRenderer.featureYOffsetPerFrame[player.FarmerSprite.CurrentFrame]) * 0.5f) : 0f), SpriteEffects.None, 0f);
+ }
+ currentLocation.Map.GetLayer("Buildings").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
+ mapDisplayDevice.EndScene();
+ spriteBatch.End();
+ spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ if (CurrentEvent == null)
+ {
+ using (List<NPC>.Enumerator enumerator3 = currentLocation.characters.GetEnumerator())
+ {
+ while (enumerator3.MoveNext())
+ {
+ NPC current3 = enumerator3.Current;
+ if (current3 != null && !current3.swimming && !current3.hideShadow && currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current3.getTileLocation()))
+ {
+ spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current3.position + new Vector2(current3.sprite.spriteWidth * pixelZoom / 2f, current3.GetBoundingBox().Height + (current3.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current3.yJumpOffset / 40f) * current3.scale, SpriteEffects.None, Math.Max(0f, current3.getStandingY() / 10000f) - 1E-06f);
+ }
+ }
+ goto IL_F5F;
+ }
+ }
+ foreach (NPC current4 in CurrentEvent.actors)
+ {
+ if (!current4.swimming && !current4.hideShadow && currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(current4.getTileLocation()))
+ {
+ spriteBatch.Draw(shadowTexture, GlobalToLocal(viewport, current4.position + new Vector2(current4.sprite.spriteWidth * pixelZoom / 2f, current4.GetBoundingBox().Height + (current4.IsMonster ? 0 : (pixelZoom * 3)))), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), (pixelZoom + current4.yJumpOffset / 40f) * current4.scale, SpriteEffects.None, Math.Max(0f, current4.getStandingY() / 10000f) - 1E-06f);
+ }
+ }
+ IL_F5F:
+ if (!player.swimming && !player.isRidingHorse() && currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(player.getTileLocation()))
+ {
+ spriteBatch.Draw(shadowTexture, GlobalToLocal(player.position + new Vector2(32f, 24f)), shadowTexture.Bounds, Color.White, 0f, new Vector2(shadowTexture.Bounds.Center.X, shadowTexture.Bounds.Center.Y), 4f - (((player.running || player.usingTool) && player.FarmerSprite.indexInCurrentAnimation > 1) ? (Math.Abs(FarmerRenderer.featureYOffsetPerFrame[player.FarmerSprite.CurrentFrame]) * 0.5f) : 0f), SpriteEffects.None, Math.Max(0.0001f, player.getStandingY() / 10000f + 0.00011f) - 0.0001f);
+ }
+ if (displayFarmer)
+ {
+ player.draw(spriteBatch);
+ }
+ if ((eventUp || killScreen) && !killScreen)
+ {
+ currentLocation.currentEvent?.draw(spriteBatch);
+ }
+ if (player.currentUpgrade != null && player.currentUpgrade.daysLeftTillUpgradeDone <= 3 && currentLocation.Name.Equals("Farm"))
+ {
+ spriteBatch.Draw(player.currentUpgrade.workerTexture, GlobalToLocal(viewport, player.currentUpgrade.positionOfCarpenter), player.currentUpgrade.getSourceRectangle(), Color.White, 0f, Vector2.Zero, 1f, SpriteEffects.None, (player.currentUpgrade.positionOfCarpenter.Y + tileSize * 3 / 4) / 10000f);
+ }
+ currentLocation.draw(spriteBatch);
+ if (eventUp && currentLocation.currentEvent?.messageToScreen != null)
+ {
+ drawWithBorder(currentLocation.currentEvent.messageToScreen, Color.Black, Color.White, new Vector2(graphics.GraphicsDevice.Viewport.TitleSafeArea.Width / 2 - borderFont.MeasureString(currentLocation.currentEvent.messageToScreen).X / 2f, graphics.GraphicsDevice.Viewport.TitleSafeArea.Height - tileSize), 0f, 1f, 0.999f);
+ }
+ if (player.ActiveObject == null && (player.UsingTool || pickingTool) && player.CurrentTool != null && (!player.CurrentTool.Name.Equals("Seeds") || pickingTool))
+ {
+ drawTool(player);
+ }
+ if (currentLocation.Name.Equals("Farm"))
+ {
+ //typeof (Game1).GetMethod("drawFarmBuildings", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
+ DrawFarmBuildings.Invoke(Program.gamePtr, null);
+ //this.drawFarmBuildings();
+ }
+ if (tvStation >= 0)
+ {
+ spriteBatch.Draw(tvStationTexture, GlobalToLocal(viewport, new Vector2(6 * tileSize + tileSize / 4, 2 * tileSize + tileSize / 2)), new Rectangle(tvStation * 24, 0, 24, 15), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 1E-08f);
+ }
+ if (panMode)
+ {
+ spriteBatch.Draw(fadeToBlackRect, new Rectangle((int) Math.Floor((getOldMouseX() + viewport.X) / (double) tileSize) * tileSize - viewport.X, (int) Math.Floor((getOldMouseY() + viewport.Y) / (double) tileSize) * tileSize - viewport.Y, tileSize, tileSize), Color.Lime * 0.75f);
+ foreach (Warp current5 in currentLocation.warps)
+ {
+ spriteBatch.Draw(fadeToBlackRect, new Rectangle(current5.X * tileSize - viewport.X, current5.Y * tileSize - viewport.Y, tileSize, tileSize), Color.Red * 0.75f);
+ }
}
- }
- mapDisplayDevice.BeginScene(spriteBatch);
- currentLocation.Map.GetLayer("Front").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
- mapDisplayDevice.EndScene();
- currentLocation.drawAboveFrontLayer(spriteBatch);
- spriteBatch.End();
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- if (currentLocation.Name.Equals("Farm") && stats.SeedsSown >= 200u)
- {
- spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(3 * tileSize + tileSize / 4, tileSize + tileSize / 3)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
- spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(4 * tileSize + tileSize, 2 * tileSize + tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
- spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(5 * tileSize, 2 * tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
- spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(3 * tileSize + tileSize / 2, 3 * tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
- spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(5 * tileSize - tileSize / 4, tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
- spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(4 * tileSize, 3 * tileSize + tileSize / 6)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
- spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(4 * tileSize + tileSize / 5, 2 * tileSize + tileSize / 3)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
- }
- if (displayFarmer && player.ActiveObject != null && player.ActiveObject.bigCraftable && checkBigCraftableBoundariesForFrontLayer() && currentLocation.Map.GetLayer("Front").PickTile(new Location(player.getStandingX(), player.getStandingY()), viewport.Size) == null)
- {
- drawPlayerHeldObject(player);
- }
- else if (displayFarmer && player.ActiveObject != null && ((currentLocation.Map.GetLayer("Front").PickTile(new Location((int) player.position.X, (int) player.position.Y - tileSize * 3 / 5), viewport.Size) != null && !currentLocation.Map.GetLayer("Front").PickTile(new Location((int) player.position.X, (int) player.position.Y - tileSize * 3 / 5), viewport.Size).TileIndexProperties.ContainsKey("FrontAlways")) || (currentLocation.Map.GetLayer("Front").PickTile(new Location(player.GetBoundingBox().Right, (int) player.position.Y - tileSize * 3 / 5), viewport.Size) != null && !currentLocation.Map.GetLayer("Front").PickTile(new Location(player.GetBoundingBox().Right, (int) player.position.Y - tileSize * 3 / 5), viewport.Size).TileIndexProperties.ContainsKey("FrontAlways"))))
- {
- drawPlayerHeldObject(player);
- }
- if ((player.UsingTool || pickingTool) && player.CurrentTool != null && (!player.CurrentTool.Name.Equals("Seeds") || pickingTool) && currentLocation.Map.GetLayer("Front").PickTile(new Location(player.getStandingX(), (int) player.position.Y - tileSize * 3 / 5), viewport.Size) != null && currentLocation.Map.GetLayer("Front").PickTile(new Location(player.getStandingX(), player.getStandingY()), viewport.Size) == null)
- {
- drawTool(player);
- }
- if (currentLocation.Map.GetLayer("AlwaysFront") != null)
- {
mapDisplayDevice.BeginScene(spriteBatch);
- currentLocation.Map.GetLayer("AlwaysFront").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
+ currentLocation.Map.GetLayer("Front").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
mapDisplayDevice.EndScene();
- }
- if (toolHold > 400f && player.CurrentTool.UpgradeLevel >= 1 && player.canReleaseTool)
- {
- Color color = Color.White;
- switch ((int) (toolHold / 600f) + 2)
+ currentLocation.drawAboveFrontLayer(spriteBatch);
+ spriteBatch.End();
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ if (currentLocation.Name.Equals("Farm") && stats.SeedsSown >= 200u)
{
- case 1:
- color = Tool.copperColor;
- break;
- case 2:
- color = Tool.steelColor;
- break;
- case 3:
- color = Tool.goldColor;
- break;
- case 4:
- color = Tool.iridiumColor;
- break;
+ spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(3 * tileSize + tileSize / 4, tileSize + tileSize / 3)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
+ spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(4 * tileSize + tileSize, 2 * tileSize + tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
+ spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(5 * tileSize, 2 * tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
+ spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(3 * tileSize + tileSize / 2, 3 * tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
+ spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(5 * tileSize - tileSize / 4, tileSize)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
+ spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(4 * tileSize, 3 * tileSize + tileSize / 6)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
+ spriteBatch.Draw(debrisSpriteSheet, GlobalToLocal(viewport, new Vector2(4 * tileSize + tileSize / 5, 2 * tileSize + tileSize / 3)), getSourceRectForStandardTileSheet(debrisSpriteSheet, 16), Color.White);
}
- spriteBatch.Draw(littleEffect, new Rectangle((int) player.getLocalPosition(viewport).X - 2, (int) player.getLocalPosition(viewport).Y - (player.CurrentTool.Name.Equals("Watering Can") ? 0 : tileSize) - 2, (int) (toolHold % 600f * 0.08f) + 4, tileSize / 8 + 4), Color.Black);
- spriteBatch.Draw(littleEffect, new Rectangle((int) player.getLocalPosition(viewport).X, (int) player.getLocalPosition(viewport).Y - (player.CurrentTool.Name.Equals("Watering Can") ? 0 : tileSize), (int) (toolHold % 600f * 0.08f), tileSize / 8), color);
- }
- if (isDebrisWeather && currentLocation.IsOutdoors && !currentLocation.ignoreDebrisWeather && !currentLocation.Name.Equals("Desert") && viewport.X > -10)
- {
- foreach (WeatherDebris current6 in debrisWeather)
+ if (displayFarmer && player.ActiveObject != null && player.ActiveObject.bigCraftable && checkBigCraftableBoundariesForFrontLayer() && currentLocation.Map.GetLayer("Front").PickTile(new Location(player.getStandingX(), player.getStandingY()), viewport.Size) == null)
{
- current6.draw(spriteBatch);
+ drawPlayerHeldObject(player);
}
- }
- farmEvent?.draw(spriteBatch);
- if (currentLocation.LightLevel > 0f && timeOfDay < 2000)
- {
- spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * currentLocation.LightLevel);
- }
- if (screenGlow)
- {
- spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, screenGlowColor * screenGlowAlpha);
- }
- currentLocation.drawAboveAlwaysFrontLayer(spriteBatch);
- if (player.CurrentTool is FishingRod && ((player.CurrentTool as FishingRod).isTimingCast || (player.CurrentTool as FishingRod).castingChosenCountdown > 0f || (player.CurrentTool as FishingRod).fishCaught || (player.CurrentTool as FishingRod).showingTreasure))
- {
- player.CurrentTool.draw(spriteBatch);
- }
- if (isRaining && currentLocation.IsOutdoors && !currentLocation.Name.Equals("Desert") && !(currentLocation is Summit) && (!eventUp || currentLocation.isTileOnMap(new Vector2(viewport.X / tileSize, viewport.Y / tileSize))))
- {
- for (int j = 0; j < rainDrops.Length; j++)
+ else if (displayFarmer && player.ActiveObject != null && ((currentLocation.Map.GetLayer("Front").PickTile(new Location((int) player.position.X, (int) player.position.Y - tileSize * 3 / 5), viewport.Size) != null && !currentLocation.Map.GetLayer("Front").PickTile(new Location((int) player.position.X, (int) player.position.Y - tileSize * 3 / 5), viewport.Size).TileIndexProperties.ContainsKey("FrontAlways")) || (currentLocation.Map.GetLayer("Front").PickTile(new Location(player.GetBoundingBox().Right, (int) player.position.Y - tileSize * 3 / 5), viewport.Size) != null && !currentLocation.Map.GetLayer("Front").PickTile(new Location(player.GetBoundingBox().Right, (int) player.position.Y - tileSize * 3 / 5), viewport.Size).TileIndexProperties.ContainsKey("FrontAlways"))))
{
- spriteBatch.Draw(rainTexture, rainDrops[j].position, getSourceRectForStandardTileSheet(rainTexture, rainDrops[j].frame), Color.White);
+ drawPlayerHeldObject(player);
}
- }
- spriteBatch.End();
- //base.Draw(gameTime);
- spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- if (eventUp && currentLocation.currentEvent != null)
- {
- foreach (NPC current7 in currentLocation.currentEvent.actors)
+ if ((player.UsingTool || pickingTool) && player.CurrentTool != null && (!player.CurrentTool.Name.Equals("Seeds") || pickingTool) && currentLocation.Map.GetLayer("Front").PickTile(new Location(player.getStandingX(), (int) player.position.Y - tileSize * 3 / 5), viewport.Size) != null && currentLocation.Map.GetLayer("Front").PickTile(new Location(player.getStandingX(), player.getStandingY()), viewport.Size) == null)
+ {
+ drawTool(player);
+ }
+ if (currentLocation.Map.GetLayer("AlwaysFront") != null)
+ {
+ mapDisplayDevice.BeginScene(spriteBatch);
+ currentLocation.Map.GetLayer("AlwaysFront").Draw(mapDisplayDevice, viewport, Location.Origin, false, pixelZoom);
+ mapDisplayDevice.EndScene();
+ }
+ if (toolHold > 400f && player.CurrentTool.UpgradeLevel >= 1 && player.canReleaseTool)
{
- if (current7.isEmoting)
+ Color color = Color.White;
+ switch ((int) (toolHold / 600f) + 2)
{
- Vector2 localPosition = current7.getLocalPosition(viewport);
- localPosition.Y -= tileSize * 2 + pixelZoom * 3;
- if (current7.age == 2)
- {
- localPosition.Y += tileSize / 2;
- }
- else if (current7.gender == 1)
+ case 1:
+ color = Tool.copperColor;
+ break;
+ case 2:
+ color = Tool.steelColor;
+ break;
+ case 3:
+ color = Tool.goldColor;
+ break;
+ case 4:
+ color = Tool.iridiumColor;
+ break;
+ }
+ spriteBatch.Draw(littleEffect, new Rectangle((int) player.getLocalPosition(viewport).X - 2, (int) player.getLocalPosition(viewport).Y - (player.CurrentTool.Name.Equals("Watering Can") ? 0 : tileSize) - 2, (int) (toolHold % 600f * 0.08f) + 4, tileSize / 8 + 4), Color.Black);
+ spriteBatch.Draw(littleEffect, new Rectangle((int) player.getLocalPosition(viewport).X, (int) player.getLocalPosition(viewport).Y - (player.CurrentTool.Name.Equals("Watering Can") ? 0 : tileSize), (int) (toolHold % 600f * 0.08f), tileSize / 8), color);
+ }
+ if (isDebrisWeather && currentLocation.IsOutdoors && !currentLocation.ignoreDebrisWeather && !currentLocation.Name.Equals("Desert") && viewport.X > -10)
+ {
+ foreach (WeatherDebris current6 in debrisWeather)
+ {
+ current6.draw(spriteBatch);
+ }
+ }
+ farmEvent?.draw(spriteBatch);
+ if (currentLocation.LightLevel > 0f && timeOfDay < 2000)
+ {
+ spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * currentLocation.LightLevel);
+ }
+ if (screenGlow)
+ {
+ spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, screenGlowColor * screenGlowAlpha);
+ }
+ currentLocation.drawAboveAlwaysFrontLayer(spriteBatch);
+ if (player.CurrentTool is FishingRod && ((player.CurrentTool as FishingRod).isTimingCast || (player.CurrentTool as FishingRod).castingChosenCountdown > 0f || (player.CurrentTool as FishingRod).fishCaught || (player.CurrentTool as FishingRod).showingTreasure))
+ {
+ player.CurrentTool.draw(spriteBatch);
+ }
+ if (isRaining && currentLocation.IsOutdoors && !currentLocation.Name.Equals("Desert") && !(currentLocation is Summit) && (!eventUp || currentLocation.isTileOnMap(new Vector2(viewport.X / tileSize, viewport.Y / tileSize))))
+ {
+ for (int j = 0; j < rainDrops.Length; j++)
+ {
+ spriteBatch.Draw(rainTexture, rainDrops[j].position, getSourceRectForStandardTileSheet(rainTexture, rainDrops[j].frame), Color.White);
+ }
+ }
+
+ spriteBatch.End();
+
+ base.Draw(gameTime);
+
+ /*try
+ {
+ BaseBaseDraw bbd = (BaseBaseDraw) Delegate.CreateDelegate(typeof (BaseBaseDraw), Program.gamePtr, "Draw");
+ bbd.GetType().BaseType.BaseType.GetField("_target", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(bbd, this);
+ bbd();
+ }
+ catch(Exception ex)
+ {
+ Log.Error(ex);
+ }*/
+
+ spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ if (eventUp && currentLocation.currentEvent != null)
+ {
+ foreach (NPC current7 in currentLocation.currentEvent.actors)
+ {
+ if (current7.isEmoting)
{
- localPosition.Y += tileSize / 6;
+ Vector2 localPosition = current7.getLocalPosition(viewport);
+ localPosition.Y -= tileSize * 2 + pixelZoom * 3;
+ if (current7.age == 2)
+ {
+ localPosition.Y += tileSize / 2;
+ }
+ else if (current7.gender == 1)
+ {
+ localPosition.Y += tileSize / 6;
+ }
+ spriteBatch.Draw(emoteSpriteSheet, localPosition, new Rectangle(current7.CurrentEmoteIndex * (tileSize / 4) % emoteSpriteSheet.Width, current7.CurrentEmoteIndex * (tileSize / 4) / emoteSpriteSheet.Width * (tileSize / 4), tileSize / 4, tileSize / 4), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, current7.getStandingY() / 10000f);
}
- spriteBatch.Draw(emoteSpriteSheet, localPosition, new Rectangle(current7.CurrentEmoteIndex * (tileSize / 4) % emoteSpriteSheet.Width, current7.CurrentEmoteIndex * (tileSize / 4) / emoteSpriteSheet.Width * (tileSize / 4), tileSize / 4, tileSize / 4), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, current7.getStandingY() / 10000f);
}
}
- }
- spriteBatch.End();
- if (drawLighting)
- {
- spriteBatch.Begin(SpriteSortMode.Deferred, new BlendState
+ spriteBatch.End();
+ if (drawLighting)
{
- ColorBlendFunction = BlendFunction.ReverseSubtract,
- ColorDestinationBlend = Blend.One,
- ColorSourceBlend = Blend.SourceColor
- }, SamplerState.LinearClamp, null, null);
- spriteBatch.Draw(lightmap, Vector2.Zero, lightmap.Bounds, Color.White, 0f, Vector2.Zero, options.lightingQuality, SpriteEffects.None, 1f);
- if (isRaining && currentLocation.isOutdoors && !(currentLocation is Desert))
+ spriteBatch.Begin(SpriteSortMode.Deferred, new BlendState
+ {
+ ColorBlendFunction = BlendFunction.ReverseSubtract,
+ ColorDestinationBlend = Blend.One,
+ ColorSourceBlend = Blend.SourceColor
+ }, SamplerState.LinearClamp, null, null);
+ spriteBatch.Draw(lightmap, Vector2.Zero, lightmap.Bounds, Color.White, 0f, Vector2.Zero, options.lightingQuality, SpriteEffects.None, 1f);
+ if (isRaining && currentLocation.isOutdoors && !(currentLocation is Desert))
+ {
+ spriteBatch.Draw(staminaRect, graphics.GraphicsDevice.Viewport.Bounds, Color.OrangeRed * 0.45f);
+ }
+ spriteBatch.End();
+ }
+ spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
+ if (drawGrid)
{
- spriteBatch.Draw(staminaRect, graphics.GraphicsDevice.Viewport.Bounds, Color.OrangeRed * 0.45f);
+ int num2 = -viewport.X % tileSize;
+ float num3 = -(float) viewport.Y % tileSize;
+ for (int k = num2; k < graphics.GraphicsDevice.Viewport.Width; k += tileSize)
+ {
+ spriteBatch.Draw(staminaRect, new Rectangle(k, (int) num3, 1, graphics.GraphicsDevice.Viewport.Height), Color.Red * 0.5f);
+ }
+ for (float num4 = num3; num4 < (float) graphics.GraphicsDevice.Viewport.Height; num4 += (float) tileSize)
+ {
+ spriteBatch.Draw(staminaRect, new Rectangle(num2, (int) num4, graphics.GraphicsDevice.Viewport.Width, 1), Color.Red * 0.5f);
+ }
}
- spriteBatch.End();
- }
- spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
- if (drawGrid)
- {
- int num2 = -viewport.X % tileSize;
- float num3 = -(float) viewport.Y % tileSize;
- for (int k = num2; k < graphics.GraphicsDevice.Viewport.Width; k += tileSize)
+ if (currentBillboard != 0)
{
- spriteBatch.Draw(staminaRect, new Rectangle(k, (int) num3, 1, graphics.GraphicsDevice.Viewport.Height), Color.Red * 0.5f);
+ drawBillboard();
}
- for (float num4 = num3; num4 < (float) graphics.GraphicsDevice.Viewport.Height; num4 += (float) tileSize)
+ if ((displayHUD || eventUp) && currentBillboard == 0 && gameMode == 3 && !freezeControls && !panMode)
{
- spriteBatch.Draw(staminaRect, new Rectangle(num2, (int) num4, graphics.GraphicsDevice.Viewport.Width, 1), Color.Red * 0.5f);
+ GraphicsEvents.InvokeOnPreRenderHudEvent(null, EventArgs.Empty);
+ //typeof (Game1).GetMethod("drawHUD", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
+ DrawHUD.Invoke(Program.gamePtr, null);
+ GraphicsEvents.InvokeOnPostRenderHudEvent(null, EventArgs.Empty);
+ //this.drawHUD();
+ }
+ else if (activeClickableMenu == null && farmEvent == null)
+ {
+ spriteBatch.Draw(mouseCursors, new Vector2(getOldMouseX(), getOldMouseY()), getSourceRectForStandardTileSheet(mouseCursors, 0, 16, 16), Color.White, 0f, Vector2.Zero, 4f + dialogueButtonScale / 150f, SpriteEffects.None, 1f);
+ }
+ if (hudMessages.Any() && (!eventUp || isFestival()))
+ {
+ for (int l = hudMessages.Count - 1; l >= 0; l--)
+ {
+ hudMessages[l].draw(spriteBatch, l);
+ }
}
}
- if (currentBillboard != 0)
+ farmEvent?.draw(spriteBatch);
+ if (dialogueUp && !nameSelectUp && !messagePause && !(activeClickableMenu is DialogueBox))
+ {
+ //typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
+ DrawDialogueBox.Invoke(Program.gamePtr, null);
+ //this.drawDialogueBox();
+ }
+ if (progressBar)
{
- drawBillboard();
+ spriteBatch.Draw(fadeToBlackRect, new Rectangle((graphics.GraphicsDevice.Viewport.TitleSafeArea.Width - dialogueWidth) / 2, graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - tileSize * 2, dialogueWidth, tileSize / 2), Color.LightGray);
+ spriteBatch.Draw(staminaRect, new Rectangle((graphics.GraphicsDevice.Viewport.TitleSafeArea.Width - dialogueWidth) / 2, graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - tileSize * 2, (int) (pauseAccumulator / pauseTime * dialogueWidth), tileSize / 2), Color.DimGray);
}
- if ((displayHUD || eventUp) && currentBillboard == 0 && gameMode == 3 && !freezeControls && !panMode)
+ if (eventUp)
{
- GraphicsEvents.InvokeOnPreRenderHudEvent(null, EventArgs.Empty);
- //typeof (Game1).GetMethod("drawHUD", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
- DrawHUD.Invoke(Program.gamePtr, null);
- GraphicsEvents.InvokeOnPostRenderHudEvent(null, EventArgs.Empty);
- //this.drawHUD();
+ currentLocation.currentEvent?.drawAfterMap(spriteBatch);
}
- else if (activeClickableMenu == null && farmEvent == null)
+ if (isRaining && currentLocation.isOutdoors && !(currentLocation is Desert))
{
- spriteBatch.Draw(mouseCursors, new Vector2(getOldMouseX(), getOldMouseY()), getSourceRectForStandardTileSheet(mouseCursors, 0, 16, 16), Color.White, 0f, Vector2.Zero, 4f + dialogueButtonScale / 150f, SpriteEffects.None, 1f);
+ spriteBatch.Draw(staminaRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Blue * 0.2f);
+ }
+ if ((fadeToBlack || globalFade) && !menuUp && (!nameSelectUp || messagePause))
+ {
+ spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * ((gameMode == 0) ? (1f - fadeToBlackAlpha) : fadeToBlackAlpha));
}
- if (hudMessages.Any() && (!eventUp || isFestival()))
+ else if (flashAlpha > 0f)
{
- for (int l = hudMessages.Count - 1; l >= 0; l--)
+ if (options.screenFlash)
{
- hudMessages[l].draw(spriteBatch, l);
+ spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.White * Math.Min(1f, flashAlpha));
}
+ flashAlpha -= 0.1f;
}
- }
- farmEvent?.draw(spriteBatch);
- if (dialogueUp && !nameSelectUp && !messagePause && !(activeClickableMenu is DialogueBox))
- {
- //typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
- DrawDialogueBox.Invoke(Program.gamePtr, null);
- //this.drawDialogueBox();
- }
- if (progressBar)
- {
- spriteBatch.Draw(fadeToBlackRect, new Rectangle((graphics.GraphicsDevice.Viewport.TitleSafeArea.Width - dialogueWidth) / 2, graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - tileSize * 2, dialogueWidth, tileSize / 2), Color.LightGray);
- spriteBatch.Draw(staminaRect, new Rectangle((graphics.GraphicsDevice.Viewport.TitleSafeArea.Width - dialogueWidth) / 2, graphics.GraphicsDevice.Viewport.TitleSafeArea.Bottom - tileSize * 2, (int) (pauseAccumulator / pauseTime * dialogueWidth), tileSize / 2), Color.DimGray);
- }
- if (eventUp)
- {
- currentLocation.currentEvent?.drawAfterMap(spriteBatch);
- }
- if (isRaining && currentLocation.isOutdoors && !(currentLocation is Desert))
- {
- spriteBatch.Draw(staminaRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Blue * 0.2f);
- }
- if ((fadeToBlack || globalFade) && !menuUp && (!nameSelectUp || messagePause))
- {
- spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.Black * ((gameMode == 0) ? (1f - fadeToBlackAlpha) : fadeToBlackAlpha));
- }
- else if (flashAlpha > 0f)
- {
- if (options.screenFlash)
+ if ((messagePause || globalFade) && dialogueUp)
{
- spriteBatch.Draw(fadeToBlackRect, graphics.GraphicsDevice.Viewport.Bounds, Color.White * Math.Min(1f, flashAlpha));
+ //typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
+ DrawDialogueBox.Invoke(Program.gamePtr, null);
+ //this.drawDialogueBox();
}
- flashAlpha -= 0.1f;
- }
- if ((messagePause || globalFade) && dialogueUp)
- {
- //typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
- DrawDialogueBox.Invoke(Program.gamePtr, null);
- //this.drawDialogueBox();
- }
- foreach (TemporaryAnimatedSprite current8 in screenOverlayTempSprites)
- {
- current8.draw(spriteBatch, true);
- }
- if (debugMode)
- {
- spriteBatch.DrawString(smallFont, string.Concat(new object[]
+ foreach (TemporaryAnimatedSprite current8 in screenOverlayTempSprites)
{
- panMode ? ((getOldMouseX() + viewport.X) / tileSize + "," + (getOldMouseY() + viewport.Y) / tileSize) : string.Concat("aplayer: ", player.getStandingX() / tileSize, ", ", player.getStandingY() / tileSize),
- Environment.NewLine,
- "debugOutput: ",
- debugOutput
- }), new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.9999999f);
- }
- if (inputMode)
- {
- spriteBatch.DrawString(smallFont, "Input: " + debugInput, new Vector2(tileSize, tileSize * 3), Color.Purple);
- }
- if (showKeyHelp)
- {
- spriteBatch.DrawString(smallFont, keyHelpString, new Vector2(tileSize, viewport.Height - tileSize - (dialogueUp ? (tileSize * 3 + (isQuestion ? (questionChoices.Count * tileSize) : 0)) : 0) - smallFont.MeasureString(keyHelpString).Y), Color.LightGray, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.9999999f);
- }
- if (activeClickableMenu != null)
- {
- GraphicsEvents.InvokeOnPreRenderGuiEvent(null, EventArgs.Empty);
- activeClickableMenu.draw(spriteBatch);
- GraphicsEvents.InvokeOnPostRenderGuiEvent(null, EventArgs.Empty);
- }
- else
- {
- farmEvent?.drawAboveEverything(spriteBatch);
- }
-
- GraphicsEvents.InvokeOnPostRenderEvent(null, EventArgs.Empty);
- spriteBatch.End();
+ current8.draw(spriteBatch, true);
+ }
+ if (debugMode)
+ {
+ spriteBatch.DrawString(smallFont, string.Concat(new object[]
+ {
+ panMode ? ((getOldMouseX() + viewport.X) / tileSize + "," + (getOldMouseY() + viewport.Y) / tileSize) : string.Concat("aplayer: ", player.getStandingX() / tileSize, ", ", player.getStandingY() / tileSize),
+ Environment.NewLine,
+ "debugOutput: ",
+ debugOutput
+ }), new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.Red, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.9999999f);
+ }
+ if (inputMode)
+ {
+ spriteBatch.DrawString(smallFont, "Input: " + debugInput, new Vector2(tileSize, tileSize * 3), Color.Purple);
+ }
+ if (showKeyHelp)
+ {
+ spriteBatch.DrawString(smallFont, keyHelpString, new Vector2(tileSize, viewport.Height - tileSize - (dialogueUp ? (tileSize * 3 + (isQuestion ? (questionChoices.Count * tileSize) : 0)) : 0) - smallFont.MeasureString(keyHelpString).Y), Color.LightGray, 0f, Vector2.Zero, 1f, SpriteEffects.None, 0.9999999f);
+ }
+ if (activeClickableMenu != null)
+ {
+ GraphicsEvents.InvokeOnPreRenderGuiEvent(null, EventArgs.Empty);
+ activeClickableMenu.draw(spriteBatch);
+ GraphicsEvents.InvokeOnPostRenderGuiEvent(null, EventArgs.Empty);
+ }
+ else
+ {
+ farmEvent?.drawAboveEverything(spriteBatch);
+ }
- GraphicsEvents.InvokeDrawTick();
- GraphicsEvents.InvokeDrawInRenderTargetTick();
+ GraphicsEvents.InvokeOnPostRenderEvent(null, EventArgs.Empty);
+ spriteBatch.End();
- if (!ZoomLevelIsOne)
+ GraphicsEvents.InvokeDrawTick();
+ GraphicsEvents.InvokeDrawInRenderTargetTick();
+
+ if (!ZoomLevelIsOne)
+ {
+ GraphicsDevice.SetRenderTarget(null);
+ GraphicsDevice.Clear(BgColour);
+ spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
+ spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
+ spriteBatch.End();
+ }
+ }
+ catch (Exception ex)
{
- GraphicsDevice.SetRenderTarget(null);
- GraphicsDevice.Clear(BgColour);
- spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
- spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
- spriteBatch.End();
+ Log.Error("An error occured in the overridden draw loop: " + ex);
}
#endregion
|