From 625f9c89e4db470c0325b5d148c5286c1b5e54eb Mon Sep 17 00:00:00 2001 From: Gormogon Date: Sun, 29 May 2016 16:13:24 -0400 Subject: Take advantage of some new language opportunities. --- StardewModdingAPI/Inheritance/Menus/SBobberBar.cs | 8 ++--- StardewModdingAPI/Inheritance/Menus/SGameMenu.cs | 3 +- .../Inheritance/Menus/SInventoryPage.cs | 3 +- StardewModdingAPI/Inheritance/SGame.cs | 13 ++++----- StardewModdingAPI/Inheritance/SObject.cs | 34 ++++++++++++---------- 5 files changed, 27 insertions(+), 34 deletions(-) (limited to 'StardewModdingAPI/Inheritance') 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; } -- cgit