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); }
}
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;
}

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -181,22 +181,24 @@ namespace StardewModdingAPI.Inheritance
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;
}

View File

@ -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; }

View File

@ -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

View File

@ -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);
}