summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/StardewModdingAPI/Inheritance/SObject.cs96
-rw-r--r--src/StardewModdingAPI/Manifest.cs2
-rw-r--r--src/StardewModdingAPI/Mod.cs15
-rw-r--r--src/StardewModdingAPI/ModHelper.cs2
-rw-r--r--src/StardewModdingAPI/Program.cs2
-rw-r--r--src/TrainerMod/TrainerMod.cs2
6 files changed, 60 insertions, 59 deletions
diff --git a/src/StardewModdingAPI/Inheritance/SObject.cs b/src/StardewModdingAPI/Inheritance/SObject.cs
index a90ed624..4a218f33 100644
--- a/src/StardewModdingAPI/Inheritance/SObject.cs
+++ b/src/StardewModdingAPI/Inheritance/SObject.cs
@@ -40,8 +40,8 @@ namespace StardewModdingAPI.Inheritance
public override int Stack
{
- get { return stack; }
- set { stack = value; }
+ get { return this.stack; }
+ set { this.stack = value; }
}
/*********
@@ -51,35 +51,35 @@ namespace StardewModdingAPI.Inheritance
{
Program.DeprecationManager.Warn(nameof(SObject), "0.39.3", DeprecationLevel.Notice);
- name = "Modded Item Name";
- Description = "Modded Item Description";
- CategoryName = "Modded Item Category";
- Category = 4163;
- CategoryColour = Color.White;
- IsPassable = false;
- IsPlaceable = false;
- boundingBox = new Rectangle(0, 0, 64, 64);
- MaxStackSize = 999;
+ this.name = "Modded Item Name";
+ this.Description = "Modded Item Description";
+ this.CategoryName = "Modded Item Category";
+ this.Category = 4163;
+ this.CategoryColour = Color.White;
+ this.IsPassable = false;
+ this.IsPlaceable = false;
+ this.boundingBox = new Rectangle(0, 0, 64, 64);
+ this.MaxStackSize = 999;
- type = "interactive";
+ this.type = "interactive";
}
public override string Name
{
- get { return name; }
- set { name = value; }
+ get { return this.name; }
+ set { this.name = value; }
}
public override string getDescription()
{
- return Description;
+ return this.Description;
}
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
{
- if (Texture != null)
+ if (this.Texture != null)
{
- spriteBatch.Draw(Texture, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * Game1.tileSize + Game1.tileSize / 2 + (shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0), y * Game1.tileSize + Game1.tileSize / 2 + (shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0))), Game1.currentLocation.getSourceRectForObject(ParentSheetIndex), Color.White * alpha, 0f, new Vector2(8f, 8f), scale.Y > 1f ? getScale().Y : Game1.pixelZoom, flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (isPassable() ? getBoundingBox(new Vector2(x, y)).Top : getBoundingBox(new Vector2(x, y)).Bottom) / 10000f);
+ spriteBatch.Draw(this.Texture, Game1.GlobalToLocal(Game1.viewport, new Vector2(x * Game1.tileSize + Game1.tileSize / 2 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0), y * Game1.tileSize + Game1.tileSize / 2 + (this.shakeTimer > 0 ? Game1.random.Next(-1, 2) : 0))), Game1.currentLocation.getSourceRectForObject(this.ParentSheetIndex), Color.White * alpha, 0f, new Vector2(8f, 8f), this.scale.Y > 1f ? this.getScale().Y : Game1.pixelZoom, this.flipped ? SpriteEffects.FlipHorizontally : SpriteEffects.None, (this.isPassable() ? this.getBoundingBox(new Vector2(x, y)).Top : this.getBoundingBox(new Vector2(x, y)).Bottom) / 10000f);
}
}
@@ -89,13 +89,13 @@ namespace StardewModdingAPI.Inheritance
public override void drawInMenu(SpriteBatch spriteBatch, Vector2 location, float scaleSize, float transparency, float layerDepth, bool drawStackNumber)
{
- if (isRecipe)
+ if (this.isRecipe)
{
transparency = 0.5f;
scaleSize *= 0.75f;
}
- if (Texture != null)
+ if (this.Texture != null)
{
var targSize = (int) (64 * scaleSize * 0.9f);
var midX = (int) (location.X + 32);
@@ -104,18 +104,18 @@ namespace StardewModdingAPI.Inheritance
var targX = midX - targSize / 2;
var targY = midY - targSize / 2;
- spriteBatch.Draw(Texture, new Rectangle(targX, targY, targSize, targSize), null, new Color(255, 255, 255, transparency), 0, Vector2.Zero, SpriteEffects.None, layerDepth);
+ spriteBatch.Draw(this.Texture, new Rectangle(targX, targY, targSize, targSize), null, new Color(255, 255, 255, transparency), 0, Vector2.Zero, SpriteEffects.None, layerDepth);
}
if (drawStackNumber)
{
var _scale = 0.5f + scaleSize;
- Game1.drawWithBorder(stack.ToString(), Color.Black, Color.White, location + new Vector2(Game1.tileSize - Game1.tinyFont.MeasureString(string.Concat(stack.ToString())).X * _scale, Game1.tileSize - (float) ((double) Game1.tinyFont.MeasureString(string.Concat(stack.ToString())).Y * 3.0f / 4.0f) * _scale), 0.0f, _scale, 1f, true);
+ Game1.drawWithBorder(this.stack.ToString(), Color.Black, Color.White, location + new Vector2(Game1.tileSize - Game1.tinyFont.MeasureString(string.Concat(this.stack.ToString())).X * _scale, Game1.tileSize - (float) ((double) Game1.tinyFont.MeasureString(string.Concat(this.stack.ToString())).Y * 3.0f / 4.0f) * _scale), 0.0f, _scale, 1f, true);
}
}
public override void drawWhenHeld(SpriteBatch spriteBatch, Vector2 objectPosition, Farmer f)
{
- if (Texture != null)
+ if (this.Texture != null)
{
var targSize = 64;
var midX = (int) (objectPosition.X + 32);
@@ -124,55 +124,55 @@ namespace StardewModdingAPI.Inheritance
var targX = midX - targSize / 2;
var targY = midY - targSize / 2;
- spriteBatch.Draw(Texture, new Rectangle(targX, targY, targSize, targSize), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (f.getStandingY() + 2) / 10000f);
+ spriteBatch.Draw(this.Texture, new Rectangle(targX, targY, targSize, targSize), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, (f.getStandingY() + 2) / 10000f);
}
}
public override Color getCategoryColor()
{
- return CategoryColour;
+ return this.CategoryColour;
}
public override string getCategoryName()
{
- if (string.IsNullOrEmpty(CategoryName))
+ if (string.IsNullOrEmpty(this.CategoryName))
return "Modded Item";
- return CategoryName;
+ return this.CategoryName;
}
public override bool isPassable()
{
- return IsPassable;
+ return this.IsPassable;
}
public override bool isPlaceable()
{
- return IsPlaceable;
+ return this.IsPlaceable;
}
public override int maximumStackSize()
{
- return MaxStackSize;
+ return this.MaxStackSize;
}
public SObject Clone()
{
var toRet = new SObject
{
- Name = Name,
- CategoryName = CategoryName,
- Description = Description,
- Texture = Texture,
- IsPassable = IsPassable,
- IsPlaceable = IsPlaceable,
- quality = quality,
- scale = scale,
- isSpawnedObject = isSpawnedObject,
- isRecipe = isRecipe,
- questItem = questItem,
+ Name = this.Name,
+ CategoryName = this.CategoryName,
+ Description = this.Description,
+ Texture = this.Texture,
+ IsPassable = this.IsPassable,
+ IsPlaceable = this.IsPlaceable,
+ quality = this.quality,
+ scale = this.scale,
+ isSpawnedObject = this.isSpawnedObject,
+ isRecipe = this.isRecipe,
+ questItem = this.questItem,
stack = 1,
- HasBeenRegistered = HasBeenRegistered,
- RegisteredId = RegisteredId
+ HasBeenRegistered = this.HasBeenRegistered,
+ RegisteredId = this.RegisteredId
};
@@ -181,7 +181,7 @@ namespace StardewModdingAPI.Inheritance
public override Item getOne()
{
- return Clone();
+ return this.Clone();
}
public override void actionWhenBeingHeld(Farmer who)
@@ -192,7 +192,7 @@ namespace StardewModdingAPI.Inheritance
x = x / Game1.tileSize;
y = y / Game1.tileSize;
- CurrentMouse = new Vector2(x, y);
+ this.CurrentMouse = new Vector2(x, y);
//Program.LogDebug(canBePlacedHere(Game1.currentLocation, CurrentMouse));
base.actionWhenBeingHeld(who);
}
@@ -216,13 +216,13 @@ namespace StardewModdingAPI.Inheritance
var key = new Vector2(x, y);
- if (!canBePlacedHere(location, key))
+ if (!this.canBePlacedHere(location, key))
return false;
- var s = Clone();
+ var s = this.Clone();
s.PlacedAt = key;
- s.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, boundingBox.Width, boundingBox.Height);
+ s.boundingBox = new Rectangle(x / Game1.tileSize * Game1.tileSize, y / Game1.tileSize * Game1.tileSize, this.boundingBox.Width, this.boundingBox.Height);
location.objects.Add(key, s);
@@ -236,7 +236,7 @@ namespace StardewModdingAPI.Inheritance
public override void drawPlacementBounds(SpriteBatch spriteBatch, GameLocation location)
{
- if (canBePlacedHere(location, CurrentMouse))
+ if (this.canBePlacedHere(location, this.CurrentMouse))
{
var targSize = Game1.tileSize;
diff --git a/src/StardewModdingAPI/Manifest.cs b/src/StardewModdingAPI/Manifest.cs
index c7e54335..bfc66c43 100644
--- a/src/StardewModdingAPI/Manifest.cs
+++ b/src/StardewModdingAPI/Manifest.cs
@@ -41,7 +41,7 @@ namespace StardewModdingAPI
public virtual string UniqueID { get; set; } = Guid.NewGuid().ToString();
/// <summary>Whether the mod uses per-save config files.</summary>
- [Obsolete("Use " + nameof(Mod) + "." + nameof(Mod.Helper) + "." + nameof(ModHelper.ReadConfig) + " instead")]
+ [Obsolete("Use " + nameof(Mod) + "." + nameof(Mod.Helper) + "." + nameof(IModHelper.ReadConfig) + " instead")]
public virtual bool PerSaveConfigs { get; set; }
/// <summary>The minimum SMAPI version required by this mod, if any.</summary>
diff --git a/src/StardewModdingAPI/Mod.cs b/src/StardewModdingAPI/Mod.cs
index c2a755b0..23002c1f 100644
--- a/src/StardewModdingAPI/Mod.cs
+++ b/src/StardewModdingAPI/Mod.cs
@@ -31,7 +31,7 @@ namespace StardewModdingAPI
{
get
{
- Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(PathOnDisk)}", "1.0", DeprecationLevel.Notice);
+ Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0", DeprecationLevel.Notice);
return this._pathOnDisk;
}
internal set { this._pathOnDisk = value; }
@@ -43,8 +43,8 @@ namespace StardewModdingAPI
{
get
{
- Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(BaseConfigPath)}", "1.0", DeprecationLevel.Notice);
- Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(PathOnDisk)}", "1.0"); // avoid redundant warnings
+ Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.BaseConfigPath)}", "1.0", DeprecationLevel.Notice);
+ Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0"); // avoid redundant warnings
return Path.Combine(this.PathOnDisk, "config.json");
}
}
@@ -59,8 +59,8 @@ namespace StardewModdingAPI
{
get
{
- Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(PerSaveConfigPath)}", "1.0", DeprecationLevel.Notice);
- Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(PerSaveConfigFolder)}", "1.0"); // avoid redundant warnings
+ Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigPath)}", "1.0", DeprecationLevel.Notice);
+ Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigFolder)}", "1.0"); // avoid redundant warnings
return Constants.CurrentSavePathExists ? Path.Combine(this.PerSaveConfigFolder, Constants.SaveFolderName + ".json") : "";
}
}
@@ -87,10 +87,11 @@ namespace StardewModdingAPI
** Private methods
*********/
/// <summary>Get the full path to the per-save configuration file for the current save (if <see cref="StardewModdingAPI.Manifest.PerSaveConfigs"/> is <c>true</c>).</summary>
+ [Obsolete]
private string GetPerSaveConfigFolder()
{
- Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(PerSaveConfigFolder)}", "1.0", DeprecationLevel.Notice);
- Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(PathOnDisk)}", "1.0"); // avoid redundant warnings
+ Program.DeprecationManager.Warn($"{nameof(Mod)}.{nameof(Mod.PerSaveConfigFolder)}", "1.0", DeprecationLevel.Notice);
+ Program.DeprecationManager.MarkWarned($"{nameof(Mod)}.{nameof(Mod.PathOnDisk)}", "1.0"); // avoid redundant warnings
if (!this.Manifest.PerSaveConfigs)
{
diff --git a/src/StardewModdingAPI/ModHelper.cs b/src/StardewModdingAPI/ModHelper.cs
index 29ae1280..6a7e200a 100644
--- a/src/StardewModdingAPI/ModHelper.cs
+++ b/src/StardewModdingAPI/ModHelper.cs
@@ -6,7 +6,7 @@ using StardewModdingAPI.Advanced;
namespace StardewModdingAPI
{
/// <summary>Provides methods for interacting with a mod directory.</summary>
- [Obsolete("Use " + nameof(IModHelper) + "instead.")]
+ [Obsolete("Use " + nameof(IModHelper) + " instead.")]
public class ModHelper : IModHelper
{
/*********
diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs
index e60fb6b2..4268a944 100644
--- a/src/StardewModdingAPI/Program.cs
+++ b/src/StardewModdingAPI/Program.cs
@@ -299,7 +299,7 @@ namespace StardewModdingAPI
return;
}
- ModHelper helper = new ModHelper(directory);
+ IModHelper helper = new ModHelper(directory);
string errorPrefix = $"Couldn't load mod for manifest '{manifestPath}'";
// read manifest
diff --git a/src/TrainerMod/TrainerMod.cs b/src/TrainerMod/TrainerMod.cs
index 61b36685..2409e6b4 100644
--- a/src/TrainerMod/TrainerMod.cs
+++ b/src/TrainerMod/TrainerMod.cs
@@ -40,7 +40,7 @@ namespace TrainerMod
*********/
/// <summary>The entry point for your mod. It will always be called once when the mod loads.</summary>
/// <param name="helper">Provides methods for interacting with the mod directory, such as read/writing a config file or custom JSON files.</param>
- public override void Entry(ModHelper helper)
+ public override void Entry(IModHelper helper)
{
this.RegisterCommands();
GameEvents.UpdateTick += this.ReceiveUpdateTick;