summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGormogon <Gormogon@users.noreply.github.com>2016-05-29 16:13:24 -0400
committerGormogon <Gormogon@users.noreply.github.com>2016-05-29 16:13:24 -0400
commit625f9c89e4db470c0325b5d148c5286c1b5e54eb (patch)
tree31076fbf57cbbc993abca39eef7bc48762505754
parent9503dfb94b432b1e6e268dc415327eec507a70c2 (diff)
downloadSMAPI-625f9c89e4db470c0325b5d148c5286c1b5e54eb.tar.gz
SMAPI-625f9c89e4db470c0325b5d148c5286c1b5e54eb.tar.bz2
SMAPI-625f9c89e4db470c0325b5d148c5286c1b5e54eb.zip
Take advantage of some new language opportunities.
-rw-r--r--StardewModdingAPI/Inheritance/Menus/SBobberBar.cs8
-rw-r--r--StardewModdingAPI/Inheritance/Menus/SGameMenu.cs3
-rw-r--r--StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs3
-rw-r--r--StardewModdingAPI/Inheritance/SGame.cs13
-rw-r--r--StardewModdingAPI/Inheritance/SObject.cs34
-rw-r--r--StardewModdingAPI/ModItem.cs5
-rw-r--r--StardewModdingAPI/Program.cs13
-rw-r--r--TrainerMod/TrainerMod.cs3
8 files changed, 33 insertions, 49 deletions
diff --git a/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs b/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs
index 5f410280..1e424f73 100644
--- a/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs
+++ b/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs
@@ -267,15 +267,11 @@ namespace StardewModdingAPI.Inheritance.Menus
set { GetBaseFieldInfo("bobberBarAcceleration").SetValue(BaseBobberBar, value); }
}
- public static FieldInfo[] PrivateFields
- {
- get { return GetPrivateFields(); }
- }
+ public static FieldInfo[] PrivateFields => GetPrivateFields();
public static SBobberBar ConstructFromBaseClass(BobberBar baseClass)
{
- var b = new SBobberBar(0, 0, false, 0);
- b.BaseBobberBar = baseClass;
+ var b = new SBobberBar(0, 0, false, 0) {BaseBobberBar = baseClass};
return b;
}
diff --git a/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs b/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs
index 7264faac..a4d3d8d0 100644
--- a/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs
+++ b/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs
@@ -22,8 +22,7 @@ namespace StardewModdingAPI.Inheritance.Menus
public static SGameMenu ConstructFromBaseClass(GameMenu baseClass)
{
- var s = new SGameMenu();
- s.BaseGameMenu = baseClass;
+ var s = new SGameMenu {BaseGameMenu = baseClass};
return s;
}
diff --git a/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs b/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs
index a51b2d71..436b834d 100644
--- a/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs
+++ b/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs
@@ -12,8 +12,7 @@ namespace StardewModdingAPI.Inheritance.Menus
public static SInventoryPage ConstructFromBaseClass(InventoryPage baseClass)
{
- var s = new SInventoryPage(0, 0, 0, 0);
- s.BaseInventoryPage = baseClass;
+ var s = new SInventoryPage(0, 0, 0, 0) {BaseInventoryPage = baseClass};
return s;
}
}
diff --git a/StardewModdingAPI/Inheritance/SGame.cs b/StardewModdingAPI/Inheritance/SGame.cs
index 5597e463..9b69434a 100644
--- a/StardewModdingAPI/Inheritance/SGame.cs
+++ b/StardewModdingAPI/Inheritance/SGame.cs
@@ -506,8 +506,7 @@ namespace StardewModdingAPI.Inheritance
//this.checkForEscapeKeys();
updateMusic();
updateRaindropPosition();
- if (bloom != null)
- bloom.tick(gameTime);
+ bloom?.tick(gameTime);
if (globalFade)
{
if (!dialogueUp)
@@ -559,8 +558,7 @@ namespace StardewModdingAPI.Inheritance
if (pauseThenDoFunctionTimer <= 0)
{
freezeControls = false;
- if (afterPause != null)
- afterPause();
+ afterPause?.Invoke();
}
}
if (gameMode == 3 || gameMode == 2)
@@ -657,8 +655,8 @@ namespace StardewModdingAPI.Inheritance
currentMinigame.releaseLeftClick(getMouseX(), getMouseY());
foreach (Buttons b in Utility.getPressedButtons(oldPadState, state3))
currentMinigame.receiveKeyRelease(Utility.mapGamePadButtonToKey(b));
- if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && currentMinigame != null)
- currentMinigame.leftClickHeld(0, 0);
+ if (state3.IsConnected && state3.IsButtonDown(Buttons.A))
+ currentMinigame?.leftClickHeld(0, 0);
}
if (currentMinigame == null)
{
@@ -774,8 +772,7 @@ namespace StardewModdingAPI.Inheritance
if (gameMode == 10)
UpdateOther(gameTime);
}
- if (audioEngine != null)
- audioEngine.Update();
+ audioEngine?.Update();
if (multiplayerMode == 2 && gameMode == 3)
server.sendMessages(gameTime);
}
diff --git a/StardewModdingAPI/Inheritance/SObject.cs b/StardewModdingAPI/Inheritance/SObject.cs
index 9ffe2a85..639b85b1 100644
--- a/StardewModdingAPI/Inheritance/SObject.cs
+++ b/StardewModdingAPI/Inheritance/SObject.cs
@@ -181,22 +181,24 @@ namespace StardewModdingAPI.Inheritance
public SObject Clone()
{
- var toRet = new SObject();
-
- toRet.Name = Name;
- toRet.CategoryName = CategoryName;
- toRet.Description = Description;
- toRet.Texture = Texture;
- toRet.IsPassable = IsPassable;
- toRet.IsPlaceable = IsPlaceable;
- toRet.quality = quality;
- toRet.scale = scale;
- toRet.isSpawnedObject = isSpawnedObject;
- toRet.isRecipe = isRecipe;
- toRet.questItem = questItem;
- toRet.stack = 1;
- toRet.HasBeenRegistered = HasBeenRegistered;
- toRet.RegisteredId = RegisteredId;
+ 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,
+ stack = 1,
+ HasBeenRegistered = HasBeenRegistered,
+ RegisteredId = RegisteredId
+ };
+
return toRet;
}
diff --git a/StardewModdingAPI/ModItem.cs b/StardewModdingAPI/ModItem.cs
index 10c4fde4..cf2e10b2 100644
--- a/StardewModdingAPI/ModItem.cs
+++ b/StardewModdingAPI/ModItem.cs
@@ -5,10 +5,7 @@ namespace StardewModdingAPI
{
internal class ModItem : Object
{
- public Item AsItem
- {
- get { return this; }
- }
+ public Item AsItem => this;
public override string Name { get; set; }
public string Description { get; set; }
diff --git a/StardewModdingAPI/Program.cs b/StardewModdingAPI/Program.cs
index 60e6efb4..35963b08 100644
--- a/StardewModdingAPI/Program.cs
+++ b/StardewModdingAPI/Program.cs
@@ -89,25 +89,23 @@ namespace StardewModdingAPI
{
Log.AsyncY("Validating api paths...");
- _modPaths = new List<string>();
+ _modPaths = new List<string> {Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods"), Path.Combine(Constants.ExecutionPath, "Mods")};
//_modContentPaths = new List<string>();
//TODO: Have an app.config and put the paths inside it so users can define locations to load mods from
- _modPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods"));
- _modPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods"));
//Mods need to make their own content paths, since we're doing a different, manifest-driven, approach.
//_modContentPaths.Add(Path.Combine(Constants.ExecutionPath, "Mods", "Content"));
//_modContentPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods", "Content"));
//Checks that all defined modpaths exist as directories
- _modPaths.ForEach(path => VerifyPath(path));
+ _modPaths.ForEach(VerifyPath);
//_modContentPaths.ForEach(path => VerifyPath(path));
VerifyPath(Constants.LogDir);
if (!File.Exists(Constants.ExecutionPath + "\\Stardew Valley.exe"))
{
- throw new FileNotFoundException(string.Format("Could not found: {0}\\Stardew Valley.exe", Constants.ExecutionPath));
+ throw new FileNotFoundException($"Could not found: {Constants.ExecutionPath}\\Stardew Valley.exe");
}
}
@@ -440,10 +438,7 @@ namespace StardewModdingAPI
Log.AsyncR("The command specified could not be found");
else
{
- if (fnd.CommandArgs.Length > 0)
- Log.AsyncY($"{fnd.CommandName}: {fnd.CommandDesc} - {fnd.CommandArgs.ToSingular()}");
- else
- Log.AsyncY($"{fnd.CommandName}: {fnd.CommandDesc}");
+ Log.AsyncY(fnd.CommandArgs.Length > 0 ? $"{fnd.CommandName}: {fnd.CommandDesc} - {fnd.CommandArgs.ToSingular()}" : $"{fnd.CommandName}: {fnd.CommandDesc}");
}
}
else
diff --git a/TrainerMod/TrainerMod.cs b/TrainerMod/TrainerMod.cs
index 91db4c88..da5365cb 100644
--- a/TrainerMod/TrainerMod.cs
+++ b/TrainerMod/TrainerMod.cs
@@ -629,8 +629,7 @@ namespace TrainerMod
}
}
- var o = new Object(e.Command.CalledArgs[0].AsInt32(), count);
- o.quality = quality;
+ var o = new Object(e.Command.CalledArgs[0].AsInt32(), count) {quality = quality};
Game1.player.addItemByMenuIfNecessary(o);
}