mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-13 12:14:18 +01:00
Change fixed design migration slightly for better matching.
This commit is contained in:
parent
3ede044439
commit
db6687d896
1 changed files with 10 additions and 9 deletions
|
|
@ -14,7 +14,7 @@ namespace Glamourer.Automation;
|
||||||
public class FixedDesignMigrator
|
public class FixedDesignMigrator
|
||||||
{
|
{
|
||||||
private readonly JobService _jobs;
|
private readonly JobService _jobs;
|
||||||
private List<(string Name, bool Enabled, List<(string, JobGroup)> Data)>? _migratedData;
|
private List<(string Name, List<(string, JobGroup, bool)> Data)>? _migratedData;
|
||||||
|
|
||||||
public FixedDesignMigrator(JobService jobs)
|
public FixedDesignMigrator(JobService jobs)
|
||||||
=> _jobs = jobs;
|
=> _jobs = jobs;
|
||||||
|
|
@ -26,8 +26,8 @@ public class FixedDesignMigrator
|
||||||
|
|
||||||
foreach (var data in _migratedData)
|
foreach (var data in _migratedData)
|
||||||
{
|
{
|
||||||
var enabled = data.Enabled;
|
var allEnabled = true;
|
||||||
var name = data.Name + (enabled ? " (Enabled)" : " (Disabled)");
|
var name = data.Name;
|
||||||
if (autoManager.Any(d => name == d.Name))
|
if (autoManager.Any(d => name == d.Name))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
@ -43,18 +43,18 @@ public class FixedDesignMigrator
|
||||||
{
|
{
|
||||||
byteString = ByteString.FromSpanUnsafe("Mig Ration"u8, true, false, true);
|
byteString = ByteString.FromSpanUnsafe("Mig Ration"u8, true, false, true);
|
||||||
id = actors.AwaitedService.CreatePlayer(byteString, actors.AwaitedService.Data.Worlds.First().Key);
|
id = actors.AwaitedService.CreatePlayer(byteString, actors.AwaitedService.Data.Worlds.First().Key);
|
||||||
enabled = false;
|
|
||||||
if (!id.IsValid)
|
if (!id.IsValid)
|
||||||
{
|
{
|
||||||
Glamourer.Chat.NotificationMessage($"Could not migrate fixed design {data.Name}.", "Error", NotificationType.Error);
|
Glamourer.Chat.NotificationMessage($"Could not migrate fixed design {data.Name}.", "Error", NotificationType.Error);
|
||||||
|
allEnabled = false;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
autoManager.AddDesignSet(name, id);
|
autoManager.AddDesignSet(name, id);
|
||||||
autoManager.SetState(autoManager.Count - 1, enabled);
|
autoManager.SetState(autoManager.Count - 1, allEnabled);
|
||||||
var set = autoManager[^1];
|
var set = autoManager[^1];
|
||||||
foreach (var design in data.Data)
|
foreach (var design in data.Data.AsEnumerable().Reverse())
|
||||||
{
|
{
|
||||||
if (!designFileSystem.Find(design.Item1, out var child) || child is not DesignFileSystem.Leaf leaf)
|
if (!designFileSystem.Find(design.Item1, out var child) || child is not DesignFileSystem.Leaf leaf)
|
||||||
{
|
{
|
||||||
|
|
@ -65,6 +65,7 @@ public class FixedDesignMigrator
|
||||||
|
|
||||||
autoManager.AddDesign(set, leaf.Value);
|
autoManager.AddDesign(set, leaf.Value);
|
||||||
autoManager.ChangeJobCondition(set, set.Designs.Count - 1, design.Item2);
|
autoManager.ChangeJobCondition(set, set.Designs.Count - 1, design.Item2);
|
||||||
|
autoManager.ChangeApplicationType(set, set.Designs.Count - 1, design.Item3 ? AutoDesign.Type.All : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -105,8 +106,8 @@ public class FixedDesignMigrator
|
||||||
list.Add((name, path, group, enabled));
|
list.Add((name, path, group, enabled));
|
||||||
}
|
}
|
||||||
|
|
||||||
_migratedData = list.GroupBy(t => (t.Name, t.Enabled))
|
_migratedData = list.GroupBy(t => t.Name)
|
||||||
.Select(kvp => (kvp.Key.Name, kvp.Key.Enabled, kvp.Select(k => (k.Path, k.Group)).ToList()))
|
.Select(kvp => (kvp.Key, kvp.Select(k => (k.Path, k.Group, k.Enabled)).ToList()))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue