Oddity: When swinging a tool or sword, anything running in PostRenderEvent stops
Sakorona opened this issue ยท 4 comments
Example:
private void DrawObjects(object sender, EventArgs e)
{
snowPos = Game1.updateFloatingObjectPositionForMovement(snowPos, new Vector2(Game1.viewport.X, Game1.viewport.Y),
Game1.previousViewportPosition, -1f);
snowPos.X = snowPos.X % (16 * Game1.pixelZoom);
Vector2 position = new Vector2();
float num1 = -16 * Game1.pixelZoom + snowPos.X % (16 * Game1.pixelZoom);
while ((double)num1 < Game1.viewport.Width)
{
float num2 = -16 * Game1.pixelZoom + snowPos.Y % (16 * Game1.pixelZoom);
while (num2 < (double)Game1.viewport.Height)
{
position.X = (int)num1;
position.Y = (int)num2;
Game1.spriteBatch.Draw(Game1.mouseCursors, position, new Microsoft.Xna.Framework.Rectangle?
(new Microsoft.Xna.Framework.Rectangle
(368 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + 150) % 1200.0) / 75 * 16, 192, 16, 16)),
Color.White * Game1.options.snowTransparency, 0.0f, Vector2.Zero,
Game1.pixelZoom + 1f / 1000f, SpriteEffects.None, 1f);
num2 += 16 * Game1.pixelZoom;
}
num1 += 16 * Game1.pixelZoom;
}
}
where snowPos
is a Vector2 from Microsoft.Xna.Framework.Graphics
@JohnsonNicholas I can't reproduce this in SMAPI 1.15.1 or 2.0 dev. I'm using this code in Entry
:
Vector2 snowPos = Vector2.Zero;
GraphicsEvents.OnPostRenderEvent += (sender, args) =>
{
snowPos = Game1.updateFloatingObjectPositionForMovement(snowPos, new Vector2(Game1.viewport.X, Game1.viewport.Y), Game1.previousViewportPosition, -1f);
snowPos.X = snowPos.X % (16 * Game1.pixelZoom);
Vector2 position = new Vector2();
float num1 = -16 * Game1.pixelZoom + snowPos.X % (16 * Game1.pixelZoom);
while ((double)num1 < Game1.viewport.Width)
{
float num2 = -16 * Game1.pixelZoom + snowPos.Y % (16 * Game1.pixelZoom);
while (num2 < (double)Game1.viewport.Height)
{
position.X = (int)num1;
position.Y = (int)num2;
Game1.spriteBatch.Draw(Game1.mouseCursors, position, new Rectangle(368 + (int)((Game1.currentGameTime.TotalGameTime.TotalMilliseconds + 150) % 1200.0) / 75 * 16, 192, 16, 16), Color.White * Game1.options.snowTransparency, 0.0f, Vector2.Zero, Game1.pixelZoom + 1f / 1000f, SpriteEffects.None, 1f);
num2 += 16 * Game1.pixelZoom;
}
num1 += 16 * Game1.pixelZoom;
}
};
I see the snow fine, and there's no flicker when swinging any tools. Does it still happen for you?
I found the problem. In an effort to stop it from constantly drawing over, I had added this:
if (!Context.IsPlayerFree)
return;
to stop it from drawing over. Apparently, during the action, the player is obviously not free. I'll just need to find something else.
Context.IsPlayerFree
isn't meant to be false when using a tool; I'll look into that.