Updated weatherDebrisSystem with way to clear screen with wind.
This commit is contained in:
parent
20f7d723ed
commit
daa2dbdc83
|
@ -12,25 +12,35 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
|
|
||||||
public class WeatherDebrisPlus
|
public class WeatherDebrisPlus
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Rectangle sourceRect;
|
public Rectangle sourceRect;
|
||||||
|
|
||||||
public bool blowing;
|
public bool blowing;
|
||||||
public Vector2 position;
|
public Vector2 position;
|
||||||
public int which;
|
public int which;
|
||||||
public float dx;
|
public float dx;
|
||||||
public float dy;
|
public float dy;
|
||||||
public int animationIntervalOffset;
|
public int animationIntervalOffset;
|
||||||
|
public Texture2D debrisTexture;
|
||||||
|
|
||||||
public WeatherDebrisPlus()
|
public WeatherDebrisPlus()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WeatherDebrisPlus(Vector2 position,Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy)
|
/// <summary>
|
||||||
|
/// Create a new debris particle to be shown across the screen.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <param name="SourceRect">Source on the texture sprite sheet.</param>
|
||||||
|
/// <param name="animationOffset"></param>
|
||||||
|
/// <param name="which">Not really used, but can be used for default list.</param>
|
||||||
|
/// <param name="rotationVelocity"></param>
|
||||||
|
/// <param name="dx"></param>
|
||||||
|
/// <param name="dy"></param>
|
||||||
|
/// <param name="texture">If NULL, then Game1.mouseCursors is used.</param>
|
||||||
|
public WeatherDebrisPlus(Vector2 position,Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy, Texture2D texture=null)
|
||||||
{
|
{
|
||||||
|
if (texture == null) debrisTexture = Game1.mouseCursors;
|
||||||
|
else debrisTexture = texture;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.which = which;
|
this.which = which;
|
||||||
this.dx = dx;
|
this.dx = dx;
|
||||||
|
@ -39,7 +49,17 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
animationIntervalOffset = animationOffset;
|
animationIntervalOffset = animationOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WeatherDebrisPlus(Vector2 position, Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy,bool specificSetUp)
|
/// <summary>
|
||||||
|
/// Default system that uses some presets. Might or might not use.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="position"></param>
|
||||||
|
/// <param name="SourceRect">Source on the texture sprite sheet.</param>
|
||||||
|
/// <param name="animationOffset"></param>
|
||||||
|
/// <param name="which">Not really used, but can be used for default list.</param>
|
||||||
|
/// <param name="rotationVelocity"></param>
|
||||||
|
/// <param name="dx"></param>
|
||||||
|
/// <param name="dy"></param>
|
||||||
|
public WeatherDebrisPlus(Vector2 position, Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy)
|
||||||
{
|
{
|
||||||
this.position = position;
|
this.position = position;
|
||||||
this.which = which;
|
this.which = which;
|
||||||
|
@ -47,10 +67,6 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
this.dy = dy;
|
this.dy = dy;
|
||||||
// sourceRect = SourceRect;
|
// sourceRect = SourceRect;
|
||||||
animationIntervalOffset = animationOffset;
|
animationIntervalOffset = animationOffset;
|
||||||
|
|
||||||
Log.AsyncC(this.dx);
|
|
||||||
Log.AsyncC(this.dy);
|
|
||||||
|
|
||||||
switch (which)
|
switch (which)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -129,7 +145,7 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
|
|
||||||
public void draw(SpriteBatch b)
|
public void draw(SpriteBatch b)
|
||||||
{
|
{
|
||||||
b.Draw(Game1.mouseCursors, this.position, new Rectangle?(this.sourceRect), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, 1E-06f);
|
b.Draw(this.debrisTexture, this.position, new Rectangle?(this.sourceRect), Color.White, 0f, Vector2.Zero, 3f, SpriteEffects.None, 1E-06f);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,9 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Timers;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using StardewModdingAPI;
|
||||||
|
|
||||||
namespace Revitalize.Aesthetics.WeatherDebris
|
namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
{
|
{
|
||||||
|
@ -14,6 +16,8 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
public WeatherDebrisPlus weatherDebris;
|
public WeatherDebrisPlus weatherDebris;
|
||||||
public int TimesToAdd;
|
public int TimesToAdd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public weatherNode(WeatherDebrisPlus w, int addThisMany)
|
public weatherNode(WeatherDebrisPlus w, int addThisMany)
|
||||||
{
|
{
|
||||||
weatherDebris = w;
|
weatherDebris = w;
|
||||||
|
@ -24,6 +28,8 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
class WeatherDebrisSystem
|
class WeatherDebrisSystem
|
||||||
{
|
{
|
||||||
public static List<WeatherDebrisPlus> thisWeatherDebris;
|
public static List<WeatherDebrisPlus> thisWeatherDebris;
|
||||||
|
public static Timer debrisClearTimer;
|
||||||
|
public static float oldWindGust;
|
||||||
public static void update()
|
public static void update()
|
||||||
{
|
{
|
||||||
foreach (WeatherDebrisPlus w in WeatherDebrisSystem.thisWeatherDebris)
|
foreach (WeatherDebrisPlus w in WeatherDebrisSystem.thisWeatherDebris)
|
||||||
|
@ -45,9 +51,14 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void cleanWeatherDebris()
|
public static void cleanWeatherDebrisTimer(System.Object source, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
thisWeatherDebris.Clear();
|
thisWeatherDebris.Clear();
|
||||||
|
debrisClearTimer.Enabled = false;
|
||||||
|
debrisClearTimer.Dispose();
|
||||||
|
Game1.windGust = 0.0f;
|
||||||
|
StardewValley.WeatherDebris.globalWind = oldWindGust;
|
||||||
|
// Log.AsyncG("Cleared Wind Debris");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addMultipleDebrisWithVaryingCounts(List<weatherNode> listToAdd)
|
public static void addMultipleDebrisWithVaryingCounts(List<weatherNode> listToAdd)
|
||||||
|
@ -67,10 +78,26 @@ namespace Revitalize.Aesthetics.WeatherDebris
|
||||||
if (w.TimesToAdd == 0 || w.weatherDebris == null) return;
|
if (w.TimesToAdd == 0 || w.weatherDebris == null) return;
|
||||||
for(int i = 1; i <= w.TimesToAdd; i++)
|
for(int i = 1; i <= w.TimesToAdd; i++)
|
||||||
{
|
{
|
||||||
var v= new WeatherDebrisPlus(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), w.weatherDebris.sourceRect, w.weatherDebris.animationIntervalOffset, w.weatherDebris.which, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f, true);
|
var v= new WeatherDebrisPlus(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), w.weatherDebris.sourceRect, w.weatherDebris.animationIntervalOffset, w.weatherDebris.which, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f,w.weatherDebris.debrisTexture);
|
||||||
thisWeatherDebris.Add(v);
|
thisWeatherDebris.Add(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void speedUpWindAndClear(float f)
|
||||||
|
{
|
||||||
|
oldWindGust= StardewValley.WeatherDebris.globalWind;
|
||||||
|
for (float g=StardewValley.WeatherDebris.globalWind; g <= 2f; g += f)
|
||||||
|
{
|
||||||
|
StardewValley.Game1.windGust = g;
|
||||||
|
}
|
||||||
|
debrisClearTimer = new Timer(5000);
|
||||||
|
debrisClearTimer.Elapsed += cleanWeatherDebrisTimer;
|
||||||
|
debrisClearTimer.Start();
|
||||||
|
debrisClearTimer.AutoReset = false;
|
||||||
|
debrisClearTimer.Enabled = true;
|
||||||
|
// StardewValley.Game1.windGust = d;
|
||||||
|
// thisWeatherDebris.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -350,7 +350,10 @@ namespace Revitalize
|
||||||
newDebris();
|
newDebris();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (e.KeyPressed.ToString() == "G")
|
||||||
|
{
|
||||||
|
WeatherDebrisSystem.speedUpWindAndClear(0.001f);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -361,14 +364,9 @@ namespace Revitalize
|
||||||
// WeatherDebris w = new WeatherDebris();
|
// WeatherDebris w = new WeatherDebris();
|
||||||
// Game1.debrisWeather.Add(new WeatherDebris(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), 0, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f));
|
// Game1.debrisWeather.Add(new WeatherDebris(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), 0, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f));
|
||||||
// WeatherDebris w = new WeatherDebris(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), 0, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f);
|
// WeatherDebris w = new WeatherDebris(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), 0, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f);
|
||||||
WeatherDebrisPlus w= new WeatherDebrisPlus(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), new Rectangle(338, 400, 8, 8), 0, 4, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f,true);
|
WeatherDebrisPlus w= new WeatherDebrisPlus(new Vector2((float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Width), (float)Game1.random.Next(0, Game1.graphics.GraphicsDevice.Viewport.Height)), new Rectangle(338, 400, 8, 8), 0, 4, (float)Game1.random.Next(15) / 500f, (float)Game1.random.Next(-10, 0) / 50f, (float)Game1.random.Next(10) / 50f);
|
||||||
WeatherDebrisSystem.addMultipleDebrisFromSingleType(new weatherNode(w, 20));
|
WeatherDebrisSystem.addMultipleDebrisFromSingleType(new weatherNode(w, 20));
|
||||||
// WeatherDebrisSystem.thisWeatherDebris.Add(w);
|
|
||||||
|
|
||||||
Game1.isDebrisWeather = true;
|
Game1.isDebrisWeather = true;
|
||||||
// Game1.updateDebrisWeatherForMovement(Game1.debrisWeather);
|
|
||||||
// Game1.windGust = 0.15f;
|
|
||||||
Log.AsyncC("WIND");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue