Made multi tile objects that can be used in the future for things like machines and more furniture. Bigger things here we come. Need to edit sme click functionality however.
This commit is contained in:
parent
a928f7d18e
commit
4469fbd9b3
|
@ -501,9 +501,6 @@ namespace AdditionalCropsFramework
|
|||
this.locationsName = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 191 B |
Binary file not shown.
After Width: | Height: | Size: 171 B |
Binary file not shown.
After Width: | Height: | Size: 193 B |
|
@ -1,8 +1,10 @@
|
|||
using Microsoft.Xna.Framework.Input;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using StardewModdingAPI;
|
||||
using StardewValley;
|
||||
using StardewValley.Menus;
|
||||
using StardustCore.ModInfo;
|
||||
using StardustCore.Objects;
|
||||
using StardustCore.Objects.Tools;
|
||||
using StardustCore.Serialization;
|
||||
using StardustCore.UIUtilities;
|
||||
|
@ -21,6 +23,7 @@ namespace StardustCore
|
|||
public static IModHelper ModHelper;
|
||||
public static IMonitor ModMonitor;
|
||||
public static Serialization.SerializationManager SerializationManager;
|
||||
public static UIUtilities.TextureManager TextureManager;
|
||||
|
||||
public static string ContentDirectory;
|
||||
public override void Entry(IModHelper helper)
|
||||
|
@ -47,6 +50,7 @@ namespace StardustCore
|
|||
SpriteFonts.initialize();
|
||||
|
||||
SerializationManager.initializeDefaultSuportedTypes();
|
||||
TextureManager = new TextureManager();
|
||||
|
||||
|
||||
}
|
||||
|
@ -56,26 +60,18 @@ namespace StardustCore
|
|||
private void SaveEvents_AfterLoad(object sender, EventArgs e)
|
||||
{
|
||||
SerializationManager.restoreAllModObjects(SerializationManager.trackedObjectList);
|
||||
List<KeyValuePair<Vector2, MultiTileComponent>> objs = new List<KeyValuePair<Vector2, MultiTileComponent>>();
|
||||
MultiTileComponent tile1 = new MultiTileComponent(new CoreObject(new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test1.png")), 0, Vector2.Zero, 0));
|
||||
MultiTileComponent tile2 = new MultiTileComponent(new CoreObject(new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test2.png")), 0, Vector2.Zero, 0));
|
||||
MultiTileComponent tile3 = new MultiTileComponent(new CoreObject(new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png")), 0, Vector2.Zero, 0));
|
||||
|
||||
ExtendedAxe axe = new ExtendedAxe(new BasicToolInfo("My First Axe",7,"An axe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")));
|
||||
Game1.player.addItemToInventory(axe);
|
||||
objs.Add(new KeyValuePair<Vector2, MultiTileComponent>(new Vector2(0, 0), tile1));
|
||||
objs.Add(new KeyValuePair<Vector2, MultiTileComponent>(new Vector2(1, 0), tile2));
|
||||
objs.Add(new KeyValuePair<Vector2, MultiTileComponent>(new Vector2(2, 0), tile3));
|
||||
|
||||
ExtendedHoe hoe = new ExtendedHoe(new BasicToolInfo("My First Hoe", 7, "An hoe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")));
|
||||
Game1.player.addItemToInventory(hoe);
|
||||
|
||||
ExtendedPickaxe pick = new ExtendedPickaxe(new BasicToolInfo("My First pickaxe", 7, "An pickaxe so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")));
|
||||
Game1.player.addItemToInventory(pick);
|
||||
|
||||
ExtendedWateringCan water = new ExtendedWateringCan(new BasicToolInfo("My First Can", 7, "An can so legendary it shakes the heavens."), new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png")),10,3);
|
||||
Game1.player.addItemToInventory(water);
|
||||
|
||||
|
||||
|
||||
ExtendedWateringCan.Serialize(water);
|
||||
ExtendedAxe.Serialize(axe);
|
||||
ExtendedPickaxe.Serialize(pick);
|
||||
ExtendedHoe.Serialize(hoe);
|
||||
MultiTileObject collection= new MultiTileObject("MultiTest", "Trying to get multi object testing working", Vector2.Zero, new Texture2DExtended(ModCore.ModHelper, Path.Combine("Content", "Graphics", "MultiTest", "Test3.png")), objs, StardustCore.IlluminateFramework.Colors.invertColor(StardustCore.IlluminateFramework.LightColorsList.Purple), "MultiTest");
|
||||
|
||||
Game1.player.addItemToInventory(collection);
|
||||
}
|
||||
|
||||
private void SaveEvents_AfterSave(object sender, EventArgs e)
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace StardustCore
|
|||
|
||||
public int sourceIndexOffset;
|
||||
|
||||
protected Vector2 drawPosition;
|
||||
public Vector2 drawPosition;
|
||||
|
||||
public Rectangle sourceRect;
|
||||
|
||||
|
@ -136,19 +136,13 @@ namespace StardustCore
|
|||
this.defaultSourceRect = new Rectangle(which * 16 % TextureSheet.getTexture().Width, which * 16 / TextureSheet.getTexture().Width * 16, 1, 1);
|
||||
if (array[2].Equals("-1"))
|
||||
{
|
||||
this.sourceRect = this.getDefaultSourceRectForType(which, this.Decoration_type);
|
||||
this.sourceRect = new Rectangle(0, 0, 16, 16);
|
||||
this.defaultSourceRect = this.sourceRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.defaultSourceRect.Width = Convert.ToInt32(array[2].Split(new char[]
|
||||
{
|
||||
' '
|
||||
})[0]);
|
||||
this.defaultSourceRect.Height = Convert.ToInt32(array[2].Split(new char[]
|
||||
{
|
||||
' '
|
||||
})[1]);
|
||||
this.defaultSourceRect.Width = 16;
|
||||
this.defaultSourceRect.Height = 16;
|
||||
this.sourceRect = new Rectangle(which * 16 % TextureSheet.getTexture().Width, which * 16 / TextureSheet.getTexture().Width * 16, this.defaultSourceRect.Width * 16, this.defaultSourceRect.Height * 16);
|
||||
this.defaultSourceRect = this.sourceRect;
|
||||
}
|
||||
|
@ -168,7 +162,7 @@ namespace StardustCore
|
|||
{
|
||||
' '
|
||||
})[1]);
|
||||
this.boundingBox.Value = new Rectangle((int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize, this.defaultBoundingBox.Width * Game1.tileSize, this.defaultBoundingBox.Height * Game1.tileSize);
|
||||
this.boundingBox.Value = new Rectangle((int)this.TileLocation.X * Game1.tileSize, (int)this.TileLocation.Y * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize);
|
||||
this.defaultBoundingBox = this.boundingBox.Value;
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
|
@ -190,7 +184,7 @@ namespace StardustCore
|
|||
/// <param name="tileX">The x tile location to "place".</param>
|
||||
/// <param name="tileY">The y tile location to "place".</param>
|
||||
/// <param name="trackSerialization">If true then the Serialization manager will keep track of this object.</param>
|
||||
public void fakePlacementAction(GameLocation location, int tileX, int tileY,bool trackSerialization=true)
|
||||
public virtual void fakePlacementAction(GameLocation location, int tileX, int tileY,bool trackSerialization=true)
|
||||
{
|
||||
this.thisLocation = location;
|
||||
this.TileLocation = new Vector2(tileX, tileY);
|
||||
|
@ -605,7 +599,14 @@ namespace StardustCore
|
|||
environment.lightGlows.Remove(new Vector2((float)(this.boundingBox.X + Game1.tileSize / 2), (float)(this.boundingBox.Y + Game1.tileSize)));
|
||||
this.lightGlowAdded = false;
|
||||
}
|
||||
try
|
||||
{
|
||||
this.spillInventoryEverywhere();
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
|
||||
}
|
||||
base.performRemoveAction(tileLocation, environment);
|
||||
}
|
||||
|
||||
|
@ -980,162 +981,36 @@ namespace StardustCore
|
|||
public override bool placementAction(GameLocation location, int x, int y, StardewValley.Farmer who = null)
|
||||
{
|
||||
|
||||
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
|
||||
|
||||
|
||||
if (location is FarmHouse)
|
||||
{
|
||||
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
|
||||
List<Rectangle> walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel);
|
||||
this.TileLocation = new Vector2((float)point.X, (float)point.Y);
|
||||
bool flag = false;
|
||||
if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.ParentSheetIndex == 1293)
|
||||
|
||||
this.boundingBox.Value = new Rectangle(x, y, Game1.tileSize, Game1.tileSize);
|
||||
|
||||
using (List<StardewValley.Farmer>.Enumerator enumerator3 = location.getFarmers().GetEnumerator())
|
||||
{
|
||||
int num = (this.ParentSheetIndex == 1293) ? 3 : 0;
|
||||
bool flag2 = false;
|
||||
foreach (Rectangle current in walls)
|
||||
while (enumerator3.MoveNext())
|
||||
{
|
||||
if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num))
|
||||
{
|
||||
flag2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!flag2)
|
||||
{
|
||||
Game1.showRedMessage("Must be placed on wall");
|
||||
return false;
|
||||
}
|
||||
flag = true;
|
||||
}
|
||||
for (int i = point.X; i < point.X + this.getTilesWide(); i++)
|
||||
{
|
||||
for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
|
||||
{
|
||||
if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
|
||||
{
|
||||
Game1.showRedMessage("Furniture can't be placed here");
|
||||
return false;
|
||||
}
|
||||
if (!flag && Utility.pointInRectangles(walls, i, j))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on wall");
|
||||
return false;
|
||||
}
|
||||
if (location.getTileIndexAt(i, j, "Buildings") != -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.boundingBox.Value = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
|
||||
foreach (var c in location.objects.Pairs)
|
||||
{
|
||||
StardewValley.Object ehh = c.Value;
|
||||
if (((ehh.GetType()).ToString()).Contains("Spawner"))
|
||||
{
|
||||
CoreObject current2 = (CoreObject)ehh;
|
||||
if (current2.Decoration_type == 11 && current2.heldObject.Value == null && current2.getBoundingBox(current2.TileLocation).Intersects(this.boundingBox.Value))
|
||||
{
|
||||
current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (StardewValley.Farmer current3 in location.getFarmers())
|
||||
{
|
||||
if (current3.GetBoundingBox().Intersects(this.boundingBox.Value))
|
||||
if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox.Value))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on top of a person.");
|
||||
bool result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
// Log.AsyncO(this.boundingBox);
|
||||
// Log.AsyncO(x);
|
||||
// Log.AsyncY(y);
|
||||
for (int i = 0; i <= this.boundingBox.X / Game1.tileSize; i++)
|
||||
{
|
||||
base.placementAction(location, x + 1, y, who);
|
||||
}
|
||||
for (int i = 0; i <= this.boundingBox.Y / Game1.tileSize; i++)
|
||||
{
|
||||
base.placementAction(location, x, y + 1, who);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
|
||||
// List<Rectangle> walls = FarmHouse.getWalls((location as FarmHouse).upgradeLevel);
|
||||
this.TileLocation = new Vector2((float)point.X, (float)point.Y);
|
||||
if (this.Decoration_type == 6 || this.Decoration_type == 13 || this.ParentSheetIndex == 1293)
|
||||
{
|
||||
int num = (this.ParentSheetIndex == 1293) ? 3 : 0;
|
||||
bool flag2 = false;
|
||||
/*
|
||||
foreach (Rectangle current in walls)
|
||||
{
|
||||
if ((this.Decoration_type == 6 || this.Decoration_type == 13 || num != 0) && current.Y + num == point.Y && current.Contains(point.X, point.Y - num))
|
||||
{
|
||||
flag2 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (!flag2)
|
||||
{
|
||||
Game1.showRedMessage("Must be placed on wall");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (int i = point.X; i < point.X + this.getTilesWide(); i++)
|
||||
{
|
||||
for (int j = point.Y; j < point.Y + this.getTilesHigh(); j++)
|
||||
{
|
||||
if (location.doesTileHaveProperty(i, j, "NoFurniture", "Back") != null)
|
||||
{
|
||||
Game1.showRedMessage("Furniture can't be placed here");
|
||||
return false;
|
||||
}
|
||||
/*
|
||||
if (!flag && Utility.pointInRectangles(walls, i, j))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on wall");
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
if (location.getTileIndexAt(i, j, "Buildings") != -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.boundingBox.Value = new Rectangle(x / Game1.tileSize, y / Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
|
||||
/*
|
||||
foreach (Furniture current2 in (location as FarmHouse).furniture)
|
||||
{
|
||||
if (current2.furniture_type == 11 && current2.heldObject == null && current2.getBoundingBox(current2.tileLocation).Intersects(this.boundingBox))
|
||||
{
|
||||
current2.performObjectDropInAction(this, false, (who == null) ? Game1.player : who);
|
||||
bool result = true;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
*/
|
||||
foreach (StardewValley.Farmer current3 in location.getFarmers())
|
||||
{
|
||||
if (current3.GetBoundingBox().Intersects(this.boundingBox.Value))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on top of a person.");
|
||||
bool result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
|
||||
bool f = Utilities.placementAction(this, location, x, y, StardustCore.ModCore.SerializationManager,who);
|
||||
this.thisLocation = Game1.player.currentLocation;
|
||||
return base.placementAction(location, x * Game1.tileSize, y * Game1.tileSize, who);
|
||||
}
|
||||
return f;
|
||||
// Game1.showRedMessage("Can only be placed in House");
|
||||
// return false;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public override bool isPlaceable()
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewValley;
|
||||
|
||||
namespace StardustCore.Objects
|
||||
{
|
||||
public class MultiTileComponent : CoreObject
|
||||
{
|
||||
public MultiTileObject containerObject;
|
||||
public CoreObject objectPart;
|
||||
|
||||
public MultiTileComponent(CoreObject part)
|
||||
{
|
||||
this.objectPart = part;
|
||||
this.name = this.objectPart.name;
|
||||
this.defaultBoundingBox = new Rectangle(0, 0, 16, 16);
|
||||
this.boundingBox.Value = new Rectangle((int)0 * Game1.tileSize, (int)0* Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize);
|
||||
}
|
||||
|
||||
public override bool clicked(Farmer who)
|
||||
{
|
||||
containerObject.RemoveAllObjects();
|
||||
return true;
|
||||
}
|
||||
|
||||
public override Item getOne()
|
||||
{
|
||||
var obj= new MultiTileComponent((CoreObject)objectPart.getOne());
|
||||
obj.containerObject = this.containerObject;
|
||||
return obj;
|
||||
}
|
||||
|
||||
public override bool RightClicked(Farmer who)
|
||||
{
|
||||
return this.objectPart.RightClicked(who);
|
||||
}
|
||||
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
Point point = new Point(x / Game1.tileSize, y / Game1.tileSize);
|
||||
|
||||
this.TileLocation = new Vector2((float)point.X, (float)point.Y);
|
||||
this.boundingBox.Value = new Rectangle((int)TileLocation.X * Game1.tileSize, (int)TileLocation.Y * Game1.tileSize, 1 * Game1.tileSize, 1 * Game1.tileSize);
|
||||
using (List<StardewValley.Farmer>.Enumerator enumerator3 = location.getFarmers().GetEnumerator())
|
||||
{
|
||||
while (enumerator3.MoveNext())
|
||||
{
|
||||
if (enumerator3.Current.GetBoundingBox().Intersects(this.boundingBox.Value))
|
||||
{
|
||||
Game1.showRedMessage("Can't place on top of a person.");
|
||||
bool result = false;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
this.updateDrawPosition();
|
||||
|
||||
bool f = Utilities.placementAction(this, location, x, y,StardustCore.ModCore.SerializationManager ,who);
|
||||
this.thisLocation = Game1.player.currentLocation;
|
||||
return f;
|
||||
// Game1.showRedMessage("Can only be placed in House");
|
||||
// return false;
|
||||
}
|
||||
|
||||
public override void performRemoveAction(Vector2 tileLocation, GameLocation environment)
|
||||
{
|
||||
// Game1.showRedMessage("Why3?");
|
||||
try
|
||||
{
|
||||
this.heldObject.Value.performRemoveAction(this.TileLocation, this.thisLocation);
|
||||
this.heldObject.Value = null;
|
||||
}
|
||||
catch(Exception err)
|
||||
{
|
||||
|
||||
}
|
||||
StardustCore.ModCore.SerializationManager.trackedObjectList.Remove(this);
|
||||
this.thisLocation.objects.Remove(this.TileLocation);
|
||||
this.thisLocation = null;
|
||||
this.locationsName = "";
|
||||
base.performRemoveAction(tileLocation, environment);
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1f)
|
||||
{
|
||||
if (x == -1)
|
||||
{
|
||||
spriteBatch.Draw(this.objectPart.TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, this.objectPart.drawPosition), new Rectangle?(this.objectPart.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.objectPart.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.objectPart.Decoration_type == 12) ? 0f : ((float)(this.objectPart.boundingBox.Bottom - 8) / 10000f));
|
||||
}
|
||||
else
|
||||
{
|
||||
//The actual planter box being drawn.
|
||||
if (animationManager == null)
|
||||
{
|
||||
spriteBatch.Draw(this.objectPart.TextureSheet.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.objectPart.sourceRect), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.objectPart.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
|
||||
// Log.AsyncG("ANIMATION IS NULL?!?!?!?!");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//Log.AsyncC("Animation Manager is working!");
|
||||
this.animationManager.draw(spriteBatch, this.objectPart.animationManager.objectTexture.getTexture(), Game1.GlobalToLocal(Game1.viewport, new Vector2((float)(x * Game1.tileSize), y * Game1.tileSize)), new Rectangle?(this.objectPart.animationManager.currentAnimation.sourceRectangle), Color.White * alpha, 0f, Vector2.Zero, (float)Game1.pixelZoom, this.objectPart.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
|
||||
try
|
||||
{
|
||||
this.animationManager.tickAnimation();
|
||||
// Log.AsyncC("Tick animation");
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
ModCore.ModMonitor.Log(err.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
// spriteBatch.Draw(Game1.mouseCursors, Game1.GlobalToLocal(Game1.viewport, new Vector2((float)((double)tileLocation.X * (double)Game1.tileSize + (((double)tileLocation.X * 11.0 + (double)tileLocation.Y * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2), (float)((double)tileLocation.Y * (double)Game1.tileSize + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) + (float)(Game1.tileSize / 2))), new Rectangle?(new Rectangle((int)((double)tileLocation.X * 51.0 + (double)tileLocation.Y * 77.0) % 3 * 16, 128 + this.whichForageCrop * 16, 16, 16)), Color.White, 0.0f, new Vector2(8f, 8f), (float)Game1.pixelZoom, SpriteEffects.None, (float)(((double)tileLocation.Y * (double)Game1.tileSize + (double)(Game1.tileSize / 2) + (((double)tileLocation.Y * 11.0 + (double)tileLocation.X * 7.0) % 10.0 - 5.0)) / 10000.0));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,185 @@
|
|||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using StardewValley;
|
||||
using StardustCore.UIUtilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StardustCore.Objects
|
||||
{
|
||||
public class MultiTileObject : CoreObject
|
||||
{
|
||||
public List<KeyValuePair<Vector2,MultiTileComponent>> objects;
|
||||
public Color categoryColor;
|
||||
public String categoryName;
|
||||
|
||||
public MultiTileObject(String Name, String Description,Vector2 tile, Texture2DExtended texture, List<KeyValuePair<Vector2, MultiTileComponent>> Objects, Color CategoryColor, String CategoryName) :base(texture,0,tile,0)
|
||||
{
|
||||
this.objects = Objects;
|
||||
this.TextureSheet = texture;
|
||||
this.texturePath = texture.path;
|
||||
this.categoryColor = CategoryColor;
|
||||
this.categoryName = CategoryName;
|
||||
this.name = Name;
|
||||
this.displayName = Name;
|
||||
this.description = Description;
|
||||
|
||||
foreach(var v in this.objects)
|
||||
{
|
||||
v.Value.containerObject = this;
|
||||
}
|
||||
|
||||
InitializeBasics(0, tile);
|
||||
}
|
||||
|
||||
public MultiTileObject(String Name, String Description, Vector2 tile, Animations.AnimationManager animationManager, List<KeyValuePair<Vector2, MultiTileComponent>> Objects, Color CategoryColor, String CategoryName)
|
||||
{
|
||||
this.animationManager = animationManager;
|
||||
this.objects = Objects;
|
||||
this.TextureSheet =animationManager.objectTexture;
|
||||
this.texturePath = animationManager.objectTexture.path;
|
||||
this.name = Name;
|
||||
this.displayName = Name;
|
||||
this.description = Description;
|
||||
InitializeBasics(0, tile);
|
||||
}
|
||||
|
||||
public void RemoveAllObjects()
|
||||
{
|
||||
if (Game1.player.isInventoryFull() == false){
|
||||
foreach (var v in this.objects)
|
||||
{
|
||||
v.Value.performRemoveAction(v.Value.TileLocation, v.Value.objectPart.thisLocation);
|
||||
}
|
||||
Game1.player.addItemToInventory(this);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
public override Type getCustomType()
|
||||
{
|
||||
return this.GetType();
|
||||
}
|
||||
|
||||
public override string GetSerializationName()
|
||||
{
|
||||
return typeof(MultiTileObject).ToString();
|
||||
}
|
||||
|
||||
public override void InitializeBasics(int InvMaxSize, Vector2 tile)
|
||||
{
|
||||
base.InitializeBasics(InvMaxSize, tile);
|
||||
}
|
||||
public override bool placementAction(GameLocation location, int x, int y, Farmer who = null)
|
||||
{
|
||||
foreach(var pair in this.objects)
|
||||
{
|
||||
pair.Value.placementAction(location, x+(int)(pair.Key.X*Game1.tileSize), y+ (int)(pair.Key.Y * Game1.tileSize), who);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool clicked(Farmer who)
|
||||
{
|
||||
foreach (var pair in this.objects)
|
||||
{
|
||||
pair.Value.clicked(who);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool RightClicked(Farmer who)
|
||||
{
|
||||
foreach (var pair in this.objects)
|
||||
{
|
||||
pair.Value.RightClicked(who);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Need to fix this for sure!!!
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public override Item getOne()
|
||||
{
|
||||
List<KeyValuePair<Vector2, MultiTileComponent>> items = new List<KeyValuePair<Vector2, MultiTileComponent>>();
|
||||
foreach (var pair in this.objects)
|
||||
{
|
||||
items.Add(new KeyValuePair<Vector2, MultiTileComponent>(pair.Key, (pair.Value.getOne()) as MultiTileComponent));
|
||||
}
|
||||
if (this.animationManager != null)
|
||||
{
|
||||
return new MultiTileObject(this.name, this.description, this.TileLocation, this.animationManager, items, this.categoryColor, this.categoryName);
|
||||
//throw new NotImplementedException();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new MultiTileObject(this.name, this.description, this.TileLocation, this.TextureSheet, items, this.categoryColor, this.categoryName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
|
||||
{
|
||||
|
||||
foreach(var v in this.objects)
|
||||
{
|
||||
if (v.Value.objectPart.thisLocation != null)
|
||||
{
|
||||
v.Value.draw(spriteBatch, (int)v.Value.position.X, (int)v.Value.position.Y, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
//base.draw(spriteBatch, x, y, alpha);
|
||||
}
|
||||
|
||||
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
|
||||
{
|
||||
foreach (var v in this.objects)
|
||||
{
|
||||
//v.Value.draw(spriteBatch, (int)v.Value.position.X, (int)v.Value.position.Y, layerDepth, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, StardewValley.Farmer f)
|
||||
{
|
||||
if (animationManager == null)
|
||||
{
|
||||
spriteBatch.Draw(this.TextureSheet.getTexture(), objectPosition, new Microsoft.Xna.Framework.Rectangle?(GameLocation.getSourceRectForObject(f.ActiveObject.ParentSheetIndex)), Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
||||
}
|
||||
else
|
||||
{
|
||||
spriteBatch.Draw(animationManager.objectTexture.getTexture(), objectPosition, this.animationManager.currentAnimation.sourceRectangle, Color.White, 0f, Vector2.Zero, (float)Game1.pixelZoom, SpriteEffects.None, Math.Max(0f, (float)(f.getStandingY() + 2) / 10000f));
|
||||
}
|
||||
|
||||
//base.drawWhenHeld(spriteBatch, objectPosition, f);
|
||||
}
|
||||
|
||||
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color c, bool drawShadows)
|
||||
{
|
||||
if (animationManager == null) spriteBatch.Draw(this.TextureSheet.getTexture(), location,this.defaultSourceRect, Color.White * transparency, 0f, new Vector2(0,0), scaleSize, SpriteEffects.None, layerDepth);
|
||||
else
|
||||
{
|
||||
spriteBatch.Draw(animationManager.objectTexture.getTexture(), location, animationManager.currentAnimation.sourceRectangle, Color.White * transparency, 0f, new Vector2(0,0), scaleSize, SpriteEffects.None, layerDepth);
|
||||
//this.modularCrop.drawInMenu(spriteBatch, location + new Vector2((float)(Game1.tileSize / 2), (float)(Game1.tileSize / 2)), Color.White, 0f,true);
|
||||
if (Game1.player.CurrentItem != this) animationManager.tickAnimation();
|
||||
}
|
||||
}
|
||||
|
||||
public override Color getCategoryColor()
|
||||
{
|
||||
return this.categoryColor;
|
||||
}
|
||||
|
||||
public override string getCategoryName()
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ namespace StardustCore.Objects.Tools
|
|||
StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedAxe).Name);
|
||||
this.displayName = "Hello";
|
||||
this.description = (dataBase as Serialization_ExtendedAxe).Description;
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedAxe).TextureInformation.Name); //new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.UpgradeLevel = (dataBase as Serialization_ExtendedAxe).UpgradeLevel;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace StardustCore.Objects.Tools
|
|||
StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedHoe).Name);
|
||||
this.displayName = "Hello";
|
||||
this.description = (dataBase as Serialization_ExtendedHoe).Description;
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedHoe).TextureInformation.Name);
|
||||
this.UpgradeLevel = (dataBase as Serialization_ExtendedHoe).UpgradeLevel;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ namespace StardustCore.Objects.Tools
|
|||
StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedPickaxe).Name);
|
||||
this.displayName = "Hello";
|
||||
this.description = (dataBase as Serialization_ExtendedPickaxe).Description;
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.texture = this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedPickaxe).TextureInformation.Name);
|
||||
this.UpgradeLevel = (dataBase as Serialization_ExtendedPickaxe).UpgradeLevel;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace StardustCore.Objects.Tools
|
|||
StardustCore.ModCore.ModMonitor.Log((dataBase as Serialization_ExtendedWateringCan).Name);
|
||||
this.displayName = "Hello";
|
||||
this.description = (dataBase as Serialization_ExtendedWateringCan).Description;
|
||||
this.texture = new Texture2DExtended(StardustCore.ModCore.ModHelper, Path.Combine("Content", "Graphics", "Tools", "CustomAxe.png"));
|
||||
this.texture = StardustCore.ModCore.TextureManager.getTexture((dataBase as Serialization_ExtendedWateringCan).TextureInformation.Name);
|
||||
this.UpgradeLevel = (dataBase as Serialization_ExtendedWateringCan).UpgradeLevel;
|
||||
this.waterCanMax= (dataBase as Serialization_ExtendedWateringCan).MaxCapacity;
|
||||
this.WaterLeft= (dataBase as Serialization_ExtendedWateringCan).WaterLeft;
|
||||
|
|
|
@ -89,6 +89,8 @@
|
|||
<Compile Include="Interfaces\IToolSerializer.cs" />
|
||||
<Compile Include="Math\Hex.cs" />
|
||||
<Compile Include="Math\Hex32.cs" />
|
||||
<Compile Include="Objects\MultiTileComponent.cs" />
|
||||
<Compile Include="Objects\MultiTileObject.cs" />
|
||||
<Compile Include="Objects\Tools\BasicToolInfo.cs" />
|
||||
<Compile Include="Objects\Tools\ExtendedAxe.cs" />
|
||||
<Compile Include="Objects\Tools\ExtendedHoe.cs" />
|
||||
|
@ -422,6 +424,15 @@
|
|||
</Content>
|
||||
<Content Include="Content\Graphics\Icons\Prismatic Star Big.png" />
|
||||
<Content Include="Content\Graphics\Icons\Prismatic Star.png" />
|
||||
<Content Include="Content\Graphics\MultiTest\Test1.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\MultiTest\Test2.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\MultiTest\Test3.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Content\Graphics\Tools\CustomAxe.png">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
|
|
|
@ -116,6 +116,10 @@ namespace StardustCore
|
|||
// cObj.health = 10;
|
||||
if (who != null)
|
||||
{
|
||||
if (cObj == null)
|
||||
{
|
||||
StardustCore.ModCore.ModMonitor.Log("WHY IS MY COMPONENT NULL???");
|
||||
}
|
||||
cObj.owner.Value = who.UniqueMultiplayerID;
|
||||
}
|
||||
else
|
||||
|
@ -267,7 +271,7 @@ namespace StardustCore
|
|||
}
|
||||
if (!cObj.performDropDownAction(who))
|
||||
{
|
||||
CoreObject @object = (CoreObject)cObj.getOne();
|
||||
CoreObject @object = cObj;
|
||||
@object.shakeTimer = 50;
|
||||
@object.TileLocation = vector;
|
||||
@object.performDropDownAction(who);
|
||||
|
@ -305,7 +309,6 @@ namespace StardustCore
|
|||
}
|
||||
|
||||
|
||||
|
||||
public static bool addItemToInventoryAndCleanTrackedList(CoreObject I,Serialization.SerializationManager s)
|
||||
{
|
||||
if (Game1.player.isInventoryFull() == false)
|
||||
|
@ -463,6 +466,8 @@ namespace StardustCore
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether or not the net inventory list is full of items.
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue