Skip to content

Commit

Permalink
Merge branch 'develop' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
Pathoschild committed Jun 8, 2024
2 parents 541810d + 7869756 commit fb7ce6d
Show file tree
Hide file tree
Showing 294 changed files with 3,394 additions and 1,474 deletions.
2 changes: 1 addition & 1 deletion Automate/Automate.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>2.2.2</Version>
<Version>2.2.3</Version>
<RootNamespace>Pathoschild.Stardew.Automate</RootNamespace>

<TranslationClassBuilder_AddGetByKey>true</TranslationClassBuilder_AddGetByKey>
Expand Down
5 changes: 2 additions & 3 deletions Automate/Framework/Commands/CommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@ public CommandHandler(IMonitor monitor, Func<ModConfig> config, MachineManager m
/// <param name="machineManager">Manages machine groups.</param>
private static ICommand[] BuildCommands(IMonitor monitor, Func<ModConfig> config, MachineManager machineManager)
{
return new ICommand[]
{
return [
new ResetCommand(monitor, machineManager),
new SummaryCommand(monitor, config, machineManager)
};
];
}
}
}
14 changes: 7 additions & 7 deletions Automate/Framework/JunimoMachineGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal class JunimoMachineGroup : MachineGroup
private readonly Func<IEnumerable<IMachine>, IEnumerable<IMachine>> SortMachines;

/// <summary>The underlying machine groups.</summary>
private readonly List<IMachineGroup> MachineGroups = new();
private readonly List<IMachineGroup> MachineGroups = [];

/// <summary>A map of covered tiles by location key, if loaded.</summary>
private Dictionary<string, IReadOnlySet<Vector2>>? Tiles;
Expand All @@ -41,9 +41,9 @@ internal class JunimoMachineGroup : MachineGroup
public JunimoMachineGroup(Func<IEnumerable<IMachine>, IEnumerable<IMachine>> sortMachines, Func<IContainer[], StorageManager> buildStorage, IMonitor monitor)
: base(
locationKey: null,
machines: Array.Empty<IMachine>(),
containers: Array.Empty<IContainer>(),
tiles: Array.Empty<Vector2>(),
machines: [],
containers: [],
tiles: [],
buildStorage: buildStorage,
monitor: monitor
)
Expand Down Expand Up @@ -71,10 +71,10 @@ public void Clear()
{
this.MachineGroups.Clear();

this.StorageManager.SetContainers(Array.Empty<IContainer>());
this.StorageManager.SetContainers([]);

this.Containers = Array.Empty<IContainer>();
this.Machines = Array.Empty<IMachine>();
this.Containers = [];
this.Machines = [];
this.Tiles = null;
}

Expand Down
4 changes: 2 additions & 2 deletions Automate/Framework/LocationFloodFillIndex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal class LocationFloodFillIndex
** Accessors
*********/
/// <summary>The log keys for entities which throw an exception when scanned, to avoid logging them repeatedly.</summary>
private static readonly HashSet<string> LoggedErrorKeys = new();
private static readonly HashSet<string> LoggedErrorKeys = [];

/// <summary>The indexed entities.</summary>
private readonly IDictionary<Vector2, object[]> Entities;
Expand Down Expand Up @@ -52,7 +52,7 @@ public IEnumerable<object> GetEntities(Vector2 tile)
{
return this.Entities.TryGetValue(tile, out object[]? entities)
? entities
: Array.Empty<object>();
: [];
}


Expand Down
8 changes: 4 additions & 4 deletions Automate/Framework/MachineGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ internal class MachineGroup : IMachineGroup
** (These just minimize object allocations, and aren't used to store state between ticks.)
****/
/// <summary>The pre-allocated list used to store machines which have output ready during the current automation tick.</summary>
private readonly List<IMachine> PooledOutputReady = new();
private readonly List<IMachine> PooledOutputReady = [];

/// <summary>The pre-allocated list used to store machines which have input ready during the current automation tick.</summary>
private readonly List<IMachine> PooledInputReady = new();
private readonly List<IMachine> PooledInputReady = [];

/// <summary>A pre-allocated set used to store machine IDs that should be ignored for input during the current automation tick.</summary>
private readonly HashSet<string> PooledIgnoreMachinesForInput = new();
private readonly HashSet<string> PooledIgnoreMachinesForInput = [];


/*********
Expand Down Expand Up @@ -88,7 +88,7 @@ public MachineGroup(string? locationKey, IEnumerable<IMachine> machines, IEnumer
this.LocationKey = locationKey;
this.Machines = machines.ToArray();
this.Containers = containers.ToArray();
this.Tiles = new HashSet<Vector2>(tiles);
this.Tiles = [..tiles];
this.Monitor = monitor;

this.IsJunimoGroup = this.Containers.Any(p => p.IsJunimoChest);
Expand Down
6 changes: 3 additions & 3 deletions Automate/Framework/MachineGroupBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ internal class MachineGroupBuilder
private readonly IMonitor Monitor;

/// <summary>The machines in the group.</summary>
private readonly HashSet<IMachine> Machines = new();
private readonly HashSet<IMachine> Machines = [];

/// <summary>The containers in the group.</summary>
private readonly HashSet<IContainer> Containers = new();
private readonly HashSet<IContainer> Containers = [];

/// <summary>The tiles comprising the group.</summary>
private readonly HashSet<Vector2> Tiles = new();
private readonly HashSet<Vector2> Tiles = [];

/// <summary>Sort machines by priority.</summary>
private readonly Func<IEnumerable<IMachine>, IEnumerable<IMachine>> SortMachines;
Expand Down
20 changes: 10 additions & 10 deletions Automate/Framework/MachineManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ internal class MachineManager
private readonly Dictionary<string, MachineDataForLocation> MachineData = new();

/// <summary>The cached machines to process.</summary>
private IMachineGroup[] ActiveMachineGroups = Array.Empty<IMachineGroup>();
private IMachineGroup[] ActiveMachineGroups = [];

/// <summary>The cached disabled machine groups (e.g. machines not connected to a chest).</summary>
private IMachineGroup[] DisabledMachineGroups = Array.Empty<IMachineGroup>();
private IMachineGroup[] DisabledMachineGroups = [];

/// <summary>The locations that should be removed on the next update tick.</summary>
private readonly HashSet<GameLocation> RemoveQueue = new(new GameLocationNameComparer());
Expand Down Expand Up @@ -139,8 +139,8 @@ public IDictionary<string, ModConfigMachine> GetMachineOverrides()
public void Clear()
{
this.MachineData.Clear();
this.ActiveMachineGroups = Array.Empty<IMachineGroup>();
this.DisabledMachineGroups = Array.Empty<IMachineGroup>();
this.ActiveMachineGroups = [];
this.DisabledMachineGroups = [];
this.JunimoMachineGroup.Clear();
}

Expand Down Expand Up @@ -218,7 +218,7 @@ private void ReloadMachinesIn(ISet<GameLocation> locations, ISet<GameLocation> r

// remove old groups
{
HashSet<string> locationKeys = new(locations.Concat(removedLocations).Select(this.Factory.GetLocationKey));
HashSet<string> locationKeys = [..locations.Concat(removedLocations).Select(this.Factory.GetLocationKey)];
if (this.Monitor.IsVerbose)
this.Monitor.Log($"Reloading machines in {locationKeys.Count} locations: {string.Join(", ", locationKeys)}...");

Expand All @@ -238,9 +238,9 @@ private void ReloadMachinesIn(ISet<GameLocation> locations, ISet<GameLocation> r
string locationKey = this.Factory.GetLocationKey(location);

// collect new groups
List<IMachineGroup> active = new();
List<IMachineGroup> disabled = new();
List<IMachineGroup> junimo = new();
List<IMachineGroup> active = [];
List<IMachineGroup> disabled = [];
List<IMachineGroup> junimo = [];
foreach (IMachineGroup group in this.Factory.GetMachineGroups(location, this.Monitor))
{
if (!group.HasInternalAutomation)
Expand Down Expand Up @@ -270,8 +270,8 @@ private void ReloadMachinesIn(ISet<GameLocation> locations, ISet<GameLocation> r
// rebuild caches
if (anyChanged)
{
List<IMachineGroup> active = new();
List<IMachineGroup> disabled = new();
List<IMachineGroup> active = [];
List<IMachineGroup> disabled = [];

foreach (MachineDataForLocation locationData in this.MachineData.Values)
{
Expand Down
4 changes: 2 additions & 2 deletions Automate/Framework/Machines/DataBasedBuildingMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ internal class DataBasedBuildingMachine : BaseMachineForBuilding<Building>
private BuildingData Data;

/// <summary>The output chest IDs.</summary>
private readonly HashSet<string> OutputChests = new();
private readonly HashSet<string> OutputChests = [];

/// <summary>The input chest IDs.</summary>
private readonly HashSet<string> InputChests = new();
private readonly HashSet<string> InputChests = [];


/*********
Expand Down
2 changes: 1 addition & 1 deletion Automate/Framework/Models/DataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class DataModel
/// <param name="suggestedIntegrations">Mods which add custom machine recipes and require a separate automation component.</param>
public DataModel(DataModelIntegration[]? suggestedIntegrations)
{
this.SuggestedIntegrations = suggestedIntegrations ?? Array.Empty<DataModelIntegration>();
this.SuggestedIntegrations = suggestedIntegrations ?? [];
this.DefaultMachineOverrides = this.DefaultMachineOverrides.ToNonNullCaseInsensitive();
}
}
Expand Down
8 changes: 8 additions & 0 deletions Automate/docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[← back to readme](README.md)

# Release notes
## 2.2.3
Released 08 June 2024 for SMAPI 4.0.7 or later.

* Raised minimum versions to SMAPI 4.0.7 and Stardew Valley 1.6.4.
_This avoids errors due to breaking changes in earlier 1.6 patches._
* Internal refactoring.
* Improved translations. Thanks to mehmetgorkemarslan (updated Turkish)!

## 2.2.2
Released 25 May 2024 for SMAPI 4.0.0 or later.

Expand Down
14 changes: 6 additions & 8 deletions Automate/i18n/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@
"config.machine-settings-priority.desc": "Diğer makinelerle kıyasla {{machineName}} makinelerinin işlenme öncelik sırası. Makinelerin varsayılan önceliği 0'dır, daha yüksek değerler önce işlenir.",

// machine names
// TODO
"config.machines.bush": "Bush",
"config.machines.fruit-tree": "Tree (Fruit Tree)",
"config.machines.trash-can": "Trash Can",
"config.machines.wild-tree": "Tree (Wild Tree)",
"config.machines.bush": "Çalı",
"config.machines.fruit-tree": "Ağaç (Meyve Ağacı)",
"config.machines.trash-can": "Çöp Kutusu",
"config.machines.wild-tree": "Ağaç (Vahşi Ağaç)",

// special settings for individual machines
// TODO
"config.machines.wild-tree.collect-moss.name": "Collect Moss",
"config.machines.wild-tree.collect-moss.desc": "Whether to collect moss on trees. For example, keeping moss on trees will boost the quality of mushrooms from nearby mushroom logs."
"config.machines.wild-tree.collect-moss.name": "Yosunları Topla",
"config.machines.wild-tree.collect-moss.desc": "Yosunların toplanıp toplanmayacağı. Örneğin, ağaçlardaki yosunu toplamamak Mantar Kütüğü tarafından üretilecek mantarların kalitesini arttırır."
}
6 changes: 3 additions & 3 deletions Automate/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"Name": "Automate",
"Author": "Pathoschild",
"Version": "2.2.2",
"MinimumApiVersion": "4.0.0",
"MinimumGameVersion": "1.6.3",
"Version": "2.2.3",
"MinimumApiVersion": "4.0.7",
"MinimumGameVersion": "1.6.4",
"Description": "Lets you automate crafting machines, fruit trees, and more by connecting them to chests.",
"UniqueID": "Pathoschild.Automate",
"EntryDll": "Automate.dll",
Expand Down
8 changes: 7 additions & 1 deletion ChestsAnywhere/ChestFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,14 @@ from GameLocation location in this.GetAccessibleLocations()
}

// dressers
foreach (StorageFurniture furniture in location.furniture.OfType<StorageFurniture>())
foreach (Furniture rawFurniture in location.furniture)
{
if (rawFurniture is not StorageFurniture furniture)
continue;

if (furniture.QualifiedItemId == "(F)CCFishTank" && location is CommunityCenter)
continue; // temporary fish tank

var container = new StorageFurnitureContainer(furniture);
yield return new ManagedChest(
container: container,
Expand Down
2 changes: 1 addition & 1 deletion ChestsAnywhere/ChestsAnywhere.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Version>1.23.4</Version>
<Version>1.23.5</Version>
<RootNamespace>Pathoschild.Stardew.ChestsAnywhere</RootNamespace>

<TranslationClassBuilder_AddGetByKey>true</TranslationClassBuilder_AddGetByKey>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public StorageFurnitureContainer(StorageFurniture furniture)
this.Furniture = furniture;
this.Data = new ContainerData(furniture.modData);

StorageFurnitureContainer.DresserCategories ??= new HashSet<int>(new ShopMenu("Dresser", new List<ISalable>()).categoriesToSellHere);
StorageFurnitureContainer.DresserCategories ??= [..new ShopMenu("Dresser", new List<ISalable>()).categoriesToSellHere];
}

/// <inheritdoc />
Expand Down
12 changes: 5 additions & 7 deletions ChestsAnywhere/Menus/Overlays/BaseChestOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ internal abstract class BaseChestOverlay : BaseOverlay, IStorageOverlay
private ClickableTextureComponent EditExitButton;

/// <summary>The textboxes managed by Chests Anywhere.</summary>
private IEnumerable<ValidatedTextBox> ManagedTextboxes => new[] { this.EditNameField, this.EditOrderField, this.EditCategoryField };
private IEnumerable<ValidatedTextBox> ManagedTextboxes => [this.EditNameField, this.EditOrderField, this.EditCategoryField];


/*********
Expand Down Expand Up @@ -640,21 +640,19 @@ private void ReinitializeBaseComponents()
this.EditHideChestField = new Checkbox();
this.EditAutomateStorage = new SimpleDropdown<AutomateContainerPreference>(
this.Reflection,
options: new[]
{
options: [
new KeyValuePair<AutomateContainerPreference, string>(AutomateContainerPreference.Allow, I18n.Label_AutomateStore()),
new KeyValuePair<AutomateContainerPreference, string>(AutomateContainerPreference.Prefer, I18n.Label_AutomateStoreFirst()),
new KeyValuePair<AutomateContainerPreference, string>(AutomateContainerPreference.Disable, I18n.Label_AutomateStoreDisabled())
}
]
);
this.EditAutomateFetch = new SimpleDropdown<AutomateContainerPreference>(
this.Reflection,
options: new[]
{
options: [
new KeyValuePair<AutomateContainerPreference, string>(AutomateContainerPreference.Allow, I18n.Label_AutomateTake()),
new KeyValuePair<AutomateContainerPreference, string>(AutomateContainerPreference.Prefer, I18n.Label_AutomateTakeFirst()),
new KeyValuePair<AutomateContainerPreference, string>(AutomateContainerPreference.Disable, I18n.Label_AutomateTakeDisabled())
}
]
);
this.FillForm();

Expand Down
4 changes: 2 additions & 2 deletions ChestsAnywhere/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class ModEntry : Mod
/// <summary>The menu instance for which the <see cref="CurrentOverlay"/> was created, if any.</summary>
private readonly PerScreen<IClickableMenu> ForMenuInstance = new();

/// <summary>The overlay for the current menu which which lets the player navigate and edit chests (or <c>null</c> if not applicable).</summary>
/// <summary>The overlay for the current menu, which lets the player navigate and edit chests (or <c>null</c> if not applicable).</summary>
private readonly PerScreen<IStorageOverlay?> CurrentOverlay = new();


Expand Down Expand Up @@ -286,7 +286,7 @@ private void NotifyAutomateOfChestUpdate(ManagedChest chest)
{
long hostId = Game1.MasterPlayer.UniqueMultiplayerID;
var message = new AutomateUpdateChestMessage { LocationName = chest.Location.NameOrUniqueName, Tile = chest.Tile };
this.Helper.Multiplayer.SendMessage(message, nameof(AutomateUpdateChestMessage), modIDs: new[] { "Pathoschild.Automate" }, playerIDs: new[] { hostId });
this.Helper.Multiplayer.SendMessage(message, nameof(AutomateUpdateChestMessage), modIDs: ["Pathoschild.Automate"], playerIDs: [hostId]);
}

/// <summary>Validate that the game versions match the minimum requirements, and return an appropriate error message if not.</summary>
Expand Down
8 changes: 8 additions & 0 deletions ChestsAnywhere/docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[← back to readme](README.md)

# Release notes
## 1.23.5
Released 08 June 2024 for SMAPI 4.0.7 or later.

* Fixed the community center fish tank being accessible through Chests Anywhere.
* Raised minimum versions to SMAPI 4.0.7 and Stardew Valley 1.6.4.
_This avoids errors due to breaking changes in earlier 1.6 patches._
* Internal refactoring.

## 1.23.4
Released 22 May 2024 for SMAPI 4.0.0 or later.

Expand Down
5 changes: 3 additions & 2 deletions ChestsAnywhere/manifest.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"Name": "Chests Anywhere",
"Author": "Pathoschild",
"Version": "1.23.4",
"MinimumApiVersion": "4.0.0",
"Version": "1.23.5",
"MinimumApiVersion": "4.0.7",
"MinimumGameVersion": "1.6.4",
"Description": "Access your chests from anywhere and organize them your way.",
"UniqueID": "Pathoschild.ChestsAnywhere",
"EntryDll": "ChestsAnywhere.dll",
Expand Down
2 changes: 1 addition & 1 deletion Common/CollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal static class CollectionExtensions
/// <returns>Returns whether any values were removed.</returns>
public static bool RemoveAll<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, Func<TKey, TValue, bool> where)
{
List<TKey> removeKeys = new();
List<TKey> removeKeys = [];
foreach ((TKey key, TValue value) in dictionary)
{
if (where(key, value))
Expand Down
4 changes: 2 additions & 2 deletions Common/CommonHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ internal static class CommonHelper
private static readonly Lazy<Texture2D> LazyPixel = new(() =>
{
Texture2D pixel = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
pixel.SetData(new[] { Color.White });
pixel.SetData([Color.White]);
return pixel;
});

Expand Down Expand Up @@ -353,7 +353,7 @@ public static Vector2 DrawTextBlock(this SpriteBatch batch, SpriteFont font, str
return new Vector2(0, 0);

// get word list
List<string> words = new List<string>();
List<string> words = [];
foreach (string word in text.Split(' ', StringSplitOptions.RemoveEmptyEntries))
{
// split on newlines
Expand Down
2 changes: 1 addition & 1 deletion Common/DataParsers/CropDataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public CropDataParser(Crop? crop, bool isPlanted)
this.DaysToFirstHarvest = (int)(this.DaysToFirstHarvest * 0.9);
}
else
this.Seasons = Array.Empty<Season>();
this.Seasons = [];
}

/// <summary>Get the date when the crop will next be ready to harvest.</summary>
Expand Down
Loading

0 comments on commit fb7ce6d

Please sign in to comment.