Updated Revitalize.WeatherDebrisSystem to you know, be a system. Still need better way of cleaning up the system.

This commit is contained in:
Joshua Navarro 2017-02-25 00:37:43 -08:00
parent 2a76f772f9
commit 20f7d723ed
32 changed files with 99 additions and 22 deletions

View File

@ -5,7 +5,7 @@ using StardewValley;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
namespace Revitalize.Aesthetics namespace Revitalize.Aesthetics.WeatherDebris
{ {
@ -18,11 +18,16 @@ namespace Revitalize.Aesthetics
public Rectangle sourceRect; public Rectangle sourceRect;
public bool blowing; public bool blowing;
private Vector2 position; public Vector2 position;
private int which; public int which;
private float dx; public float dx;
private float dy; public float dy;
private int animationIntervalOffset; public int animationIntervalOffset;
public WeatherDebrisPlus()
{
}
public WeatherDebrisPlus(Vector2 position,Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy) public WeatherDebrisPlus(Vector2 position,Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy)
{ {
@ -34,7 +39,7 @@ namespace Revitalize.Aesthetics
animationIntervalOffset = animationOffset; animationIntervalOffset = animationOffset;
} }
public WeatherDebrisPlus(Vector2 position, Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy,bool yup) public WeatherDebrisPlus(Vector2 position, Rectangle SourceRect, int animationOffset, int which, float rotationVelocity, float dx, float dy,bool specificSetUp)
{ {
this.position = position; this.position = position;
this.which = which; this.which = which;
@ -79,7 +84,7 @@ namespace Revitalize.Aesthetics
public new void update(bool slow) public new void update(bool slow)
{ {
this.position.X = this.position.X + (this.dx + (slow ? 0f : WeatherDebris.globalWind)); this.position.X = this.position.X + (this.dx + (slow ? 0f :StardewValley.WeatherDebris.globalWind));
this.position.Y = this.position.Y + (this.dy - (slow ? 0f : -0.5f)); this.position.Y = this.position.Y + (this.dy - (slow ? 0f : -0.5f));
if (this.dy < 0f && !this.blowing) if (this.dy < 0f && !this.blowing)
{ {

View File

@ -0,0 +1,76 @@
using Microsoft.Xna.Framework;
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Revitalize.Aesthetics.WeatherDebris
{
public class weatherNode
{
public WeatherDebrisPlus weatherDebris;
public int TimesToAdd;
public weatherNode(WeatherDebrisPlus w, int addThisMany)
{
weatherDebris = w;
TimesToAdd = addThisMany;
}
}
class WeatherDebrisSystem
{
public static List<WeatherDebrisPlus> thisWeatherDebris;
public static void update()
{
foreach (WeatherDebrisPlus w in WeatherDebrisSystem.thisWeatherDebris)
{
// Log.AsyncM("COUNT" + Lists.thisWeatherDebris.Count);
w.update();
}
}
public static void draw()
{
if (Game1.player.currentLocation.ignoreDebrisWeather == false)
{
foreach (WeatherDebrisPlus w in WeatherDebrisSystem.thisWeatherDebris)
{
w.draw(Game1.spriteBatch);
}
}
}
public static void cleanWeatherDebris()
{
thisWeatherDebris.Clear();
}
public static void addMultipleDebrisWithVaryingCounts(List<weatherNode> listToAdd)
{
foreach(var v in listToAdd)
{
if (v.TimesToAdd == 0 || v.weatherDebris==null) continue;
for(int i=1; i <= v.TimesToAdd; i++)
{
thisWeatherDebris.Add(v.weatherDebris);
}
}
}
public static void addMultipleDebrisFromSingleType(weatherNode w)
{
if (w.TimesToAdd == 0 || w.weatherDebris == null) return;
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);
thisWeatherDebris.Add(v);
}
}
}
}

View File

@ -26,6 +26,7 @@ using xTile;
using Revitalize.Persistance; using Revitalize.Persistance;
using Revitalize.Draw; using Revitalize.Draw;
using Revitalize.Aesthetics; using Revitalize.Aesthetics;
using Revitalize.Aesthetics.WeatherDebris;
namespace Revitalize namespace Revitalize
{ {
@ -94,10 +95,7 @@ namespace Revitalize
private void draw(object sender, EventArgs e) private void draw(object sender, EventArgs e)
{ {
foreach(WeatherDebrisPlus w in Lists.thisWeatherDebris) WeatherDebrisSystem.draw();
{
w.draw(Game1.spriteBatch);
}
} }
private void GraphicsEvents_OnPreRenderHudEvent(object sender, EventArgs e) private void GraphicsEvents_OnPreRenderHudEvent(object sender, EventArgs e)
@ -141,11 +139,7 @@ namespace Revitalize
Lists.loadAllLists(); Lists.loadAllLists();
Util.WaterAllCropsInAllLocations(); Util.WaterAllCropsInAllLocations();
} }
foreach(WeatherDebrisPlus w in Lists.thisWeatherDebris) WeatherDebrisSystem.update();
{
// Log.AsyncM("COUNT" + Lists.thisWeatherDebris.Count);
w.update();
}
} }
@ -368,8 +362,8 @@ namespace Revitalize
// 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,true);
WeatherDebrisSystem.addMultipleDebrisFromSingleType(new weatherNode(w, 20));
Lists.thisWeatherDebris.Add(w); // WeatherDebrisSystem.thisWeatherDebris.Add(w);
Game1.isDebrisWeather = true; Game1.isDebrisWeather = true;
// Game1.updateDebrisWeatherForMovement(Game1.debrisWeather); // Game1.updateDebrisWeatherForMovement(Game1.debrisWeather);

View File

@ -1,4 +1,5 @@
using Revitalize.Aesthetics; using Revitalize.Aesthetics;
using Revitalize.Aesthetics.WeatherDebris;
using StardewModdingAPI; using StardewModdingAPI;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -16,14 +17,14 @@ namespace Revitalize.Resources
public static List<Revitalize.CoreObject> trackedObjectList; public static List<Revitalize.CoreObject> trackedObjectList;
public static List<WeatherDebrisPlus> thisWeatherDebris;
public static void initializeAllLists() public static void initializeAllLists()
{ {
trackedTerrainFeatures = new List<DataNodes.TrackedTerrainDataNode>(); trackedTerrainFeatures = new List<DataNodes.TrackedTerrainDataNode>();
trackedTerrainFeaturesDummyList = new List<DataNodes.TrackedTerrainDummyDataNode>(); trackedTerrainFeaturesDummyList = new List<DataNodes.TrackedTerrainDummyDataNode>();
trackedObjectList = new List<CoreObject>(); trackedObjectList = new List<CoreObject>();
thisWeatherDebris = new List<WeatherDebrisPlus>(); WeatherDebrisSystem.thisWeatherDebris = new List<WeatherDebrisPlus>();
} }
public static void loadAllLists() public static void loadAllLists()

View File

@ -50,7 +50,8 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Aesthetics\WeatherDebrisPlus.cs" /> <Compile Include="Aesthetics\WeatherDebris\WeatherDebrisPlus.cs" />
<Compile Include="Aesthetics\WeatherDebris\WeatherDebrisSystem.cs" />
<Compile Include="Class1.cs" /> <Compile Include="Class1.cs" />
<Compile Include="CoreObject.cs" /> <Compile Include="CoreObject.cs" />
<Compile Include="Draw\ThingsToDraw.cs" /> <Compile Include="Draw\ThingsToDraw.cs" />