Take advantage of some new language opportunities.

This commit is contained in:
Gormogon 2016-05-29 16:13:24 -04:00
parent 9503dfb94b
commit 625f9c89e4
8 changed files with 32 additions and 48 deletions

View File

@ -267,15 +267,11 @@ namespace StardewModdingAPI.Inheritance.Menus
set { GetBaseFieldInfo("bobberBarAcceleration").SetValue(BaseBobberBar, value); } set { GetBaseFieldInfo("bobberBarAcceleration").SetValue(BaseBobberBar, value); }
} }
public static FieldInfo[] PrivateFields public static FieldInfo[] PrivateFields => GetPrivateFields();
{
get { return GetPrivateFields(); }
}
public static SBobberBar ConstructFromBaseClass(BobberBar baseClass) public static SBobberBar ConstructFromBaseClass(BobberBar baseClass)
{ {
var b = new SBobberBar(0, 0, false, 0); var b = new SBobberBar(0, 0, false, 0) {BaseBobberBar = baseClass};
b.BaseBobberBar = baseClass;
return b; return b;
} }

View File

@ -22,8 +22,7 @@ namespace StardewModdingAPI.Inheritance.Menus
public static SGameMenu ConstructFromBaseClass(GameMenu baseClass) public static SGameMenu ConstructFromBaseClass(GameMenu baseClass)
{ {
var s = new SGameMenu(); var s = new SGameMenu {BaseGameMenu = baseClass};
s.BaseGameMenu = baseClass;
return s; return s;
} }

View File

@ -12,8 +12,7 @@ namespace StardewModdingAPI.Inheritance.Menus
public static SInventoryPage ConstructFromBaseClass(InventoryPage baseClass) public static SInventoryPage ConstructFromBaseClass(InventoryPage baseClass)
{ {
var s = new SInventoryPage(0, 0, 0, 0); var s = new SInventoryPage(0, 0, 0, 0) {BaseInventoryPage = baseClass};
s.BaseInventoryPage = baseClass;
return s; return s;
} }
} }

View File

@ -506,8 +506,7 @@ namespace StardewModdingAPI.Inheritance
//this.checkForEscapeKeys(); //this.checkForEscapeKeys();
updateMusic(); updateMusic();
updateRaindropPosition(); updateRaindropPosition();
if (bloom != null) bloom?.tick(gameTime);
bloom.tick(gameTime);
if (globalFade) if (globalFade)
{ {
if (!dialogueUp) if (!dialogueUp)
@ -559,8 +558,7 @@ namespace StardewModdingAPI.Inheritance
if (pauseThenDoFunctionTimer <= 0) if (pauseThenDoFunctionTimer <= 0)
{ {
freezeControls = false; freezeControls = false;
if (afterPause != null) afterPause?.Invoke();
afterPause();
} }
} }
if (gameMode == 3 || gameMode == 2) if (gameMode == 3 || gameMode == 2)
@ -657,8 +655,8 @@ namespace StardewModdingAPI.Inheritance
currentMinigame.releaseLeftClick(getMouseX(), getMouseY()); currentMinigame.releaseLeftClick(getMouseX(), getMouseY());
foreach (Buttons b in Utility.getPressedButtons(oldPadState, state3)) foreach (Buttons b in Utility.getPressedButtons(oldPadState, state3))
currentMinigame.receiveKeyRelease(Utility.mapGamePadButtonToKey(b)); currentMinigame.receiveKeyRelease(Utility.mapGamePadButtonToKey(b));
if (state3.IsConnected && state3.IsButtonDown(Buttons.A) && currentMinigame != null) if (state3.IsConnected && state3.IsButtonDown(Buttons.A))
currentMinigame.leftClickHeld(0, 0); currentMinigame?.leftClickHeld(0, 0);
} }
if (currentMinigame == null) if (currentMinigame == null)
{ {
@ -774,8 +772,7 @@ namespace StardewModdingAPI.Inheritance
if (gameMode == 10) if (gameMode == 10)
UpdateOther(gameTime); UpdateOther(gameTime);
} }
if (audioEngine != null) audioEngine?.Update();
audioEngine.Update();
if (multiplayerMode == 2 && gameMode == 3) if (multiplayerMode == 2 && gameMode == 3)
server.sendMessages(gameTime); server.sendMessages(gameTime);
} }

View File

@ -181,22 +181,24 @@ namespace StardewModdingAPI.Inheritance
public SObject Clone() public SObject Clone()
{ {
var toRet = new SObject(); 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
};
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;
return toRet; return toRet;
} }

View File

@ -5,10 +5,7 @@ namespace StardewModdingAPI
{ {
internal class ModItem : Object internal class ModItem : Object
{ {
public Item AsItem public Item AsItem => this;
{
get { return this; }
}
public override string Name { get; set; } public override string Name { get; set; }
public string Description { get; set; } public string Description { get; set; }

View File

@ -89,25 +89,23 @@ namespace StardewModdingAPI
{ {
Log.AsyncY("Validating api paths..."); 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>(); //_modContentPaths = new List<string>();
//TODO: Have an app.config and put the paths inside it so users can define locations to load mods from //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. //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(Constants.ExecutionPath, "Mods", "Content"));
//_modContentPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods", "Content")); //_modContentPaths.Add(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "Mods", "Content"));
//Checks that all defined modpaths exist as directories //Checks that all defined modpaths exist as directories
_modPaths.ForEach(path => VerifyPath(path)); _modPaths.ForEach(VerifyPath);
//_modContentPaths.ForEach(path => VerifyPath(path)); //_modContentPaths.ForEach(path => VerifyPath(path));
VerifyPath(Constants.LogDir); VerifyPath(Constants.LogDir);
if (!File.Exists(Constants.ExecutionPath + "\\Stardew Valley.exe")) 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"); Log.AsyncR("The command specified could not be found");
else else
{ {
if (fnd.CommandArgs.Length > 0) Log.AsyncY(fnd.CommandArgs.Length > 0 ? $"{fnd.CommandName}: {fnd.CommandDesc} - {fnd.CommandArgs.ToSingular()}" : $"{fnd.CommandName}: {fnd.CommandDesc}");
Log.AsyncY($"{fnd.CommandName}: {fnd.CommandDesc} - {fnd.CommandArgs.ToSingular()}");
else
Log.AsyncY($"{fnd.CommandName}: {fnd.CommandDesc}");
} }
} }
else else

View File

@ -629,8 +629,7 @@ namespace TrainerMod
} }
} }
var o = new Object(e.Command.CalledArgs[0].AsInt32(), count); var o = new Object(e.Command.CalledArgs[0].AsInt32(), count) {quality = quality};
o.quality = quality;
Game1.player.addItemByMenuIfNecessary(o); Game1.player.addItemByMenuIfNecessary(o);
} }