summaryrefslogtreecommitdiff
path: root/src/SMAPI/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI/Framework')
-rw-r--r--src/SMAPI/Framework/Content/AssetDataForObject.cs4
-rw-r--r--src/SMAPI/Framework/Input/SInputState.cs2
-rw-r--r--src/SMAPI/Framework/ModLoading/ModResolver.cs7
-rw-r--r--src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs2
4 files changed, 6 insertions, 9 deletions
diff --git a/src/SMAPI/Framework/Content/AssetDataForObject.cs b/src/SMAPI/Framework/Content/AssetDataForObject.cs
index 40f49190..bafd8941 100644
--- a/src/SMAPI/Framework/Content/AssetDataForObject.cs
+++ b/src/SMAPI/Framework/Content/AssetDataForObject.cs
@@ -47,9 +47,9 @@ namespace StardewModdingAPI.Framework.Content
/// <inheritdoc />
public TData GetData<TData>()
{
- if (this.Data is not TData)
+ if (this.Data is not TData data)
throw new InvalidCastException($"The content data of type {this.Data.GetType().FullName} can't be converted to the requested {typeof(TData).FullName}.");
- return (TData)this.Data;
+ return data;
}
}
}
diff --git a/src/SMAPI/Framework/Input/SInputState.cs b/src/SMAPI/Framework/Input/SInputState.cs
index 5ff7432b..d5feaf94 100644
--- a/src/SMAPI/Framework/Input/SInputState.cs
+++ b/src/SMAPI/Framework/Input/SInputState.cs
@@ -234,7 +234,7 @@ namespace StardewModdingAPI.Framework.Input
isDown: pressed.Contains(button)
);
- if (button == SButton.MouseLeft || button == SButton.MouseMiddle || button == SButton.MouseRight || button == SButton.MouseX1 || button == SButton.MouseX2)
+ if (button is SButton.MouseLeft or SButton.MouseMiddle or SButton.MouseRight or SButton.MouseX1 or SButton.MouseX2)
mouseOverrides[button] = newState;
else if (button.TryGetKeyboard(out Keys _))
keyboardOverrides[button] = newState;
diff --git a/src/SMAPI/Framework/ModLoading/ModResolver.cs b/src/SMAPI/Framework/ModLoading/ModResolver.cs
index e3386f75..21366bb4 100644
--- a/src/SMAPI/Framework/ModLoading/ModResolver.cs
+++ b/src/SMAPI/Framework/ModLoading/ModResolver.cs
@@ -32,11 +32,8 @@ namespace StardewModdingAPI.Framework.ModLoading
ModDataRecordVersionedFields dataRecord = modDatabase.Get(manifest?.UniqueID)?.GetVersionedFields(manifest);
// apply defaults
- if (manifest != null && dataRecord != null)
- {
- if (dataRecord.UpdateKey != null)
- manifest.UpdateKeys = new[] { dataRecord.UpdateKey };
- }
+ if (manifest != null && dataRecord?.UpdateKey is not null)
+ manifest.UpdateKeys = new[] { dataRecord.UpdateKey };
// build metadata
bool shouldIgnore = folder.Type == ModType.Ignored;
diff --git a/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs b/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs
index 57f1dd17..2eee8ff9 100644
--- a/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs
+++ b/src/SMAPI/Framework/ModLoading/Rewriters/HeuristicFieldRewriter.cs
@@ -37,7 +37,7 @@ namespace StardewModdingAPI.Framework.ModLoading.Rewriters
// skip if not broken
FieldDefinition fieldDefinition = fieldRef.Resolve();
- if (fieldDefinition != null && !fieldDefinition.HasConstant)
+ if (fieldDefinition?.HasConstant == false)
return false;
// rewrite if possible