Stardew_Valley_Mods/GeneralMods/Revitalize/Framework/Objects/BasicItemInformation.cs

118 lines
4.1 KiB
C#
Raw Normal View History

using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using PyTK.CustomElementHandler;
using StardustCore.Animations;
using Revitalize.Framework.Illuminate;
using Revitalize.Framework.Utilities;
2019-01-10 18:31:23 +08:00
using StardewValley;
using StardustCore.UIUtilities;
namespace Revitalize.Framework.Objects
{
public class BasicItemInformation
{
public string name;
public string id;
public string description;
public string categoryName;
public Color categoryColor;
public int price;
public int edibility;
public int fragility;
public bool canBeSetIndoors;
public bool canBeSetOutdoors;
public bool isLamp;
2019-01-10 18:31:23 +08:00
public AnimationManager animationManager;
public Vector2 drawPosition;
2018-12-23 14:55:03 +08:00
public Color drawColor;
public bool ignoreBoundingBox;
public InventoryManager inventory;
public LightManager lightManager;
public Enums.Direction facingDirection;
2019-08-17 03:39:27 +08:00
public int shakeTimer;
public BasicItemInformation()
{
this.name = "";
this.description = "";
this.categoryName = "";
this.categoryColor = new Color(0, 0, 0);
this.price = 0;
this.edibility = -300;
this.canBeSetIndoors = false;
this.canBeSetOutdoors = false;
this.animationManager = new AnimationManager();
this.drawPosition = Vector2.Zero;
2018-12-23 14:55:03 +08:00
this.drawColor = Color.White;
this.inventory = new InventoryManager();
this.lightManager = new LightManager();
this.facingDirection = Enums.Direction.Down;
this.id = "";
2019-08-17 03:39:27 +08:00
this.shakeTimer = 0;
2019-01-10 18:31:23 +08:00
}
public BasicItemInformation(string name, string id, string description, string categoryName, Color categoryColor,int edibility, int fragility, bool isLamp, int price, bool canBeSetOutdoors, bool canBeSetIndoors, Texture2D texture, AnimationManager animationManager, Color drawColor, bool ignoreBoundingBox, InventoryManager Inventory, LightManager Lights)
{
this.name = name;
this.id = id;
this.description = description;
this.categoryName = categoryName;
this.categoryColor = categoryColor;
this.price = price;
this.edibility = edibility;
this.canBeSetOutdoors = canBeSetOutdoors;
this.canBeSetIndoors = canBeSetIndoors;
this.fragility = fragility;
this.isLamp = isLamp;
this.animationManager = animationManager;
if (this.animationManager.IsNull)
{
this.animationManager = new AnimationManager(new Texture2DExtended(), new Animation(new Rectangle(0, 0, 16, 16)), false);
this.animationManager.getExtendedTexture().texture = texture;
}
this.drawPosition = Vector2.Zero;
this.drawColor = drawColor;
this.ignoreBoundingBox = ignoreBoundingBox;
this.inventory = Inventory ?? new InventoryManager();
this.lightManager = Lights ?? new LightManager();
this.facingDirection = Enums.Direction.Down;
2019-08-17 03:39:27 +08:00
this.shakeTimer = 0;
}
2019-08-17 03:39:27 +08:00
/// <summary>
/// Gets an x offset for shaking an object. Source code used from game.
/// </summary>
/// <returns></returns>
public int shakeTimerOffset()
{
return (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0);
}
/// <summary>
/// Returns a copy of this object.
/// </summary>
/// <returns></returns>
public BasicItemInformation Copy()
{
return new BasicItemInformation(this.name, this.id,this.description, this.categoryName, this.categoryColor, this.edibility, this.fragility, this.isLamp, this.price, this.canBeSetOutdoors, this.canBeSetIndoors, this.animationManager.getTexture(), this.animationManager, this.drawColor, this.ignoreBoundingBox, this.inventory.Copy(), this.lightManager.Copy());
}
}
}