2018-12-21 05:34:08 +08:00
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
using Microsoft.Xna.Framework.Graphics;
|
2018-12-21 05:54:00 +08:00
|
|
|
|
using Microsoft.Xna.Framework.Input;
|
2018-12-21 05:34:08 +08:00
|
|
|
|
using PyTK.CustomElementHandler;
|
|
|
|
|
using Revitalize.Framework.Graphics;
|
|
|
|
|
using StardewValley;
|
|
|
|
|
using StardewValley.Objects;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Revitalize.Framework.Objects
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Change draw functions.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class CustomObject : PySObject
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public string id;
|
|
|
|
|
public Texture2DExtended texture;
|
|
|
|
|
public BasicItemInformation info;
|
|
|
|
|
public Texture2D displayTexture
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return texture.texture;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CustomObject()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CustomObject(BasicItemInformation info):base(info,Vector2.Zero)
|
|
|
|
|
{
|
|
|
|
|
this.info = info;
|
|
|
|
|
this.initializeBasics();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CustomObject(BasicItemInformation info,Vector2 TileLocation) : base(info, TileLocation)
|
|
|
|
|
{
|
|
|
|
|
this.info = info;
|
|
|
|
|
this.initializeBasics();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void initializeBasics()
|
|
|
|
|
{
|
|
|
|
|
this.name = info.name;
|
|
|
|
|
this.displayName = getDisplayNameFromStringsFile(this.id);
|
|
|
|
|
this.Edibility = info.edibility;
|
|
|
|
|
this.Category = -9; //For crafting.
|
|
|
|
|
this.displayName = info.name;
|
|
|
|
|
this.setOutdoors.Value = true;
|
|
|
|
|
this.setIndoors.Value = true;
|
|
|
|
|
this.isLamp.Value = false;
|
|
|
|
|
this.fragility.Value = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool checkForAction(Farmer who, bool justCheckingForActivity = false)
|
|
|
|
|
{
|
2018-12-21 05:54:00 +08:00
|
|
|
|
var mState = Microsoft.Xna.Framework.Input.Mouse.GetState();
|
|
|
|
|
var keyboardState = Game1.GetKeyboardState();
|
|
|
|
|
|
|
|
|
|
if (mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift))==false)
|
|
|
|
|
{
|
|
|
|
|
Revitalize.ModCore.log("Right clicked!");
|
|
|
|
|
return rightClicked(who);
|
|
|
|
|
}
|
|
|
|
|
else if(mState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && (keyboardState.IsKeyDown(Keys.LeftShift) || keyboardState.IsKeyDown(Keys.RightShift)))
|
|
|
|
|
{
|
|
|
|
|
return shiftRightClicked(who);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-21 05:34:08 +08:00
|
|
|
|
if (justCheckingForActivity)
|
2018-12-21 05:54:00 +08:00
|
|
|
|
{
|
2018-12-21 05:34:08 +08:00
|
|
|
|
return true;
|
2018-12-21 05:54:00 +08:00
|
|
|
|
}
|
|
|
|
|
Revitalize.ModCore.log("Left clicked!");
|
|
|
|
|
return this.clicked(who);
|
2018-12-21 05:34:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override ICustomObject recreate(Dictionary<string, string> additionalSaveData, object replacement)
|
|
|
|
|
{
|
|
|
|
|
BasicItemInformation data =(BasicItemInformation) CustomObjectData.collection[additionalSaveData["id"]];
|
|
|
|
|
return new CustomObject((BasicItemInformation) CustomObjectData.collection[additionalSaveData["id"]], (replacement as Chest).TileLocation);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-12-21 05:54:00 +08:00
|
|
|
|
public virtual bool rightClicked(Farmer who)
|
|
|
|
|
{
|
|
|
|
|
// Game1.showRedMessage("YOOO");
|
|
|
|
|
//do some stuff when the right button is down
|
|
|
|
|
// rotate();
|
|
|
|
|
if (this.heldObject.Value != null)
|
|
|
|
|
{
|
|
|
|
|
// Game1.player.addItemByMenuIfNecessary(this.heldObject);
|
|
|
|
|
// this.heldObject = null;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// this.heldObject = Game1.player.ActiveObject;
|
|
|
|
|
// Game1.player.removeItemFromInventory(heldObject);
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool shiftRightClicked(Farmer who)
|
|
|
|
|
{
|
|
|
|
|
Revitalize.ModCore.log("Shift right clicked!");
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool clicked(Farmer who)
|
|
|
|
|
{
|
|
|
|
|
Revitalize.ModCore.log("Clicky click!");
|
|
|
|
|
return base.clicked(who);
|
|
|
|
|
}
|
|
|
|
|
|
2018-12-21 05:34:08 +08:00
|
|
|
|
public override Color getCategoryColor()
|
|
|
|
|
{
|
|
|
|
|
return info.categoryColor;
|
|
|
|
|
//return data.categoryColor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string getCategoryName()
|
|
|
|
|
{
|
|
|
|
|
return info.categoryName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string getDescription()
|
|
|
|
|
{
|
|
|
|
|
string text = info.description;
|
|
|
|
|
SpriteFont smallFont = Game1.smallFont;
|
|
|
|
|
int width = Game1.tileSize * 4 + Game1.tileSize / 4;
|
|
|
|
|
return Game1.parseText(text, smallFont, width);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override Item getOne()
|
|
|
|
|
{
|
|
|
|
|
return new CustomObject((BasicItemInformation)this.data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
|
|
|
|
|
{
|
|
|
|
|
base.draw(spriteBatch, x, y, alpha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
|
|
|
|
|
{
|
|
|
|
|
base.draw(spriteBatch, xNonTile, yNonTile, layerDepth, alpha);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void drawAsProp(SpriteBatch b)
|
|
|
|
|
{
|
|
|
|
|
base.drawAsProp(b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void drawAttachments(SpriteBatch b, int x, int y)
|
|
|
|
|
{
|
|
|
|
|
base.drawAttachments(b, x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber, Color color, bool drawShadow)
|
|
|
|
|
{
|
|
|
|
|
base.drawInMenu(spriteBatch, location, scaleSize, transparency, layerDepth, drawStackNumber, color, drawShadow);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
|
|
|
|
|
{
|
|
|
|
|
base.drawPlacementBounds(spriteBatch, location);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
|
|
|
|
|
{
|
|
|
|
|
base.drawWhenHeld(spriteBatch, objectPosition, f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public string getDisplayNameFromStringsFile(string objectID)
|
|
|
|
|
{
|
|
|
|
|
//Load in a file that has all object names referenced here or something.
|
|
|
|
|
return info.name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|