From 4c16905249a268f2d4f3e9e874a39173efc94442 Mon Sep 17 00:00:00 2001 From: Kurt Date: Mon, 4 Mar 2024 20:19:09 -0600 Subject: [PATCH] Use c#11 features --- pkNX.Containers/FileMitm.cs | 4 +- pkNX.Containers/FolderContainer.cs | 2 +- pkNX.Containers/Mini/MiniUtil.cs | 5 +- pkNX.Containers/Misc/AHTBEntry.cs | 20 +- pkNX.Containers/Misc/GFPack.cs | 4 +- .../Archives/ZipArchiveFileSystem.cs | 2 +- .../VFS/FileSystems/LayeredFileSystem.cs | 11 +- .../VFS/FileSystems/ReadOnlyFileSystem.cs | 9 +- .../VFS/FileSystems/RelativeFileSystem.cs | 21 +- pkNX.Containers/VFS/Util/FileSystemPath.cs | 5 +- pkNX.Game/Editors/DataCache.cs | 10 +- pkNX.Game/Editors/EditorFactory.cs | 4 +- pkNX.Game/Editors/EditorUtil.cs | 2 +- pkNX.Game/Editors/ShinyRate/ShinyRateGG.cs | 14 +- pkNX.Game/Editors/ShinyRate/ShinyRateInfo.cs | 5 +- pkNX.Game/Editors/ShinyRate/ShinyRateSWSH.cs | 17 +- pkNX.Game/Editors/TypeChartEditor.cs | 10 +- pkNX.Game/File/GameFileMapping.cs | 25 +- pkNX.Game/GameManagerGG.cs | 3 +- pkNX.Game/GameManagerPLA.cs | 3 +- pkNX.Game/GameManagerSWSH.cs | 3 +- pkNX.Game/Text/TextManager.cs | 12 +- pkNX.Game/Text/TextMapping.cs | 36 +-- .../Randomizers/FormRandomizer.cs | 13 +- .../Randomizers/GenericRandomizer.cs | 18 +- .../Randomizers/LearnsetRandomizer.cs | 6 +- .../Randomizers/MoveRandomizer.cs | 6 +- .../Personal/PersonalRandSettings.cs | 2 +- .../Personal/PersonalRandomizer.cs | 2 +- .../Settings/MovesetRandSettings.cs | 2 +- .../Randomizers/Settings/RandSettings.cs | 4 +- .../Randomizers/Settings/SpeciesSettings.cs | 2 +- .../Randomizers/TrainerRandomizer.cs | 26 +-- .../Arceus/Condition/ConditionUtil.cs | 3 - .../Arceus/Config/AppConfigList.cs | 4 +- .../Arceus/Config/ConfigureTable.cs | 2 +- .../Arceus/DressUp/DressUpTable.cs | 4 +- .../Arceus/Event/Trigger.cs | 8 +- .../Arceus/Field/LandmarkItemSpawnTable.cs | 4 +- .../Arceus/Field/LandmarkItemTable.cs | 2 +- .../Arceus/Field/MassOutbreakTable.cs | 8 +- .../Field/NewHuge/NewHugeOutbreakGroup.cs | 2 +- .../Field/NewHuge/NewHugeOutbreakLottery.cs | 4 +- .../Field/NewHuge/NewHugeOutbreakTimeLimit.cs | 4 +- .../Field/Placement/OybnSettingTable.cs | 4 +- .../Field/Placement/PlacementItemArchive.cs | 8 +- .../Placement/PlacementLocationArchive.cs | 2 +- .../Field/Placement/PlacementMkrgTable.cs | 2 +- .../Placement/PlacementSearchItemTable.cs | 2 +- .../Field/Placement/PlacementSpawnerData.cs | 2 +- .../Field/Placement/PlacementSpawnerF21.cs | 2 - .../Field/Placement/PlacementUnnnTable.cs | 2 +- .../Arceus/Field/Resident/AreaBGMTable.cs | 4 +- .../Field/Resident/AreaSettingsTable.cs | 2 +- .../Arceus/Field/Resident/AreaWeatherTable.cs | 2 +- .../Field/Resident/Editing/ResidentArea.cs | 19 +- .../Field/Resident/Editing/ResidentInfo.cs | 34 +-- .../Field/Slots/EncounterDataArchive.cs | 6 +- .../Field/Slots/EncounterMultiplerArchive.cs | 5 +- .../Field/Static/EventEncountArchive.cs | 4 +- .../Arceus/KeyAssignmentTable.cs | 4 +- .../Arceus/LbPointsTable.cs | 4 +- .../Arceus/MoveShopTable.cs | 4 +- .../Arceus/NPC/NPCModelSet.cs | 12 +- .../Arceus/PlayReportTable.cs | 4 +- .../Arceus/Poke/EvolutionTable.cs | 4 +- .../Arceus/Poke/Model Set/PokeModelSet.cs | 2 +- .../Arceus/Poke/Model/BoneScalarMesh.cs | 10 +- .../Arceus/Poke/Model/Material.cs | 10 +- .../Arceus/Poke/Model/Mesh.cs | 16 +- .../Arceus/Poke/Model/MeshBuffer.cs | 20 +- .../Arceus/Poke/Model/Model.cs | 14 +- .../Arceus/Poke/Model/MultiMaterialTable.cs | 22 +- .../Arceus/Poke/Model/PokeConfig.cs | 2 +- .../Arceus/Poke/Model/Skeleton.cs | 8 +- .../Arceus/Poke/Moves/Learnset.cs | 4 +- .../Poke/Moves/PokeFieldObstructionWaza.cs | 2 +- ...PokeFieldObstructionWazaNsLegendArchive.cs | 4 +- ...eldObstructionWazaNsLegendEffectArchive.cs | 4 +- .../PokeFieldObstructionWazaSeArchive.cs | 4 +- .../PokeFieldObstructionWazaWildArchive.cs | 2 +- ...keFieldObstructionWazaWildEffectArchive.cs | 4 +- ...okeFieldObstructionWazaWildWaterArchive.cs | 2 +- ...ldObstructionWazaWildWaterEffectArchive.cs | 4 +- .../Arceus/Poke/Moves/Waza.cs | 2 +- .../Arceus/Poke/PersonalInfoLAfb.cs | 4 +- .../Arceus/Poke/PokeAIArchive.cs | 34 +-- .../Arceus/Poke/PokeAdd.cs | 2 +- .../Arceus/Poke/PokeBattleSpawnArchive.cs | 4 +- .../Arceus/Poke/PokeBodyParticleArchive.cs | 6 +- .../Poke/PokeCaptureCollisionArchive.cs | 18 +- .../Arceus/Poke/PokeDefaultLocatorArchive.cs | 4 +- .../Arceus/Poke/PokeDropItemArchive.cs | 2 +- .../Arceus/Poke/PokeDropItemBattleArchive.cs | 2 +- .../Arceus/Poke/PokeEatingHabitsArchive.cs | 4 +- .../Arceus/Poke/PokeMiscTable.cs | 4 +- .../Arceus/Poke/PokeResource/PokeInfoList.cs | 36 +-- .../Poke/PokeResource/PokeResourceTable.cs | 20 +- .../Pokedex/PokedexDistributionTable.cs | 4 +- .../Arceus/Pokedex/PokedexRankTable.cs | 4 +- .../Arceus/Pokedex/PokedexResearchTable.cs | 2 +- .../Arceus/ScriptIDRecordRelease.cs | 4 +- .../Arceus/Shop/HaShopTable.cs | 4 +- .../Arceus/Throw/CommonCaptureConfigTable.cs | 4 +- .../Arceus/Throw/ThrowParamTable.cs | 2 +- .../Throw/ThrowPermissionSetDictionary.cs | 4 +- .../Throw/ThrowableBaitParamDictionary.cs | 4 +- .../Arceus/Throw/ThrowableParamTable.cs | 2 +- .../Throw/ThrowableResourceDictionary.cs | 4 +- .../Throw/ThrowableResourceSetDictionary.cs | 4 +- .../Arceus/Util/ArchiveContents.cs | 4 +- .../Arceus/Util/EncounterDetail.cs | 2 +- .../Arceus/Util/EncounterTableUtil.cs | 9 +- .../Arceus/Util/TriggerUtil.cs | 2 +- .../Dumpers/PersonalDumperPLA.cs | 4 +- .../Dumpers/PersonalInfo8LA.cs | 9 +- .../Dumpers/PersonalTable8LA.cs | 2 +- .../Gen7/EncounterArchive.cs | 6 +- .../Gen7/ShopInventory.cs | 2 +- .../ReflectionDumpSchema.cs | 2 +- .../Misc/DanCarBattleDataArray.cs | 6 +- .../Dumpers/PersonalDumperSV.cs | 2 +- .../Personal/PersonalTable.cs | 4 +- .../Personal/Types/PersonalInfoDex.cs | 2 +- .../Personal/Types/PersonalInfoEvolution.cs | 2 +- .../Personal/Wrapper/PersonalInfo9SV.cs | 10 +- .../Personal/Wrapper/PersonalTable9SV.cs | 2 +- .../Raid/DeliveryRaidEnemyTableArray.cs | 1 - .../Raid/DeliveryRaidFixedRewardItemArray.cs | 2 +- .../Gen9/PokeData/PokeDataEventBattle.cs | 2 +- .../Gen9/PokeData/PokeDataFull.cs | 2 +- .../Gen9/PokeData/PokeDataSymbol.cs | 2 +- .../Gen9/PokeData/PokeDataTrade.cs | 3 +- .../Gen9/PokeData/WazaSet.cs | 4 +- .../Gen9/SpeciesConverterSV.cs | 12 +- .../Archive/TrinityFileDescriptors.cs | 12 +- .../World/DeliveryOutbreak.cs | 5 +- .../World/DeliveryOutbreakPokeData.cs | 4 +- .../World/PointDataArray.cs | 2 +- .../BattleTower/BattleTowerPokeArchive.cs | 4 +- .../BattleTower/BattleTowerTrainerArchive.cs | 4 +- .../Gen8/Gift/EncounterGiftArchive.cs | 2 +- .../Gen8/Gift/GiftEncounter.cs | 10 +- .../Gen8/Model/GFBModel.cs | 52 ++--- .../Gen8/Model/GFBPokeConfig.cs | 16 +- .../Gen8/Nest/EncounterNestArchive.cs | 2 +- .../Gen8/Nest/EncounterUndergroundArchive.cs | 2 +- .../Nest/NestHoleCrystalEncounterArchive.cs | 4 +- .../NestHoleDistributionEncounterArchive.cs | 2 +- .../Nest/NestHoleDistributionRewardArchive.cs | 4 +- .../Gen8/Nest/NestHoleLevelArchive.cs | 6 +- .../Gen8/Nest/NestHoleRewardArchive.cs | 2 +- .../Gen8/Other/ArchiveContent.cs | 4 +- .../Gen8/Other/CellTable.cs | 2 +- .../Gen8/Other/PokeResourceTable.cs | 2 +- .../Gen8/Other/Rental.cs | 2 +- .../Gen8/Other/ScriptMeta.cs | 4 +- .../Gen8/Other/ShopInventory.cs | 2 +- .../Gen8/Other/SymbolBehavior.cs | 2 +- .../Gen8/Other/Waza.cs | 2 +- .../Gen8/Other/WeatherEntry.cs | 8 +- .../Gen8/Placement/PlacementArea8Archive.cs | 2 +- .../Gen8/Placement/PlacementArea8_F04.cs | 2 +- .../Holders/PlacementZoneAdvancedTipHolder.cs | 12 +- .../Holders/PlacementZoneBerryTreeHolder.cs | 14 +- .../Holders/PlacementZoneEnvironmentHolder.cs | 4 +- .../Holders/PlacementZoneFieldItemHolder.cs | 6 +- .../PlacementZoneFishingPointHolder.cs | 2 +- .../PlacementZoneFlightAnchorHolder.cs | 4 +- .../Holders/PlacementZoneHiddenItemHolder.cs | 8 +- .../Zone/Holders/PlacementZoneIKStepHolder.cs | 6 +- .../Zone/Holders/PlacementZoneLadderHolder.cs | 6 +- .../PlacementZoneMovementPathHolder.cs | 2 +- .../Zone/Holders/PlacementZoneNPCHolder.cs | 4 +- .../Holders/PlacementZoneNestHoleHolder.cs | 12 +- .../Holders/PlacementZoneOtherNPCHolder.cs | 8 +- .../Holders/PlacementZoneParticleHolder.cs | 2 +- ...lacementZonePokeCenterSpawnAnchorHolder.cs | 4 +- .../Zone/Holders/PlacementZonePopupHolder.cs | 8 +- .../Holders/PlacementZoneQuadrantHolder.cs | 6 +- .../Holders/PlacementZoneRotomRallyEntry.cs | 2 +- .../Holders/PlacementZoneSpeciesHolder.cs | 10 +- .../PlacementZoneStaticObjectsHolder.cs | 4 +- .../Holders/PlacementZoneStepJumpHolder.cs | 4 +- .../Holders/PlacementZoneSymbolSpawnHolder.cs | 6 +- .../Holders/PlacementZoneTrainerHolder.cs | 10 +- .../Holders/PlacementZoneTrainerTipHolder.cs | 10 +- .../Holders/PlacementZoneTriggerHolder.cs | 8 +- .../Holders/PlacementZoneUnitObjectHolder.cs | 8 +- .../Zone/Holders/PlacementZoneWarpHolder.cs | 4 +- .../Gen8/Static/EncounterStaticArchive.cs | 6 +- .../Gen8/Trade/EncounterTradeArchive.cs | 12 +- .../Gen8/Waza/Waza.cs | 67 +++--- .../Gen8/Wild/EncounterArchive.cs | 8 +- .../Gen8/Wild/EncounterTableUtil.cs | 36 +-- pkNX.Structures.FlatBuffers/Data/Color3f.cs | 11 +- pkNX.Structures.FlatBuffers/Data/Color4f.cs | 29 +-- pkNX.Structures.FlatBuffers/Data/Vec4i.cs | 2 - .../Geomerty/Sphere.cs | 8 +- .../Math/PackedVec3f.cs | 9 +- pkNX.Structures.FlatBuffers/Math/Vec3f.cs | 7 +- .../Util/FlatSchemaDump.cs | 2 +- pkNX.Structures/ArrayUtil.cs | 53 ----- pkNX.Structures/CodePattern.cs | 4 +- pkNX.Structures/Dumpers/PersonalDumper.cs | 40 ++-- pkNX.Structures/EggMove/EggMoves.cs | 5 +- pkNX.Structures/Encounter/EncounterGift.cs | 9 +- pkNX.Structures/Encounter/EncounterStatic.cs | 10 +- pkNX.Structures/Encounter/EncounterTrade.cs | 8 +- .../Encounter/Gen6/EncounterGift6AO.cs | 3 +- .../Encounter/Gen6/EncounterGift6XY.cs | 3 +- .../Encounter/Gen6/EncounterStatic6.cs | 3 +- .../Encounter/Gen7/EncounterGift7.cs | 3 +- .../Encounter/Gen7/EncounterGift7b.cs | 9 +- .../Encounter/Gen7/EncounterStatic7.cs | 9 +- .../Encounter/Gen7/EncounterStatic7b.cs | 15 +- .../Encounter/Gen7/EncounterTrade7b.cs | 3 +- pkNX.Structures/Evolution/EvolutionSet.cs | 4 +- pkNX.Structures/Havok/HavokCollision.cs | 58 ++--- pkNX.Structures/Item/Item8.cs | 12 +- pkNX.Structures/Item/Item8a.cs | 8 +- pkNX.Structures/Learnset/Learnset.cs | 14 +- pkNX.Structures/Legality/Encounters.cs | 20 +- pkNX.Structures/Legality/Item.cs | 17 +- pkNX.Structures/Legality/Legal.cs | 2 +- pkNX.Structures/Legality/Species.cs | 73 +++--- pkNX.Structures/Legality/Tables/Tables5.cs | 26 +-- pkNX.Structures/Legality/Tables/Tables6.cs | 156 ++++++------- pkNX.Structures/Legality/Tables/Tables7.cs | 72 +++--- pkNX.Structures/Legality/Tables/Tables7b.cs | 78 +++---- pkNX.Structures/Legality/Tables/Tables8.cs | 92 ++++---- pkNX.Structures/Legality/Tables/Tables8a.cs | 16 +- pkNX.Structures/Legality/Tables/Tables9.cs | 42 ++-- pkNX.Structures/Legality/Trainers.cs | 16 +- pkNX.Structures/Misc/CaptureReward.cs | 15 +- pkNX.Structures/Move/Move.cs | 5 +- pkNX.Structures/Move/Move6.cs | 3 +- pkNX.Structures/Move/Move7.cs | 3 +- .../Personal/Info/PersonalInfo5B2W2.cs | 92 ++++---- .../Personal/Info/PersonalInfo5BW.cs | 87 ++++--- .../Personal/Interfaces/IMovesInfo.cs | 4 +- .../Personal/Interfaces/IPersonalEgg.cs | 4 +- .../Personal/Interfaces/IPersonalInfo.cs | 18 +- pkNX.Structures/Text/TextConfig.cs | 7 +- pkNX.Structures/Text/TextFile.cs | 58 +++-- pkNX.Structures/Text/TextVariableCode.cs | 16 +- pkNX.Structures/VsTrainer/3DS/TrData6AO.cs | 5 +- pkNX.Structures/VsTrainer/3DS/TrData6XY.cs | 5 +- pkNX.Structures/VsTrainer/Base/IAwakened.cs | 2 +- .../VsTrainer/Base/TrainerClass.cs | 6 +- pkNX.Structures/VsTrainer/Base/TrainerData.cs | 5 +- pkNX.Structures/VsTrainer/Base/TrainerPoke.cs | 11 +- .../VsTrainer/GG/TrainerClass7b.cs | 3 +- pkNX.Structures/VsTrainer/GG/TrainerClass8.cs | 3 +- pkNX.Structures/VsTrainer/GG/TrainerData7b.cs | 5 +- pkNX.Structures/VsTrainer/GG/TrainerData8.cs | 3 +- pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs | 11 +- pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs | 3 +- pkNX.Structures/VsTrainer/VsTrainer.cs | 6 +- .../VFS/FileSystemPathTest.cs | 4 +- .../VFS/FileSystems/PhysicalFSTests.cs | 12 +- pkNX.Tests/pkNX.Tests.Trinity/SceneTests.cs | 6 +- pkNX.WinForms/App.xaml.cs | 2 +- .../Controls/EncounterTableEditor8a.cs | 16 +- pkNX.WinForms/Controls/EvolutionEntry.xaml.cs | 2 +- pkNX.WinForms/Controls/EvolutionRow.cs | 2 +- pkNX.WinForms/Controls/EvolutionRow8a.cs | 2 +- pkNX.WinForms/Controls/LandmarkEditor8a.cs | 14 +- .../Controls/PlacementSpawnerEditor8a.cs | 14 +- pkNX.WinForms/Controls/StatEditor.cs | 12 +- pkNX.WinForms/Dumping/GameDumperPLA.cs | 132 ++++++----- pkNX.WinForms/Dumping/GameDumperSV.cs | 62 +++-- pkNX.WinForms/Dumping/GameDumperSWSH.cs | 168 +++++++------ pkNX.WinForms/Dumping/MassOutbreakRipper.cs | 15 +- pkNX.WinForms/Dumping/SV/EncounterDumperSV.cs | 33 ++- .../Dumping/SV/LocationPointDetail.cs | 5 +- pkNX.WinForms/Dumping/SV/LocationStorage.cs | 21 +- .../Dumping/SV/PaldeaCoinSymbolModel.cs | 15 +- .../Dumping/SV/PaldeaCoinSymbolPoint.cs | 26 +-- pkNX.WinForms/Dumping/SV/PaldeaFieldModel.cs | 2 +- .../Dumping/SV/PaldeaFixedSymbolModel.cs | 4 +- .../Dumping/SV/PaldeaFixedSymbolPoint.cs | 20 +- pkNX.WinForms/Dumping/SV/PaldeaSceneModel.cs | 11 +- pkNX.WinForms/Dumping/TeraRaidRipper.cs | 6 +- .../MainEditor/EditorCallableAttribute.cs | 32 +-- pkNX.WinForms/MainEditor/EditorGG.cs | 16 +- pkNX.WinForms/MainEditor/EditorPLA.cs | 8 +- pkNX.WinForms/MainEditor/EditorSWSH.cs | 18 +- pkNX.WinForms/Ripper/FileRipper.cs | 6 +- pkNX.WinForms/Subforms/AreaEditor8a.cs | 2 +- pkNX.WinForms/Subforms/BTTE.cs | 4 +- pkNX.WinForms/Subforms/GGWE.cs | 8 +- pkNX.WinForms/Subforms/MapViewer8a.cs | 50 ++-- pkNX.WinForms/Subforms/ModelConverter.cs | 170 +++++++------- pkNX.WinForms/Subforms/PaldeaMap.cs | 221 +++++++++--------- pkNX.WinForms/Subforms/PokeDataUI.cs | 12 +- pkNX.WinForms/Subforms/PokeDataUI8a.cs | 8 +- pkNX.WinForms/Subforms/SSWE.cs | 22 +- pkNX.WinForms/Subforms/TextEditor.cs | 6 +- pkNX.WinForms/Subforms/TypeChart.cs | 6 +- .../Themes/LeftMarginMultiplierConverter.cs | 27 ++- .../Themes/TreeViewItemExtensions.cs | 42 ++-- pkNX.WinForms/UI/MainWindow.xaml.cs | 26 +-- pkNX.WinForms/UI/UIStaticSources.cs | 53 +++-- pkNX.WinForms/UI/WPFTextEditor.xaml.cs | 8 +- pkNX.WinForms/Utils/DockPanelSplitter.cs | 4 +- pkNX.WinForms/Utils/DockableWindow.cs | 6 +- pkNX.WinForms/Utils/EditableTextBlock.cs | 9 +- pkNX.WinForms/Utils/FormsIconHelper.cs | 4 +- pkNX.WinForms/Utils/MultiSelectTreeView.cs | 14 +- .../Utils/NotifyObservableCollection.cs | 2 +- pkNX.WinForms/Utils/NumericTextBox.cs | 11 +- pkNX.WinForms/Utils/Utils.cs | 152 ++++-------- 313 files changed, 1871 insertions(+), 2382 deletions(-) diff --git a/pkNX.Containers/FileMitm.cs b/pkNX.Containers/FileMitm.cs index b5d99f96..4c27c888 100644 --- a/pkNX.Containers/FileMitm.cs +++ b/pkNX.Containers/FileMitm.cs @@ -49,9 +49,7 @@ public static string GetRedirectedWritePath(string path) if (PathOriginal is null) throw new ArgumentException("No original path specified."); var newDest = path.Replace(PathOriginal, PathRedirect); - var parent = Path.GetDirectoryName(newDest); - if (parent is null) - throw new ArgumentException("Invalid path specified."); + var parent = Path.GetDirectoryName(newDest) ?? throw new ArgumentException("Invalid path specified."); Directory.CreateDirectory(parent); return newDest; } diff --git a/pkNX.Containers/FolderContainer.cs b/pkNX.Containers/FolderContainer.cs index bf55fec0..91848ee8 100644 --- a/pkNX.Containers/FolderContainer.cs +++ b/pkNX.Containers/FolderContainer.cs @@ -22,7 +22,7 @@ public class FolderContainer : IFileContainer public FolderContainer(string path, Func filter) : this(path) => Initialize(filter); public IReadOnlyList GetPaths() => Paths; - public IReadOnlyList GetFileNames() => Paths.Select(Path.GetFileName).ToList()!; + public IReadOnlyList GetFileNames() => Paths.ConvertAll(Path.GetFileName)!; public void Initialize(Func? filter = null) { diff --git a/pkNX.Containers/Mini/MiniUtil.cs b/pkNX.Containers/Mini/MiniUtil.cs index aad0bb1e..83bc40b3 100644 --- a/pkNX.Containers/Mini/MiniUtil.cs +++ b/pkNX.Containers/Mini/MiniUtil.cs @@ -97,10 +97,7 @@ public static Mini GetMini(string path) path = FileMitm.GetRedirectedReadPath(path); using var fs = new FileStream(path, FileMode.Open, FileAccess.Read); using var br = new BinaryReader(fs); - var result = GetMini(br); - if (result is null) - throw new FormatException($"The file at {path} is not a {nameof(Mini)} file."); - return result; + return GetMini(br) ?? throw new FormatException($"The file at {path} is not a {nameof(Mini)} file."); } public static Mini? GetMini(BinaryReader br) diff --git a/pkNX.Containers/Misc/AHTBEntry.cs b/pkNX.Containers/Misc/AHTBEntry.cs index b4bc19f1..cf7d6e12 100644 --- a/pkNX.Containers/Misc/AHTBEntry.cs +++ b/pkNX.Containers/Misc/AHTBEntry.cs @@ -2,24 +2,14 @@ namespace pkNX.Containers; -public class AHTBEntry +public class AHTBEntry(ulong hash, ushort namelen, string name) { - public ulong Hash; - public ushort NameLength; - public string Name; + public ulong Hash = hash; + public ushort NameLength = namelen; + public string Name = name; - public AHTBEntry(ulong hash, ushort namelen, string name) + public AHTBEntry(BinaryReader br) : this(br.ReadUInt64(), br.ReadUInt16(), br.ReadStringBytesUntil(0)) { - Hash = hash; - NameLength = namelen; - Name = name; - } - - public AHTBEntry(BinaryReader br) - { - Hash = br.ReadUInt64(); - NameLength = br.ReadUInt16(); - Name = br.ReadStringBytesUntil(0); // could use Length field, but they're always \0 terminated //Debug.Assert(FnvHash.HashFnv1a_64(Name) == Hash); //Debug.Assert(Name.Length + 1 == NameLength); // Always null terminated } diff --git a/pkNX.Containers/Misc/GFPack.cs b/pkNX.Containers/Misc/GFPack.cs index 61823d8e..605d2985 100644 --- a/pkNX.Containers/Misc/GFPack.cs +++ b/pkNX.Containers/Misc/GFPack.cs @@ -164,9 +164,7 @@ public void LoadFiles(string[] directories, string parent, CompressionType type for (int f = 0; f < groups.Length; f++) { var folderFiles = groups[f]; - var folderName = Path.GetDirectoryName(directories[f]); - if (folderName is null) - throw new Exception("Invalid folder name"); + var folderName = Path.GetDirectoryName(directories[f]) ?? throw new Exception("Invalid folder name"); var table = HashInFolder[f] = new FileHashFolder(); table.Folder = new FileHashFolderInfo { diff --git a/pkNX.Containers/VFS/FileSystems/Archives/ZipArchiveFileSystem.cs b/pkNX.Containers/VFS/FileSystems/Archives/ZipArchiveFileSystem.cs index 20bf5f5f..f6cb89c0 100644 --- a/pkNX.Containers/VFS/FileSystems/Archives/ZipArchiveFileSystem.cs +++ b/pkNX.Containers/VFS/FileSystems/Archives/ZipArchiveFileSystem.cs @@ -6,7 +6,7 @@ namespace pkNX.Containers.VFS; -public class ZipArchiveFileSystem : IFileSystem +public sealed class ZipArchiveFileSystem : IFileSystem { public ZipArchive ZipArchive { get; } public bool IsReadOnly => false; diff --git a/pkNX.Containers/VFS/FileSystems/LayeredFileSystem.cs b/pkNX.Containers/VFS/FileSystems/LayeredFileSystem.cs index 2b8808d2..9f51ac5d 100644 --- a/pkNX.Containers/VFS/FileSystems/LayeredFileSystem.cs +++ b/pkNX.Containers/VFS/FileSystems/LayeredFileSystem.cs @@ -3,8 +3,6 @@ using System.Diagnostics; using System.IO; using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; namespace pkNX.Containers.VFS; @@ -82,12 +80,12 @@ public bool Exists(FileSystemPath path) public IFileSystem? GetFirstWhereExists(FileSystemPath path) { - return _fileSystems.FirstOrDefault(fs => fs.Exists(path)); + return Array.Find(_fileSystems, fs => fs.Exists(path)); } public IFileSystem? GetFirstWritableWhereExists(FileSystemPath path) { - return _fileSystems.FirstOrDefault(fs => !fs.IsReadOnly && fs.Exists(path)); + return Array.Find(_fileSystems, fs => !fs.IsReadOnly && fs.Exists(path)); } private bool ValidateOpenMode(FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read) @@ -115,10 +113,7 @@ public Stream OpenFile(FileSystemPath path, FileMode mode = FileMode.Open, FileA case FileMode.Open: { // just read from top layer - IFileSystem? fs = GetFirstWhereExists(path); - if (fs == null) - throw new FileNotFoundException($"Could not find the file at the specified path: {path}", nameof(path)); - + var fs = GetFirstWhereExists(path) ?? throw new FileNotFoundException($"Could not find the file at the specified path: {path}", nameof(path)); return fs.OpenFile(path, FileMode.Open, access); } case FileMode.OpenOrCreate: diff --git a/pkNX.Containers/VFS/FileSystems/ReadOnlyFileSystem.cs b/pkNX.Containers/VFS/FileSystems/ReadOnlyFileSystem.cs index 1648eee1..58e7aa6d 100644 --- a/pkNX.Containers/VFS/FileSystems/ReadOnlyFileSystem.cs +++ b/pkNX.Containers/VFS/FileSystems/ReadOnlyFileSystem.cs @@ -5,16 +5,11 @@ namespace pkNX.Containers.VFS; -public class ReadOnlyFileSystem : IFileSystem +public class ReadOnlyFileSystem(IFileSystem fileSystem) : IFileSystem { public bool IsReadOnly => true; - public IFileSystem FileSystem { get; } - - public ReadOnlyFileSystem(IFileSystem fileSystem) - { - FileSystem = fileSystem; - } + public IFileSystem FileSystem { get; } = fileSystem; public void Dispose() { diff --git a/pkNX.Containers/VFS/FileSystems/RelativeFileSystem.cs b/pkNX.Containers/VFS/FileSystems/RelativeFileSystem.cs index 65db43a6..2b0da41e 100644 --- a/pkNX.Containers/VFS/FileSystems/RelativeFileSystem.cs +++ b/pkNX.Containers/VFS/FileSystems/RelativeFileSystem.cs @@ -8,21 +8,18 @@ namespace pkNX.Containers.VFS; public delegate FileSystemPath PathTransformation(FileSystemPath arg); -public class RelativeFileSystem : IFileSystem +[method: MethodImpl(MethodImplOptions.AggressiveInlining)] +public class RelativeFileSystem( + IFileSystem fileSystem, + PathTransformation toAbsolutePath, + PathTransformation toRelativePath) + : IFileSystem { - public IFileSystem FileSystem { get; } + public IFileSystem FileSystem { get; } = fileSystem; public bool IsReadOnly => FileSystem.IsReadOnly; - public PathTransformation ToAbsolutePath { get; } - public PathTransformation ToRelativePath { get; } - - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public RelativeFileSystem(IFileSystem fileSystem, PathTransformation toAbsolutePath, PathTransformation toRelativePath) - { - FileSystem = fileSystem; - ToAbsolutePath = toAbsolutePath; - ToRelativePath = toRelativePath; - } + public PathTransformation ToAbsolutePath { get; } = toAbsolutePath; + public PathTransformation ToRelativePath { get; } = toRelativePath; public void Dispose() { diff --git a/pkNX.Containers/VFS/Util/FileSystemPath.cs b/pkNX.Containers/VFS/Util/FileSystemPath.cs index 4971131c..7820ed9e 100644 --- a/pkNX.Containers/VFS/Util/FileSystemPath.cs +++ b/pkNX.Containers/VFS/Util/FileSystemPath.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Diagnostics.Contracts; -using System.Linq; namespace pkNX.Containers.VFS; @@ -185,13 +184,13 @@ public IEnumerable GetDirectorySegments() segments.AddFirst(path.EntityName); path = path.ParentPath; } - return segments.ToArray(); + return [.. segments]; } [Pure] public int CompareTo(FileSystemPath other) { - return string.Compare(Path, other.Path, StringComparison.Ordinal); + return string.CompareOrdinal(Path, other.Path); } [Pure] diff --git a/pkNX.Game/Editors/DataCache.cs b/pkNX.Game/Editors/DataCache.cs index 1469c262..13bbf7db 100644 --- a/pkNX.Game/Editors/DataCache.cs +++ b/pkNX.Game/Editors/DataCache.cs @@ -7,16 +7,16 @@ namespace pkNX.Game; -public class DataCache : IDataEditor where T : class +public class DataCache(IList cache) : IDataEditor + where T : class { public IFileContainer Data { protected get; set; } = null!; public Func Create { private get; set; } = null!; public Func Write { protected get; set; } = null!; - public DataCache(IList cache) => Cache = cache; public DataCache(IFileContainer f) : this(new T[f.Count]) => Data = f; - protected readonly IList Cache; + protected readonly IList Cache = cache; private bool Cached; public int Length => Cache.Count; @@ -75,9 +75,9 @@ public virtual void Save() /// Data with already known contents. /// /// -public class DirectCache : DataCache where T : class +public class DirectCache(IList cache) : DataCache(cache) + where T : class { - public DirectCache(IList cache) : base(cache) { } public override void Save() { } } diff --git a/pkNX.Game/Editors/EditorFactory.cs b/pkNX.Game/Editors/EditorFactory.cs index a8ff978c..2000360a 100644 --- a/pkNX.Game/Editors/EditorFactory.cs +++ b/pkNX.Game/Editors/EditorFactory.cs @@ -1,5 +1,3 @@ namespace pkNX.Game; -public class EditorFactory -{ -} \ No newline at end of file +public class EditorFactory; \ No newline at end of file diff --git a/pkNX.Game/Editors/EditorUtil.cs b/pkNX.Game/Editors/EditorUtil.cs index 2dc6c334..627c7454 100644 --- a/pkNX.Game/Editors/EditorUtil.cs +++ b/pkNX.Game/Editors/EditorUtil.cs @@ -7,7 +7,7 @@ public static string[] SanitizeMoveList(string[] list) var movelist = (string[])list.Clone(); if (movelist.Length < 658) return movelist; - string[] ps = { "P", "S" }; // Distinguish Physical/Special Z Moves + string[] ps = ["P", "S"]; // Distinguish Physical/Special Z Moves for (int i = 622; i < 658; i++) movelist[i] += $" ({ps[i % 2]})"; return movelist; diff --git a/pkNX.Game/Editors/ShinyRate/ShinyRateGG.cs b/pkNX.Game/Editors/ShinyRate/ShinyRateGG.cs index b2030741..506747fc 100644 --- a/pkNX.Game/Editors/ShinyRate/ShinyRateGG.cs +++ b/pkNX.Game/Editors/ShinyRate/ShinyRateGG.cs @@ -3,7 +3,7 @@ namespace pkNX.Game; -public sealed class ShinyRateGG : ShinyRateInfo +public sealed class ShinyRateGG(byte[] data) : ShinyRateInfo(data) { /* Shiny Rate Patch -- fix the loop counter regardless of input param value. @@ -32,13 +32,11 @@ public sealed class ShinyRateGG : ShinyRateInfo write AB FE FF 54 after the above 12 byte sequence */ - private readonly int CodeOffset; - private static readonly byte[] Pattern = { 0x68, 0x96, 0x40, 0x39, 0x94, 0x06, 0x00, 0x11 }; - private static readonly byte[] Default = { 0x9F, 0x02, 0x08, 0x6B }; // cmp W20, W8 - private static readonly byte[] Always12 = { 0x1F, 0x20, 0x03, 0xD5 }; // nop - private static readonly byte[] Revert12 = { 0xAB, 0xFE, 0xFF, 0x54 }; // bl - - public ShinyRateGG(byte[] data) : base(data) => CodeOffset = CodePattern.IndexOfBytes(data, Pattern, 0x500_000); + private readonly int CodeOffset = CodePattern.IndexOfBytes(data, Pattern, 0x500_000); + private static readonly byte[] Pattern = [0x68, 0x96, 0x40, 0x39, 0x94, 0x06, 0x00, 0x11]; + private static readonly byte[] Default = [0x9F, 0x02, 0x08, 0x6B]; // cmp W20, W8 + private static readonly byte[] Always12 = [0x1F, 0x20, 0x03, 0xD5]; // nop + private static readonly byte[] Revert12 = [0xAB, 0xFE, 0xFF, 0x54]; // bl public override bool IsEditable => CodeOffset > 0; diff --git a/pkNX.Game/Editors/ShinyRate/ShinyRateInfo.cs b/pkNX.Game/Editors/ShinyRate/ShinyRateInfo.cs index ea29dfe9..3cd3bfa2 100644 --- a/pkNX.Game/Editors/ShinyRate/ShinyRateInfo.cs +++ b/pkNX.Game/Editors/ShinyRate/ShinyRateInfo.cs @@ -1,9 +1,8 @@ namespace pkNX.Game; -public abstract class ShinyRateInfo +public abstract class ShinyRateInfo(byte[] data) { - public byte[] Data { get; } - protected ShinyRateInfo(byte[] data) => Data = data; + public byte[] Data { get; } = data; public abstract bool IsEditable { get; } diff --git a/pkNX.Game/Editors/ShinyRate/ShinyRateSWSH.cs b/pkNX.Game/Editors/ShinyRate/ShinyRateSWSH.cs index 67e909e5..3f40bca8 100644 --- a/pkNX.Game/Editors/ShinyRate/ShinyRateSWSH.cs +++ b/pkNX.Game/Editors/ShinyRate/ShinyRateSWSH.cs @@ -3,7 +3,7 @@ namespace pkNX.Game; -public sealed class ShinyRateSWSH : ShinyRateInfo +public sealed class ShinyRateSWSH(byte[] data, int offset = 0x700_000) : ShinyRateInfo(data) { /* Shiny Rate Patch -- fix the overworld loop counter regardless of shiny rate factors. @@ -32,20 +32,15 @@ public sealed class ShinyRateSWSH : ShinyRateInfo write 62 00 00 54 after the above 12 byte sequence. */ - private readonly int FunctionOffset; // loop counter and break - private static readonly byte[] FunctionPrelude = { 0xff, 0x03, 0x06, 0xd1, 0xfc, 0x6f, 0x12, 0xa9, 0xfa, 0x67, 0x13, 0xa9, 0xf8, 0x5f, 0x14, 0xa9, 0xf6, 0x57, 0x15, 0xa9, 0xf4, 0x4f, 0x16, 0xa9, 0xfd, 0x7b, 0x17, 0xa9, 0xfd, 0xc3, 0x05, 0x91, 0xfa, 0xc6, 0x00, 0xf0 }; + private readonly int FunctionOffset = CodePattern.IndexOfBytes(data, FunctionPrelude, offset); // loop counter and break + private static readonly byte[] FunctionPrelude = [0xff, 0x03, 0x06, 0xd1, 0xfc, 0x6f, 0x12, 0xa9, 0xfa, 0x67, 0x13, 0xa9, 0xf8, 0x5f, 0x14, 0xa9, 0xf6, 0x57, 0x15, 0xa9, 0xf4, 0x4f, 0x16, 0xa9, 0xfd, 0x7b, 0x17, 0xa9, 0xfd, 0xc3, 0x05, 0x91, 0xfa, 0xc6, 0x00, 0xf0]; private const int RerollCountCheckOffset = 0x2C8; - private static readonly byte[] RerollCountCheckDefault = { 0x3f, 0x03, 0x17, 0x6b}; + private static readonly byte[] RerollCountCheckDefault = [0x3f, 0x03, 0x17, 0x6b]; private const int RerollCountBreakOffset = 0x2CC; - private static readonly byte[] RerollCountBreakDefault = { 0x62, 0x00, 0x00, 0x54 }; // b.cs $pc + 12 - private static readonly byte[] RerollCountBreakNop = { 0x1F, 0x20, 0x03, 0xD5 }; // nop - - public ShinyRateSWSH(byte[] data, int offset = 0x700_000) : base(data) - { - FunctionOffset = CodePattern.IndexOfBytes(data, FunctionPrelude, offset); - } + private static readonly byte[] RerollCountBreakDefault = [0x62, 0x00, 0x00, 0x54]; // b.cs $pc + 12 + private static readonly byte[] RerollCountBreakNop = [0x1F, 0x20, 0x03, 0xD5]; // nop public override bool IsEditable => FunctionOffset > 0; diff --git a/pkNX.Game/Editors/TypeChartEditor.cs b/pkNX.Game/Editors/TypeChartEditor.cs index df8b87ca..21b6377e 100644 --- a/pkNX.Game/Editors/TypeChartEditor.cs +++ b/pkNX.Game/Editors/TypeChartEditor.cs @@ -4,14 +4,12 @@ namespace pkNX.Game; -public class TypeChartEditor +public class TypeChartEditor(byte[] data) { - public byte[] Data; + public byte[] Data = data; public int Width => (int)Math.Sqrt(Data.Length); public int Height => (int)Math.Sqrt(Data.Length); - public TypeChartEditor(byte[] data) => Data = data; - public void Randomize() { var rnd = Util.Random; @@ -34,7 +32,7 @@ private static byte GetEffectiveness(int rv) } private static readonly uint[] Colors = - { + [ 0xFF000000, 0, // unused 0xFFFF0000, @@ -42,7 +40,7 @@ private static byte GetEffectiveness(int rv) 0xFFFFFFFF, 0, 0, 0, // unused 0xFF008000, - }; + ]; public static byte[] GetTypeChartImageData(int itemsize, int itemsPerRow, byte[] vals, out int width, out int height) { diff --git a/pkNX.Game/File/GameFileMapping.cs b/pkNX.Game/File/GameFileMapping.cs index 288a0b85..c7cbecb4 100644 --- a/pkNX.Game/File/GameFileMapping.cs +++ b/pkNX.Game/File/GameFileMapping.cs @@ -32,10 +32,7 @@ internal IFileContainer GetFile(GameFile file, int language, GameManager gameMan if (Cache.TryGetValue(file, out var container)) return container; - var info = FileMap.FirstOrDefault(f => f.File == file); - if (info == null) - throw new ArgumentException($"Unknown {nameof(GameFile)} provided.", file.ToString()); - + var info = FileMap.FirstOrDefault(f => f.File == file) ?? throw new ArgumentException($"Unknown {nameof(GameFile)} provided.", file.ToString()); if (info.Type is SingleFileInternal && gameManager is IFileInternal irom) { var data = irom.GetPackedFile(info.RelativePath); @@ -43,9 +40,7 @@ internal IFileContainer GetFile(GameFile file, int language, GameManager gameMan } else { - var basePath = info.Parent == ContainerParent.ExeFS ? ROM.ExeFS : ROM.RomFS; - if (basePath == null) - throw new ArgumentException($"No {info.Parent} found for {file}."); + var basePath = (info.Parent == ContainerParent.ExeFS ? ROM.ExeFS : ROM.RomFS) ?? throw new ArgumentException($"No {info.Parent} found for {file}."); container = info.Get(basePath); } Cache.Add(file, container); @@ -80,7 +75,7 @@ internal void SaveAll() /// Let's Go Pikachu & Let's Go Eevee /// private static readonly GameFileReference[] FilesGG = - { + [ new(TrainerSpecData, "bin", "trainer", "trainer_data"), new(TrainerSpecPoke, "bin", "trainer", "trainer_poke"), new(TrainerSpecClass, "bin", "trainer", "trainer_type"), @@ -126,7 +121,7 @@ internal void SaveAll() // Cutscenes bin\demo // Models bin\archive\pokemon // pretty much everything is obviously named :) - }; + ]; #endregion @@ -135,7 +130,7 @@ internal void SaveAll() /// Sword & Shield /// private static readonly GameFileReference[] FilesSWSH = - { + [ new(TrainerSpecData, "bin", "trainer", "trainer_data"), new(TrainerSpecPoke, "bin", "trainer", "trainer_poke"), new(TrainerSpecClass, "bin", "trainer", "trainer_type"), @@ -190,13 +185,13 @@ internal void SaveAll() // Cutscenes bin\demo // Models bin\archive\pokemon // pretty much everything is obviously named :) - }; + ]; /// /// Legends: Arceus /// private static readonly GameFileReference[] FilesPLA = - { + [ new(TrainerSpecData, "bin", "trainer"), new(GameText0, 0, "bin", "message", "JPN", "common"), @@ -391,7 +386,7 @@ internal void SaveAll() // Cutscenes bin\demo // Models bin\archive\pokemon // pretty much everything is obviously named :) - }; + ]; #endregion #region Gen9 @@ -399,7 +394,7 @@ internal void SaveAll() /// Scarlet & Violet /// private static readonly GameFileReference[] FilesSV = - { + [ new(DataTrpfd, SingleFile, "arc", "data.trpfd"), new(DataTrpfs, SingleFile, "arc", "data.trpfs"), // new(TrainerSpecData, "bin", "trainer"), @@ -436,6 +431,6 @@ internal void SaveAll() // // new(EncounterTableGift , SingleFile, "bin", "pokemon", "data", "poke_add.bin"), // new(EncounterTableTrade , SingleFile, "bin", "script_event_data", "field_trade.bin"), // Incorrect? - }; + ]; #endregion } diff --git a/pkNX.Game/GameManagerGG.cs b/pkNX.Game/GameManagerGG.cs index c12f4063..face934e 100644 --- a/pkNX.Game/GameManagerGG.cs +++ b/pkNX.Game/GameManagerGG.cs @@ -5,9 +5,8 @@ namespace pkNX.Game; -public class GameManagerGG : GameManager +public class GameManagerGG(GameLocation rom, int language) : GameManager(rom, language) { - public GameManagerGG(GameLocation rom, int language) : base(rom, language) { } private GameVersion ActualGame; private string TitleID => ActualGame == GameVersion.GP ? Pikachu : Eevee; private const string Pikachu = "010003F003A34000"; diff --git a/pkNX.Game/GameManagerPLA.cs b/pkNX.Game/GameManagerPLA.cs index 385fa2a7..40efb908 100644 --- a/pkNX.Game/GameManagerPLA.cs +++ b/pkNX.Game/GameManagerPLA.cs @@ -10,9 +10,8 @@ namespace pkNX.Game; -public class GameManagerPLA : GameManager +public class GameManagerPLA(GameLocation rom, int language) : GameManager(rom, language) { - public GameManagerPLA(GameLocation rom, int language) : base(rom, language) { } private string PathNPDM => Path.Combine(PathExeFS, "main.npdm"); private string TitleID => BitConverter.ToUInt64(File.ReadAllBytes(PathNPDM), 0x470).ToString("X16"); diff --git a/pkNX.Game/GameManagerSWSH.cs b/pkNX.Game/GameManagerSWSH.cs index c91c3a92..97cc8dfa 100644 --- a/pkNX.Game/GameManagerSWSH.cs +++ b/pkNX.Game/GameManagerSWSH.cs @@ -8,9 +8,8 @@ namespace pkNX.Game; -public class GameManagerSWSH : GameManager +public class GameManagerSWSH(GameLocation rom, int language) : GameManager(rom, language) { - public GameManagerSWSH(GameLocation rom, int language) : base(rom, language) { } private string npdmPath => Path.Combine(PathExeFS, "main.npdm"); private string TitleID => BitConverter.ToUInt64(File.ReadAllBytes(npdmPath), 0x290).ToString("X16"); diff --git a/pkNX.Game/Text/TextManager.cs b/pkNX.Game/Text/TextManager.cs index bfdee243..eb321cac 100644 --- a/pkNX.Game/Text/TextManager.cs +++ b/pkNX.Game/Text/TextManager.cs @@ -6,21 +6,15 @@ namespace pkNX.Game; -public class TextManager +public class TextManager(GameVersion game, TextConfig? config = null) { - private readonly TextConfig Config; - private readonly IReadOnlyCollection References; + private readonly TextConfig Config = config ?? new TextConfig(game); + private readonly IReadOnlyCollection References = TextMapping.GetMapping(game); private readonly Dictionary Cache = []; public void ClearCache() => Cache.Clear(); - public TextManager(GameVersion game, TextConfig? config = null) - { - References = TextMapping.GetMapping(game); - Config = config ?? new TextConfig(game); - } - internal string[] GetStrings(byte[] data, bool remap = false) { var txt = new TextFile(data, Config, remap); diff --git a/pkNX.Game/Text/TextMapping.cs b/pkNX.Game/Text/TextMapping.cs index 0b76d75f..7331fc1c 100644 --- a/pkNX.Game/Text/TextMapping.cs +++ b/pkNX.Game/Text/TextMapping.cs @@ -22,7 +22,7 @@ public static class TextMapping }; private static readonly TextReference[] MapXY = - { + [ new(005, Forms), new(013, MoveNames), new(015, MoveFlavor), @@ -39,10 +39,10 @@ public static class TextMapping new(130, MaisonTrainerNames), new(131, SuperTrainerNames), new(141, OPowerFlavor), - }; + ]; private static readonly TextReference[] MapAO = - { + [ new(005, Forms), new(014, MoveNames), new(016, MoveFlavor), @@ -59,10 +59,10 @@ public static class TextMapping new(153, MaisonTrainerNames), new(154, SuperTrainerNames), new(165, OPowerFlavor), - }; + ]; private static readonly TextReference[] MapSMDemo = - { + [ new(020, ItemFlavor), new(021, ItemNames), new(026, SpeciesNames), @@ -76,10 +76,10 @@ public static class TextMapping new(052, TypeNames), new(054, MoveFlavor), new(055, MoveNames), - }; + ]; private static readonly TextReference[] MapSM = - { + [ new(035, ItemFlavor), new(036, ItemNames), new(055, SpeciesNames), @@ -98,10 +98,10 @@ public static class TextMapping new(116, SpeciesClassifications), new(119, PokedexEntry1), new(120, PokedexEntry2), - }; + ]; private static readonly TextReference[] MapUSUM = - { + [ new(039, ItemFlavor), new(040, ItemNames), new(060, SpeciesNames), @@ -120,10 +120,10 @@ public static class TextMapping new(121, SpeciesClassifications), new(124, PokedexEntry1), new(125, PokedexEntry2), - }; + ]; private static readonly TextReference[] MapGG = - { + [ new("iteminfo.dat", ItemFlavor), new("itemname.dat", ItemNames), new("monsname.dat", SpeciesNames), @@ -140,10 +140,10 @@ public static class TextMapping new("zkn_form.dat", Forms), new("zkn_type.dat", SpeciesClassifications), new("zukan_comment_A.dat", PokedexEntry1), - }; + ]; private static readonly TextReference[] MapSWSH = - { + [ new("iteminfo.dat", ItemFlavor), new("itemname.dat", ItemNames), new("monsname.dat", SpeciesNames), @@ -166,10 +166,10 @@ public static class TextMapping new("zukan_comment_B.dat", PokedexEntry2), new("ribbon.dat", RibbonMark), new("poke_memory_feeling.dat", MemoryFeelings), - }; + ]; private static readonly TextReference[] MapPLA = - { + [ new("iteminfo.dat", ItemFlavor), new("itemname.dat", ItemNames), new("monsname.dat", SpeciesNames), @@ -192,10 +192,10 @@ public static class TextMapping new("zukan_comment_B.dat", PokedexEntry2), new("ribbon.dat", RibbonMark), new("poke_memory_feeling.dat", MemoryFeelings), - }; + ]; private static readonly TextReference[] MapSV = - { + [ new("iteminfo.dat", ItemFlavor), new("itemname.dat", ItemNames), new("monsname.dat", SpeciesNames), @@ -218,5 +218,5 @@ public static class TextMapping new("zukan_comment_B.dat", PokedexEntry2), new("ribbon.dat", RibbonMark), new("poke_memory_feeling.dat", MemoryFeelings), - }; + ]; } diff --git a/pkNX.Randomization/Randomizers/FormRandomizer.cs b/pkNX.Randomization/Randomizers/FormRandomizer.cs index 4058b937..8d238aef 100644 --- a/pkNX.Randomization/Randomizers/FormRandomizer.cs +++ b/pkNX.Randomization/Randomizers/FormRandomizer.cs @@ -4,18 +4,11 @@ namespace pkNX.Randomization; -public class FormRandomizer +public class FormRandomizer(IPersonalTable t) { - private readonly IPersonalTable Personal; - - public FormRandomizer(IPersonalTable t) - { - Personal = t; - } - public int GetRandomForm(int species, bool mega, bool fuse, int generation, IPersonalInfo[]? stats = null) { - stats ??= Personal.Table; + stats ??= t.Table; if (stats[species].FormCount <= 1) return 0; @@ -33,7 +26,7 @@ public int GetRandomForm(int species, bool mega, bool fuse, int generation, IPer return (Species)species switch { - Pikachu or Slowbro when generation >= 8 => GetValidForm(species, generation, Personal), + Pikachu or Slowbro when generation >= 8 => GetValidForm(species, generation, t), Unown or Deerling or Sawsbuck => 31, // pure random -- todo sv see if this behavior changed Greninja when !mega => 0, // treat Ash-Greninja as a Mega Scatterbug or Spewpa or Vivillon => 30, // save file specific -- todo sv see if this behavior changed diff --git a/pkNX.Randomization/Randomizers/GenericRandomizer.cs b/pkNX.Randomization/Randomizers/GenericRandomizer.cs index 493d85b6..9fdff484 100644 --- a/pkNX.Randomization/Randomizers/GenericRandomizer.cs +++ b/pkNX.Randomization/Randomizers/GenericRandomizer.cs @@ -5,30 +5,24 @@ namespace pkNX.Randomization; /// The shuffled list is iterated over, and reshuffled when exhausted. /// The list does not repeat values until the list is exhausted. /// -public class GenericRandomizer +public class GenericRandomizer(T[] randomValues) { - public GenericRandomizer(T[] randomValues) - { - RandomValues = randomValues; - } - - private readonly T[] RandomValues; private int ctr; - public int Count => RandomValues.Length; + public int Count => randomValues.Length; public void Reset() { ctr = 0; - Util.Shuffle(RandomValues); + Util.Shuffle(randomValues); } public T Next() { if (ctr == 0) - Util.Shuffle(RandomValues); + Util.Shuffle(randomValues); - T value = RandomValues[ctr++]; - ctr %= RandomValues.Length; + T value = randomValues[ctr++]; + ctr %= randomValues.Length; return value; } diff --git a/pkNX.Randomization/Randomizers/LearnsetRandomizer.cs b/pkNX.Randomization/Randomizers/LearnsetRandomizer.cs index fd07675b..6a69ed93 100644 --- a/pkNX.Randomization/Randomizers/LearnsetRandomizer.cs +++ b/pkNX.Randomization/Randomizers/LearnsetRandomizer.cs @@ -14,7 +14,7 @@ public class LearnsetRandomizer : Randomizer private readonly GameInfo Game; private readonly IPersonalTable Personal; private MoveRandomizer moverand; - public IReadOnlyList Moves { private get; set; } = Array.Empty(); + public IReadOnlyList Moves { private get; set; } = []; public LearnSettings Settings { get; private set; } = new(); public IList BannedMoves { set => moverand.Settings.BannedMoves = value; } @@ -29,8 +29,8 @@ public LearnsetRandomizer(GameInfo game, Learnset[] learnsets, IPersonalTable t) moverand = new MoveRandomizer(game, Moves, Personal); } - private static readonly int[] MetronomeMove = { 118 }; - private static readonly int[] MetronomeLevel = { 1 }; + private static readonly int[] MetronomeMove = [118]; + private static readonly int[] MetronomeLevel = [1]; public void ExecuteMetronome() { diff --git a/pkNX.Randomization/Randomizers/MoveRandomizer.cs b/pkNX.Randomization/Randomizers/MoveRandomizer.cs index d3e2502c..d7747611 100644 --- a/pkNX.Randomization/Randomizers/MoveRandomizer.cs +++ b/pkNX.Randomization/Randomizers/MoveRandomizer.cs @@ -25,7 +25,7 @@ public MoveRandomizer(GameInfo config, IReadOnlyList moves, IPersonalTabl public override void Execute() => throw new Exception("Shouldn't be called."); - public static readonly int[] FixedDamageMoves = { 49, 82 }; + public static readonly int[] FixedDamageMoves = [49, 82]; public void Initialize(MovesetRandSettings settings, int[] bannedMoves) { @@ -127,7 +127,7 @@ private static void ReorderMovesPower(IList moves, IReadOnlyList mov } private static readonly int[] firstMoves = - { + [ 1, // Pound 40, // Poison Sting 52, // Ember @@ -138,7 +138,7 @@ private static void ReorderMovesPower(IList moves, IReadOnlyList mov 98, // Quick Attack 122, // Lick 141, // Leech Life - }; + ]; private static readonly GenericRandomizer first = new(firstMoves); diff --git a/pkNX.Randomization/Randomizers/Personal/PersonalRandSettings.cs b/pkNX.Randomization/Randomizers/Personal/PersonalRandSettings.cs index 972539ce..e0357c40 100644 --- a/pkNX.Randomization/Randomizers/Personal/PersonalRandSettings.cs +++ b/pkNX.Randomization/Randomizers/Personal/PersonalRandSettings.cs @@ -131,7 +131,7 @@ public class PersonalRandSettings : RandSettings /// /// Flags to edit the stats when randomizing. /// - public IReadOnlyList StatsToRandomize => new[] {HP, ATK, DEF, SPE, SPA, SPD}; + public IReadOnlyList StatsToRandomize => [HP, ATK, DEF, SPE, SPA, SPD]; #endregion #region Misc diff --git a/pkNX.Randomization/Randomizers/Personal/PersonalRandomizer.cs b/pkNX.Randomization/Randomizers/Personal/PersonalRandomizer.cs index 3a9a3f29..bfd07e74 100644 --- a/pkNX.Randomization/Randomizers/Personal/PersonalRandomizer.cs +++ b/pkNX.Randomization/Randomizers/Personal/PersonalRandomizer.cs @@ -463,7 +463,7 @@ private static void RandomShuffledStats(IBaseStat z) private int GetRandomType() => Rand.Next(0, TypeCount); private int GetRandomEggGroup() => Rand.Next(1, eggGroupCount); private int GetRandomHeldItem() => Game.HeldItems.Length > 1 ? Game.HeldItems[Rand.Next(1, Game.HeldItems.Length)] : 0; - private readonly IList BannedAbilities = Array.Empty(); + private readonly IList BannedAbilities = []; private int GetRandomAbility() { diff --git a/pkNX.Randomization/Randomizers/Settings/MovesetRandSettings.cs b/pkNX.Randomization/Randomizers/Settings/MovesetRandSettings.cs index 90393718..cf516be1 100644 --- a/pkNX.Randomization/Randomizers/Settings/MovesetRandSettings.cs +++ b/pkNX.Randomization/Randomizers/Settings/MovesetRandSettings.cs @@ -28,7 +28,7 @@ public class MovesetRandSettings public float STABPercent { get; set; } = 25; [Category(Misc), Description("Banned move IDs.")] - internal IList BannedMoves { get; set; } = Array.Empty(); + internal IList BannedMoves { get; set; } = []; [Category(Misc), Description("Prevents Pokémon movesets from containing fixed damage moves.")] public bool BanFixedDamageMoves { get; set; } = true; diff --git a/pkNX.Randomization/Randomizers/Settings/RandSettings.cs b/pkNX.Randomization/Randomizers/Settings/RandSettings.cs index 3821f8b3..f2f20fe2 100644 --- a/pkNX.Randomization/Randomizers/Settings/RandSettings.cs +++ b/pkNX.Randomization/Randomizers/Settings/RandSettings.cs @@ -1,5 +1,3 @@ namespace pkNX.Randomization; -public class RandSettings -{ -} +public class RandSettings; diff --git a/pkNX.Randomization/Randomizers/Settings/SpeciesSettings.cs b/pkNX.Randomization/Randomizers/Settings/SpeciesSettings.cs index 6d73d5c2..1c881f95 100644 --- a/pkNX.Randomization/Randomizers/Settings/SpeciesSettings.cs +++ b/pkNX.Randomization/Randomizers/Settings/SpeciesSettings.cs @@ -112,7 +112,7 @@ public int[] GetSpecies(int maxSpecies, int generation) if (generation == 7 && Gen1 && Events && maxSpecies <= Legal.MaxSpeciesID_7_GG) AddGGEvents(list); - return list.Count == 0 ? GetSpeciesAll(maxSpecies) : list.ToArray(); + return list.Count == 0 ? GetSpeciesAll(maxSpecies) : [.. list]; } private static int[] GetSpeciesAll(int maxSpecies) => Enumerable.Range(1, maxSpecies).ToArray(); diff --git a/pkNX.Randomization/Randomizers/TrainerRandomizer.cs b/pkNX.Randomization/Randomizers/TrainerRandomizer.cs index a5ef3324..3355d4dc 100644 --- a/pkNX.Randomization/Randomizers/TrainerRandomizer.cs +++ b/pkNX.Randomization/Randomizers/TrainerRandomizer.cs @@ -39,7 +39,7 @@ public TrainerRandomizer(GameInfo info, IPersonalTable t, VsTrainer[] trainers, Evos = evos; PossibleHeldItems = Legal.GetRandomItemList(Info.Game); - GigantamaxForms = Legal.GigantamaxForms.ToArray(); + GigantamaxForms = [.. Legal.GigantamaxForms]; MegaDictionary = Legal.GetMegaDictionary(Info.Game); IndexFixedCount = GetFixedCountIndexes(Info.Game); SpecialClasses = GetSpecialClasses(Info.Game); @@ -236,7 +236,7 @@ private void UpdatePKMFromSettings(TrainerPoke pk) if (Settings.RandomAbilities) pk.Ability = Util.Random.Next(1, 4); // 1, 2, or H if (Settings.MaxIVs) - pk.IVs = new[] { 31, 31, 31, 31, 31, 31 }; + pk.IVs = [31, 31, 31, 31, 31, 31]; TryForceEvolve(pk); @@ -304,7 +304,7 @@ private void RandomizeEntryMoves(TrainerPoke pk) pk.Moves = Learn.GetHighPoweredMoves((ushort)pk.Species, (byte)pk.Form); break; case MoveRandType.MetronomeOnly: // Metronome - pk.Moves = new[] { 118, 0, 0, 0 }; + pk.Moves = [118, 0, 0, 0]; break; default: return; @@ -332,26 +332,26 @@ private static int[] GetRandomMega(Dictionary megas, out int species } // 1 poke max - private static readonly int[] royal = { 081, 082, 083, 084, 185 }; + private static ReadOnlySpan royal => [081, 082, 083, 084, 185]; // 3 poke max - private static readonly int[] MultiBattle_GG = - { + private static ReadOnlySpan MultiBattle_GG => + [ 007, 008, 020, 021, 024, 025, 032, 033, 050, 051, // Jessie & James 028, 029, 030, 031, // Rival vs Archer & Grunt - }; + ]; // 3 poke max - private static readonly int[] MultiBattle_SWSH = - { + private static ReadOnlySpan MultiBattle_SWSH => + [ 156, 157, 158, 197, 198, 199, 225, 226, 227, 312, 313, 314, // Hop 223, 224, // Sordward and Shielbert - }; + ]; // 3 poke max - private static readonly int[] MultiBattle_SV = - { - }; + private static ReadOnlySpan MultiBattle_SV => + [ + ]; private static Dictionary GetFixedCountIndexes(GameVersion game) { diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Condition/ConditionUtil.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Condition/ConditionUtil.cs index 9c2a2634..14132164 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Condition/ConditionUtil.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Condition/ConditionUtil.cs @@ -1,6 +1,3 @@ -using System; -using System.Linq; - namespace pkNX.Structures.FlatBuffers.Arceus; public static class ConditionUtil diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/AppConfigList.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/AppConfigList.cs index 41bba8bc..467e1780 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/AppConfigList.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/AppConfigList.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class AppConfigEntry { } +public partial class AppConfigEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class AppConfigList { } +public partial class AppConfigList; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/ConfigureTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/ConfigureTable.cs index 5bc72100..9232fa0a 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/ConfigureTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Config/ConfigureTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ConfigArchive { } +public partial class ConfigArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class ConfigEntry diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/DressUp/DressUpTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/DressUp/DressUpTable.cs index c4994f1d..7623f025 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/DressUp/DressUpTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/DressUp/DressUpTable.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DressUpTable { } +public partial class DressUpTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DressUpEntry { } +public partial class DressUpEntry; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Event/Trigger.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Event/Trigger.cs index 9609fecd..29233368 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Event/Trigger.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Event/Trigger.cs @@ -10,13 +10,13 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TriggerTable { } +public partial class TriggerTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Trigger { } +public partial class Trigger; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TriggerMeta { } +public partial class TriggerMeta; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class TriggerCondition : IHasCondition @@ -27,4 +27,4 @@ public partial class TriggerCondition : IHasCondition } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TriggerCommand { } +public partial class TriggerCommand; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemSpawnTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemSpawnTable.cs index 7d3d57af..af68a4e2 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemSpawnTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemSpawnTable.cs @@ -13,7 +13,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LandmarkItemSpawnTable { } +public partial class LandmarkItemSpawnTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class LandmarkItemSpawn @@ -92,4 +92,4 @@ public string NameSummary } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LandmarkItemSpawn_F03 { } +public partial class LandmarkItemSpawn_F03; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemTable.cs index 4bf740fd..2f580534 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/LandmarkItemTable.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LandmarkItemTable { } +public partial class LandmarkItemTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class LandmarkItem : ISlotTableConsumer diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/MassOutbreakTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/MassOutbreakTable.cs index 18b81e1e..57035f4d 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/MassOutbreakTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/MassOutbreakTable.cs @@ -11,12 +11,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MassOutbreakTable { } +public partial class MassOutbreakTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MassOutbreak { } +public partial class MassOutbreak; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MassOutbreakCondition : IHasCondition -{ -} +public partial class MassOutbreakCondition : IHasCondition; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakGroup.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakGroup.cs index fc2316b3..7f2681b2 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakGroup.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakGroup.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NewHugeOutbreakGroupArchive { } +public partial class NewHugeOutbreakGroupArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class NewHugeOutbreakGroup diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakLottery.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakLottery.cs index 0c87388b..de309984 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakLottery.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakLottery.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NewHugeOutbreakLotteryArchive { } +public partial class NewHugeOutbreakLotteryArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NewHugeOutbreakLottery { } +public partial class NewHugeOutbreakLottery; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakTimeLimit.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakTimeLimit.cs index 4e21797f..e29e9a1d 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakTimeLimit.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/NewHuge/NewHugeOutbreakTimeLimit.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NewHugeOutbreakTimeLimitArchive { } +public partial class NewHugeOutbreakTimeLimitArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NewHugeOutbreakTimeLimit { } +public partial class NewHugeOutbreakTimeLimit; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/OybnSettingTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/OybnSettingTable.cs index 2913593b..f9b0ae97 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/OybnSettingTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/OybnSettingTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class OybnSettingTable { } +public partial class OybnSettingTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class OybnSetting { } +public partial class OybnSetting; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementItemArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementItemArchive.cs index f127b026..fa9b6864 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementItemArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementItemArchive.cs @@ -11,13 +11,13 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementItemArchive { } +public partial class PlacementItemArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementItem { } +public partial class PlacementItem; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementItem_F03 { } +public partial class PlacementItem_F03; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementItem_F08 { } +public partial class PlacementItem_F08; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementLocationArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementLocationArchive.cs index 5089a3f1..3db2e1f4 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementLocationArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementLocationArchive.cs @@ -11,4 +11,4 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementLocationArchive { } +public partial class PlacementLocationArchive; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementMkrgTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementMkrgTable.cs index 4507c1f4..8c02b212 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementMkrgTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementMkrgTable.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementMkrgTable { } +public partial class PlacementMkrgTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PlacementMkrgEntry diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSearchItemTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSearchItemTable.cs index 1f621f0b..1e587bee 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSearchItemTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSearchItemTable.cs @@ -13,7 +13,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementSearchItemTable { } +public partial class PlacementSearchItemTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PlacementSearchItem diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerData.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerData.cs index 733571d4..eac5e473 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerData.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerData.cs @@ -11,4 +11,4 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementSpawnerArchive { } +public partial class PlacementSpawnerArchive; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerF21.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerF21.cs index f8686dd0..f754e092 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerF21.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementSpawnerF21.cs @@ -1,6 +1,4 @@ -using System; using System.ComponentModel; -using System.Linq; // ReSharper disable UnusedAutoPropertyAccessor.Global // ReSharper disable ClassNeverInstantiated.Global diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementUnnnTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementUnnnTable.cs index d7a18703..d40bcbb5 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementUnnnTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Placement/PlacementUnnnTable.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementUnnnTable { } +public partial class PlacementUnnnTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PlacementUnnnEntry diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaBGMTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaBGMTable.cs index 29283fad..b434c7de 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaBGMTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaBGMTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class AreaBGMTable { } +public partial class AreaBGMTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class AreaBGM { } +public partial class AreaBGM; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaSettingsTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaSettingsTable.cs index 7188ac7a..a44c6a1f 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaSettingsTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaSettingsTable.cs @@ -41,4 +41,4 @@ public string FriendlyAreaName } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class AreaSettings_F50 { } +public partial class AreaSettings_F50; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaWeatherTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaWeatherTable.cs index b35f3436..55cea374 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaWeatherTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/AreaWeatherTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class AreaWeatherTable { } +public partial class AreaWeatherTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class AreaWeather diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentArea.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentArea.cs index 1bca4b98..7149e336 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentArea.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentArea.cs @@ -5,16 +5,9 @@ namespace pkNX.Structures.FlatBuffers.Arceus; // Not a FlatBuffer; wraps the fields into a single object. -public sealed class ResidentArea +public sealed class ResidentArea(GFPack resident, AreaSettings settings) { - public readonly AreaSettings Settings; - private readonly GFPack Resident; - - public ResidentArea(GFPack resident, AreaSettings settings) - { - Resident = resident; - Settings = settings; - } + public readonly AreaSettings Settings = settings; public string AreaName => Settings.Name; public string FriendlyAreaName => Settings.FriendlyAreaName; @@ -34,11 +27,11 @@ public ResidentArea(GFPack resident, AreaSettings settings) private T TryRead(string path) where T : class, IFlatBufferSerializable { - var index = Resident.GetIndexFull(path); + var index = resident.GetIndexFull(path); if (index == -1) throw new ArgumentOutOfRangeException(nameof(path)); - var data = Resident[index]; + var data = resident[index]; return T.GreedyMutableSerializer.Parse(data); } @@ -55,12 +48,12 @@ public ResidentArea(GFPack resident, AreaSettings settings) private void TryWrite(string path, T obj) where T : class, IFlatBufferSerializable { - var index = Resident.GetIndexFull(path); + var index = resident.GetIndexFull(path); if (index == -1) return; byte[] result = Write(obj); - Resident[index] = result; + resident[index] = result; } public void LoadInfo() diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentInfo.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentInfo.cs index d73ea9e9..2a08d317 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentInfo.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Resident/Editing/ResidentInfo.cs @@ -18,8 +18,8 @@ private ResidentAreaSet(string parentName, IReadOnlyList subAreas) } public static readonly ResidentAreaSet[] AreaNames = - { - new("ha_area00", new[] { + [ + new("ha_area00", [ "ha_area00_s01", "ha_area00_s02", "ha_area00_s03_a", @@ -51,31 +51,31 @@ private ResidentAreaSet(string parentName, IReadOnlyList subAreas) "ha_area00_s12_d", "ha_area00_s16_a", "ha_area00_s16_b", - }), - new("ha_area01", new[] { + ]), + new("ha_area01", [ "ha_area01_s01", - }), - new("ha_area02", new[] { + ]), + new("ha_area02", [ "ha_area02_s01", "ha_area02_s01_a", "ha_area02_s01_b", "ha_area02_s01_c", "ha_area02_s01_d", "ha_area02_s02", - }), - new("ha_area03", new[] { + ]), + new("ha_area03", [ "ha_area03_s01", "ha_area03_s02", "ha_area03_s03", "ha_area03_s04", - }), - new("ha_area04", new[] { + ]), + new("ha_area04", [ "ha_area04_s01", "ha_area04_s02", "ha_area04_s03", "ha_area04_s04", - }), - new("ha_area05", new[] { + ]), + new("ha_area05", [ "ha_area05_s01", "ha_area05_s02", "ha_area05_s03", @@ -84,10 +84,10 @@ private ResidentAreaSet(string parentName, IReadOnlyList subAreas) "ha_area05_s04_b", "ha_area05_s04_c", "ha_area05_s04_d", - }), - new("ha_area06", new[] { + ]), + new("ha_area06", [ "ha_area06_s01", - }), - new("ha_area11", Array.Empty()), - }; + ]), + new("ha_area11", []), + ]; } diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterDataArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterDataArchive.cs index 598de8bd..4f1ba3f1 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterDataArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterDataArchive.cs @@ -10,12 +10,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterDataArchive { } +public partial class EncounterDataArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterEligiblityTraits : IHasCondition, ISlotModifierTime, ISlotModifierWeather -{ -} +public partial class EncounterEligiblityTraits : IHasCondition, ISlotModifierTime, ISlotModifierWeather; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class EncounterOybnTraits diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterMultiplerArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterMultiplerArchive.cs index 25866463..71e01ebe 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterMultiplerArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Slots/EncounterMultiplerArchive.cs @@ -45,10 +45,7 @@ public partial class EncounterMultiplierArchive { public EncounterMultiplier GetEncounterMultiplier(EncounterSlot slot) { - var result = GetEntry((ushort)slot.Species, (ushort)slot.Form); - if (result == null) - throw new ArgumentException($"Invalid Encounter Slot {slot.Species} - {slot.Form}"); - return result; + return GetEntry((ushort)slot.Species, (ushort)slot.Form) ?? throw new ArgumentException($"Invalid Encounter Slot {slot.Species} - {slot.Form}"); } public EncounterMultiplier GetEntry(ushort species, ushort form) diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Static/EventEncountArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Static/EventEncountArchive.cs index 3a1335fb..b25920cc 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Static/EventEncountArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Field/Static/EventEncountArchive.cs @@ -11,10 +11,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EventEncount { } +public partial class EventEncount; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EventEncountArchive { } +public partial class EventEncountArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class EventEncountPoke diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/KeyAssignmentTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/KeyAssignmentTable.cs index 8ff147f4..734fbc3d 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/KeyAssignmentTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/KeyAssignmentTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class KeyAssignmentTable { } +public partial class KeyAssignmentTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class KeyAssignment { } +public partial class KeyAssignment; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/LbPointsTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/LbPointsTable.cs index 1dbbec71..a4a13f4d 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/LbPointsTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/LbPointsTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LbPointsTable { } +public partial class LbPointsTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LbPointsInfo { } +public partial class LbPointsInfo; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/MoveShopTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/MoveShopTable.cs index a293e9e6..d913b4b3 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/MoveShopTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/MoveShopTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MoveShopTable { } +public partial class MoveShopTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MoveShopIndex { } +public partial class MoveShopIndex; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/NPC/NPCModelSet.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/NPC/NPCModelSet.cs index 3b7bd473..eeaefad7 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/NPC/NPCModelSet.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/NPC/NPCModelSet.cs @@ -4,19 +4,19 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NPCModelSet { } +public partial class NPCModelSet; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NPCModelSetEntry { } +public partial class NPCModelSetEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NPCModelAnimations { } +public partial class NPCModelAnimations; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NPCModelMeshes { } +public partial class NPCModelMeshes; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NPCModelRigs { } +public partial class NPCModelRigs; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NPCModelColorConfig { } +public partial class NPCModelColorConfig; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/PlayReportTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/PlayReportTable.cs index 2dbc5265..30c14d76 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/PlayReportTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/PlayReportTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlayReportTable { } +public partial class PlayReportTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlayReportItem { } +public partial class PlayReportItem; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/EvolutionTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/EvolutionTable.cs index b1e21dfe..09b4702e 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/EvolutionTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/EvolutionTable.cs @@ -10,10 +10,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EvolutionTable { } +public partial class EvolutionTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EvolutionEntry { } +public partial class EvolutionEntry; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class EvolutionSet diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model Set/PokeModelSet.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model Set/PokeModelSet.cs index d33dc82c..fece2079 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model Set/PokeModelSet.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model Set/PokeModelSet.cs @@ -41,4 +41,4 @@ public PokeModelSetEntry AddEntry(ushort species, ushort form) } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeModelSetEntry { } +public partial class PokeModelSetEntry; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/BoneScalarMesh.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/BoneScalarMesh.cs index 93f7f404..b0382fcb 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/BoneScalarMesh.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/BoneScalarMesh.cs @@ -7,16 +7,16 @@ namespace pkNX.Structures.FlatBuffers.Arceus; // *.trbsm [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class UnkEntry { } +public partial class UnkEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class BoneEntry { } +public partial class BoneEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ScalerEntry { } +public partial class ScalerEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MeshEntry { } +public partial class MeshEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class BoneMeshScalar { } +public partial class BoneMeshScalar; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Material.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Material.cs index 9ffc8eca..5edddd20 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Material.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Material.cs @@ -6,7 +6,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; // *.trmtr [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class SamplerState { } +public partial class SamplerState; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class Float4Parameter @@ -76,13 +76,13 @@ public TextureParameter(string shaderPropertyBinding, uint slot, string textureF } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class WriteMaskData { } +public partial class WriteMaskData; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class IntExtraData { } +public partial class IntExtraData; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MaterialPass { } +public partial class MaterialPass; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Material { } +public partial class Material; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Mesh.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Mesh.cs index 00cfcf2c..082a4ab7 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Mesh.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Mesh.cs @@ -27,21 +27,13 @@ public partial class VertexSize } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class VertexAttributeLayout -{ -} +public partial class VertexAttributeLayout; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class SubMesh -{ -} +public partial class SubMesh; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MeshShape -{ -} +public partial class MeshShape; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Mesh -{ -} +public partial class Mesh; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MeshBuffer.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MeshBuffer.cs index 4d220b75..4c4da45e 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MeshBuffer.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MeshBuffer.cs @@ -11,16 +11,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; // *.trmbf -public class VertexWrapper +public class VertexWrapper(InputLayoutElement layoutElement, object data) { - public InputLayoutElement LayoutElement { get; set; } - public object Data { get; set; } - - public VertexWrapper(InputLayoutElement layoutElement, object data) - { - LayoutElement = layoutElement; - Data = data; - } + public InputLayoutElement LayoutElement { get; set; } = layoutElement; + public object Data { get; set; } = data; public override string ToString() => $"{{ {LayoutElement.SemanticName}{LayoutElement.SemanticIndex:#}, {Data} }}"; } @@ -62,11 +56,7 @@ public VertexWrapper[][] FromInputLayout(VertexAttributeLayout inputLayout) } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MeshBuffer -{ -} +public partial class MeshBuffer; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MeshBufferTable -{ -} +public partial class MeshBufferTable; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Model.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Model.cs index ec23b060..f4204bec 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Model.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Model.cs @@ -15,23 +15,19 @@ public partial class FileReference } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LODIndex -{ -} +public partial class LODIndex; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LOD -{ -} +public partial class LOD; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class Model { public static Model Empty => new() { - Meshes = Array.Empty(), - LODs = Array.Empty(), + Meshes = [], + LODs = [], Skeleton = FileReference.Empty, - Materials = Array.Empty(), + Materials = [], }; } diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MultiMaterialTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MultiMaterialTable.cs index cb435839..f27b4766 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MultiMaterialTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/MultiMaterialTable.cs @@ -7,36 +7,26 @@ namespace pkNX.Structures.FlatBuffers.Arceus; // *.trmmt [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MaterialSwitch -{ -} +public partial class MaterialSwitch; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MaterialMapper -{ -} +public partial class MaterialMapper; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EmbeddedTracm -{ -} +public partial class EmbeddedTracm; //Appears only on Arceus? [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MaterialProperty -{ -} +public partial class MaterialProperty; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MaterialTable -{ -} +public partial class MaterialTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class MultiMaterialTable { public static MultiMaterialTable Empty => new() { - Material = Array.Empty(), + Material = [], }; } diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/PokeConfig.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/PokeConfig.cs index 9ec83b4a..8cdd1fb4 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/PokeConfig.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/PokeConfig.cs @@ -9,4 +9,4 @@ namespace pkNX.Structures.FlatBuffers.Arceus; // *.trpokecfg [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeConfig {} +public partial class PokeConfig; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Skeleton.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Skeleton.cs index 5f91c8c7..f1c6f999 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Skeleton.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Model/Skeleton.cs @@ -6,13 +6,13 @@ namespace pkNX.Structures.FlatBuffers.Arceus; // *.trskl [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Skeleton { } +public partial class Skeleton; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TransformNode { } +public partial class TransformNode; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class IKControl { } +public partial class IKControl; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Bone { } +public partial class Bone; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Learnset.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Learnset.cs index b037013d..8f35fbe3 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Learnset.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Learnset.cs @@ -12,10 +12,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Learnset { } +public partial class Learnset; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LearnsetEntry { } +public partial class LearnsetEntry; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class LearnsetMeta diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWaza.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWaza.cs index 289845bd..b2a70915 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWaza.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWaza.cs @@ -11,4 +11,4 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWaza { } +public partial class PokeFieldObstructionWaza; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendArchive.cs index f8774927..adf9dda6 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaNsLegendArchive { } +public partial class PokeFieldObstructionWazaNsLegendArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaNsLegend { } +public partial class PokeFieldObstructionWazaNsLegend; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendEffectArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendEffectArchive.cs index 0e883723..587c59cc 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendEffectArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaNsLegendEffectArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaNsLegendEffectArchive { } +public partial class PokeFieldObstructionWazaNsLegendEffectArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaNsLegendEffect { } +public partial class PokeFieldObstructionWazaNsLegendEffect; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaSeArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaSeArchive.cs index 85c6f708..49d9302b 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaSeArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaSeArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaSeArchive { } +public partial class PokeFieldObstructionWazaSeArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaSe { } +public partial class PokeFieldObstructionWazaSe; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildArchive.cs index 5ab94a5a..302c9334 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildArchive.cs @@ -11,4 +11,4 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaWildArchive { } +public partial class PokeFieldObstructionWazaWildArchive; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildEffectArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildEffectArchive.cs index 075721f6..2c039614 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildEffectArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildEffectArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaWildEffectArchive { } +public partial class PokeFieldObstructionWazaWildEffectArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaWildEffect { } +public partial class PokeFieldObstructionWazaWildEffect; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterArchive.cs index 73004a15..9bb9733a 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterArchive.cs @@ -11,4 +11,4 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaWildWaterArchive { } +public partial class PokeFieldObstructionWazaWildWaterArchive; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterEffectArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterEffectArchive.cs index 46e33ee2..f66151a3 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterEffectArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/PokeFieldObstructionWazaWildWaterEffectArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaWildWaterEffectArchive { } +public partial class PokeFieldObstructionWazaWildWaterEffectArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeFieldObstructionWazaWildWaterEffect { } +public partial class PokeFieldObstructionWazaWildWaterEffect; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Waza.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Waza.cs index 7b2f2920..51a63c24 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Waza.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/Moves/Waza.cs @@ -10,4 +10,4 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Waza { } +public partial class Waza; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PersonalInfoLAfb.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PersonalInfoLAfb.cs index e1880843..0a09245e 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PersonalInfoLAfb.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PersonalInfoLAfb.cs @@ -14,10 +14,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; /// Personal Info class with values from the games. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PersonalTable { } +public partial class PersonalTable; /// /// Personal Info class with values from the games. /// [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PersonalInfo { } +public partial class PersonalInfo; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAIArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAIArchive.cs index c123ef6a..606b1953 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAIArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAIArchive.cs @@ -66,25 +66,25 @@ public static PokeAI GetNew(ushort species = 0, ushort form = 0, bool isAlpha = } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeAI_F24 { } +public partial class PokeAI_F24; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeAI_F18 { } +public partial class PokeAI_F18; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PokeAI_F09 { public static readonly PokeAI_F09 DefaultBehaviour02 = new() { - Field00 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field01 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field02 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field03 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field04 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field05 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field06 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field07 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, - Field08 = new() { BehaviourHash = 9252365659083253459, Parameters = new[] { "0.5", "35" } }, + Field00 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field01 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field02 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field03 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field04 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field05 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field06 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field07 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, + Field08 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }, }; public static readonly PokeAI_F09 DefaultBehaviour_F09 = new() @@ -130,10 +130,10 @@ public partial class PokeAI_F09 [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PokeAIBehaviour { - public static readonly PokeAIBehaviour DefaultBehaviour02 = new() { BehaviourHash = 9252365659083253459, Parameters = new [] { "0.2", "35" } }; - public static readonly PokeAIBehaviour DefaultBehaviour02_20 = new() { BehaviourHash = 9252365659083253459, Parameters = new [] { "0.2", "20" } }; - public static readonly PokeAIBehaviour DefaultBehaviour05 = new() { BehaviourHash = 9252365659083253459, Parameters = new [] { "0.5", "35" } }; - public static readonly PokeAIBehaviour Behaviour_X_Params = new() { BehaviourHash = 17205188591700921149, Parameters = new [] { "10", "3", "run", "Normal" } }; - public static readonly PokeAIBehaviour Behaviour_X2_Params = new() { BehaviourHash = 17205188591700921149, Parameters = new [] { "10", "0.5", "run", "Normal" } }; - public static readonly PokeAIBehaviour Behaviour_04_Params = new() { BehaviourHash = 1234775724179408742, Parameters = new [] { "3", "5", "60", "90", "4", "run", "Normal" } }; + public static readonly PokeAIBehaviour DefaultBehaviour02 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.2", "35"] }; + public static readonly PokeAIBehaviour DefaultBehaviour02_20 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.2", "20"] }; + public static readonly PokeAIBehaviour DefaultBehaviour05 = new() { BehaviourHash = 9252365659083253459, Parameters = ["0.5", "35"] }; + public static readonly PokeAIBehaviour Behaviour_X_Params = new() { BehaviourHash = 17205188591700921149, Parameters = ["10", "3", "run", "Normal"] }; + public static readonly PokeAIBehaviour Behaviour_X2_Params = new() { BehaviourHash = 17205188591700921149, Parameters = ["10", "0.5", "run", "Normal"] }; + public static readonly PokeAIBehaviour Behaviour_04_Params = new() { BehaviourHash = 1234775724179408742, Parameters = ["3", "5", "60", "90", "4", "run", "Normal"] }; } diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAdd.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAdd.cs index b62ab741..cb60f9bd 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAdd.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeAdd.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeAddArchive { } +public partial class PokeAddArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PokeAdd diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBattleSpawnArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBattleSpawnArchive.cs index 80a96154..01dc4141 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBattleSpawnArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBattleSpawnArchive.cs @@ -14,7 +14,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; /// Seems to be a file left over from development. Only has test entries /// [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeBattleSpawnArchive { } +public partial class PokeBattleSpawnArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeBattleSpawn { } +public partial class PokeBattleSpawn; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBodyParticleArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBodyParticleArchive.cs index 17096cd0..ed0fe5e9 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBodyParticleArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeBodyParticleArchive.cs @@ -11,10 +11,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeBodyParticleArchive { } +public partial class PokeBodyParticleArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeBodyParticle { } +public partial class PokeBodyParticle; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeBodyParticle_F03 { } +public partial class PokeBodyParticle_F03; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeCaptureCollisionArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeCaptureCollisionArchive.cs index b023071e..c2ee577e 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeCaptureCollisionArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeCaptureCollisionArchive.cs @@ -11,10 +11,10 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeCaptureCollision { } +public partial class PokeCaptureCollision; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeCaptureCollider { } +public partial class PokeCaptureCollider; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PokeCaptureCollisionArchive @@ -23,7 +23,7 @@ public PokeCaptureCollision GetEntry(ushort species, ushort form) { return Table.FirstOrDefault(x => x.Species == species && x.Form == form) ?? new() { - Colliders = new List(), + Colliders = [], }; } @@ -40,30 +40,30 @@ public PokeCaptureCollision AddEntry(ushort species, ushort form) { Species = species, Form = form, - Colliders = new PokeCaptureCollider[] - { + Colliders = + [ new() { Shape = "Capsule", - ShapeParameters = new[]{ 0.5f, 0.2f, 0, 0, 0, 0, 0, 0 }, + ShapeParameters = [0.5f, 0.2f, 0, 0, 0, 0, 0, 0], SocketName = "waist", Type = "Normal", Field07 = string.Empty, }, new() { Shape = "Capsule", - ShapeParameters = new[]{ 0.5f, 0.2f, 0, 0, 0, 0, 0, 0 }, + ShapeParameters = [0.5f, 0.2f, 0, 0, 0, 0, 0, 0], SocketName = string.Empty, Type = "Pysics", Field07 = string.Empty, }, new() { Shape = "Capsule", - ShapeParameters = new[]{ 0.5f, 0.2f, 0, 0, 0, 0, 0, 0 }, + ShapeParameters = [0.5f, 0.2f, 0, 0, 0, 0, 0, 0], SocketName = "origin", Type = "Barrier", Field07 = string.Empty, }, - }, + ], }; Table = Table.Append(entry) diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDefaultLocatorArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDefaultLocatorArchive.cs index 80a50167..5ef7c078 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDefaultLocatorArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDefaultLocatorArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDefaultLocatorArchive { } +public partial class PokeDefaultLocatorArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDefaultLocator { } +public partial class PokeDefaultLocator; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemArchive.cs index a0900291..69667ee4 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDropItemArchive { } +public partial class PokeDropItemArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PokeDropItem diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemBattleArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemBattleArchive.cs index b813c2a1..623b8d1a 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemBattleArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeDropItemBattleArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDropItemBattleArchive { } +public partial class PokeDropItemBattleArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PokeDropItemBattle diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeEatingHabitsArchive.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeEatingHabitsArchive.cs index 92e322cd..4609af1f 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeEatingHabitsArchive.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeEatingHabitsArchive.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeEatingHabitsArchive { } +public partial class PokeEatingHabitsArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeEatingHabits { } +public partial class PokeEatingHabits; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeMiscTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeMiscTable.cs index f0469f1e..ccdaf103 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeMiscTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeMiscTable.cs @@ -26,7 +26,7 @@ public PokeMisc GetEntry(ushort species, ushort form) return Table.FirstOrDefault(z => z.Species == species && z.Form == form) ?? new() { Value = $"{species}-{form} is not in {nameof(PokeMiscTable)}.", - Field10 = Array.Empty(), + Field10 = [], }; } @@ -44,7 +44,7 @@ public PokeMisc AddEntry(ushort species, ushort form) Value = $"{species}-{form} is not in {nameof(PokeMiscTable)}.", Species = species, Form = form, - Field10 = Array.Empty(), + Field10 = [], }; Table = Table.Append(entry) .OrderBy(x => x.Species) diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeInfoList.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeInfoList.cs index 10b45ec6..ad9c408d 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeInfoList.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeInfoList.cs @@ -20,7 +20,7 @@ public PokeInfo GetEntry(ushort species) return Table.FirstOrDefault(z => z.Species == species) ?? new() { Species = species, - Children = Array.Empty(), + Children = [], }; } @@ -46,35 +46,35 @@ public PokeInfo AddEntry(ushort species, byte formCount) entry.Children[form] = new PokeInfoDetail { Form = form, - Detail = new PokeInfoDetail_2[] - { + Detail = + [ new() { IsRare = false, - Detail = new PokeInfoDetail_3[] { + Detail = [ new() { - Detail = new PokeInfoDetail_5[] { + Detail = [ new() { AssetName = $"{species:0000}_{genderId:000}_{form:000}_n_00000000_fn_n", Gender = new PokeInfoGender(), }, - }, + ], }, - }, + ], }, new() { IsRare = true, // Shiny form - Detail = new PokeInfoDetail_3[] { + Detail = [ new() { - Detail = new PokeInfoDetail_5[] { + Detail = [ new() { AssetName = $"{species:0000}_{genderId:000}_{form:000}_n_00000000_fn_r", Gender = new PokeInfoGender(), }, - }, + ], }, - }, + ], }, - }, + ], }; } @@ -133,19 +133,19 @@ public IEnumerable GetDexFormEntries() } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeInfo { } +public partial class PokeInfo; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeInfoDetail { } +public partial class PokeInfoDetail; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeInfoDetail_2 { } +public partial class PokeInfoDetail_2; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeInfoDetail_3 { } +public partial class PokeInfoDetail_3; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeInfoDetail_5 { } +public partial class PokeInfoDetail_5; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeInfoGender { } +public partial class PokeInfoGender; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeResourceTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeResourceTable.cs index a0926e4f..50e4e614 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeResourceTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Poke/PokeResource/PokeResourceTable.cs @@ -15,16 +15,16 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeResourceMeta { } +public partial class PokeResourceMeta; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeModelConfig { } +public partial class PokeModelConfig; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeModelSpeciesInfo { } +public partial class PokeModelSpeciesInfo; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class FileNamePathPair { } +public partial class FileNamePathPair; /// for Legends: Arceus, adding [TypeConverter(typeof(ExpandableObjectConverter))] @@ -34,12 +34,12 @@ public PokeModelConfig GetEntry(ushort species, ushort form, byte gender) { return Table.FirstOrDefault(x => x.SpeciesInfo.Species == species && x.SpeciesInfo.Form == form && x.SpeciesInfo.Gender == gender) ?? new() { - Animations = Array.Empty(), + Animations = [], SpeciesInfo = new PokeModelSpeciesInfo(), ModelPath = string.Empty, MaterialTablePath = string.Empty, ConfigPath = string.Empty, - Effects = Array.Empty(), + Effects = [], }; } @@ -66,19 +66,19 @@ public PokeModelConfig AddEntry(ushort species, ushort form, byte gender) MaterialTablePath = $"{basePath}/mdl/{pmStr}.trmmt", ConfigPath = $"{basePath}/{pmStr}.trpokecfg", - Animations = new FileNamePathPair[] { + Animations = [ new(){ Name = "base", Path = $"{basePath}/anm/{pmStr}_base.tracn", }, - }, + ], - Effects = new FileNamePathPair[] { + Effects = [ new() { Name = "eff", Path = $"{basePath}/locators/{pmStr}_eff.trskl", }, - }, + ], }; Table = Table.Append(entry) diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexDistributionTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexDistributionTable.cs index bad9dd05..5d1ca87a 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexDistributionTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexDistributionTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokedexDistributionTable { } +public partial class PokedexDistributionTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokedexDistributionEntry { } +public partial class PokedexDistributionEntry; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexRankTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexRankTable.cs index ab20f152..d868c3ed 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexRankTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexRankTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokedexRankTable { } +public partial class PokedexRankTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokedexRankLevel { } +public partial class PokedexRankLevel; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexResearchTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexResearchTable.cs index 5d639c20..82d060e7 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexResearchTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Pokedex/PokedexResearchTable.cs @@ -32,4 +32,4 @@ public bool RemoveTask(PokedexResearchTask taskToRemove) } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokedexResearchTask { } +public partial class PokedexResearchTask; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/ScriptIDRecordRelease.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/ScriptIDRecordRelease.cs index 78d2ef2a..c70af417 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/ScriptIDRecordRelease.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/ScriptIDRecordRelease.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ScriptIDRecordRelease { } +public partial class ScriptIDRecordRelease; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ScriptIDRecord { } +public partial class ScriptIDRecord; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Shop/HaShopTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Shop/HaShopTable.cs index d563471c..d397d2de 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Shop/HaShopTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Shop/HaShopTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class HaShopTable { } +public partial class HaShopTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class HaShopItem { } +public partial class HaShopItem; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/CommonCaptureConfigTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/CommonCaptureConfigTable.cs index 6d532f7d..a739007e 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/CommonCaptureConfigTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/CommonCaptureConfigTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class CommonCaptureConfigTable { } +public partial class CommonCaptureConfigTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class CommonCaptureConfig { } +public partial class CommonCaptureConfig; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowParamTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowParamTable.cs index a4c1f2ab..e2659810 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowParamTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowParamTable.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowParamTable { } +public partial class ThrowParamTable; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class ThrowParam diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowPermissionSetDictionary.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowPermissionSetDictionary.cs index 5dd94a1b..b39da877 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowPermissionSetDictionary.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowPermissionSetDictionary.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowPermissionSetDictionary { } +public partial class ThrowPermissionSetDictionary; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowPermissionSetEntry { } +public partial class ThrowPermissionSetEntry; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableBaitParamDictionary.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableBaitParamDictionary.cs index 4c6a9dd9..3db59e9b 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableBaitParamDictionary.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableBaitParamDictionary.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowableBaitParamDictionary { } +public partial class ThrowableBaitParamDictionary; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowableBaitParamEntry { } +public partial class ThrowableBaitParamEntry; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableParamTable.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableParamTable.cs index b5db5581..2946ca49 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableParamTable.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableParamTable.cs @@ -23,4 +23,4 @@ public void AddEntry(int i) } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowableParam { } +public partial class ThrowableParam; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceDictionary.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceDictionary.cs index ce8a950e..8d885a57 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceDictionary.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceDictionary.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowableResourceDictionary { } +public partial class ThrowableResourceDictionary; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowableResourceEntry { } +public partial class ThrowableResourceEntry; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceSetDictionary.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceSetDictionary.cs index efec4f2e..d981f405 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceSetDictionary.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Throw/ThrowableResourceSetDictionary.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.Arceus; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowableResourceSetDictionary { } +public partial class ThrowableResourceSetDictionary; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ThrowableResourceSetEntry { } +public partial class ThrowableResourceSetEntry; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/ArchiveContents.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/ArchiveContents.cs index 41feb1da..15197375 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/ArchiveContents.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/ArchiveContents.cs @@ -16,7 +16,7 @@ public ArchiveContent AddEntry() { var entry = new ArchiveContent { - ArchiveContentPathHashes = new List(), + ArchiveContentPathHashes = [], }; Table = Table.Append(entry).ToList(); @@ -37,4 +37,4 @@ public ArchiveContent AddEntry(string archiveFile, string[] internalArchiveFiles } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ArchiveContent { } +public partial class ArchiveContent; diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterDetail.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterDetail.cs index 0b569dc7..f836f6b5 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterDetail.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterDetail.cs @@ -25,7 +25,7 @@ public static void Divide(List[,] table) { for (var weather = 0; weather < WeatherCount; weather++) { - table[time, weather] = table[time, weather].OrderByDescending(xt => xt.Rate).ToList(); + table[time, weather] = [.. table[time, weather].OrderByDescending(xt => xt.Rate)]; var totalRate = 0.0; foreach (var tup in table[time, weather]) diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterTableUtil.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterTableUtil.cs index bbaac6a0..798cee5c 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterTableUtil.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/EncounterTableUtil.cs @@ -1,8 +1,3 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - namespace pkNX.Structures.FlatBuffers.Arceus; public static class EncounterTableUtil @@ -136,7 +131,7 @@ private static SpawnerType GetSpawnerType(PlacementSpawner spawner) // 095 Snowpoint Temple private static bool IsDungeonZone(int a) => a is 64 or 86 or 95; - private static readonly int[] OybnSettings = { 15, 15, 15, 20, 20 }; + private static ReadOnlySpan OybnSettings => [15, 15, 15, 20, 20]; private static byte[] GetArea(IReadOnlyList locations, IReadOnlyCollection slots, int tableMinLevel, int tableMaxLevel, SpawnerType type, @@ -320,7 +315,7 @@ public static IEnumerable GetUnownLinesBias(AreaInstance area, IReadOnly EncounterDetail.Divide(dividedTables); var sym = EncounterDetail.AnalyzeSymmetry(dividedTables); - if (sym.Time && sym.Weather) + if (sym is { Time: true, Weather: true }) { yield return "Any Time/All Weather:"; foreach (var line in GetEffectiveTableSummary(dividedTables[0, 0], speciesNames, lvMin, lvMax, misc)) diff --git a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/TriggerUtil.cs b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/TriggerUtil.cs index 48920851..31dbc940 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/TriggerUtil.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Arceus/Util/TriggerUtil.cs @@ -29,7 +29,7 @@ public static string GetTriggerMetaSummary(TriggerMeta meta) if (meta.Unused01 != 0) throw new ArgumentException("TriggerMeta has unused field set?"); - var argsSummary = GetTriggerArgsSummary(new string[] {meta.TriggerMetaArg1, meta.TriggerMetaArg2, meta.TriggerMetaArg3}); + var argsSummary = GetTriggerArgsSummary([meta.TriggerMetaArg1, meta.TriggerMetaArg2, meta.TriggerMetaArg3]); return $"0x{(ulong)meta.TriggerTypeID:X16}({argsSummary})"; } diff --git a/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalDumperPLA.cs b/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalDumperPLA.cs index 8f7fba2d..ec7125f2 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalDumperPLA.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalDumperPLA.cs @@ -46,8 +46,8 @@ private void AddTRs(List lines, IMovesInfo_v1 pi, string specCode) public IList Evos { private get; set; } public IReadOnlyList TMIndexes { protected get; set; } - private static readonly string[] AbilitySuffix = { " (1)", " (2)", " (H)" }; - private static readonly string[] ItemPrefix = { "Item 1 (50%)", "Item 2 (5%)", "Item 3 (1%)" }; + private static readonly string[] AbilitySuffix = [" (1)", " (2)", " (H)"]; + private static readonly string[] ItemPrefix = ["Item 1 (50%)", "Item 2 (5%)", "Item 3 (1%)"]; public IReadOnlyList> MoveSpeciesLearn { get; private set; } diff --git a/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalInfo8LA.cs b/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalInfo8LA.cs index 314b5e8d..4050f2e0 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalInfo8LA.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalInfo8LA.cs @@ -6,9 +6,9 @@ namespace pkNX.Structures.FlatBuffers.Arceus; /// /// Personal Info class with values from the games. /// -public sealed class PersonalInfo8LA : IPersonalInfoPLA +public sealed class PersonalInfo8LA(PersonalInfo fb) : IPersonalInfoPLA { - public PersonalInfo FB { get; } + public PersonalInfo FB { get; } = fb; public bool[] SpecialTutors { @@ -128,11 +128,6 @@ public bool[] TR } } - public PersonalInfo8LA(PersonalInfo fb) - { - FB = fb; - } - public int HP { get => FB.StatHP; set => FB.StatHP = (byte)value; } public int ATK { get => FB.StatATK; set => FB.StatATK = (byte)value; } public int DEF { get => FB.StatDEF; set => FB.StatDEF = (byte)value; } diff --git a/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalTable8LA.cs b/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalTable8LA.cs index a2b23207..9d16db4f 100644 --- a/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalTable8LA.cs +++ b/pkNX.Structures.FlatBuffers.Arceus/Dumpers/PersonalTable8LA.cs @@ -42,7 +42,7 @@ public PersonalTable8LA(IFileContainer file) formTable.Add(GetObj(forms[f], forms, MaxSpecies, formTable, f)); } - Table = baseForms.Concat(formTable).ToArray(); + Table = [.. baseForms, .. formTable]; } private static PersonalInfo8LA GetObj(PersonalInfo e, ICollection forms, ushort max, ICollection formTable, int f = 0) diff --git a/pkNX.Structures.FlatBuffers.LGPE/Gen7/EncounterArchive.cs b/pkNX.Structures.FlatBuffers.LGPE/Gen7/EncounterArchive.cs index acee85f3..765d7214 100644 --- a/pkNX.Structures.FlatBuffers.LGPE/Gen7/EncounterArchive.cs +++ b/pkNX.Structures.FlatBuffers.LGPE/Gen7/EncounterArchive.cs @@ -9,10 +9,10 @@ namespace pkNX.Structures.FlatBuffers.LGPE; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterArchive { } +public partial class EncounterArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterTable { } +public partial class EncounterTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterSlot { } +public partial class EncounterSlot; diff --git a/pkNX.Structures.FlatBuffers.LGPE/Gen7/ShopInventory.cs b/pkNX.Structures.FlatBuffers.LGPE/Gen7/ShopInventory.cs index fe4b7ae0..2c6bbed1 100644 --- a/pkNX.Structures.FlatBuffers.LGPE/Gen7/ShopInventory.cs +++ b/pkNX.Structures.FlatBuffers.LGPE/Gen7/ShopInventory.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.LGPE; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ShopInventory { } +public partial class ShopInventory; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class SingleShop diff --git a/pkNX.Structures.FlatBuffers.Reflection/ReflectionDumpSchema.cs b/pkNX.Structures.FlatBuffers.Reflection/ReflectionDumpSchema.cs index 6f0cf054..c0b43ce0 100644 --- a/pkNX.Structures.FlatBuffers.Reflection/ReflectionDumpSchema.cs +++ b/pkNX.Structures.FlatBuffers.Reflection/ReflectionDumpSchema.cs @@ -108,7 +108,7 @@ private static void DumpObjects(Schema schema, TextWriter fbs, TextWriter cs, bo cs.WriteLine(); cs.WriteLine("[TypeConverter(typeof(ExpandableObjectConverter))]"); - cs.WriteLine($"public partial {(obj.IsStruct ? "struct" : "class")} {GetName(obj.Name, stripNamespace)} {{ }}"); + cs.WriteLine($"public partial {(obj.IsStruct ? "struct" : "class")} {GetName(obj.Name, stripNamespace)};"); DumpObjectFBS(schema, fbs, stripNamespace, obj); } diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Misc/Misc/DanCarBattleDataArray.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Misc/Misc/DanCarBattleDataArray.cs index 30929062..f31a53c4 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Misc/Misc/DanCarBattleDataArray.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Misc/Misc/DanCarBattleDataArray.cs @@ -6,10 +6,10 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DanCarBattleDataArray { } +public partial class DanCarBattleDataArray; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DanBossCarBattleTable { } +public partial class DanBossCarBattleTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DanCarBattleData { } +public partial class DanCarBattleData; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Dumpers/PersonalDumperSV.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Dumpers/PersonalDumperSV.cs index 88b92dd2..1a83471a 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Dumpers/PersonalDumperSV.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Dumpers/PersonalDumperSV.cs @@ -22,7 +22,7 @@ public class PersonalDumperSV public static ushort[] TMIndexes => PersonalInfo9SV.TMIndexes; - private static readonly string[] AbilitySuffix = { " (1)", " (2)", " (H)" }; + private static readonly string[] AbilitySuffix = [" (1)", " (2)", " (H)"]; public IReadOnlyList> MoveSpeciesLearn { get; private set; } diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/PersonalTable.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/PersonalTable.cs index fd896d62..693ae59b 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/PersonalTable.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/PersonalTable.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PersonalTable { } +public partial class PersonalTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PersonalInfo { } +public partial class PersonalInfo; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoDex.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoDex.cs index f745577d..0bd5655b 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoDex.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoDex.cs @@ -4,4 +4,4 @@ namespace pkNX.Structures.FlatBuffers.SV; -public partial class PersonalInfoDex { } +public partial class PersonalInfoDex; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoEvolution.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoEvolution.cs index bbddc5a4..0c9408cd 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoEvolution.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Types/PersonalInfoEvolution.cs @@ -4,4 +4,4 @@ namespace pkNX.Structures.FlatBuffers.SV; -public partial class PersonalInfoEvolution { } +public partial class PersonalInfoEvolution; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalInfo9SV.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalInfo9SV.cs index 9f468427..d2d5ca27 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalInfo9SV.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalInfo9SV.cs @@ -6,11 +6,9 @@ namespace pkNX.Structures.FlatBuffers.SV; /// /// Personal Info class with values from the games. /// -public sealed class PersonalInfo9SV : IPersonalInfo +public sealed class PersonalInfo9SV(PersonalInfo fb) : IPersonalInfo { - public PersonalInfo FB { get; } - - public PersonalInfo9SV(PersonalInfo fb) => FB = fb; + public PersonalInfo FB { get; } = fb; public int HP { get => FB.Base.HP; set => FB.Base.HP = (byte)value; } public int ATK { get => FB.Base.ATK; set => FB.Base.ATK = (byte)value; } @@ -143,7 +141,7 @@ public void Write(BinaryWriter bw) } public static readonly ushort[] TMIndexes = - { + [ 005, 036, 204, 313, 097, 189, 184, 182, 424, 422, 423, 352, 067, 491, 512, 522, 060, 109, 168, 574, 885, 884, 886, 451, 083, 263, 342, 332, 523, 506, @@ -167,5 +165,5 @@ public void Write(BinaryWriter bw) 799, 802, 220, 244, 038, 283, 572, 915, 250, 330, 916, 527, 813, 811, 482, 815, 297, 248, 797, 806, 800, 675, 784, 319, 174, 912, 913, 914, 917, 918, - }; + ]; } diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalTable9SV.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalTable9SV.cs index 5b8a1959..9cf3e163 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalTable9SV.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Personal/Personal/Wrapper/PersonalTable9SV.cs @@ -42,7 +42,7 @@ public PersonalTable9SV(IFileContainer file) formTable.Add(GetObj(forms[f], forms, MaxSpecies, formTable, f)); } - Table = baseForms.Concat(formTable).ToArray(); + Table = [.. baseForms, .. formTable]; } private static PersonalInfo9SV GetObj(PersonalInfo e, ICollection forms, ushort max, ICollection formTable, int f = 0) diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidEnemyTableArray.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidEnemyTableArray.cs index bbf8f476..27cef942 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidEnemyTableArray.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidEnemyTableArray.cs @@ -4,7 +4,6 @@ // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global // ReSharper disable UnusedType.Global -#nullable disable namespace pkNX.Structures.FlatBuffers.SV; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidFixedRewardItemArray.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidFixedRewardItemArray.cs index 5b3f5126..7a08765b 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidFixedRewardItemArray.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Raid/Raid/DeliveryRaidFixedRewardItemArray.cs @@ -7,7 +7,7 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DeliveryRaidFixedRewardItemArray { } +public partial class DeliveryRaidFixedRewardItemArray; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class DeliveryRaidFixedRewardItem diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataEventBattle.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataEventBattle.cs index 5918e1f7..66f992d0 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataEventBattle.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataEventBattle.cs @@ -6,4 +6,4 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDataEventBattle { } +public partial class PokeDataEventBattle; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataFull.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataFull.cs index 7e5bed66..971e507a 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataFull.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataFull.cs @@ -6,4 +6,4 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDataFull { } +public partial class PokeDataFull; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataSymbol.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataSymbol.cs index 42476cba..7b3a51df 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataSymbol.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataSymbol.cs @@ -6,4 +6,4 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDataSymbol { } +public partial class PokeDataSymbol; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataTrade.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataTrade.cs index 5a590063..33312c87 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataTrade.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/PokeDataTrade.cs @@ -2,9 +2,8 @@ // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global // ReSharper disable UnusedType.Global -#nullable disable namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PokeDataTrade { } +public partial class PokeDataTrade; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/WazaSet.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/WazaSet.cs index f8892e55..7838f4c6 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/WazaSet.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/PokeData/WazaSet.cs @@ -6,12 +6,12 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class WazaSet { } +public partial class WazaSet; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class ParamSet { public string SlashSeparated() => $"{HP}/{ATK}/{DEF}/{SPA}/{SPD}/{SPE}"; - public int[] ToArray() => new[] { HP, ATK, DEF, SPA, SPD, SPE }; + public int[] ToArray() => [HP, ATK, DEF, SPA, SPD, SPE]; } diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/SpeciesConverterSV.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/SpeciesConverterSV.cs index 56d4fc75..5c4c7415 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/SpeciesConverterSV.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Shared/Gen9/SpeciesConverterSV.cs @@ -53,8 +53,8 @@ public static ushort GetNational9(ushort raw) /// /// Difference of National Dex IDs (index) and the associated Gen9 Species IDs (value) /// - private static ReadOnlySpan Table9NationalToInternal => new sbyte[] - { + private static ReadOnlySpan Table9NationalToInternal => + [ 001, 001, 001, 001, 033, 033, 033, 021, 021, 044, 044, 007, 007, 007, 029, 031, 031, 031, 068, 068, 068, 002, 002, @@ -67,13 +67,13 @@ public static ushort GetNational9(ushort raw) -23, -05, -07, -09, -07, -20, -13, -09, -09, -29, -23, 001, 012, 012, 000, 000, 000, -06, 005, -06, -03, -03, -02, -04, -03, -03, - }; + ]; /// /// Difference of Gen9 Species IDs (index) and the associated National Dex IDs (value) /// - private static ReadOnlySpan Table9InternalToNational => new sbyte[] - { + private static ReadOnlySpan Table9InternalToNational => + [ 065, -01, -01, -01, -01, 031, 031, 047, 047, 029, 029, 053, 031, 031, 046, 044, 030, 030, -07, -07, -07, 013, 013, @@ -86,5 +86,5 @@ public static ushort GetNational9(ushort raw) -43, -43, -43, -68, -68, -68, -58, -58, -25, -29, -31, 006, -01, 006, 000, 000, 000, 003, 003, 004, 002, 003, 003, -05, -12, -12, - }; + ]; } diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Trinity/Archive/TrinityFileDescriptors.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Trinity/Archive/TrinityFileDescriptors.cs index 75021eeb..55bb469b 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Trinity/Archive/TrinityFileDescriptors.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.Trinity/Archive/TrinityFileDescriptors.cs @@ -47,16 +47,10 @@ private int BinarySearch(ulong hash) } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TrinityFileDescriptorSubFileInfo -{ -} +public partial class TrinityFileDescriptorSubFileInfo; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TrinityFileDescriptorInfo -{ -} +public partial class TrinityFileDescriptorInfo; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TrinityFileDescriptorSubFileUnknown -{ -} +public partial class TrinityFileDescriptorSubFileUnknown; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreak.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreak.cs index 6b6145e9..394ab33c 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreak.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreak.cs @@ -2,12 +2,11 @@ // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global // ReSharper disable UnusedType.Global -#nullable disable namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DeliveryOutbreakArray { } +public partial class DeliveryOutbreakArray; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DeliveryOutbreak { } +public partial class DeliveryOutbreak; diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreakPokeData.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreakPokeData.cs index 2a68e123..e9e89a5a 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreakPokeData.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/DeliveryOutbreakPokeData.cs @@ -6,7 +6,7 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class DeliveryOutbreakPokeDataArray { } +public partial class DeliveryOutbreakPokeDataArray; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class DeliveryOutbreakPokeData @@ -69,7 +69,7 @@ public bool IsLevelRangeCompatible(PackedVec2f range) } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class AreaNo { } +public partial class AreaNo; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class OutbreakEnableTable diff --git a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/PointDataArray.cs b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/PointDataArray.cs index dca0d9a9..bc2d39c5 100644 --- a/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/PointDataArray.cs +++ b/pkNX.Structures.FlatBuffers.SV/pkNX.Structures.FlatBuffers.SV.World/World/PointDataArray.cs @@ -6,4 +6,4 @@ namespace pkNX.Structures.FlatBuffers.SV; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PointDataArray { } +public partial class PointDataArray; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerPokeArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerPokeArchive.cs index dcfa221b..f94b725d 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerPokeArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerPokeArchive.cs @@ -8,7 +8,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class BattleTowerPokeArchive { } +public partial class BattleTowerPokeArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class BattleTowerPoke { } +public partial class BattleTowerPoke; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerTrainerArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerTrainerArchive.cs index 80daba22..faf194e9 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerTrainerArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/BattleTower/BattleTowerTrainerArchive.cs @@ -8,7 +8,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class BattleTowerTrainerArchive { } +public partial class BattleTowerTrainerArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class BattleTowerTrainer8 { } +public partial class BattleTowerTrainer8; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/EncounterGiftArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/EncounterGiftArchive.cs index 8a06e03a..adc7d6e8 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/EncounterGiftArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/EncounterGiftArchive.cs @@ -9,4 +9,4 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterGiftArchive { } +public partial class EncounterGiftArchive; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/GiftEncounter.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/GiftEncounter.cs index 257c2012..7a440999 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/GiftEncounter.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Gift/GiftEncounter.cs @@ -12,8 +12,8 @@ public partial class EncounterGift { public Species SpeciesID => (Species)Species; - public static readonly int[] BallToItem = - { + public static ReadOnlySpan BallToItem => + [ 000, // None 001, // Master 002, // Ultra @@ -41,17 +41,17 @@ public partial class EncounterGift 499, // Sport 576, // Dream 851, // Beast - }; + ]; public Ball Ball { - get => (Ball)Array.IndexOf(BallToItem, BallItemID); + get => (Ball)BallToItem.IndexOf((ushort)BallItemID); set => BallItemID = BallToItem[(int)value]; } public int[] IVs { - get => new int[] { IVHP, IVATK, IVDEF, IVSPE, IVSPA, IVSPD }; + get => [IVHP, IVATK, IVDEF, IVSPE, IVSPA, IVSPD]; set { if (value.Length != 6) return; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBModel.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBModel.cs index 3a4e47e7..928fd2a4 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBModel.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBModel.cs @@ -7,64 +7,40 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // *.gfbmdl [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class LayerData -{ -} +public partial class LayerData; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class RenderLayer -{ -} +public partial class RenderLayer; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class VersionInfo -{ -} +public partial class VersionInfo; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class GFBModel -{ -} +public partial class GFBModel; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class VertexAttribute -{ -} +public partial class VertexAttribute; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Polygon -{ -} +public partial class Polygon; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Shape -{ -} +public partial class Shape; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Mesh -{ -} +public partial class Mesh; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class TransparencyGroupNode -{ -} +public partial class TransparencyGroupNode; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Bone -{ -} +public partial class Bone; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class UberShaderSettings -{ -} +public partial class UberShaderSettings; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class SamplerState -{ -} +public partial class SamplerState; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class Texture @@ -91,6 +67,4 @@ public partial class Color3Param } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Material -{ -} +public partial class Material; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBPokeConfig.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBPokeConfig.cs index a9f37998..217201b4 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBPokeConfig.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Model/GFBPokeConfig.cs @@ -6,24 +6,16 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MeshProperty -{ -} +public partial class MeshProperty; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MeshEntries -{ -} +public partial class MeshEntries; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class SpeciesModelProperties -{ -} +public partial class SpeciesModelProperties; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class MaterialEntry -{ -} +public partial class MaterialEntry; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class GFBPokeConfig diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterNestArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterNestArchive.cs index cd4a1b79..0491117a 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterNestArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterNestArchive.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterNestArchive { } +public partial class EncounterNestArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class EncounterNestTable diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterUndergroundArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterUndergroundArchive.cs index 29d9b0b1..97961374 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterUndergroundArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/EncounterUndergroundArchive.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterUndergroundArchive { } +public partial class EncounterUndergroundArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class EncounterUnderground diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleCrystalEncounterArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleCrystalEncounterArchive.cs index c5593527..c6a5cb9f 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleCrystalEncounterArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleCrystalEncounterArchive.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleCrystalEncounterArchive { } +public partial class NestHoleCrystalEncounterArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class NestHoleCrystalEncounterTable @@ -155,4 +155,4 @@ public string GetSummarySimple() } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleCrystalEncounter { } +public partial class NestHoleCrystalEncounter; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionEncounterArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionEncounterArchive.cs index a75e27ee..de1036c3 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionEncounterArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionEncounterArchive.cs @@ -14,7 +14,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleDistributionEncounterArchive { } +public partial class NestHoleDistributionEncounterArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class NestHoleDistributionEncounterTable diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionRewardArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionRewardArchive.cs index 8db2da3f..de0238bc 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionRewardArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleDistributionRewardArchive.cs @@ -8,7 +8,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleDistributionRewardArchive { } +public partial class NestHoleDistributionRewardArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class NestHoleDistributionRewardTable : INestHoleRewardTable @@ -23,7 +23,7 @@ public partial class NestHoleDistributionReward : INestHoleReward public IList Values { - get => new uint[] { Value0, Value1, Value2, Value3, Value4 }; + get => [Value0, Value1, Value2, Value3, Value4]; set { Value0 = (byte)value[0]; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleLevelArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleLevelArchive.cs index b219b524..1e1716d8 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleLevelArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleLevelArchive.cs @@ -10,10 +10,10 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleLevelArchive { } +public partial class NestHoleLevelArchive; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleLevelTable { } +public partial class NestHoleLevelTable; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleLevel { } +public partial class NestHoleLevel; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleRewardArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleRewardArchive.cs index 70907c4c..74bdbc85 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleRewardArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Nest/NestHoleRewardArchive.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class NestHoleRewardArchive { } +public partial class NestHoleRewardArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class NestHoleRewardTable : INestHoleRewardTable diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ArchiveContent.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ArchiveContent.cs index d067a62e..ebf49db2 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ArchiveContent.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ArchiveContent.cs @@ -10,7 +10,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // archive_contents.bin -- 7707 entry table (file, files) [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ArchiveContents { } +public partial class ArchiveContents; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ArchiveContent { } +public partial class ArchiveContent; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/CellTable.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/CellTable.cs index 0e9c42a2..b8fcc9b0 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/CellTable.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/CellTable.cs @@ -58,7 +58,7 @@ public partial struct CellUnion [TypeConverter(typeof(ExpandableObjectConverter))] public partial class CellHash { public override string ToString() => Hash.ToString("X16"); } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class CellMetaHashes { } +public partial class CellMetaHashes; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class CellHashTuple diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/PokeResourceTable.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/PokeResourceTable.cs index 02fd6636..63cffa49 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/PokeResourceTable.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/PokeResourceTable.cs @@ -12,4 +12,4 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // poke_resource_table.gfbpmcatalog /// for Sword/Shield [TypeConverter(typeof(ExpandableObjectConverter))] -partial class GFBpmcatalog { } +partial class GFBpmcatalog; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Rental.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Rental.cs index a237ef9f..81aca745 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Rental.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Rental.cs @@ -8,7 +8,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class RentalArchive { } +public partial class RentalArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class Rental diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ScriptMeta.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ScriptMeta.cs index ecab4ce8..44855c9e 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ScriptMeta.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ScriptMeta.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // script_id_record.bin [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ScriptMeta { } +public partial class ScriptMeta; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ScriptMetaEntry { } +public partial class ScriptMetaEntry; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ShopInventory.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ShopInventory.cs index 6bc4f9a8..925a367a 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ShopInventory.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/ShopInventory.cs @@ -7,7 +7,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class ShopInventory { } +public partial class ShopInventory; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class SingleShop diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/SymbolBehavior.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/SymbolBehavior.cs index 12c7bb0c..4830d443 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/SymbolBehavior.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/SymbolBehavior.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // symbol_encount_mons_param.bin [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class SymbolBehaveRoot { } +public partial class SymbolBehaveRoot; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class SymbolBehave diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Waza.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Waza.cs index 741da6c1..c15e7766 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Waza.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/Waza.cs @@ -9,4 +9,4 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class Waza8 { } +public partial class Waza8; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/WeatherEntry.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/WeatherEntry.cs index 0182c12d..396a5377 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/WeatherEntry.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Other/WeatherEntry.cs @@ -11,7 +11,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // field\param\weather\weather_data.bin // field\param\weather\weather_data_alt.bin [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class WeatherTable { } -public partial class WeatherEntry { } -public partial class PentaFloat { } -public partial class QuadFloatSet { } +public partial class WeatherTable; +public partial class WeatherEntry; +public partial class PentaFloat; +public partial class QuadFloatSet; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8Archive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8Archive.cs index 1a1831f2..1eba7775 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8Archive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8Archive.cs @@ -8,4 +8,4 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneArchive { } +public partial class PlacementZoneArchive; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8_F04.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8_F04.cs index 459bec97..05ec855e 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8_F04.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/PlacementArea8_F04.cs @@ -8,4 +8,4 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementArea_F04 { } +public partial class PlacementArea_F04; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneAdvancedTipHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneAdvancedTipHolder.cs index 7d213248..6c75edcb 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneAdvancedTipHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneAdvancedTipHolder.cs @@ -8,19 +8,19 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneAdvancedTipHolder { } +public partial class PlacementZoneAdvancedTipHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneAdvancedTip { } +public partial class PlacementZoneAdvancedTip; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F14 { } +public partial class PlacementZone_F14; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F14_B { } +public partial class PlacementZone_F14_B; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F14_Union { } +public partial class PlacementZone_F14_Union; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F14_Sub { } +public partial class PlacementZone_F14_Sub; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneBerryTreeHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneBerryTreeHolder.cs index 3444b8d0..39c39087 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneBerryTreeHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneBerryTreeHolder.cs @@ -9,22 +9,22 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneBerryTreeHolder { } +public partial class PlacementZoneBerryTreeHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F22_0 { } +public partial class PlacementZone_F22_0; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F22_0_0 { } +public partial class PlacementZone_F22_0_0; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F22_Sub { } +public partial class PlacementZone_F22_Sub; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F22_BoolObject14 { } +public partial class PlacementZone_F22_BoolObject14; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F22_Inner { } +public partial class PlacementZone_F22_Inner; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneBerryTreeRandom { } +public partial class PlacementZoneBerryTreeRandom; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneEnvironmentHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneEnvironmentHolder.cs index 9f612738..6d4890c8 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneEnvironmentHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneEnvironmentHolder.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneEnvironmentHolder { } +public partial class PlacementZoneEnvironmentHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F10 { } +public partial class PlacementZone_F10; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFieldItemHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFieldItemHolder.cs index a0a78c07..0f5f1d26 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFieldItemHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFieldItemHolder.cs @@ -9,10 +9,10 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneFieldItemHolder { } +public partial class PlacementZoneFieldItemHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneFieldItem { } +public partial class PlacementZoneFieldItem; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneFieldItem_A { } +public partial class PlacementZoneFieldItem_A; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFishingPointHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFishingPointHolder.cs index 8b893518..80c73c0a 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFishingPointHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFishingPointHolder.cs @@ -14,4 +14,4 @@ public partial class PlacementZoneFishingPointHolder } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneFishingPoint { } +public partial class PlacementZoneFishingPoint; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFlightAnchorHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFlightAnchorHolder.cs index a361df8c..8d5d8226 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFlightAnchorHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneFlightAnchorHolder.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // player flying to location [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneFlightAnchorHolder { } +public partial class PlacementZoneFlightAnchorHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneFlightAnchor { } +public partial class PlacementZoneFlightAnchor; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneHiddenItemHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneHiddenItemHolder.cs index 6baa95a6..76490adc 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneHiddenItemHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneHiddenItemHolder.cs @@ -9,13 +9,13 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneHiddenItemHolder { } +public partial class PlacementZoneHiddenItemHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneHiddenItem { } +public partial class PlacementZoneHiddenItem; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneHiddenItemValue { } +public partial class PlacementZoneHiddenItemValue; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneHiddenItemChance { } +public partial class PlacementZoneHiddenItemChance; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneIKStepHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneIKStepHolder.cs index a6cba096..baeae05a 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneIKStepHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneIKStepHolder.cs @@ -10,10 +10,10 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // IK_Step [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneIKStepHolder { } +public partial class PlacementZoneIKStepHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F25 { } +public partial class PlacementZone_F25; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F25_X { } +public partial class PlacementZone_F25_X; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneLadderHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneLadderHolder.cs index d3f12060..682ab123 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneLadderHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneLadderHolder.cs @@ -8,10 +8,10 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneLadderHolder { } +public partial class PlacementZoneLadderHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneLadder { } +public partial class PlacementZoneLadder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F23_Sub { } +public partial class PlacementZone_F23_Sub; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneMovementPathHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneMovementPathHolder.cs index dd6b31ab..08c6d0a5 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneMovementPathHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneMovementPathHolder.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneMovementPathHolder { } +public partial class PlacementZoneMovementPathHolder; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PlacementZone_V3f diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNPCHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNPCHolder.cs index 8956e64b..aeb26770 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNPCHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNPCHolder.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneNPCHolder { } +public partial class PlacementZoneNPCHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneNPC { } +public partial class PlacementZoneNPC; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNestHoleHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNestHoleHolder.cs index eb7b658b..09476db7 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNestHoleHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneNestHoleHolder.cs @@ -9,19 +9,19 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneNestHoleHolder { } +public partial class PlacementZoneNestHoleHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F21_A { } +public partial class PlacementZone_F21_A; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F21_B { } +public partial class PlacementZone_F21_B; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F21_IntFloat { } +public partial class PlacementZone_F21_IntFloat; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F21_BoolObject14 { } +public partial class PlacementZone_F21_BoolObject14; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F21_Inner { } +public partial class PlacementZone_F21_Inner; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneOtherNPCHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneOtherNPCHolder.cs index b5bcf649..16a79d27 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneOtherNPCHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneOtherNPCHolder.cs @@ -172,13 +172,13 @@ public override string ToString() } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F16_ArrayEntry { } +public partial class PlacementZone_F16_ArrayEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F16 { } +public partial class PlacementZone_F16; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F16_A { } +public partial class PlacementZone_F16_A; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F16_IntFloat { } +public partial class PlacementZone_F16_IntFloat; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneParticleHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneParticleHolder.cs index 61e02e50..2a09e066 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneParticleHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneParticleHolder.cs @@ -14,4 +14,4 @@ public partial class PlacementZoneParticleHolder } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneParticle { } +public partial class PlacementZoneParticle; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePokeCenterSpawnAnchorHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePokeCenterSpawnAnchorHolder.cs index 7701b8c1..27661ef0 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePokeCenterSpawnAnchorHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePokeCenterSpawnAnchorHolder.cs @@ -8,7 +8,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZonePokeCenterSpawnAnchorHolder { } +public partial class PlacementZonePokeCenterSpawnAnchorHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F12 { } +public partial class PlacementZone_F12; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePopupHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePopupHolder.cs index cedfd374..ce45be6f 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePopupHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZonePopupHolder.cs @@ -10,13 +10,13 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZonePopupHolder { } +public partial class PlacementZonePopupHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F24 { } +public partial class PlacementZone_F24; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F24_Table { } +public partial class PlacementZone_F24_Table; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F24_IntFloat { } +public partial class PlacementZone_F24_IntFloat; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneQuadrantHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneQuadrantHolder.cs index 3268a977..af966506 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneQuadrantHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneQuadrantHolder.cs @@ -10,10 +10,10 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // highplace? [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneQuadrantHolder { } +public partial class PlacementZoneQuadrantHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F17 { } +public partial class PlacementZone_F17; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F17_Sub { } +public partial class PlacementZone_F17_Sub; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneRotomRallyEntry.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneRotomRallyEntry.cs index c7e7155f..c58129c0 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneRotomRallyEntry.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneRotomRallyEntry.cs @@ -9,4 +9,4 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // No maps have data for this. [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneRotomRallyEntry { } +public partial class PlacementZoneRotomRallyEntry; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSpeciesHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSpeciesHolder.cs index bda5f9d4..fdd829ba 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSpeciesHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSpeciesHolder.cs @@ -15,16 +15,16 @@ public partial class PlacementZoneSpeciesHolder } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F02_Nine { } +public partial class PlacementZone_F02_Nine; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F02 { } +public partial class PlacementZone_F02; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F02_Field1 { } +public partial class PlacementZone_F02_Field1; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F02_Inner { } +public partial class PlacementZone_F02_Inner; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F02_IntFloat { } +public partial class PlacementZone_F02_IntFloat; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStaticObjectsHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStaticObjectsHolder.cs index f8ee1ebc..171c570f 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStaticObjectsHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStaticObjectsHolder.cs @@ -10,10 +10,10 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneStaticObjectsHolder { } +public partial class PlacementZoneStaticObjectsHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneStaticObject { } +public partial class PlacementZoneStaticObject; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class PlacementZoneStaticObjectSpawn diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStepJumpHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStepJumpHolder.cs index 9f9648cf..8a5ecb5c 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStepJumpHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneStepJumpHolder.cs @@ -8,7 +8,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneStepJumpHolder { } +public partial class PlacementZoneStepJumpHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneStepJump { } +public partial class PlacementZoneStepJump; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSymbolSpawnHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSymbolSpawnHolder.cs index efd129af..933ec5c2 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSymbolSpawnHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneSymbolSpawnHolder.cs @@ -9,10 +9,10 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // wild encounter spawner? [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneSymbolSpawnHolder { } +public partial class PlacementZoneSymbolSpawnHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneSymbolSpawn { } +public partial class PlacementZoneSymbolSpawn; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F20_Sub { } +public partial class PlacementZone_F20_Sub; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerHolder.cs index 84b4f1c5..3d84559e 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerHolder.cs @@ -20,16 +20,16 @@ public override string ToString() } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F08_ArrayEntry { } +public partial class PlacementZone_F08_ArrayEntry; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F08_Nine { } +public partial class PlacementZone_F08_Nine; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F08 { } +public partial class PlacementZone_F08; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F08_A { } +public partial class PlacementZone_F08_A; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F08_IntFloat { } +public partial class PlacementZone_F08_IntFloat; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerTipHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerTipHolder.cs index 0171e09d..3f7ca07e 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerTipHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTrainerTipHolder.cs @@ -8,17 +8,17 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneTrainerTipHolder { } +public partial class PlacementZoneTrainerTipHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneTrainerTip { } +public partial class PlacementZoneTrainerTip; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F09 { } +public partial class PlacementZone_F09; // union? [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F09_Union { } +public partial class PlacementZone_F09_Union; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZone_F09_Sub { } +public partial class PlacementZone_F09_Sub; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTriggerHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTriggerHolder.cs index 08c6ade7..d91f9c39 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTriggerHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneTriggerHolder.cs @@ -9,13 +9,13 @@ namespace pkNX.Structures.FlatBuffers.SWSH; // Trigger tiles? [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneTriggerHolder { } +public partial class PlacementZoneTriggerHolder; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneTrigger { } +public partial class PlacementZoneTrigger; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneDeepX { } +public partial class PlacementZoneDeepX; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneDeepY { } +public partial class PlacementZoneDeepY; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneUnitObjectHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneUnitObjectHolder.cs index d75b504f..18230ca5 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneUnitObjectHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneUnitObjectHolder.cs @@ -16,14 +16,14 @@ public partial class PlacementZoneUnitObjectHolder } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneUnitObject { } +public partial class PlacementZoneUnitObject; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneUnitObjectDetails { } +public partial class PlacementZoneUnitObjectDetails; // probably a union, with only 1 object type used [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneUnitObjectToggle { } +public partial class PlacementZoneUnitObjectToggle; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneUnitObjectInner { } +public partial class PlacementZoneUnitObjectInner; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneWarpHolder.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneWarpHolder.cs index 79814f30..d6d79df7 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneWarpHolder.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Placement/Zone/Holders/PlacementZoneWarpHolder.cs @@ -15,7 +15,7 @@ public partial class PlacementZoneWarpHolder } [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneWarp8 { } +public partial class PlacementZoneWarp8; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class PlacementZoneWarpDetails8 { } +public partial class PlacementZoneWarpDetails8; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Static/EncounterStaticArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Static/EncounterStaticArchive.cs index 28368b14..a0196123 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Static/EncounterStaticArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Static/EncounterStaticArchive.cs @@ -8,7 +8,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterStaticArchive { } +public partial class EncounterStaticArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class EncounterStatic @@ -17,7 +17,7 @@ public partial class EncounterStatic public int[] IVs { - get => new int[] { IVHP, IVATK, IVDEF, IVSPE, IVSPA, IVSPD }; + get => [IVHP, IVATK, IVDEF, IVSPE, IVSPA, IVSPD]; set { if (value?.Length != 6) return; @@ -32,7 +32,7 @@ public int[] IVs public int[] Moves { - get => new[] { Move0, Move1, Move2, Move3 }; + get => [Move0, Move1, Move2, Move3]; set { if (value?.Length != 4) return; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Trade/EncounterTradeArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Trade/EncounterTradeArchive.cs index b14a9707..7cfc24d3 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Trade/EncounterTradeArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Trade/EncounterTradeArchive.cs @@ -8,15 +8,15 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterTradeArchive { } +public partial class EncounterTradeArchive; [TypeConverter(typeof(ExpandableObjectConverter))] public partial class EncounterTrade { public Species SpeciesID => (Species)Species; - public static readonly int[] BallToItem = - { + public static ReadOnlySpan BallToItem => + [ 000, // None 001, // Master 002, // Ultra @@ -44,17 +44,17 @@ public partial class EncounterTrade 499, // Sport 576, // Dream 851, // Beast - }; + ]; public Ball Ball { - get => (Ball)Array.IndexOf(BallToItem, BallItemID); + get => (Ball)BallToItem.IndexOf(BallItemID); set => BallItemID = BallToItem[(int)value]; } public int[] IVs { - get => new int[] { IVHP, IVATK, IVDEF, IVSPE, IVSPA, IVSPD }; + get => [IVHP, IVATK, IVDEF, IVSPE, IVSPA, IVSPD]; set { if (value?.Length != 6) return; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Waza/Waza.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Waza/Waza.cs index b7d00bf7..6dcb4c3d 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Waza/Waza.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Waza/Waza.cs @@ -1,38 +1,37 @@ -namespace pkNX.Structures.FlatBuffers.SWSH +namespace pkNX.Structures.FlatBuffers.SWSH; + +public partial class Waza : IMove { - public partial class Waza : IMove - { - public byte[] Write() => this.SerializeFrom(); + public byte[] Write() => this.SerializeFrom(); - public MoveInflictDuration InflictCount { get => (MoveInflictDuration)RawInflictCount; set => RawInflictCount = (byte)value; } - public Heal Healing { get => (Heal)RawHealing; set => RawHealing = (sbyte)value; } - public MoveTarget Target { get => (MoveTarget)RawTarget; set => RawTarget = (byte)value; } + public MoveInflictDuration InflictCount { get => (MoveInflictDuration)RawInflictCount; set => RawInflictCount = (byte)value; } + public Heal Healing { get => (Heal)RawHealing; set => RawHealing = (sbyte)value; } + public MoveTarget Target { get => (MoveTarget)RawTarget; set => RawTarget = (byte)value; } - int IMove.Type { get => Type ; set => Type = (byte)value; } - int IMove.Quality { get => Quality ; set => Quality = (byte)value; } - int IMove.Category { get => Category ; set => Category = (byte)value; } - int IMove.Power { get => Power ; set => Power = (byte)value; } - int IMove.Accuracy { get => Accuracy ; set => Accuracy = (byte)value; } - int IMove.PP { get => PP ; set => PP = (byte)value; } - int IMove.Priority { get => Priority; set => Priority= (sbyte)value; } - int IMove.HitMin { get => HitMin; set => HitMin = (byte)value; } - int IMove.HitMax { get => HitMax; set => HitMax = (byte)value; } - int IMove.Inflict { get => Inflict; set => Inflict = (byte)value; } - int IMove.InflictPercent { get => InflictPercent; set => InflictPercent = (byte)value; } - int IMove.TurnMin { get => TurnMin; set => TurnMin = (byte)value; } - int IMove.TurnMax { get => TurnMax; set => TurnMax = (byte)value; } - int IMove.CritStage { get => CritStage; set => CritStage = (sbyte)value; } - int IMove.Flinch { get => Flinch; set => Flinch = (byte)value; } - int IMove.EffectSequence { get => EffectSequence; set => EffectSequence = (byte)value; } - int IMove.Recoil { get => Recoil; set => Recoil = (sbyte)value; } - int IMove.Stat1 { get => Stat1; set => Stat1 = (byte)value; } - int IMove.Stat2 { get => Stat2; set => Stat2 = (byte)value; } - int IMove.Stat3 { get => Stat3; set => Stat3 = (byte)value; } - int IMove.Stat1Stage { get => Stat1Stage; set => Stat1Stage = (sbyte)value; } - int IMove.Stat2Stage { get => Stat2Stage; set => Stat2Stage = (sbyte)value; } - int IMove.Stat3Stage { get => Stat3Stage; set => Stat3Stage = (sbyte)value; } - int IMove.Stat1Percent { get => Stat1Percent; set => Stat1Percent = (byte)value; } - int IMove.Stat2Percent { get => Stat2Percent; set => Stat2Percent = (byte)value; } - int IMove.Stat3Percent { get => Stat3Percent; set => Stat3Percent = (byte)value; } - } + int IMove.Type { get => Type ; set => Type = (byte)value; } + int IMove.Quality { get => Quality ; set => Quality = (byte)value; } + int IMove.Category { get => Category ; set => Category = (byte)value; } + int IMove.Power { get => Power ; set => Power = (byte)value; } + int IMove.Accuracy { get => Accuracy ; set => Accuracy = (byte)value; } + int IMove.PP { get => PP ; set => PP = (byte)value; } + int IMove.Priority { get => Priority; set => Priority = (sbyte)value; } + int IMove.HitMin { get => HitMin; set => HitMin = (byte)value; } + int IMove.HitMax { get => HitMax; set => HitMax = (byte)value; } + int IMove.Inflict { get => Inflict; set => Inflict = (byte)value; } + int IMove.InflictPercent { get => InflictPercent; set => InflictPercent = (byte)value; } + int IMove.TurnMin { get => TurnMin; set => TurnMin = (byte)value; } + int IMove.TurnMax { get => TurnMax; set => TurnMax = (byte)value; } + int IMove.CritStage { get => CritStage; set => CritStage = (sbyte)value; } + int IMove.Flinch { get => Flinch; set => Flinch = (byte)value; } + int IMove.EffectSequence { get => EffectSequence; set => EffectSequence = (byte)value; } + int IMove.Recoil { get => Recoil; set => Recoil = (sbyte)value; } + int IMove.Stat1 { get => Stat1; set => Stat1 = (byte)value; } + int IMove.Stat2 { get => Stat2; set => Stat2 = (byte)value; } + int IMove.Stat3 { get => Stat3; set => Stat3 = (byte)value; } + int IMove.Stat1Stage { get => Stat1Stage; set => Stat1Stage = (sbyte)value; } + int IMove.Stat2Stage { get => Stat2Stage; set => Stat2Stage = (sbyte)value; } + int IMove.Stat3Stage { get => Stat3Stage; set => Stat3Stage = (sbyte)value; } + int IMove.Stat1Percent { get => Stat1Percent; set => Stat1Percent = (byte)value; } + int IMove.Stat2Percent { get => Stat2Percent; set => Stat2Percent = (byte)value; } + int IMove.Stat3Percent { get => Stat3Percent; set => Stat3Percent = (byte)value; } } diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterArchive.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterArchive.cs index 4062cf62..b17e668a 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterArchive.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterArchive.cs @@ -9,7 +9,7 @@ namespace pkNX.Structures.FlatBuffers.SWSH; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial class EncounterArchive { } -public partial class EncounterTable { } -public partial class EncounterSubTable { } -public partial class EncounterSlot { } +public partial class EncounterArchive; +public partial class EncounterTable; +public partial class EncounterSubTable; +public partial class EncounterSlot; diff --git a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterTableUtil.cs b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterTableUtil.cs index e9693b39..67c5be62 100644 --- a/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterTableUtil.cs +++ b/pkNX.Structures.FlatBuffers.SWSH/Gen8/Wild/EncounterTableUtil.cs @@ -30,7 +30,7 @@ public static byte[][] GetBytes(IReadOnlyDictionary zone_loc, IRead stony.Slots.AddRange(slots.Where(z => z.EncounterType == SWSHEncounterType.Shaking_Trees)); } - return result.ConvertAll(z => z.Serialize()).ToArray(); + return [.. result.ConvertAll(z => z.Serialize())]; } private static DumpableLocation GetDumpable(EncounterTable zone, IReadOnlyDictionary zoneLoc, IReadOnlyDictionary zoneType) @@ -100,20 +100,13 @@ private static bool IsPermittedWeather(byte locID, SWSHEncounterType weather, by _ => false, }; - private class DumpableLocation + private class DumpableLocation(List slots, byte location, byte slotType) { public static readonly DumpableLocation Empty = new([], 0, 0); - public readonly List Slots; - public readonly byte Location; - public readonly byte SlotType; - - public DumpableLocation(List slots, byte location, byte slotType) - { - Slots = slots; - Location = location; - SlotType = slotType; - } + public readonly List Slots = slots; + public readonly byte Location = location; + public readonly byte SlotType = slotType; public byte[] Serialize() => SerializeSlot8(Location, Slots, SlotType); } @@ -196,22 +189,15 @@ public enum SWSHSlotType : ushort Inaccessible, } - private class Slot8 : IEquatable + private class Slot8(int s, int f, int n, int x) + : IEquatable { - public readonly int Species; - public readonly int Form; - public readonly int Min; - public readonly int Max; + public readonly int Species = s; + public readonly int Form = f; + public readonly int Min = n; + public readonly int Max = x; public SWSHEncounterType EncounterType; - public Slot8(int s, int f, int n, int x) - { - Species = s; - Form = f; - Min = n; - Max = x; - } - public bool Equals(Slot8? other) { if (other is null) return false; diff --git a/pkNX.Structures.FlatBuffers/Data/Color3f.cs b/pkNX.Structures.FlatBuffers/Data/Color3f.cs index da476738..b73d5da7 100644 --- a/pkNX.Structures.FlatBuffers/Data/Color3f.cs +++ b/pkNX.Structures.FlatBuffers/Data/Color3f.cs @@ -5,15 +5,8 @@ namespace pkNX.Structures.FlatBuffers; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial struct Color3f +[method: MethodImpl(MethodImplOptions.AggressiveInlining)] +public partial struct Color3f(float r = 1.0f, float g = 1.0f, float b = 1.0f) { - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Color3f(float r = 1.0f, float g = 1.0f, float b = 1.0f) - { - R = r; - G = g; - B = b; - } - public override string ToString() => $"{{ R: {R}, G: {G}, B: {B} }}"; } diff --git a/pkNX.Structures.FlatBuffers/Data/Color4f.cs b/pkNX.Structures.FlatBuffers/Data/Color4f.cs index 49ed8b3c..8fd2c6b9 100644 --- a/pkNX.Structures.FlatBuffers/Data/Color4f.cs +++ b/pkNX.Structures.FlatBuffers/Data/Color4f.cs @@ -1,41 +1,28 @@ -using System; using System.ComponentModel; using System.Runtime.CompilerServices; namespace pkNX.Structures.FlatBuffers; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial struct Color4f +[method: MethodImpl(MethodImplOptions.AggressiveInlining)] +public partial struct Color4f(float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f) { /// - /// Multiply a [0.0f..1.0f] float color by FloatToRGB to get the [0..255] byte color + /// Multiply a [0.0f,1.0f] float color by FloatToRGB to get the [0,255] byte color /// - private static readonly float FloatToRGB = 255.0f; + private const float FloatToRGB = 255.0f; /// - /// Multiply a [0..255] byte color by RGBToFloat to get the [0.0f..1.0f] float color + /// Multiply a [0,255] byte color by RGBToFloat to get the [0.0f,1.0f] float color /// - private static readonly float RGBToFloat = 0.0039215686274509803921568627451f; + private const float RGBToFloat = 0.0039215686274509803921568627451f; - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Color4f(float r = 1.0f, float g = 1.0f, float b = 1.0f, float a = 1.0f) + public Color4f(Vec4f v) : this(v.X, v.Y, v.Z, v.W) { - R = r; - G = g; - B = b; - A = a; - } - - public Color4f(Vec4f v) - { - R = v.X; - G = v.Y; - B = v.Z; - A = v.W; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color4f FromByteColor(Vec4i c) => new(c.X * RGBToFloat, c.Y * RGBToFloat, c.Z * RGBToFloat, c.W * RGBToFloat); - public override string ToString() => $"{{ R: {R}, G: {G}, B: {B}, A: {A} }}"; + public readonly override string ToString() => $"{{ R: {R}, G: {G}, B: {B}, A: {A} }}"; } diff --git a/pkNX.Structures.FlatBuffers/Data/Vec4i.cs b/pkNX.Structures.FlatBuffers/Data/Vec4i.cs index 7696c05a..497c0023 100644 --- a/pkNX.Structures.FlatBuffers/Data/Vec4i.cs +++ b/pkNX.Structures.FlatBuffers/Data/Vec4i.cs @@ -1,5 +1,3 @@ -using FlatSharp.Attributes; -using System; using System.ComponentModel; namespace pkNX.Structures.FlatBuffers; diff --git a/pkNX.Structures.FlatBuffers/Geomerty/Sphere.cs b/pkNX.Structures.FlatBuffers/Geomerty/Sphere.cs index 9ee3ffc5..09496aa2 100644 --- a/pkNX.Structures.FlatBuffers/Geomerty/Sphere.cs +++ b/pkNX.Structures.FlatBuffers/Geomerty/Sphere.cs @@ -6,13 +6,7 @@ namespace pkNX.Structures.FlatBuffers; -public partial struct Sphere +public partial struct Sphere(AABB bounds) { - public Sphere(AABB bounds) - { - Center = (PackedVec3f)bounds.Center; - Radius = bounds.Extents.Magnitude; - } - public override string ToString() => $"{{ Radius: {Radius}, Center: {Center} }}"; } diff --git a/pkNX.Structures.FlatBuffers/Math/PackedVec3f.cs b/pkNX.Structures.FlatBuffers/Math/PackedVec3f.cs index a835268f..a05bc436 100644 --- a/pkNX.Structures.FlatBuffers/Math/PackedVec3f.cs +++ b/pkNX.Structures.FlatBuffers/Math/PackedVec3f.cs @@ -3,20 +3,13 @@ namespace pkNX.Structures.FlatBuffers; [TypeConverter(typeof(ExpandableObjectConverter))] -public partial struct PackedVec3f : IEquatable +public partial struct PackedVec3f(float x = 0, float y = 0, float z = 0) : IEquatable { public static readonly PackedVec3f Zero = new(); public static readonly PackedVec3f One = new() { X = 1, Y = 1, Z = 1 }; public static explicit operator PackedVec3f(Vec3f v) => new() { X = v.X, Y = v.Y, Z = v.Z }; - public PackedVec3f(float x = 0, float y = 0, float z = 0) - { - X = x; - Y = y; - Z = z; - } - public readonly bool IsOne() => X is 1 && Y is 1 && Z is 1; public readonly bool IsZero() => X is 0 && Y is 0 && Z is 0; public readonly float Magnitude() => MathF.Sqrt(MagnitudeSqr()); diff --git a/pkNX.Structures.FlatBuffers/Math/Vec3f.cs b/pkNX.Structures.FlatBuffers/Math/Vec3f.cs index 2bd1c266..1a0f0266 100644 --- a/pkNX.Structures.FlatBuffers/Math/Vec3f.cs +++ b/pkNX.Structures.FlatBuffers/Math/Vec3f.cs @@ -1,4 +1,3 @@ -using System; using System.ComponentModel; namespace pkNX.Structures.FlatBuffers; @@ -25,11 +24,11 @@ public Vec3f(float x = 0, float y = 0, float z = 0) public float MagnitudeSqr => Dot(this); public Vec3f Normalized() => this * (1 / Magnitude); - public float Dot(Vec3f other) => X * other.X + Y * other.Y + Z * other.Z; - public Vec3f Cross(Vec3f other) => new(Y * other.Z - Z * other.Y, Z * other.X - X * other.Z, X * other.Y - Y * other.X); + public float Dot(Vec3f other) => (X * other.X) + (Y * other.Y) + (Z * other.Z); + public Vec3f Cross(Vec3f other) => new((Y * other.Z) - (Z * other.Y), (Z * other.X) - (X * other.Z), (X * other.Y) - (Y * other.X)); public float DistanceTo(Vec3f other) => (this - other).Magnitude; public float DistanceToSqr(Vec3f other) => (this - other).MagnitudeSqr; - public Vec3f Lerp(Vec3f other, float t) => this + (other - this) * t; + public Vec3f Lerp(Vec3f other, float t) => this + ((other - this) * t); public Vec3f Clone() => new() { diff --git a/pkNX.Structures.FlatBuffers/Util/FlatSchemaDump.cs b/pkNX.Structures.FlatBuffers/Util/FlatSchemaDump.cs index ead99945..b110b152 100644 --- a/pkNX.Structures.FlatBuffers/Util/FlatSchemaDump.cs +++ b/pkNX.Structures.FlatBuffers/Util/FlatSchemaDump.cs @@ -24,7 +24,7 @@ public class FlatSchemaDump private void Recurse(Type t) { var type = GetType(t); - if ((type.IsValueType && !type.IsEnum) || type == typeof(string)) + if (type is { IsValueType: true, IsEnum: false } || type == typeof(string)) return; var name = GetName(type); if (GeneratedClasses.Contains(name)) diff --git a/pkNX.Structures/ArrayUtil.cs b/pkNX.Structures/ArrayUtil.cs index ccf6df06..b2f318f8 100644 --- a/pkNX.Structures/ArrayUtil.cs +++ b/pkNX.Structures/ArrayUtil.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace pkNX.Structures; @@ -22,8 +21,6 @@ public static T[] Slice(this T[] src, int offset, int length) return data; } - public static bool WithinRange(int value, int min, int max) => min <= value && value < max; - public static T[][] Split(this T[] data, int size) { var result = new T[data.Length / size][]; @@ -31,56 +28,6 @@ public static T[][] Split(this T[] data, int size) result[i / size] = data.Slice(i, size); return result; } - - public static int FindNextValidIndex(IList dest, Func skip, int ctr) - { - while (true) - { - if ((uint)ctr >= dest.Count) - return -1; - var exist = dest[ctr]; - if (exist == null || !skip(exist)) - return ctr; - ctr++; - } - } - - internal static T[] ConcatAll(params T[][] arr) - { - int len = 0; - foreach (var a in arr) - len += a.Length; - - var result = new T[len]; - - int ctr = 0; - foreach (var a in arr) - { - a.CopyTo(result, ctr); - ctr += a.Length; - } - - return result; - } - - internal static T[] ConcatAll(T[] arr1, T[] arr2) - { - int len = arr1.Length + arr2.Length; - var result = new T[len]; - arr1.CopyTo(result, 0); - arr2.CopyTo(result, arr1.Length); - return result; - } - - internal static T[] ConcatAll(T[] arr1, T[] arr2, T[] arr3) - { - int len = arr1.Length + arr2.Length + arr3.Length; - var result = new T[len]; - arr1.CopyTo(result, 0); - arr2.CopyTo(result, arr1.Length); - arr3.CopyTo(result, arr1.Length + arr2.Length); - return result; - } } public static class FlagUtil diff --git a/pkNX.Structures/CodePattern.cs b/pkNX.Structures/CodePattern.cs index da94259a..2e89913d 100644 --- a/pkNX.Structures/CodePattern.cs +++ b/pkNX.Structures/CodePattern.cs @@ -80,9 +80,9 @@ public static int IndexOfPattern(byte[] array, byte[] pattern, ulong wildCard, i /// byte pattern which precedes the TMHM list. This list is the tail end of item IDs for each TM(01->100). /// public static readonly byte[] TMHM_GG = - { + [ 0xA0, 0x01, 0xA1, 0x01, 0xA2, 0x01, 0xA3, 0x01, 0x6A, 0x02, 0x6B, 0x02, 0x6C, 0x02, 0xB2, 0x02, 0xB3, 0x02, 0xB4, 0x02, 0xB5, 0x02, 0xB6, 0x02, - }; + ]; } diff --git a/pkNX.Structures/Dumpers/PersonalDumper.cs b/pkNX.Structures/Dumpers/PersonalDumper.cs index b1003ba5..8588a202 100644 --- a/pkNX.Structures/Dumpers/PersonalDumper.cs +++ b/pkNX.Structures/Dumpers/PersonalDumper.cs @@ -21,28 +21,28 @@ public class PersonalDumper public bool HasAbilities { get; set; } = true; public bool HasItems { get; set; } = true; - public IReadOnlyList Abilities { private get; set; } = Array.Empty(); - public IReadOnlyList Types { private get; set; } = Array.Empty(); - public IReadOnlyList Items { private get; set; } = Array.Empty(); - public IReadOnlyList Colors { private get; set; } = Array.Empty(); - public IReadOnlyList EggGroups { private get; set; } = Array.Empty(); - public IReadOnlyList ExpGroups { private get; set; } = Array.Empty(); - public IReadOnlyList EntryNames { private get; set; } = Array.Empty(); - public IReadOnlyList Moves { protected get; set; } = Array.Empty(); - public IReadOnlyList Species { private get; set; } = Array.Empty(); - public IReadOnlyList ZukanA { private get; set; } = Array.Empty(); - public IReadOnlyList ZukanB { private get; set; } = Array.Empty(); + public IReadOnlyList Abilities { private get; set; } = []; + public IReadOnlyList Types { private get; set; } = []; + public IReadOnlyList Items { private get; set; } = []; + public IReadOnlyList Colors { private get; set; } = []; + public IReadOnlyList EggGroups { private get; set; } = []; + public IReadOnlyList ExpGroups { private get; set; } = []; + public IReadOnlyList EntryNames { private get; set; } = []; + public IReadOnlyList Moves { protected get; set; } = []; + public IReadOnlyList Species { private get; set; } = []; + public IReadOnlyList ZukanA { private get; set; } = []; + public IReadOnlyList ZukanB { private get; set; } = []; - public IReadOnlyList EntryLearnsets { private get; set; } = Array.Empty(); - public IReadOnlyList EntryEggMoves { private get; set; } = Array.Empty(); - public IReadOnlyList Evos { private get; set; } = Array.Empty(); - public IReadOnlyList TMIndexes { protected get; set; } = Array.Empty(); - public IReadOnlyList TRIndexes { protected get; set; } = Array.Empty(); + public IReadOnlyList EntryLearnsets { private get; set; } = []; + public IReadOnlyList EntryEggMoves { private get; set; } = []; + public IReadOnlyList Evos { private get; set; } = []; + public IReadOnlyList TMIndexes { protected get; set; } = []; + public IReadOnlyList TRIndexes { protected get; set; } = []; - private static readonly string[] AbilitySuffix = { " (1)", " (2)", " (H)" }; - private static readonly string[] ItemPrefix = { "Item 1 (50%)", "Item 2 (5%)", "Item 3 (1%)" }; + private static readonly string[] AbilitySuffix = [" (1)", " (2)", " (H)"]; + private static readonly string[] ItemPrefix = ["Item 1 (50%)", "Item 2 (5%)", "Item 3 (1%)"]; - public IReadOnlyList> MoveSpeciesLearn { get; private set; } = Array.Empty>(); + public IReadOnlyList> MoveSpeciesLearn { get; private set; } = []; public PersonalDumperSettings Settings = new(); @@ -225,7 +225,7 @@ private void AddPersonalLines(List lines, IPersonalInfo pi, int entry, s lines.Add($"Armor Dex: #{s.ArmorDexIndex:000}"); if (s.CrownDexIndex != 0) lines.Add($"Crown Dex: #{s.CrownDexIndex:000}"); - if (s.DexIndexRegional == 0 && s.ArmorDexIndex == 0 && s.CrownDexIndex == 0) + if (s is { DexIndexRegional: 0, ArmorDexIndex: 0, CrownDexIndex: 0 }) lines.Add("Galar Dex: Foreign"); if (s.CanNotDynamax) diff --git a/pkNX.Structures/EggMove/EggMoves.cs b/pkNX.Structures/EggMove/EggMoves.cs index 0fa494cc..5e937768 100644 --- a/pkNX.Structures/EggMove/EggMoves.cs +++ b/pkNX.Structures/EggMove/EggMoves.cs @@ -2,9 +2,8 @@ namespace pkNX.Structures; -public abstract class EggMoves +public abstract class EggMoves(int[] moves) { - public readonly int[] Moves; - protected EggMoves(int[] moves) => Moves = moves; + public readonly int[] Moves = moves; public bool GetHasEggMove(int move) => Moves.Contains(move); } diff --git a/pkNX.Structures/Encounter/EncounterGift.cs b/pkNX.Structures/Encounter/EncounterGift.cs index fa68f921..41c885ae 100644 --- a/pkNX.Structures/Encounter/EncounterGift.cs +++ b/pkNX.Structures/Encounter/EncounterGift.cs @@ -1,11 +1,8 @@ -using System; - namespace pkNX.Structures; -public abstract class EncounterGift +public abstract class EncounterGift(byte[] data) { - protected readonly byte[] Data; - protected EncounterGift(byte[] data) => Data = data; + protected readonly byte[] Data = data; public virtual byte[] Write() => (byte[])Data.Clone(); public abstract Species Species { get; set; } @@ -31,7 +28,7 @@ public abstract class EncounterGift public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { if (value?.Length != 6) return; diff --git a/pkNX.Structures/Encounter/EncounterStatic.cs b/pkNX.Structures/Encounter/EncounterStatic.cs index be42bf18..27913301 100644 --- a/pkNX.Structures/Encounter/EncounterStatic.cs +++ b/pkNX.Structures/Encounter/EncounterStatic.cs @@ -1,12 +1,10 @@ -using System; using System.Linq; namespace pkNX.Structures; -public abstract class EncounterStatic +public abstract class EncounterStatic(byte[] data) { - protected readonly byte[] Data; - protected EncounterStatic(byte[] data) => Data = data; + protected readonly byte[] Data = data; public virtual byte[] Write() => (byte[])Data.Clone(); public abstract Species Species { get; set; } @@ -38,7 +36,7 @@ public abstract class EncounterStatic public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { if (value?.Length != 6) return; @@ -49,7 +47,7 @@ public int[] IVs public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { if (value?.Length != 6) return; diff --git a/pkNX.Structures/Encounter/EncounterTrade.cs b/pkNX.Structures/Encounter/EncounterTrade.cs index 2d7eb09d..e619b372 100644 --- a/pkNX.Structures/Encounter/EncounterTrade.cs +++ b/pkNX.Structures/Encounter/EncounterTrade.cs @@ -2,11 +2,9 @@ namespace pkNX.Structures; -public abstract class EncounterTrade +public abstract class EncounterTrade(byte[] data) { - protected readonly byte[] Data; - - protected EncounterTrade(byte[] data) => Data = data; + protected readonly byte[] Data = data; public virtual byte[] Write() => (byte[])Data.Clone(); @@ -33,7 +31,7 @@ public abstract class EncounterTrade public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { if (value?.Length != 6) return; diff --git a/pkNX.Structures/Encounter/Gen6/EncounterGift6AO.cs b/pkNX.Structures/Encounter/Gen6/EncounterGift6AO.cs index 71f53728..65fbf951 100644 --- a/pkNX.Structures/Encounter/Gen6/EncounterGift6AO.cs +++ b/pkNX.Structures/Encounter/Gen6/EncounterGift6AO.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures; -public class EncounterGift6AO : EncounterGift +public class EncounterGift6AO(byte[] data) : EncounterGift(data) { public const int SIZE = 0x24; public EncounterGift6AO() : this(new byte[SIZE]) { } - public EncounterGift6AO(byte[] data) : base(data) { } public override Species Species { get => (Species)BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } public int Unk02 { get => BitConverter.ToUInt16(Data, 0x02); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x02); } diff --git a/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs b/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs index 51f244a4..132dc9d1 100644 --- a/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs +++ b/pkNX.Structures/Encounter/Gen6/EncounterGift6XY.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures; -public class EncounterGift6XY : EncounterGift +public class EncounterGift6XY(byte[] data) : EncounterGift(data) { public const int SIZE = 0x18; public EncounterGift6XY() : this(new byte[SIZE]) { } - public EncounterGift6XY(byte[] data) : base(data) { } public override Species Species { get => (Species)BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } public int Unk_02 { get => BitConverter.ToUInt16(Data, 0x02); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x02); } diff --git a/pkNX.Structures/Encounter/Gen6/EncounterStatic6.cs b/pkNX.Structures/Encounter/Gen6/EncounterStatic6.cs index 233d2be7..f6facc92 100644 --- a/pkNX.Structures/Encounter/Gen6/EncounterStatic6.cs +++ b/pkNX.Structures/Encounter/Gen6/EncounterStatic6.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures.Encounter; -public sealed class EncounterStatic6 : EncounterStatic +public sealed class EncounterStatic6(byte[] data) : EncounterStatic(data) { private const int SIZE = 0xC; public EncounterStatic6() : this(new byte[SIZE]) { } - public EncounterStatic6(byte[] data) : base(data) { } public override Species Species { get => (Species)BitConverter.ToUInt16(Data, 0x0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0); } public override int Form { get => Data[0x2]; set => Data[0x2] = (byte)value; } diff --git a/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs b/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs index d2de5665..26c9f09e 100644 --- a/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs +++ b/pkNX.Structures/Encounter/Gen7/EncounterGift7.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures; -public class EncounterGift7 : EncounterGift +public class EncounterGift7(byte[] data) : EncounterGift(data) { public const int SIZE = 0x14; public EncounterGift7() : this(new byte[SIZE]) { } - public EncounterGift7(byte[] data) : base(data) { } public override Species Species { get => (Species)BitConverter.ToUInt16(Data, 0x0); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x0); } public override int Form { get => Data[0x2]; set => Data[0x2] = (byte)value; } diff --git a/pkNX.Structures/Encounter/Gen7/EncounterGift7b.cs b/pkNX.Structures/Encounter/Gen7/EncounterGift7b.cs index 8ba64d63..f3e160c4 100644 --- a/pkNX.Structures/Encounter/Gen7/EncounterGift7b.cs +++ b/pkNX.Structures/Encounter/Gen7/EncounterGift7b.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures; -public class EncounterGift7b : EncounterGift +public class EncounterGift7b(byte[] data) : EncounterGift(data) { public const int SIZE = 0x20; public EncounterGift7b() : this(new byte[SIZE]) { } - public EncounterGift7b(byte[] data) : base(data) { } public ulong Hash => BitConverter.ToUInt64(Data, 0); @@ -56,13 +55,13 @@ public override Species Species public override int[] RelearnMoves { - get => new int[] - { + get => + [ BitConverter.ToUInt16(Data, 0x18), BitConverter.ToUInt16(Data, 0x1A), BitConverter.ToUInt16(Data, 0x1C), BitConverter.ToUInt16(Data, 0x1E), - }; + ]; set { if (value?.Length != 4) diff --git a/pkNX.Structures/Encounter/Gen7/EncounterStatic7.cs b/pkNX.Structures/Encounter/Gen7/EncounterStatic7.cs index 2674c5ac..3c56dde1 100644 --- a/pkNX.Structures/Encounter/Gen7/EncounterStatic7.cs +++ b/pkNX.Structures/Encounter/Gen7/EncounterStatic7.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures; -public sealed class EncounterStatic7 : EncounterStatic +public sealed class EncounterStatic7(byte[] data) : EncounterStatic(data) { public const int SIZE = 0x38; public EncounterStatic7() : this(new byte[SIZE]) { } - public EncounterStatic7(byte[] data) : base(data) { } public override Species Species { @@ -70,13 +69,13 @@ public int Map public override int[] RelearnMoves { - get => new int[] - { + get => + [ BitConverter.ToUInt16(Data, 0xC), BitConverter.ToUInt16(Data, 0xE), BitConverter.ToUInt16(Data, 0x10), BitConverter.ToUInt16(Data, 0x12), - }; + ]; set { if (value.Length != 4) diff --git a/pkNX.Structures/Encounter/Gen7/EncounterStatic7b.cs b/pkNX.Structures/Encounter/Gen7/EncounterStatic7b.cs index 7dabb11f..602b9e30 100644 --- a/pkNX.Structures/Encounter/Gen7/EncounterStatic7b.cs +++ b/pkNX.Structures/Encounter/Gen7/EncounterStatic7b.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures; -public sealed class EncounterStatic7b : EncounterStatic +public sealed class EncounterStatic7b(byte[] data) : EncounterStatic(data) { public const int SIZE = 0x40; public EncounterStatic7b() : this(new byte[SIZE]) { } - public EncounterStatic7b(byte[] data) : base(data) { } public ulong Hash => BitConverter.ToUInt64(Data, 0); @@ -36,25 +35,25 @@ public override Species Species public uint[] Ptrs // 0x10-0x1F -- are these text line references? { - get => new[] - { + get => + [ BitConverter.ToUInt32(Data, 0x10), BitConverter.ToUInt32(Data, 0x14), BitConverter.ToUInt32(Data, 0x18), BitConverter.ToUInt32(Data, 0x1C), - }; + ]; set { } } public override int[] RelearnMoves // 0x20-0x27 -- these are actually just moves { - get => new int[] - { + get => + [ BitConverter.ToUInt16(Data, 0x20), BitConverter.ToUInt16(Data, 0x22), BitConverter.ToUInt16(Data, 0x24), BitConverter.ToUInt16(Data, 0x26), - }; + ]; set { if (value.Length != 4) diff --git a/pkNX.Structures/Encounter/Gen7/EncounterTrade7b.cs b/pkNX.Structures/Encounter/Gen7/EncounterTrade7b.cs index a1018476..d75ad7a8 100644 --- a/pkNX.Structures/Encounter/Gen7/EncounterTrade7b.cs +++ b/pkNX.Structures/Encounter/Gen7/EncounterTrade7b.cs @@ -2,11 +2,10 @@ namespace pkNX.Structures; -public class EncounterTrade7b : EncounterTrade +public class EncounterTrade7b(byte[] data) : EncounterTrade(data) { public const int SIZE = 0x58; public EncounterTrade7b() : this(new byte[SIZE]) { } - public EncounterTrade7b(byte[] data) : base(data) { } // game loops over all trades to find which one is being offered public ulong HashTradeID => BitConverter.ToUInt64(Data, 0x00); diff --git a/pkNX.Structures/Evolution/EvolutionSet.cs b/pkNX.Structures/Evolution/EvolutionSet.cs index 82a5090c..41a077b0 100644 --- a/pkNX.Structures/Evolution/EvolutionSet.cs +++ b/pkNX.Structures/Evolution/EvolutionSet.cs @@ -7,8 +7,6 @@ namespace pkNX.Structures; /// public abstract class EvolutionSet { - public EvolutionMethod[] PossibleEvolutions; + public EvolutionMethod[] PossibleEvolutions = []; public abstract byte[] Write(); - - protected EvolutionSet() => PossibleEvolutions = []; } diff --git a/pkNX.Structures/Havok/HavokCollision.cs b/pkNX.Structures/Havok/HavokCollision.cs index 2ae0958c..0d37e1b7 100644 --- a/pkNX.Structures/Havok/HavokCollision.cs +++ b/pkNX.Structures/Havok/HavokCollision.cs @@ -56,11 +56,11 @@ public static AABBTree ParseAABBTree(ReadOnlySpan trcol) foreach ((uint tag1, int start1, int end1) in ReadSections(subSec)) { var subSec1 = subSec[start1..end1]; - switch (tag1) { - case 0x4954454D: // ITEM - item = ReadItems(subSec1, tna1); - break; - } + item = tag1 switch + { + 0x4954454D => ReadItems(subSec1, tna1), // ITEM + _ => item, + }; } break; } @@ -173,21 +173,21 @@ public static AABBTree ParseAABBTree(ReadOnlySpan trcol) return new(nodes); } - private static float[] ReadVector4(ReadOnlySpan buf) => new[] - { + private static float[] ReadVector4(ReadOnlySpan buf) => + [ ReadSingleLittleEndian(buf), ReadSingleLittleEndian(buf[4..]), ReadSingleLittleEndian(buf[8..]), ReadSingleLittleEndian(buf[12..]), - }; + ]; - private static uint[] ReadNodeData(ReadOnlySpan buf) => new[] - { + private static uint[] ReadNodeData(ReadOnlySpan buf) => + [ ReadUInt32LittleEndian(buf), ReadUInt32LittleEndian(buf[4..]), ReadUInt32LittleEndian(buf[8..]), ReadUInt32LittleEndian(buf[12..]), - }; + ]; private static List ReadStrings(ReadOnlySpan buffer) { @@ -504,40 +504,28 @@ private bool ContainsPointInNode(int nodeIndex, float x, float ly, float hy, flo public bool ContainedBy(IContainsV3f other) => other.ContainsPoint(BoundingBoxRectangles[0].X, BoundingBoxRectangles[0].Y, BoundingBoxRectangles[0].Z); } - public struct Rectangle3D + public struct Rectangle3D(float x, float y, float z, float width, float height, float depth) { /// X-coordinate of one corner - public float X { get; set; } + public float X { get; set; } = x; + /// Y-coordinate of one corner - public float Y { get; set; } + public float Y { get; set; } = y; + /// Z-coordinate of one corner - public float Z { get; set; } + public float Z { get; set; } = z; /// Width of the rectangle (X) - public float Width { get; set; } + public float Width { get; set; } = width; + /// Height of the rectangle (Y) - public float Height { get; set; } + public float Height { get; set; } = height; + /// Depth of the rectangle (Z) - public float Depth { get; set; } + public float Depth { get; set; } = depth; - public Rectangle3D(float x, float y, float z, float width, float height, float depth) + public Rectangle3D(Vector3 lo, Vector3 hi) : this(lo.X, lo.Y, lo.Z, hi.X - lo.X, hi.Y - lo.Y, hi.Z - lo.Z) { - X = x; - Y = y; - Z = z; - Width = width; - Height = height; - Depth = depth; - } - - public Rectangle3D(Vector3 lo, Vector3 hi) - { - X = lo.X; - Y = lo.Y; - Z = lo.Z; - Width = hi.X - lo.X; - Height = hi.Y - lo.Y; - Depth = hi.Z - lo.Z; } } diff --git a/pkNX.Structures/Item/Item8.cs b/pkNX.Structures/Item/Item8.cs index e4b0106b..220510bb 100644 --- a/pkNX.Structures/Item/Item8.cs +++ b/pkNX.Structures/Item/Item8.cs @@ -2,17 +2,11 @@ namespace pkNX.Structures; -public class Item8 +public class Item8(int id, byte[] data) { private const int SIZE = 0x30; - public readonly int ItemID; - public readonly byte[] Data; - - public Item8(int id, byte[] data) - { - ItemID = id; - Data = data; - } + public readonly int ItemID = id; + public readonly byte[] Data = data; public uint Price { diff --git a/pkNX.Structures/Item/Item8a.cs b/pkNX.Structures/Item/Item8a.cs index b5b0f4a1..d8f69eca 100644 --- a/pkNX.Structures/Item/Item8a.cs +++ b/pkNX.Structures/Item/Item8a.cs @@ -3,19 +3,17 @@ namespace pkNX.Structures; -public class Item8a +public class Item8a(int id, byte[] data) { private const int SIZE = 0x3C; - public readonly int ItemID; - public readonly byte[] Data; + public readonly int ItemID = id; + public readonly byte[] Data = data; private const string Battle = "Battle"; private const string Field = "Field"; private const string Mart = "Mart"; private const string Heal = "Heal"; - public Item8a(int id, byte[] data) => (ItemID, Data) = (id, data); - public uint Price { get => BitConverter.ToUInt32(Data, 0x00); set => BitConverter.GetBytes(value).CopyTo(Data, 0x00); } public uint PriceWatts { get => BitConverter.ToUInt32(Data, 0x04); set => BitConverter.GetBytes(value).CopyTo(Data, 0x04); } public uint MeritPrice { get => BitConverter.ToUInt32(Data, 0x08); set => BitConverter.GetBytes(value).CopyTo(Data, 0x08); } diff --git a/pkNX.Structures/Learnset/Learnset.cs b/pkNX.Structures/Learnset/Learnset.cs index bb53acd9..79a92157 100644 --- a/pkNX.Structures/Learnset/Learnset.cs +++ b/pkNX.Structures/Learnset/Learnset.cs @@ -7,14 +7,8 @@ namespace pkNX.Structures; public abstract class Learnset { public int Count { get; protected set; } - public int[] Moves { get; protected set; } - public int[] Levels { get; protected set; } - - protected Learnset() - { - Moves = []; - Levels = []; - } + public int[] Moves { get; protected set; } = []; + public int[] Levels { get; protected set; } = []; public abstract byte[] Write(); @@ -48,7 +42,7 @@ public int[] GetMoves(int maxLevel, int minLevel = 0) public int[] GetEncounterMoves(int level) { const int count = 4; - IList moves = new int[count]; + var moves = new int[count]; int ctr = 0; for (int i = 0; i < Moves.Length; i++) { @@ -61,7 +55,7 @@ public int[] GetEncounterMoves(int level) moves[ctr++] = move; ctr &= 3; } - return (int[])moves; + return moves; } /// Returns the index of the lowest level move if the Pokémon were encountered at the specified level. diff --git a/pkNX.Structures/Legality/Encounters.cs b/pkNX.Structures/Legality/Encounters.cs index 126fb0a5..cd195ca3 100644 --- a/pkNX.Structures/Legality/Encounters.cs +++ b/pkNX.Structures/Legality/Encounters.cs @@ -1,23 +1,23 @@ -using System.Linq; - namespace pkNX.Structures; public static partial class Legal { public static readonly int[] BasicStarters_1 = - { + [ 001, 004, 007, 010, 013, 016, 029, 032, 041, 043, 060, 063, 066, 069, 074, 081, 092, 111, 116, 137, 147, - }; + ]; - public static readonly int[] BasicStarters_6 = BasicStarters_1.Concat(new[] - { + public static readonly int[] BasicStarters_6 = + [ + .. BasicStarters_1, 152, 155, 158, 172, 173, 174, 175, 179, 187, 220, 239, 240, 246, 252, 255, 258, 265, 270, 273, 280, 287, 293, 298, 304, 328, 355, 363, 371, 374, 387, 390, 393, 396, 403, 406, 440, 443, 495, 498, 501, 506, 519, 607, 610, 633, 650, 653, 656, 661, 664, 669, 679, 704, - }).ToArray(); + ]; - public static readonly int[] BasicStarters_7 = BasicStarters_6.Concat(new[] - { + public static readonly int[] BasicStarters_7 = + [ + .. BasicStarters_1, 722, 725, 728, 731, 736, 761, 782, 789, - }).ToArray(); + ]; } diff --git a/pkNX.Structures/Legality/Item.cs b/pkNX.Structures/Legality/Item.cs index 86b71c16..945d25c3 100644 --- a/pkNX.Structures/Legality/Item.cs +++ b/pkNX.Structures/Legality/Item.cs @@ -1,11 +1,9 @@ -using System.Linq; - namespace pkNX.Structures; public static partial class Legal { private static readonly int[] Items_HeldXY = - { + [ /* 000, */ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 055, 056, 057, @@ -29,17 +27,18 @@ public static partial class Legal 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 686, 687, 688, 699, 704, 708, 709, 710, 711, 715, - }; + ]; - private static readonly int[] Items_HeldAO = Items_HeldXY.Concat(new[] - { + private static readonly int[] Items_HeldAO = + [ + .. Items_HeldXY, 534, 535, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770, - }).ToArray(); + ]; private static readonly int[] Items_Ball = - { + [ 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 576, - }; + ]; } diff --git a/pkNX.Structures/Legality/Legal.cs b/pkNX.Structures/Legality/Legal.cs index 31743eed..38d0ad25 100644 --- a/pkNX.Structures/Legality/Legal.cs +++ b/pkNX.Structures/Legality/Legal.cs @@ -211,5 +211,5 @@ public static int[] GetAllowedMoves(GameVersion infoGame, int moveCount) public static readonly HashSet BattlePrimals = [382, 383]; // Kyogre and Groudon public static readonly HashSet BattleFusions = [646, 800, 898]; // Kyurem, Necrozma, Calyrex - public static readonly HashSet BattleExclusiveForms = new(BattleForms.Concat(BattleMegas.Concat(BattlePrimals).Concat(BattleFusions))); + public static readonly HashSet BattleExclusiveForms = [..BattleForms, .. BattleMegas, .. BattlePrimals, ..BattleFusions]; } diff --git a/pkNX.Structures/Legality/Species.cs b/pkNX.Structures/Legality/Species.cs index 5e17acb5..588213dd 100644 --- a/pkNX.Structures/Legality/Species.cs +++ b/pkNX.Structures/Legality/Species.cs @@ -1,17 +1,16 @@ -using System.Linq; - namespace pkNX.Structures; public static partial class Legal { public static readonly int[] FinalEvolutions_1 = - { + [ 003, 006, 009, 012, 015, 018, 020, 022, 024, 026, 028, 031, 034, 036, 038, 040, 045, 047, 049, 051, 053, 055, 057, 059, 062, 065, 068, 071, 073, 076, 078, 080, 083, 085, 087, 089, 091, 094, 097, 099, 101, 103, 105, 106, 107, 110, 115, 119, 121, 122, 124, 127, 128, 130, 131, 132, 134, 135, 136, 139, 141, 142, 143, 149, - }; + ]; - public static readonly int[] FinalEvolutions_6 = FinalEvolutions_1.Concat(new[] - { + public static readonly int[] FinalEvolutions_6 = + [ + .. FinalEvolutions_1, 154, 157, 160, 162, 164, 166, 168, 169, 171, 178, 181, 182, 184, 185, 186, 189, 192, 195, 196, 197, 199, 201, 202, 203, 205, 206, 208, 210, 211, 212, 213, 214, 217, 219, 222, 224, 225, 226, 227, 229, 230, 232, 234, 235, 237, 241, 242, 248, 254, 257, 260, 262, 264, 267, 269, 272, 275, 277, 279, 282, 284, 286, 289, 291, 292, 295, 297, 301, 302, 303, 306, 308, 310, 311, 312, 313, 314, 317, 319, 321, 323, 324, 326, 327, 330, 332, 334, 335, 336, 337, 338, 340, 342, 344, 346, 348, 350, 351, 352, 354, 357, 358, 359, 362, 365, 367, 368, 369, 370, 373, 376, @@ -20,31 +19,34 @@ public static partial class Legal 542, 545, 547, 549, 550, 553, 555, 556, 558, 560, 561, 563, 565, 567, 569, 571, 573, 576, 579, 581, 584, 586, 587, 589, 591, 593, 594, 596, 598, 601, 604, 606, 609, 612, 614, 615, 617, 618, 620, 621, 623, 625, 626, 628, 630, 631, 632, 635, 637, 652, 655, 658, 660, 663, 666, 668, 671, 673, 675, 676, 678, 681, 683, 685, 687, 689, 691, 693, 695, 697, 699, 700, 701, 702, 703, 706, 707, 709, 711, 713, 715, - }).ToArray(); + ]; - public static readonly int[] FinalEvolutions_7 = FinalEvolutions_6.Concat(new[] - { + public static readonly int[] FinalEvolutions_7 = + [ + .. FinalEvolutions_6, 724, 727, 730, 733, 735, 738, 740, 741, 743, 745, 746, 748, 750, 752, 754, 756, 758, 760, 763, 764, 765, 766, 768, 770, 771, 774, 775, 776, 777, 779, 780, 781, 784, - }).ToArray(); + ]; - public static readonly int[] FinalEvolutions_8 = FinalEvolutions_7.Concat(new[] - { + public static readonly int[] FinalEvolutions_8 = + [ + .. FinalEvolutions_7, 812, 815, 818, 820, 823, 826, 828, 830, 832, 834, 836, 839, 841, 842, 844, 845, 847, 849, 851, 853, 855, 858, 861, 862, 863, 864, 865, 866, 867, 869, 870, 871, 873, 874, 875, 876, 877, 879, 880, 881, 882, 883, 884, 887, - }).ToArray(); + ]; public static readonly int[] Legendary_1 = - { + [ #region Legendary 144, // Articuno 145, // Zapdos 146, // Moltres 150, // Mewtwo #endregion - }; + ]; - public static readonly int[] Legendary_6 = Legendary_1.Concat(new[] - { + public static readonly int[] Legendary_6 = + [ + .. Legendary_1, #region Legendary 243, // Raikou 244, // Entei @@ -81,10 +83,11 @@ public static partial class Legal 717, // Yveltal 718, // Zygarde #endregion - }).ToArray(); + ]; - public static readonly int[] Legendary_SM = Legendary_6.Concat(new[] - { + public static readonly int[] Legendary_SM = + [ + .. Legendary_6, #region Legendary 773, // Silvally 785, // Tapu Koko @@ -102,12 +105,13 @@ public static partial class Legal 799, // Guzzlord 800, // Necrozma #endregion - }).ToArray(); + ]; - public static readonly int[] Legendary_USUM = Legendary_SM.Concat(new[] { 804, 805, 806 }).ToArray(); // Poipole, Blacephalon, Stakataka + public static readonly int[] Legendary_USUM = [.. Legendary_SM, 804, 805, 806]; // Poipole, Blacephalon, Stakataka - public static readonly int[] Legendary_8 = Legendary_USUM.Concat(new[] - { + public static readonly int[] Legendary_8 = + [ + .. Legendary_USUM, #region Legendary 888, // Zacian 889, // Zamazenta @@ -120,14 +124,15 @@ public static partial class Legal 897, // Spectrier 898, // Calyrex #endregion - }).ToArray(); + ]; - public static readonly int[] Legendary_8a = Legendary_8.Concat(new[] { 905 }).ToArray(); + public static readonly int[] Legendary_8a = [.. Legendary_8, 905]; // Enamorus - public static readonly int[] Mythical_1 = { 151 }; // Mew + public static readonly int[] Mythical_1 = [151]; // Mew - public static readonly int[] Mythical_6 = Mythical_1.Concat(new[] - { + public static readonly int[] Mythical_6 = + [ + .. Mythical_1, #region Mythical 251, // Celebi 385, // Jirachi @@ -145,13 +150,13 @@ public static partial class Legal 720, // Hoopa 721, // Volcanion #endregion - }).ToArray(); + ]; - public static readonly int[] Mythical_SM = Mythical_6.Concat(new[] { 801, 802 }).ToArray(); // Magearna, Marshadow + public static readonly int[] Mythical_SM = [.. Mythical_6, 801, 802]; // Magearna, Marshadow - public static readonly int[] Mythical_USUM = Mythical_SM.Concat(new[] { 807 }).ToArray(); // Zeraora + public static readonly int[] Mythical_USUM = [.. Mythical_SM, 807]; // Zeraora - public static readonly int[] Mythical_GG = Mythical_1.Concat(new[] { 809 }).ToArray(); // Melmetal + public static readonly int[] Mythical_GG = [.. Mythical_1, 809]; // Melmetal - public static readonly int[] Mythical_8 = Mythical_USUM.Concat(new[] { 809, 893 }).ToArray(); // Melmetal, Zarude + public static readonly int[] Mythical_8 = [.. Mythical_USUM, 809, 893]; // Melmetal, Zarude } diff --git a/pkNX.Structures/Legality/Tables/Tables5.cs b/pkNX.Structures/Legality/Tables/Tables5.cs index 7c66fab3..aaadb01b 100644 --- a/pkNX.Structures/Legality/Tables/Tables5.cs +++ b/pkNX.Structures/Legality/Tables/Tables5.cs @@ -12,31 +12,31 @@ public static partial class Legal public const int MaxBallID_5 = 0x19; public const int MaxGameID_5 = 23; // B2 - public static readonly ushort[] Pouch_Items_BW = { + public static readonly ushort[] Pouch_Items_BW = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, 286, 287, 288, 289, 290, 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, 322, 323, 324, 325, 326, 327, 492, 493, 494, 495, 496, 497, 498, 499, 500, 537, 538, 539, 540, 541, 542, 543, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 571, 572, 573, 575, 576, 577, 580, 581, 582, 583, 584, 585, 586, 587, 588, 589, 590, - }; + ]; - public static readonly ushort[] Pouch_Key_BW = { + public static readonly ushort[] Pouch_Key_BW = [ 437, 442, 447, 450, 465, 466, 471, 504, 533, 574, 578, 579, 616, 617, 621, 623, 624, 625, 626, - }; + ]; - public static readonly ushort[] Pouch_TMHM_BW = { + public static readonly ushort[] Pouch_TMHM_BW = [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 618, 619, 620, 420, 421, 422, 423, 424, 425, - }; + ]; - public static readonly ushort[] Pouch_Medicine_BW = { + public static readonly ushort[] Pouch_Medicine_BW = [ 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 134, 504, 565, 566, 567, 568, 569, 570, 591, - }; + ]; - public static readonly ushort[] Pouch_Berries_BW = { + public static readonly ushort[] Pouch_Berries_BW = [ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - }; + ]; - public static readonly ushort[] HeldItems_BW = ArrayUtil.ConcatAll(Pouch_Items_BW, Pouch_Medicine_BW, Pouch_Berries_BW); + public static readonly ushort[] HeldItems_BW = [.. Pouch_Items_BW, .. Pouch_Medicine_BW, .. Pouch_Berries_BW]; - public static readonly ushort[] Pouch_Key_B2W2 = { + public static readonly ushort[] Pouch_Key_B2W2 = [ 437, 442, 447, 450, 453, 458, 465, 466, 471, 504, 578, 616, 617, 621, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 636, 637, 638, - }; + ]; public static readonly bool[] ReleasedHeldItems_5 = GetPermitList(MaxItemID_5_B2W2, HeldItems_BW, stackalloc ushort[] { diff --git a/pkNX.Structures/Legality/Tables/Tables6.cs b/pkNX.Structures/Legality/Tables/Tables6.cs index 1c744a27..db57af6b 100644 --- a/pkNX.Structures/Legality/Tables/Tables6.cs +++ b/pkNX.Structures/Legality/Tables/Tables6.cs @@ -15,10 +15,10 @@ public static partial class Legal public const int MaxGameID_6 = 27; // OR #region Met Locations - public static readonly int[] Met_XYc = { 0, 60002, 30002 }; + public static readonly int[] Met_XYc = [0, 60002, 30002]; public static readonly int[] Met_XY_0 = - { + [ /* XY */ 2, 6, 8, 10, 12, 14, 16, 17, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 82, 84, 86, 88, @@ -29,26 +29,26 @@ public static partial class Legal 262, 264, 266, 268, 270, 272, 274, 276, 278, 280, 282, 284, 286, 288, 290, 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, 312, 314, 316, 318, 320, 322, 324, 326, 328, 330, 332, 334, 336, 338, 340, 342, 344, 346, 348, 350, 352, 354, - }; + ]; public static readonly int[] Met_XY_3 = - { + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, - }; + ]; public static readonly int[] Met_XY_4 = - { + [ 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, 40030, 40031, 40032, 40033, 40034, 40035, 40036, 40037, 40038, 40039, 40040, 40041, 40042, 40043, 40044, 40045, 40046, 40047, 40048, 40049, 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, 40078, 40079, - }; + ]; - public static readonly int[] Met_XY_6 = {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static readonly int[] Met_XY_6 = [/* XY */ 60001, 60003, /* ORAS */ 60004]; - public static readonly int[] EggLocations6 = { 60002, 30002 }; + public static readonly int[] EggLocations6 = [60002, 30002]; public static readonly HashSet ValidMet_XY = [ @@ -69,7 +69,7 @@ public static partial class Legal ]; public static readonly int[] FriendSafari = - { + [ 190, 206, 216, 506, 294, 352, 531, 572, 113, 132, 133, 235, 012, 046, 165, 415, 267, 284, 313, 314, 049, 127, 214, 666, 262, 274, 624, 629, 215, 332, 342, 551, 302, 359, 510, 686, @@ -88,13 +88,13 @@ public static partial class Legal 299, 525, 557, 095, 219, 222, 247, 112, 213, 689, 082, 303, 597, 205, 227, 375, 600, 437, 530, 707, 098, 224, 400, 515, 008, 130, 195, 419, 061, 184, 657, - }; + ]; #endregion #region Inventory Pouch public static readonly ushort[] Pouch_Items_XY = - { + [ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, 057, 058, 059, 060, 061, 062, 063, 064, 065, 066, 067, 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, @@ -111,10 +111,10 @@ public static partial class Legal 647, 648, 649, 650, 652, 653, 654, 655, 656, 657, 658, 659, 660, 661, 662, 663, 664, 665, 666, 667, 668, 669, 670, 671, 672, 673, 674, 675, 676, 677, 678, 679, 680, 681, 682, 683, 684, 685, 699, 704, 710, 711, 715, - }; + ]; public static readonly ushort[] Pouch_Items_AO = - { + [ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 055, 056, 057, 058, 059, 060, 061, 062, 063, 064, 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, @@ -135,20 +135,20 @@ public static partial class Legal // ORAS 534, 535, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770, - }; + ]; public static readonly ushort[] Pouch_Key_XY = - { + [ 216, 431, 442, 445, 446, 447, 450, 465, 466, 471, 628, 629, 631, 632, 638, 641, 642, 643, 689, 695, 696, 697, 698, 700, 701, 702, 703, 705, 712, 713, 714, // Illegal // 716, 717, 706, 707, - }; + ]; public static readonly ushort[] Pouch_Key_AO = - { + [ 216, 445, 446, 447, 465, 466, 471, 628, 629, 631, 632, 638, 697, @@ -164,10 +164,10 @@ public static partial class Legal 740, 741, 742, 743, 744, 751, 765, 771, 772, 774, 775, - }; + ]; public static readonly ushort[] Pouch_TMHM_XY = - { + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, @@ -176,10 +176,10 @@ public static partial class Legal 418, 419, 618, 619, 620, 690, 691, 692, 693, 694, 420, 421, 422, 423, 424, - }; + ]; public static readonly ushort[] Pouch_TMHM_AO = - { + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, @@ -191,42 +191,42 @@ public static partial class Legal // ORAS 425, 737, - }; + ]; public static readonly ushort[] Pouch_Medicine_XY = - { + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709, - }; + ]; public static readonly ushort[] Pouch_Medicine_AO = - { + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, 054, 134, 504, 565, 566, 567, 568, 569, 570, 571, 591, 645, 708, 709, //ORAS 065, 066, 067, - }; + ]; public static readonly ushort[] Pouch_Berry_XY = - { + [ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 686, 687, 688, - }; + ]; - public static readonly ushort[] HeldItem_XY = ArrayUtil.ConcatAll(Pouch_Items_XY, Pouch_Medicine_XY, Pouch_Berry_XY); - public static readonly ushort[] HeldItem_AO = ArrayUtil.ConcatAll(Pouch_Items_AO, Pouch_Medicine_AO, Pouch_Berry_XY); + public static readonly ushort[] HeldItem_XY = [.. Pouch_Items_XY, .. Pouch_Medicine_XY, .. Pouch_Berry_XY]; + public static readonly ushort[] HeldItem_AO = [.. Pouch_Items_AO, .. Pouch_Medicine_AO, .. Pouch_Berry_XY]; #endregion #region TMHM public static readonly int[] TMHM_AO = - { + [ 468, 337, 473, 347, 046, 092, 258, 339, 474, 237, 241, 269, 058, 059, 063, 113, 182, 240, 355, 219, 218, 076, 479, 085, 087, 089, 216, 091, 094, 247, @@ -239,10 +239,10 @@ public static partial class Legal 430, 433, 528, 290, 555, 267, 399, 612, 605, 590, 15, 19, 57, 70, 127, 249, 291, - }; + ]; public static readonly int[] TMHM_XY = - { + [ 468, 337, 473, 347, 046, 092, 258, 339, 474, 237, 241, 269, 058, 059, 063, 113, 182, 240, 355, 219, 218, 076, 479, 085, 087, 089, 216, 091, 094, 247, @@ -255,25 +255,25 @@ public static partial class Legal 430, 433, 528, 249, 555, 267, 399, 612, 605, 590, 15, 19, 57, 70, 127, - }; + ]; - public static readonly int[] TypeTutor6 = { 520, 519, 518, 338, 307, 308, 434, 620 }; + public static readonly int[] TypeTutor6 = [520, 519, 518, 338, 307, 308, 434, 620]; public static readonly int[][] Tutors_AO = - { - new[] {450, 343, 162, 530, 324, 442, 402, 529, 340, 067, 441, 253, 009, 007, 008}, - new[] {277, 335, 414, 492, 356, 393, 334, 387, 276, 527, 196, 401, 399, 428, 406, 304, 231}, - new[] {020, 173, 282, 235, 257, 272, 215, 366, 143, 220, 202, 409, 355, 264, 351, 352}, - new[] {380, 388, 180, 495, 270, 271, 478, 472, 283, 200, 278, 289, 446, 214, 285}, - }; + [ + [450, 343, 162, 530, 324, 442, 402, 529, 340, 067, 441, 253, 009, 007, 008], + [277, 335, 414, 492, 356, 393, 334, 387, 276, 527, 196, 401, 399, 428, 406, 304, 231], + [020, 173, 282, 235, 257, 272, 215, 366, 143, 220, 202, 409, 355, 264, 351, 352], + [380, 388, 180, 495, 270, 271, 478, 472, 283, 200, 278, 289, 446, 214, 285], + ]; #endregion - public static readonly int[] CosplayPikachuMoves = { 309, 556, 577, 604, 560, 0 }; - public static readonly int[] WildPokeballs6 = { 0x01, 0x02, 0x03, 0x04, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F }; + public static readonly int[] CosplayPikachuMoves = [309, 556, 577, 604, 560, 0]; + public static readonly int[] WildPokeballs6 = [0x01, 0x02, 0x03, 0x04, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F]; public static readonly int[] Ban_NoHidden6 = - { + [ //Not avaliable at Friend Safari or Horde Encounter 669 + (2 << 11), //Flabébé-Orange 670 + (2 << 11), //Floette-Orange @@ -287,18 +287,18 @@ public static partial class Legal 710 + (2 << 11), //Pumpkaboo-Large 711 + (2 << 11), //Gourgeist-Large //Super Size can be obtained as a Pumpkaboo from event distributions - }; + ]; #region Ball Table public static readonly int[] Inherit_Sport = - { + [ 010, 013, 046, 048, 123, 127, 265, 290, 314, 401, 415, 313, // Via Illumise - }; + ]; public static readonly int[] Inherit_Safari = - { + [ 016, 019, 020, 021, 022, 023, 024, 025, 027, 029, 035, 039, 041, 043, 046, 048, 050, 054, 055, 060, 063, 066, 069, 070, 074, 077, 079, 080, 083, 084, 088, 092, 095, 096, 098, 099, 102, 104, 108, 109, 111, 113, 114, 115, 118, 122, 123, 125, 126, 127, 129, 131, 147, 161, 163, 165, 167, @@ -319,10 +319,10 @@ public static partial class Legal 433, // Via Chimecho 439, // Via Mr. Mime 440, // Via Chansey - }; + ]; public static readonly int[] Inherit_Dream = - { + [ 010, 013, 016, 019, 021, 023, 027, 029, 037, 041, 043, 046, 048, 050, 052, 054, 056, 058, 060, 063, 066, 069, 072, 074, 077, 079, 083, 084, 086, 088, 090, 092, 095, 096, 098, 102, 104, 108, 109, 111, 113, 114, 115, 116, 118, 122, 123, 127, 129, 131, 133, 138, 140, 142, 143, 147, 161, 163, 165, 167, 170, 173, 174, 175, 177, 179, @@ -349,10 +349,10 @@ public static partial class Legal // Via Incense Breeding 298, 360, 406, 433, 438, 439, 440, 446, 458, - }; + ]; public static readonly int[] Ban_DreamHidden = - { + [ 311, // Plusle 312, // Minun 352, // Kecleon @@ -361,10 +361,10 @@ public static partial class Legal // Via Pre-Evolution 356, // Dusclops 477, // Dusknoir - }; + ]; public static readonly int[] Ban_Gen3Ball = - { + [ 252, 255, 258, //1 - Treeko, Torchic, Mudkip 253, 256, 259, //2 254, 257, 260, //3 @@ -375,10 +375,10 @@ public static partial class Legal 496, 499, 502, //2 497, 500, 503, //3 566, 567, 696, 697, 698, 699, // Fossil Only obtain - }; + ]; public static readonly int[] Ban_Gen3BallHidden = - { + [ // can have HA and can be in gen 3 ball as eggs but can not at same time. 152, 155, 158, //1 - Gen2 Starters 153, 156, 159, //2 @@ -391,10 +391,10 @@ public static partial class Legal 586 + (3 << 11), //Sawsbuck-Winter 710 + (3 << 11), //Pumpkaboo-Super 711 + (3 << 11), //Gourgeist-Super - }; + ]; public static readonly int[] Ban_Gen4Ball_6 = - { + [ 152, 155, 158, //1 - Chikorita, Cyndaquil, Totodile 153, 156, 159, //2 154, 157, 160, //3 @@ -408,37 +408,37 @@ public static partial class Legal 496, 499, 502, //2 497, 500, 503, //3 566, 567, 696, 697, 698, 699, // Fossil Only obtain - }; + ]; public static readonly int[] WurmpleEvolutions = - { + [ 266, 267, // Silcoon Beautifly 268, 269, // Cascoon Dustox - }; + ]; #endregion #region Memory Table public static readonly int[] Memory_NotXY = - { + [ 65, // {0} was with {1} when (he/she) built a Secret Base. {4} that {3}. 66, // {0} participated in a contest with {1} and impressed many people. {4} that {3}. 67, // {0} participated in a contest with {1} and won the title. {4} that {3}. 68, // {0} soared through the sky with {1} and went to many different places. {4} that {3}. 69, // {1} asked {0} to dive. Down it went, deep into the ocean, to explore the bottom of the sea. {4} that {3}. - }; + ]; public static readonly int[] Memory_NotAO = - { + [ 11, // {0} went clothes shopping with {1}. {4} that {3}. 43, // {0} was impressed by the speed of the train it took with {1}. {4} that {3}. 44, // {0} encountered {2} with {1} using the Poké Radar. {4} that {3}. 56, // {0} was with {1} when (he/she) went to a boutique and tried on clothes, but (he/she) left the boutique without buying anything. {4} that {3}. 57, // {0} went to a nice restaurant with {1} and ate until it got totally full. {4} that {3}. 62, // {0} saw itself in a mirror in a mirror cave that it went to with {1}. {4} that {3}. - }; + ]; public static readonly int[][] MoveSpecificMemories = - { - new[] { + [ + [ 20, // {0} surfed across the water, carrying {1} on its back. {4} that {3}. 24, // {0} flew, carrying {1} on its back, to {2}. {4} that {3}. 35, // {0} proudly used Strength at {1}’s instruction in... {2}. {4} that {3}. @@ -446,13 +446,13 @@ public static partial class Legal 37, // {0} shattered rocks to its heart’s content at {1}’s instruction in... {2}. {4} that {3}. 38, // {0} used Waterfall while carrying {1} on its back in... {2}. {4} that {3}. 69, // {1} asked {0} to dive. Down it went, deep into the ocean, to explore the bottom of the sea. {4} that {3}. - }, - new[] { 57, 19, 70, 15, 249, 127, 291}, // Move IDs - }; + ], + [57, 19, 70, 15, 249, 127, 291], // Move IDs + ]; public static readonly int[][] LocationsWithPKCenter = - { - new[] { + [ + [ // Kalos locations with a PKMN CENTER 18, // Santalune City 22, // Lumiose City @@ -485,9 +485,9 @@ public static partial class Legal 198, // Sootopolis City 200, // Ever Grande City 202, // Pokémon League (OR/AS) - }, - new[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, // Region matching - }; + ], + [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], // Region matching + ]; public static readonly HashSet MemoryGeneral = [1, 2, 3, 4, 19, 24, 31, 32, 33, 35, 36, 37, 38, 39, 42, 52, 59]; public static readonly HashSet MemorySpecific = [6]; @@ -497,7 +497,7 @@ public static partial class Legal #endregion public static readonly int[] MovePP_XY = - { + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, 20, 20, 20, 05, 35, 20, 25, 20, 20, 20, 15, 25, 15, 10, 20, 25, 10, 35, 30, 15, 10, 40, 10, 15, 30, 15, 20, 10, 15, 10, 05, 10, 10, 25, 10, 20, 40, 30, 30, 20, 20, @@ -512,7 +512,7 @@ public static partial class Legal 15, 15, 15, 15, 10, 10, 10, 10, 10, 15, 15, 15, 15, 05, 05, 15, 05, 10, 10, 10, 20, 20, 20, 10, 10, 30, 15, 15, 10, 15, 25, 10, 15, 10, 10, 10, 20, 10, 10, 10, 10, 10, 15, 15, 05, 05, 10, 10, 10, 05, 05, 10, 05, 05, 15, 10, 05, 05, 05, 10, 10, 10, 10, 20, 25, 10, 20, 30, 25, 20, 20, 15, 20, 15, 20, 20, 10, 10, 10, 10, 10, 20, 10, 30, 15, 10, 10, 10, 20, 20, 05, 05, 05, 20, 10, 10, 20, 15, 20, 20, 10, 20, 30, 10, 10, 40, 40, 30, 20, 40, 20, 20, 10, 10, 10, 10, 05, 10, 10, 05, 05, - }; + ]; public static readonly bool[] ReleasedHeldItems_6 = GetPermitList(MaxItemID_6_AO, HeldItem_AO, stackalloc ushort[] { diff --git a/pkNX.Structures/Legality/Tables/Tables7.cs b/pkNX.Structures/Legality/Tables/Tables7.cs index ebc81a27..e9773124 100644 --- a/pkNX.Structures/Legality/Tables/Tables7.cs +++ b/pkNX.Structures/Legality/Tables/Tables7.cs @@ -20,7 +20,7 @@ public static partial class Legal #region Inventory Pouch public static readonly ushort[] Pouch_Regular_SM = // 00 - { + [ 068, 069, 070, 071, 072, 073, 074, 075, 076, 077, 078, 079, 080, 081, 082, 083, 084, 085, 086, 087, 088, 089, 090, 091, 092, 093, 094, 099, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 116, 117, 118, 119, 135, 136, 137, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, @@ -36,70 +36,70 @@ public static partial class Legal 680, 681, 682, 683, 684, 685, 699, 704, 710, 711, 715, 752, 753, 754, 755, 756, 757, 758, 759, 760, 761, 762, 763, 764, 767, 768, 769, 770, 795, 796, 844, 849, 853, 854, 855, 856, 879, 880, 881, 882, 883, 884, 904, 905, 906, 907, 908, 909, 910, 911, 912, 913, 914, 915, 916, 917, 918, 919, 920, - }; + ]; - public static readonly ushort[] Pouch_Ball_SM = { // 08 + public static readonly ushort[] Pouch_Ball_SM = [ // 08 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 492, 493, 494, 495, 496, 497, 498, 576, 851, - }; + ]; - public static readonly ushort[] Pouch_Battle_SM = { // 16 + public static readonly ushort[] Pouch_Battle_SM = [ // 16 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 577, 846, - }; + ]; - public static readonly ushort[] Pouch_Items_SM = ArrayUtil.ConcatAll(Pouch_Regular_SM, Pouch_Ball_SM, Pouch_Battle_SM); + public static readonly ushort[] Pouch_Items_SM = [.. Pouch_Regular_SM, .. Pouch_Ball_SM, .. Pouch_Battle_SM]; - public static readonly ushort[] Pouch_Key_SM = { + public static readonly ushort[] Pouch_Key_SM = [ 216, 465, 466, 628, 629, 631, 632, 638, 705, 706, 765, 773, 797, 841, 842, 843, 845, 847, 850, 857, 858, 860, - }; + ]; - public static readonly ushort[] Pouch_Key_USUM = ArrayUtil.ConcatAll(Pouch_Key_SM, new ushort[] { + public static readonly ushort[] Pouch_Key_USUM = [.. Pouch_Key_SM, 933, 934, 935, 936, 937, 938, 939, 940, 941, 942, 943, 944, 945, 946, 947, 948, 440, - }); + ]; - public static readonly ushort[] Pouch_Roto_USUM = { + public static readonly ushort[] Pouch_Roto_USUM = [ 949, 950, 951, 952, 953, 954, 955, 956, 957, 958, 959, - }; + ]; - public static readonly ushort[] Pouch_TMHM_SM = { // 02 + public static readonly ushort[] Pouch_TMHM_SM = [ // 02 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, 388, 389, 390, 391, 392, 393, 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 618, 619, 620, 690, 691, 692, 693, 694, - }; + ]; - public static readonly ushort[] Pouch_Medicine_SM = { // 32 + public static readonly ushort[] Pouch_Medicine_SM = [ // 32 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 65, 66, 67, 134, 504, 565, 566, 567, 568, 569, 570, 591, 645, 708, 709, 852, - }; + ]; - public static readonly ushort[] Pouch_Berries_SM = { + public static readonly ushort[] Pouch_Berries_SM = [ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 686, 687, 688, - }; + ]; - public static readonly ushort[] Pouch_ZCrystal_SM = { // Bead + public static readonly ushort[] Pouch_ZCrystal_SM = [ // Bead 807, 808, 809, 810, 811, 812, 813, 814, 815, 816, 817, 818, 819, 820, 821, 822, 823, 824, 825, 826, 827, 828, 829, 830, 831, 832, 833, 834, 835, - }; + ]; - public static readonly ushort[] Pouch_ZCrystalHeld_SM = { // Piece + public static readonly ushort[] Pouch_ZCrystalHeld_SM = [ // Piece 776, 777, 778, 779, 780, 781, 782, 783, 784, 785, 786, 787, 788, 789, 790, 791, 792, 793, 794, 798, 799, 800, 801, 802, 803, 804, 805, 806, 836, - }; + ]; - public static readonly ushort[] Pouch_ZCrystal_USUM = ArrayUtil.ConcatAll(Pouch_ZCrystal_SM, new ushort[] { // Bead + public static readonly ushort[] Pouch_ZCrystal_USUM = [.. Pouch_ZCrystal_SM, // Bead 927, 928, 929, 930, 931, 932, - }); + ]; - public static readonly ushort[] Pouch_ZCrystalHeld_USUM = ArrayUtil.ConcatAll(Pouch_ZCrystalHeld_SM, new ushort[] { // Piece + public static readonly ushort[] Pouch_ZCrystalHeld_USUM = [.. Pouch_ZCrystalHeld_SM, // Piece 921, 922, 923, 924, 925, 926, - }); + ]; public static readonly Dictionary ZCrystalDictionary = GetDictionary(Pouch_ZCrystal_USUM, Pouch_ZCrystalHeld_USUM); @@ -111,8 +111,8 @@ public static partial class Legal return result; } - public static readonly ushort[] HeldItems_SM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_SM); - public static readonly ushort[] HeldItems_USUM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Berries_SM, Pouch_Medicine_SM, Pouch_ZCrystalHeld_USUM, Pouch_Roto_USUM); + public static readonly ushort[] HeldItems_SM = [.. Pouch_Items_SM, .. Pouch_Berries_SM, .. Pouch_Medicine_SM, .. Pouch_ZCrystalHeld_SM]; + public static readonly ushort[] HeldItems_USUM = [.. Pouch_Items_SM, .. Pouch_Berries_SM, .. Pouch_Medicine_SM, .. Pouch_ZCrystalHeld_USUM, .. Pouch_Roto_USUM]; #endregion public static readonly HashSet AlolanOriginForms = @@ -141,7 +141,8 @@ public static partial class Legal (int)Marowak, ]; - public static readonly HashSet EvolveToAlolanForms = new(AlolanVariantEvolutions12.Concat(AlolanOriginForms)); + public static readonly HashSet EvolveToAlolanForms = + [..AlolanVariantEvolutions12.Concat(AlolanOriginForms)]; public static readonly HashSet PastGenAlolanNatives = [ @@ -200,12 +201,11 @@ public static partial class Legal 30016, ]; - public static readonly HashSet ValidMet_USUM = new(ValidMet_SM) - { - // 194, 195, 196, 197, // Unobtainable new Locations - 198, + public static readonly HashSet ValidMet_USUM = + [ + ..ValidMet_SM, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, - }; + ]; #region Unreleased Items public static readonly bool[] ReleasedHeldItems_7 = GetPermitList(MaxItemID_7_USUM, HeldItems_USUM, stackalloc ushort[] @@ -316,5 +316,5 @@ public static partial class Legal (int)Ribombee, ]; - public static readonly ushort[] HeldItemsBuy_SM = ArrayUtil.ConcatAll(Pouch_Items_SM, Pouch_Medicine_SM); + public static readonly ushort[] HeldItemsBuy_SM = [.. Pouch_Items_SM, .. Pouch_Medicine_SM]; } diff --git a/pkNX.Structures/Legality/Tables/Tables7b.cs b/pkNX.Structures/Legality/Tables/Tables7b.cs index 5b790f78..301e9a29 100644 --- a/pkNX.Structures/Legality/Tables/Tables7b.cs +++ b/pkNX.Structures/Legality/Tables/Tables7b.cs @@ -15,7 +15,7 @@ public static partial class Legal #region Met Locations public static readonly int[] Met_GG_0 = - { + [ 002, // Invalid 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 012, 013, 014, 015, 016, 017, 018, 019, @@ -23,15 +23,15 @@ public static partial class Legal 030, 031, 032, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 042, 043, 044, 045, 046, 047, 048, 049, 050, 051, 052, 053, - }; + ]; public static readonly int[] Met_GG_3 = - { + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, - }; + ]; public static readonly int[] Met_GG_4 = - { + [ 40001, 40002, 40003, 40004, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40015, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40023, 40024, 40025, 40026, 40027, 40028, 40029, @@ -40,24 +40,24 @@ public static partial class Legal 40050, 40051, 40052, 40053, 40054, 40055, 40056, 40057, 40058, 40059, 40060, 40061, 40062, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40073, 40074, 40075, 40076, 40077, - }; + ]; - public static readonly int[] Met_GG_6 = {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static readonly int[] Met_GG_6 = [/* XY */ 60001, 60003, /* ORAS */ 60004]; #endregion #region Items public static readonly ushort[] Pouch_Candy_GG_Regular = - { + [ 050, // Rare Candy 960, 961, 962, 963, 964, 965, // S 966, 967, 968, 969, 970, 971, // L 972, 973, 974, 975, 976, 977, // XL - }; + ]; public static readonly ushort[] Pouch_Candy_GG_Species = - { + [ 978, 979, 980, 981, 982, 983, 984, 985, 986, 987, 988, 989, 990, 991, 992, 993, 994, 995, 996, 997, 998, 999, @@ -68,46 +68,46 @@ public static partial class Legal 1040, 1041, 1042, 1043, 1044, 1045, 1046, 1047, 1048, 1049, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1057, - }; + ]; - public static readonly ushort[] Pouch_Candy_GG = ArrayUtil.ConcatAll(Pouch_Candy_GG_Regular, Pouch_Candy_GG_Species); + public static readonly ushort[] Pouch_Candy_GG = [.. Pouch_Candy_GG_Regular, .. Pouch_Candy_GG_Species]; public static readonly ushort[] Pouch_Medicine_GG = - { + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 038, 039, 040, 041, 709, 903, - }; + ]; public static readonly ushort[] Pouch_TM_GG = - { + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, 358, 359, 360, 361, 362, 363, 364, 365, 366, 367, 368, 369, 370, 371, 372, 373, 374, 375, 376, 377, 378, 379, 380, 381, 382, 383, 384, 385, 386, 387, - }; + ]; public static readonly ushort[] Pouch_PowerUp_GG = - { + [ 051, 053, 081, 082, 083, 084, 085, 849, - }; + ]; public static readonly ushort[] Pouch_Catching_GG = - { + [ 001, 002, 003, 004, 012, 164, 166, 168, 861, 862, 863, 864, 865, 866, - }; + ]; public static readonly ushort[] Pouch_Battle_GG = - { + [ 055, 056, 057, 058, 059, 060, 061, 062, 656, 659, 660, 661, 662, 663, 671, 672, 675, 676, 678, 679, 760, 762, 770, 773, - }; + ]; public static readonly ushort[] Pouch_Regular_GG = - { + [ 076, 077, 078, 079, 086, 087, 088, 089, 090, 091, 092, 093, 101, 102, 103, 113, 115, 121, 122, 123, 124, 125, 126, 127, 128, @@ -116,10 +116,10 @@ public static partial class Legal 632, 651, 795, 796, 872, 873, 874, 875, 876, 877, 878, 885, 886, 887, 888, 889, 890, 891, 892, 893, 894, 895, 896, 900, 901, 902, - }; + ]; public static readonly ushort[] Pouch_Regular_GG_Item = - { + [ 076, // Super Repel 077, // Max Repel 078, // Escape Rope @@ -140,10 +140,10 @@ public static partial class Legal 900, // Lure 901, // Super Lure 902, // Max Lure - }; + ]; public static readonly ushort[] Pouch_Regular_GG_Key = - { + [ 113, // Tea 115, // Autograph 121, // Pokémon Box @@ -177,9 +177,9 @@ public static partial class Legal 894, // Leaf Letter (P) 895, // Leaf Letter (E) 896, // Small Bouquet - }; + ]; - public static readonly ushort[] HeldItems_GG = ArrayUtil.ConcatAll(Pouch_Candy_GG, Pouch_Medicine_GG, Pouch_PowerUp_GG, Pouch_Catching_GG, Pouch_Battle_GG, Pouch_Regular_GG_Item); + public static readonly ushort[] HeldItems_GG = [.. Pouch_Candy_GG, .. Pouch_Medicine_GG, .. Pouch_PowerUp_GG, .. Pouch_Catching_GG, .. Pouch_Battle_GG, .. Pouch_Regular_GG_Item]; #endregion @@ -188,7 +188,7 @@ public static partial class Legal public static bool IsAllowedMoveGG(ushort move) => Array.BinarySearch(AllowedMovesGG, move) >= 0; private static readonly int[] AllowedMovesGG = - { + [ 000, 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, @@ -214,10 +214,10 @@ public static partial class Legal 503, 504, 525, 529, 583, 585, 603, 605, 606, 607, 729, 730, 731, 733, 734, 735, 736, 737, 738, 739, 740, 742, - }; + ]; public static readonly int[] MovePP_GG = - { + [ // Absorb: 25 -> 15 (damage buffed from 20->40) // Mega Drain: 15 -> 10 (damage buffed from 40->75) @@ -237,10 +237,10 @@ public static partial class Legal 10, 20, 30, 10, 10, 40, 40, 30, 20, 40, 20, 20, 10, 10, 10, 10, 05, 10, 10, 05, 05, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 01, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 40, 15, 20, 30, 20, 15, 15, 20, 10, 15, 15, 10, 05, 10, 10, 20, 15, 10, 15, 15, 15, 05, 15, 20, 20, 01, 01, 01, 01, 01, 01, 01, 01, 01, 05, 05, 10, 10, 10, 20, 10, 10, 10, 05, 05, 20, 10, 10, 10, 01, 05, 15, 05, 01, 01, 01, 01, 01, 01, 15, 15, 15, 20, 15, 15, 15, 15, 15, 15, 15, 15, 20, 05, - }; + ]; public static readonly ushort[] TMHM_GG = - { + [ 029, 269, 270, 100, 156, 113, 182, 164, 115, 091, 261, 263, 280, 019, 069, 086, 525, 369, 231, 399, 492, 157, 009, 404, 127, 398, 092, 161, 503, 339, @@ -250,18 +250,18 @@ public static partial class Legal // rest are same as SM, unused // No HMs - }; + ]; public static readonly int[] Tutor_StarterPikachu = - { + [ 729, // Zippy Zap 730, // Splishy Splash 731, // Floaty Fall 732, // Pika Papow - }; + ]; public static readonly int[] Tutor_StarterEevee = - { + [ 733, // Bouncy Bubble 734, // Buzzy Buzz 735, // Sizzly Slide @@ -271,7 +271,7 @@ public static partial class Legal 739, // Freezy Frost 740, // Sparkly Swirl 741, // Veevee Volley - }; + ]; #endregion } diff --git a/pkNX.Structures/Legality/Tables/Tables8.cs b/pkNX.Structures/Legality/Tables/Tables8.cs index f7ec8a23..96e83b09 100644 --- a/pkNX.Structures/Legality/Tables/Tables8.cs +++ b/pkNX.Structures/Legality/Tables/Tables8.cs @@ -35,7 +35,7 @@ public static partial class Legal #region Met Locations public static readonly int[] Met_SWSH_0 = - { + [ 002, 004, 006, 008, 012, 014, 016, 018, 020, 022, 024, 028, @@ -63,15 +63,15 @@ public static partial class Legal 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, - }; + ]; public static readonly int[] Met_SWSH_3 = - { + [ 30001, 30003, 30004, 30005, 30006, 30007, 30008, 30009, 30010, 30011, 30012, 30013, 30014, 30015, 30016, 30017, 30018, - }; + ]; public static readonly int[] Met_SWSH_4 = - { + [ 40001, 40002, 40003, 40005, 40006, 40007, 40008, 40009, 40010, 40011, 40012, 40013, 40014, 40016, 40017, 40018, 40019, 40020, 40021, 40022, 40024, 40025, 40026, 40027, 40028, 40029, 40030, @@ -81,9 +81,9 @@ public static partial class Legal 40061, 40063, 40064, 40065, 40066, 40067, 40068, 40069, 40070, 40071, 40072, 40074, 40075, 40076, 40077, 40078, 40079, 40080, 40081, 40082, 40083, 40084, 40085, 40086, - }; + ]; - public static readonly int[] Met_SWSH_6 = {/* XY */ 60001, 60003, /* ORAS */ 60004 }; + public static readonly int[] Met_SWSH_6 = [/* XY */ 60001, 60003, /* ORAS */ 60004]; public static readonly HashSet ValidMet_SWSH = [ @@ -120,7 +120,7 @@ public static partial class Legal #region Inventory Pouch public static readonly ushort[] Dynamax_Crystals_SWSH = - { + [ 1279, 1280, 1281, 1282, 1283, 1284, 1285, 1286, 1287, 1288, 1289, 1290, 1291, 1292, 1293, 1294, 1295, 1296, 1297, 1298, 1299, 1300, 1301, 1302, 1303, 1304, 1305, 1306, 1307, 1308, 1309, 1310, 1311, 1312, 1313, 1314, 1315, @@ -139,10 +139,10 @@ public static partial class Legal 1532, 1533, 1534, 1535, 1536, 1537, 1538, 1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, - }; + ]; public static readonly ushort[] Regular_Items_SWSH = - { + [ 045, 046, 047, 048, 049, 050, 051, 052, 053, 076, 077, 079, 080, 081, 082, 083, 084, 085, 107, 108, 109, 110, 112, 116, 117, 118, 119, 135, 136, 213, 214, 215, 217, 218, 219, 220, 221, 222, 223, 224, 225, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, @@ -162,27 +162,27 @@ public static partial class Legal // DLC 2 1592, 1604, 1606, - }; + ]; - public static readonly ushort[] Pouch_Regular_SWSH = ArrayUtil.ConcatAll(Regular_Items_SWSH, Dynamax_Crystals_SWSH); + public static readonly ushort[] Pouch_Regular_SWSH = [.. Regular_Items_SWSH, .. Dynamax_Crystals_SWSH]; public static readonly ushort[] Pouch_Ball_SWSH = - { + [ 001, 002, 003, 004, 005, 006, 007, 008, 009, 010, 011, 012, 013, 014, 015, 016, 492, 493, 494, 495, 496, 497, 498, 499, 500, 576, 851, - }; + ]; public static readonly ushort[] Pouch_Battle_SWSH = - { + [ 055, 056, 057, 058, 059, 060, 061, 062, 063, 1580, - }; + ]; - public static readonly ushort[] Pouch_Items_SWSH = ArrayUtil.ConcatAll(Pouch_Regular_SWSH, Pouch_Ball_SWSH, Pouch_Battle_SWSH); + public static readonly ushort[] Pouch_Items_SWSH = [.. Pouch_Regular_SWSH, .. Pouch_Ball_SWSH, .. Pouch_Battle_SWSH]; public static readonly ushort[] Pouch_Key_SWSH = - { + [ 078, 628, 629, 631, 632, 638, 703, @@ -193,10 +193,10 @@ public static partial class Legal // DLC 2 1590, 1591, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1605, 1607, - }; + ]; public static readonly ushort[] Pouch_TM_SWSH = - { + [ 328, 329, 330, 331, 332, 333, 334, 335, 336, 337, 338, 339, 340, 341, 342, 343, 344, 345, 346, 347, 348, 349, 350, 351, 352, 353, 354, 355, 356, 357, @@ -208,10 +208,10 @@ public static partial class Legal 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 618, 619, 620, 690, 691, 692, 693, // TM99 1230, // TM00 - }; + ]; public static readonly ushort[] Pouch_TR_SWSH = - { + [ 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, @@ -222,12 +222,12 @@ public static partial class Legal 1200, 1201, 1202, 1203, 1204, 1205, 1206, 1207, 1208, 1209, 1210, 1211, 1212, 1213, 1214, 1215, 1216, 1217, 1218, 1219, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1228, 1229, - }; + ]; - public static readonly ushort[] Pouch_TMHM_SWSH = ArrayUtil.ConcatAll(Pouch_TM_SWSH, Pouch_TR_SWSH); + public static readonly ushort[] Pouch_TMHM_SWSH = [.. Pouch_TM_SWSH, .. Pouch_TR_SWSH]; public static readonly ushort[] Pouch_Medicine_SWSH = - { + [ 017, 018, 019, 020, 021, 022, 023, 024, 025, 026, 027, 028, 029, 030, 031, 032, 033, 034, 035, 036, 037, 038, 039, 040, 041, 042, 043, 054, @@ -236,56 +236,56 @@ public static partial class Legal 708, 709, 852, 903, 1579, - }; + ]; public static readonly ushort[] Pouch_Berries_SWSH = - { + [ 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 169, 170, 171, 172, 173, 174, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 686, 687, 688, - }; + ]; public static readonly ushort[] Pouch_Ingredients_SWSH = - { + [ 1084, 1085, 1086, 1087, 1088, 1089, 1090, 1091, 1092, 1093, 1094, 1095, 1096, 1097, 1098, 1099, 1256, 1257, 1258, 1259, 1260, 1261, 1262, 1263, 1264, - }; + ]; public static readonly ushort[] Pouch_Treasure_SWSH = - { + [ 086, 087, 088, 089, 090, 091, 092, 094, 106, 571, 580, 581, 582, 583, 795, 796, 1105, 1106, 1107, 1108, - }; + ]; - public static readonly ushort[] HeldItems_SWSH = ArrayUtil.ConcatAll(Pouch_Items_SWSH, Pouch_Berries_SWSH, Pouch_Medicine_SWSH, Pouch_TR_SWSH, Pouch_Treasure_SWSH, Pouch_Ingredients_SWSH); + public static readonly ushort[] HeldItems_SWSH = [.. Pouch_Items_SWSH, .. Pouch_Berries_SWSH, .. Pouch_Medicine_SWSH, .. Pouch_TR_SWSH, .. Pouch_Treasure_SWSH, .. Pouch_Ingredients_SWSH]; #endregion #region Moves public static readonly int[] TypeTutor8 = - { + [ 520, 519, 518, // Pledge 338, 307, 308, // Elemental Beam 434, // Draco Meteor 796, // Steel Beam - }; + ]; public static readonly int[] Tutors_SWSH_1 = - { + [ 805, 807, 812, 804, 803, 813, 811, 810, 815, 814, 797, 806, 800, 809, 799, 808, 798, 802, - }; + ]; public static readonly ushort[] TMHM_SWSH = - { + [ // TM 005, 025, 006, 007, 008, 009, 019, 042, 063, 416, 345, 076, 669, 083, 086, 091, 103, 113, 115, 219, @@ -297,10 +297,10 @@ public static partial class Legal 433, 472, 478, 440, 474, 490, 496, 506, 512, 514, 521, 523, 527, 534, 541, 555, 566, 577, 580, 581, 604, 678, 595, 598, 206, 403, 684, 693, 707, 784, - }; + ]; public static readonly ushort[] TR_SWSH = - { + [ // TR 014, 034, 053, 056, 057, 058, 059, 067, 085, 087, 089, 094, 097, 116, 118, 126, 127, 133, 141, 161, @@ -312,10 +312,10 @@ public static partial class Legal 430, 437, 438, 441, 442, 444, 446, 447, 482, 484, 486, 492, 500, 502, 503, 526, 528, 529, 535, 542, 583, 599, 605, 663, 667, 675, 676, 706, 710, 776, - }; + ]; public static readonly byte[] MovePP_SWSH = - { + [ 00, 35, 25, 10, 15, 20, 20, 15, 15, 15, 35, 30, 05, 10, 20, 30, 35, 35, 20, 15, 20, 20, 25, 20, 30, 05, 10, 15, 15, 15, 25, 20, 05, 35, 15, 20, 20, 10, 15, 30, 35, 20, 20, 30, 25, 40, 20, 15, 20, 20, 20, 30, 25, 15, 30, 25, 05, 15, 10, 05, 20, 20, 20, 05, 35, 20, 20, 20, 20, 20, 15, 25, 15, 10, 20, 25, 10, 35, 30, 15, 10, 40, 10, 15, 30, 15, 20, 10, 15, 10, 05, 10, 10, 25, 10, 20, 40, 30, 30, 20, 20, @@ -334,7 +334,7 @@ public static partial class Legal 01, 01, 01, 05, 05, 10, 10, 10, 20, 10, 10, 10, 05, 05, 20, 10, 10, 10, 01, 05, 15, 05, 01, 01, 01, 01, 01, 01, 10, 15, 15, 20, 20, 20, 20, 15, 15, 10, 10, 05, 20, 05, 10, 05, 15, 10, 10, 05, 15, 20, 10, 10, 15, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 05, 10, 15, 10, 15, 05, 05, 05, 10, 15, 40, 10, 10, 10, 15, 10, 10, 10, 10, 05, 05, 05, 10, 05, 20, 10, 10, 05, 20, 20, 10, 10, 05, 05, 05, 40, 10, 20, 10, 10, 10, 10, 05, 05, 15, 05, 10, 10, 10, 05, 05, 05, - }; + ]; #endregion @@ -371,10 +371,10 @@ public static partial class Legal (int)Runerigus, ]; - public static readonly HashSet EvolveToGalarForms = new(GalarVariantFormEvolutions.Concat(GalarOriginForms)); + public static readonly HashSet EvolveToGalarForms = [..GalarVariantFormEvolutions.Concat(GalarOriginForms)]; public static readonly int[] GigantamaxForms = - { + [ (int)Charizard, (int)Butterfree, (int)Pikachu, @@ -409,7 +409,7 @@ public static partial class Legal (int)Cinderace, (int)Inteleon, (int)Urshifu, - }; + ]; #region Unreleased Items diff --git a/pkNX.Structures/Legality/Tables/Tables8a.cs b/pkNX.Structures/Legality/Tables/Tables8a.cs index f61e5d6d..d6650db7 100644 --- a/pkNX.Structures/Legality/Tables/Tables8a.cs +++ b/pkNX.Structures/Legality/Tables/Tables8a.cs @@ -16,7 +16,7 @@ public static partial class Legal public static readonly ushort[] HeldItems_LA = []; public static readonly ushort[] Pouch_Items_LA = - { + [ 017, 023, 024, 025, 026, 027, 028, 029, 039, 041, 050, 054, 072, 073, 075, 080, 081, 082, 083, 084, 085, 090, 091, 092, 107, 108, 109, 110, 149, 150, @@ -37,10 +37,10 @@ public static partial class Legal 1733, 1734, 1735, 1736, 1738, 1739, 1740, 1741, 1742, 1746, 1747, 1748, 1749, 1750, 1754, 1755, 1756, 1757, 1758, 1759, 1760, 1761, 1762, 1764, 1785, - }; + ]; public static readonly ushort[] Pouch_Recipe_LA = - { + [ 1640, 1641, 1642, 1643, 1644, 1646, 1647, 1648, 1649, 1650, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, @@ -52,10 +52,10 @@ public static partial class Legal 1751, 1752, 1753, 1783, 1784, - }; + ]; public static readonly ushort[] Pouch_Key_LA = - { + [ 111, 298, 299, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, @@ -69,13 +69,13 @@ public static partial class Legal 1795, 1796, 1797, 1798, 1799, 1800, 1801, 1802, 1803, 1804, 1805, 1806, 1807, 1828, - }; + ]; #endregion #region Moves public static readonly ushort[] MoveShop8_LA = - { + [ (int)Move.FalseSwipe, (int)Move.FireFang, (int)Move.ThunderFang, @@ -137,7 +137,7 @@ public static partial class Legal (int)Move.DracoMeteor, (int)Move.SteelBeam, (int)Move.VoltTackle, - }; + ]; #endregion } diff --git a/pkNX.Structures/Legality/Tables/Tables9.cs b/pkNX.Structures/Legality/Tables/Tables9.cs index 5ceb6bd0..e1b02b83 100644 --- a/pkNX.Structures/Legality/Tables/Tables9.cs +++ b/pkNX.Structures/Legality/Tables/Tables9.cs @@ -12,36 +12,36 @@ public static partial class Legal #region Inventory Pouch internal static readonly ushort[] Pouch_Medicine_SV = - { + [ 0017, 0018, 0019, 0020, 0021, 0022, 0023, 0024, 0025, 0026, 0027, 0028, 0029, 0030, 0031, 0032, 0033, 0034, 0035, 0036, 0037, 0038, 0039, 0040, 0041, 0708, 0709, - }; + ]; internal static readonly ushort[] Pouch_Ball_SV = - { + [ 0001, 0002, 0003, 0004, 0005, 0006, 0007, 0008, 0009, 0010, 0011, 0012, 0013, 0014, 0015, 0016, 0492, 0493, 0494, 0495, 0496, 0497, 0498, 0499, 0500, 0576, 0851, 1785, - }; + ]; internal static readonly ushort[] Pouch_Battle_SV = - { + [ 0055, 0056, 0057, 0058, 0059, 0060, 0061, 0062, 0063, - }; + ]; internal static readonly ushort[] Pouch_Berries_SV = - { + [ 0149, 0150, 0151, 0152, 0153, 0154, 0155, 0156, 0157, 0158, 0159, 0160, 0161, 0162, 0163, 0169, 0170, 0171, 0172, 0173, 0174, 0184, 0185, 0186, 0187, 0188, 0189, 0190, 0191, 0192, 0193, 0194, 0195, 0196, 0197, 0198, 0199, 0200, 0201, 0202, 0203, 0204, 0205, 0206, 0207, 0208, 0209, 0210, 0211, 0212, 0686, 0687, 0688, - }; + ]; internal static readonly ushort[] Pouch_Other_SV = - { + [ 0045, 0046, 0047, 0048, 0049, 0050, 0051, 0052, 0053, 0080, 0081, 0082, 0083, 0084, 0085, 0107, 0108, 0109, 0110, 0111, 0112, 0135, 0136, 0213, 0214, 0217, 0218, 0219, 0220, 0221, @@ -65,10 +65,10 @@ public static partial class Legal 1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875, 1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1885, 1886, 2344, 2345, - }; + ]; internal static readonly ushort[] Pouch_TM_SV = - { + [ 0328, 0329, 0330, 0331, 0332, 0333, 0334, 0335, 0336, 0337, 0338, 0339, 0340, 0341, 0342, 0343, 0344, 0345, 0346, 0347, 0348, 0349, 0350, 0351, 0352, 0353, 0354, 0355, 0356, 0357, @@ -87,16 +87,16 @@ public static partial class Legal 2210, 2211, 2212, 2213, 2214, 2215, 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2223, 2224, 2225, 2226, 2227, 2228, 2229, 2230, 2231, - }; + ]; internal static readonly ushort[] Pouch_Treasure_SV = - { + [ 0086, 0087, 0088, 0089, 0090, 0091, 0092, 0094, 0106, 0571, 0580, 0581, 0582, 0583, 1842, 1843, - }; + ]; internal static readonly ushort[] Pouch_Picnic_SV = - { + [ 1888, 1889, 1890, 1891, 1892, 1893, 1894, 1895, 1896, 1897, 1898, 1899, 1900, 1901, 1902, 1903, 1904, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 1913, 1914, 1915, 1916, 1917, @@ -113,17 +113,17 @@ public static partial class Legal 2380, 2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, - }; + ]; internal static readonly ushort[] Pouch_Event_SV = - { + [ 0078, 0466, 0631, 0632, 0638, 0703, 0765, 1267, 1278, 1587, 1589, 1590, 1591, 1829, 1830, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839, 1840, 1841, 1857, 1858, - }; + ]; internal static readonly ushort[] Pouch_Material_SV = - { + [ 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, @@ -145,9 +145,9 @@ public static partial class Legal 2138, 2139, 2140, 2141, 2142, 2143, 2144, 2145, 2146, 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2156, 2157, 2158, 2159, - }; + ]; - internal static readonly ushort[] HeldItems_SV = ArrayUtil.ConcatAll(Pouch_Medicine_SV, Pouch_Ball_SV, Pouch_Battle_SV, Pouch_Berries_SV, Pouch_Other_SV, Pouch_TM_SV, Pouch_Treasure_SV); + internal static readonly ushort[] HeldItems_SV = [.. Pouch_Medicine_SV, .. Pouch_Ball_SV, .. Pouch_Battle_SV, .. Pouch_Berries_SV, .. Pouch_Other_SV, .. Pouch_TM_SV, .. Pouch_Treasure_SV]; #endregion #region Moves diff --git a/pkNX.Structures/Legality/Trainers.cs b/pkNX.Structures/Legality/Trainers.cs index 3775c9f7..dd5ef150 100644 --- a/pkNX.Structures/Legality/Trainers.cs +++ b/pkNX.Structures/Legality/Trainers.cs @@ -13,15 +13,16 @@ public static partial class Legal 445, 448, 460, ]; - public static readonly ushort[] Mega_ORAS = Mega_XY.Concat(new ushort[] - { + public static readonly ushort[] Mega_ORAS = + [ + .. Mega_XY, 015, 018, 094, 208, 254, 260, 302, 319, 323, 334, 362, 373, 376, 384, 428, 475, 531, 719, - }).ToArray(); + ]; public static readonly int[] SpecialClasses_XY = [ @@ -344,13 +345,14 @@ public static partial class Legal /// Assigning these Trainer Classes to a Trainer crashes the game. /// A majority of these are Master Trainer related, and only used for multiplayer. They are not to be assigned to NPCs. /// - public static readonly int[] BlacklistedClasses_GG = Enumerable.Range(072, 311).Concat(new[] - { + public static readonly int[] BlacklistedClasses_GG = + [ + .. Enumerable.Range(072, 311), #region CrashClasses 032, // Pokémon Trainer 033, // Pokémon Trainer #endregion - }).ToArray(); + ]; #endregion #region Gen 8 @@ -585,7 +587,7 @@ public static partial class Legal #endregion ]; - public static readonly int[] BlacklistedClasses_SWSH = DoubleBattleClasses_SWSH.Concat(UnusedClasses_SWSH).Concat(CrashClasses_SWSH).Concat(DummyClasses_SWSH).ToArray(); + public static readonly int[] BlacklistedClasses_SWSH = [.. DoubleBattleClasses_SWSH, .. UnusedClasses_SWSH, .. CrashClasses_SWSH, .. DummyClasses_SWSH]; #endregion #region Gen 9 diff --git a/pkNX.Structures/Misc/CaptureReward.cs b/pkNX.Structures/Misc/CaptureReward.cs index 7e5de41e..f14ee6ce 100644 --- a/pkNX.Structures/Misc/CaptureReward.cs +++ b/pkNX.Structures/Misc/CaptureReward.cs @@ -89,19 +89,12 @@ public IEnumerable Dump(string[] itemNames) } } -public class CaptureRewardGroup +public class CaptureRewardGroup(int count, int entries) { - public int CaptureCount; - public int EntryCount; + public int CaptureCount = count; + public int EntryCount = entries; - public List Entries; - - public CaptureRewardGroup(int count, int entries) - { - CaptureCount = count; - EntryCount = entries; - Entries = new List(entries); - } + public List Entries = new(entries); } public class CaptureRewardEntry diff --git a/pkNX.Structures/Move/Move.cs b/pkNX.Structures/Move/Move.cs index 711c0380..cd248b0b 100644 --- a/pkNX.Structures/Move/Move.cs +++ b/pkNX.Structures/Move/Move.cs @@ -1,10 +1,9 @@ namespace pkNX.Structures; -public abstract class Move3DS : IMove +public abstract class Move3DS(byte[] data) : IMove { - protected readonly byte[] Data; + protected readonly byte[] Data = data; protected abstract int SIZE { get; } - protected Move3DS(byte[] data) => Data = data; public byte[] Write() => Data; diff --git a/pkNX.Structures/Move/Move6.cs b/pkNX.Structures/Move/Move6.cs index c26a118c..dc8015e2 100644 --- a/pkNX.Structures/Move/Move6.cs +++ b/pkNX.Structures/Move/Move6.cs @@ -2,12 +2,11 @@ namespace pkNX.Structures; -public class Move6 : Move3DS +public class Move6(byte[] data) : Move3DS(data) { private const int Size = 0x22; protected override int SIZE => Size; public Move6() : this(new byte[Size]) { } - public Move6(byte[] data) : base(data) { } public override int Type { get => Data[0x00]; set => Data[0x00] = (byte)value; } public override int Quality { get => Data[0x01]; set => Data[0x01] = (byte)value; } diff --git a/pkNX.Structures/Move/Move7.cs b/pkNX.Structures/Move/Move7.cs index 134ca1e9..4ec6ed0f 100644 --- a/pkNX.Structures/Move/Move7.cs +++ b/pkNX.Structures/Move/Move7.cs @@ -2,12 +2,11 @@ namespace pkNX.Structures; -public class Move7 : Move3DS +public class Move7(byte[] data) : Move3DS(data) { private const int Size = 0x28; protected override int SIZE => Size; public Move7() : this(new byte[Size]) { } - public Move7(byte[] data) : base(data) { } public override int Type { get => Data[0x00]; set => Data[0x00] = (byte)value; } public override int Quality { get => Data[0x01]; set => Data[0x01] = (byte)value; } diff --git a/pkNX.Structures/Personal/Info/PersonalInfo5B2W2.cs b/pkNX.Structures/Personal/Info/PersonalInfo5B2W2.cs index 45bfd7ff..a364e025 100644 --- a/pkNX.Structures/Personal/Info/PersonalInfo5B2W2.cs +++ b/pkNX.Structures/Personal/Info/PersonalInfo5B2W2.cs @@ -7,43 +7,35 @@ namespace pkNX.Structures; /// /// Personal Info class with values from the Black 2 & White 2 games. /// -public sealed class PersonalInfo5B2W2 : IPersonalInfoB2W2 +public sealed class PersonalInfo5B2W2(byte[] data) : IPersonalInfoB2W2 { public const int SIZE = 0x4C; - private readonly byte[] Data; - public bool[] TMHM { get; set; } - public bool[] TypeTutors { get; set; } - public bool[] SpecialTutors { get; set; } + public bool[] TMHM { get; set; } = GetBits(data.AsSpan(0x28, 0x10)); + public bool[] TypeTutors { get; set; } = GetBits(data.AsSpan(0x38, 0x4)); + public bool[] SpecialTutors { get; set; } = GetBits(data.AsSpan(0x3C, 0x16)); // 0x3C - 0x43 - public PersonalInfo5B2W2(byte[] data) - { - Data = data; - // Unpack TMHM & Tutors - TMHM = GetBits(data.AsSpan(0x28, 0x10)); - TypeTutors = GetBits(data.AsSpan(0x38, 0x4)); - SpecialTutors = GetBits(data.AsSpan(0x3C, 0x16)); // 0x3C - 0x43 - } + // Unpack TMHM & Tutors public byte[] Write() { - SetBits(TMHM, Data.AsSpan(0x28)); - SetBits(TypeTutors, Data.AsSpan(0x38)); - SetBits(SpecialTutors, Data.AsSpan(0x3C)); - return Data; + SetBits(TMHM, data.AsSpan(0x28)); + SetBits(TypeTutors, data.AsSpan(0x38)); + SetBits(SpecialTutors, data.AsSpan(0x3C)); + return data; } - public int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } - public int ATK { get => Data[0x01]; set => Data[0x01] = (byte)value; } - public int DEF { get => Data[0x02]; set => Data[0x02] = (byte)value; } - public int SPE { get => Data[0x03]; set => Data[0x03] = (byte)value; } - public int SPA { get => Data[0x04]; set => Data[0x04] = (byte)value; } - public int SPD { get => Data[0x05]; set => Data[0x05] = (byte)value; } - public Types Type1 { get => (Types)Data[0x06]; set => Data[0x06] = (byte)value; } - public Types Type2 { get => (Types)Data[0x07]; set => Data[0x07] = (byte)value; } - public int CatchRate { get => Data[0x08]; set => Data[0x08] = (byte)value; } - public int EvoStage { get => Data[0x09]; set => Data[0x09] = (byte)value; } - private int EVYield { get => ReadUInt16LittleEndian(Data.AsSpan(0x0A)); set => WriteUInt16LittleEndian(Data.AsSpan(0x0A), (ushort)value); } + public int HP { get => data[0x00]; set => data[0x00] = (byte)value; } + public int ATK { get => data[0x01]; set => data[0x01] = (byte)value; } + public int DEF { get => data[0x02]; set => data[0x02] = (byte)value; } + public int SPE { get => data[0x03]; set => data[0x03] = (byte)value; } + public int SPA { get => data[0x04]; set => data[0x04] = (byte)value; } + public int SPD { get => data[0x05]; set => data[0x05] = (byte)value; } + public Types Type1 { get => (Types)data[0x06]; set => data[0x06] = (byte)value; } + public Types Type2 { get => (Types)data[0x07]; set => data[0x07] = (byte)value; } + public int CatchRate { get => data[0x08]; set => data[0x08] = (byte)value; } + public int EvoStage { get => data[0x09]; set => data[0x09] = (byte)value; } + private int EVYield { get => ReadUInt16LittleEndian(data.AsSpan(0x0A)); set => WriteUInt16LittleEndian(data.AsSpan(0x0A), (ushort)value); } public int EV_HP { get => (EVYield >> 0) & 0x3; set => EVYield = (EVYield & ~(0x3 << 0)) | ((value & 0x3) << 0); } public int EV_ATK { get => (EVYield >> 2) & 0x3; set => EVYield = (EVYield & ~(0x3 << 2)) | ((value & 0x3) << 2); } public int EV_DEF { get => (EVYield >> 4) & 0x3; set => EVYield = (EVYield & ~(0x3 << 4)) | ((value & 0x3) << 4); } @@ -51,30 +43,30 @@ public byte[] Write() public int EV_SPA { get => (EVYield >> 8) & 0x3; set => EVYield = (EVYield & ~(0x3 << 8)) | ((value & 0x3) << 8); } public int EV_SPD { get => (EVYield >> 10) & 0x3; set => EVYield = (EVYield & ~(0x3 << 10)) | ((value & 0x3) << 10); } public bool Telekenesis { get => ((EVYield >> 12) & 1) == 1; set => EVYield = (EVYield & ~(0x1 << 12)) | ((value ? 1 : 0) << 12); } - public int Item1 { get => ReadInt16LittleEndian(Data.AsSpan(0x0C)); set => WriteInt16LittleEndian(Data.AsSpan(0x0C), (short)value); } - public int Item2 { get => ReadInt16LittleEndian(Data.AsSpan(0x0E)); set => WriteInt16LittleEndian(Data.AsSpan(0x0E), (short)value); } - public int Item3 { get => ReadInt16LittleEndian(Data.AsSpan(0x10)); set => WriteInt16LittleEndian(Data.AsSpan(0x10), (short)value); } - public int Gender { get => Data[0x12]; set => Data[0x12] = (byte)value; } - public byte HatchCycles { get => Data[0x13]; set => Data[0x13] = value; } - public int BaseFriendship { get => Data[0x14]; set => Data[0x14] = (byte)value; } - public int EXPGrowth { get => Data[0x15]; set => Data[0x15] = (byte)value; } - public int EggGroup1 { get => Data[0x16]; set => Data[0x16] = (byte)value; } - public int EggGroup2 { get => Data[0x17]; set => Data[0x17] = (byte)value; } - public int Ability1 { get => Data[0x18]; set => Data[0x18] = (byte)value; } - public int Ability2 { get => Data[0x19]; set => Data[0x19] = (byte)value; } - public int AbilityH { get => Data[0x1A]; set => Data[0x1A] = (byte)value; } + public int Item1 { get => ReadInt16LittleEndian(data.AsSpan(0x0C)); set => WriteInt16LittleEndian(data.AsSpan(0x0C), (short)value); } + public int Item2 { get => ReadInt16LittleEndian(data.AsSpan(0x0E)); set => WriteInt16LittleEndian(data.AsSpan(0x0E), (short)value); } + public int Item3 { get => ReadInt16LittleEndian(data.AsSpan(0x10)); set => WriteInt16LittleEndian(data.AsSpan(0x10), (short)value); } + public int Gender { get => data[0x12]; set => data[0x12] = (byte)value; } + public byte HatchCycles { get => data[0x13]; set => data[0x13] = value; } + public int BaseFriendship { get => data[0x14]; set => data[0x14] = (byte)value; } + public int EXPGrowth { get => data[0x15]; set => data[0x15] = (byte)value; } + public int EggGroup1 { get => data[0x16]; set => data[0x16] = (byte)value; } + public int EggGroup2 { get => data[0x17]; set => data[0x17] = (byte)value; } + public int Ability1 { get => data[0x18]; set => data[0x18] = (byte)value; } + public int Ability2 { get => data[0x19]; set => data[0x19] = (byte)value; } + public int AbilityH { get => data[0x1A]; set => data[0x1A] = (byte)value; } - public int EscapeRate { get => Data[0x1B]; set => Data[0x1B] = (byte)value; } - public int FormStatsIndex { get => ReadUInt16LittleEndian(Data.AsSpan(0x1C)); set => WriteUInt16LittleEndian(Data.AsSpan(0x1C), (ushort)value); } - public int FormSprite { get => ReadUInt16LittleEndian(Data.AsSpan(0x1E)); set => WriteUInt16LittleEndian(Data.AsSpan(0x1E), (ushort)value); } - public byte FormCount { get => Data[0x20]; set => Data[0x20] = value; } - public int Color { get => Data[0x21] & 0x3F; set => Data[0x21] = (byte)((Data[0x21] & 0xC0) | (value & 0x3F)); } - public bool SpriteFlip { get => ((Data[0x21] >> 6) & 1) == 1; set => Data[0x21] = (byte)((Data[0x21] & ~0x40) | (value ? 0x40 : 0)); } - public bool SpriteForm { get => ((Data[0x21] >> 7) & 1) == 1; set => Data[0x21] = (byte)((Data[0x21] & ~0x80) | (value ? 0x80 : 0)); } + public int EscapeRate { get => data[0x1B]; set => data[0x1B] = (byte)value; } + public int FormStatsIndex { get => ReadUInt16LittleEndian(data.AsSpan(0x1C)); set => WriteUInt16LittleEndian(data.AsSpan(0x1C), (ushort)value); } + public int FormSprite { get => ReadUInt16LittleEndian(data.AsSpan(0x1E)); set => WriteUInt16LittleEndian(data.AsSpan(0x1E), (ushort)value); } + public byte FormCount { get => data[0x20]; set => data[0x20] = value; } + public int Color { get => data[0x21] & 0x3F; set => data[0x21] = (byte)((data[0x21] & 0xC0) | (value & 0x3F)); } + public bool SpriteFlip { get => ((data[0x21] >> 6) & 1) == 1; set => data[0x21] = (byte)((data[0x21] & ~0x40) | (value ? 0x40 : 0)); } + public bool SpriteForm { get => ((data[0x21] >> 7) & 1) == 1; set => data[0x21] = (byte)((data[0x21] & ~0x80) | (value ? 0x80 : 0)); } - public int BaseEXP { get => ReadUInt16LittleEndian(Data.AsSpan(0x22)); set => WriteUInt16LittleEndian(Data.AsSpan(0x22), (ushort)value); } - public int Height { get => ReadUInt16LittleEndian(Data.AsSpan(0x24)); set => WriteUInt16LittleEndian(Data.AsSpan(0x24), (ushort)value); } - public int Weight { get => ReadUInt16LittleEndian(Data.AsSpan(0x26)); set => WriteUInt16LittleEndian(Data.AsSpan(0x26), (ushort)value); } + public int BaseEXP { get => ReadUInt16LittleEndian(data.AsSpan(0x22)); set => WriteUInt16LittleEndian(data.AsSpan(0x22), (ushort)value); } + public int Height { get => ReadUInt16LittleEndian(data.AsSpan(0x24)); set => WriteUInt16LittleEndian(data.AsSpan(0x24), (ushort)value); } + public int Weight { get => ReadUInt16LittleEndian(data.AsSpan(0x26)); set => WriteUInt16LittleEndian(data.AsSpan(0x26), (ushort)value); } public int AbilityCount => 3; public int GetIndexOfAbility(int abilityID) => abilityID == Ability1 ? 0 : abilityID == Ability2 ? 1 : abilityID == AbilityH ? 2 : -1; diff --git a/pkNX.Structures/Personal/Info/PersonalInfo5BW.cs b/pkNX.Structures/Personal/Info/PersonalInfo5BW.cs index 0ec3b502..d5500498 100644 --- a/pkNX.Structures/Personal/Info/PersonalInfo5BW.cs +++ b/pkNX.Structures/Personal/Info/PersonalInfo5BW.cs @@ -7,39 +7,32 @@ namespace pkNX.Structures; /// /// Personal Info class with values from the Black & White games. /// -public sealed class PersonalInfo5BW : IPersonalInfoBW +public sealed class PersonalInfo5BW(byte[] data) : IPersonalInfoBW { public const int SIZE = 0x3C; - private readonly byte[] Data; - public bool[] TMHM { get; set; } - public bool[] TypeTutors { get; set; } + public bool[] TMHM { get; set; } = GetBits(data.AsSpan(0x28, 0x10)); + public bool[] TypeTutors { get; set; } = GetBits(data.AsSpan(0x38, 0x4)); - public PersonalInfo5BW(byte[] data) - { - Data = data; - // Unpack TMHM & Tutors - TMHM = GetBits(data.AsSpan(0x28, 0x10)); - TypeTutors = GetBits(data.AsSpan(0x38, 0x4)); - } + // Unpack TMHM & Tutors public byte[] Write() { - SetBits(TMHM, Data.AsSpan(0x28)); - SetBits(TypeTutors, Data.AsSpan(0x38)); - return Data; + SetBits(TMHM, data.AsSpan(0x28)); + SetBits(TypeTutors, data.AsSpan(0x38)); + return data; } - public int HP { get => Data[0x00]; set => Data[0x00] = (byte)value; } - public int ATK { get => Data[0x01]; set => Data[0x01] = (byte)value; } - public int DEF { get => Data[0x02]; set => Data[0x02] = (byte)value; } - public int SPE { get => Data[0x03]; set => Data[0x03] = (byte)value; } - public int SPA { get => Data[0x04]; set => Data[0x04] = (byte)value; } - public int SPD { get => Data[0x05]; set => Data[0x05] = (byte)value; } - public Types Type1 { get => (Types)Data[0x06]; set => Data[0x06] = (byte)value; } - public Types Type2 { get => (Types)Data[0x07]; set => Data[0x07] = (byte)value; } - public int CatchRate { get => Data[0x08]; set => Data[0x08] = (byte)value; } - public int EvoStage { get => Data[0x09]; set => Data[0x09] = (byte)value; } - private int EVYield { get => ReadUInt16LittleEndian(Data.AsSpan(0x0A)); set => WriteUInt16LittleEndian(Data.AsSpan(0x0A), (ushort)value); } + public int HP { get => data[0x00]; set => data[0x00] = (byte)value; } + public int ATK { get => data[0x01]; set => data[0x01] = (byte)value; } + public int DEF { get => data[0x02]; set => data[0x02] = (byte)value; } + public int SPE { get => data[0x03]; set => data[0x03] = (byte)value; } + public int SPA { get => data[0x04]; set => data[0x04] = (byte)value; } + public int SPD { get => data[0x05]; set => data[0x05] = (byte)value; } + public Types Type1 { get => (Types)data[0x06]; set => data[0x06] = (byte)value; } + public Types Type2 { get => (Types)data[0x07]; set => data[0x07] = (byte)value; } + public int CatchRate { get => data[0x08]; set => data[0x08] = (byte)value; } + public int EvoStage { get => data[0x09]; set => data[0x09] = (byte)value; } + private int EVYield { get => ReadUInt16LittleEndian(data.AsSpan(0x0A)); set => WriteUInt16LittleEndian(data.AsSpan(0x0A), (ushort)value); } public int EV_HP { get => (EVYield >> 0) & 0x3; set => EVYield = (EVYield & ~(0x3 << 0)) | ((value & 0x3) << 0); } public int EV_ATK { get => (EVYield >> 2) & 0x3; set => EVYield = (EVYield & ~(0x3 << 2)) | ((value & 0x3) << 2); } public int EV_DEF { get => (EVYield >> 4) & 0x3; set => EVYield = (EVYield & ~(0x3 << 4)) | ((value & 0x3) << 4); } @@ -47,30 +40,30 @@ public byte[] Write() public int EV_SPA { get => (EVYield >> 8) & 0x3; set => EVYield = (EVYield & ~(0x3 << 8)) | ((value & 0x3) << 8); } public int EV_SPD { get => (EVYield >> 10) & 0x3; set => EVYield = (EVYield & ~(0x3 << 10)) | ((value & 0x3) << 10); } public bool Telekenesis { get => ((EVYield >> 12) & 1) == 1; set => EVYield = (EVYield & ~(0x1 << 12)) | ((value ? 1 : 0) << 12); } - public int Item1 { get => ReadInt16LittleEndian(Data.AsSpan(0x0C)); set => WriteInt16LittleEndian(Data.AsSpan(0x0C), (short)value); } - public int Item2 { get => ReadInt16LittleEndian(Data.AsSpan(0x0E)); set => WriteInt16LittleEndian(Data.AsSpan(0x0E), (short)value); } - public int Item3 { get => ReadInt16LittleEndian(Data.AsSpan(0x10)); set => WriteInt16LittleEndian(Data.AsSpan(0x10), (short)value); } - public int Gender { get => Data[0x12]; set => Data[0x12] = (byte)value; } - public byte HatchCycles { get => Data[0x13]; set => Data[0x13] = value; } - public int BaseFriendship { get => Data[0x14]; set => Data[0x14] = (byte)value; } - public int EXPGrowth { get => Data[0x15]; set => Data[0x15] = (byte)value; } - public int EggGroup1 { get => Data[0x16]; set => Data[0x16] = (byte)value; } - public int EggGroup2 { get => Data[0x17]; set => Data[0x17] = (byte)value; } - public int Ability1 { get => Data[0x18]; set => Data[0x18] = (byte)value; } - public int Ability2 { get => Data[0x19]; set => Data[0x19] = (byte)value; } - public int AbilityH { get => Data[0x1A]; set => Data[0x1A] = (byte)value; } + public int Item1 { get => ReadInt16LittleEndian(data.AsSpan(0x0C)); set => WriteInt16LittleEndian(data.AsSpan(0x0C), (short)value); } + public int Item2 { get => ReadInt16LittleEndian(data.AsSpan(0x0E)); set => WriteInt16LittleEndian(data.AsSpan(0x0E), (short)value); } + public int Item3 { get => ReadInt16LittleEndian(data.AsSpan(0x10)); set => WriteInt16LittleEndian(data.AsSpan(0x10), (short)value); } + public int Gender { get => data[0x12]; set => data[0x12] = (byte)value; } + public byte HatchCycles { get => data[0x13]; set => data[0x13] = value; } + public int BaseFriendship { get => data[0x14]; set => data[0x14] = (byte)value; } + public int EXPGrowth { get => data[0x15]; set => data[0x15] = (byte)value; } + public int EggGroup1 { get => data[0x16]; set => data[0x16] = (byte)value; } + public int EggGroup2 { get => data[0x17]; set => data[0x17] = (byte)value; } + public int Ability1 { get => data[0x18]; set => data[0x18] = (byte)value; } + public int Ability2 { get => data[0x19]; set => data[0x19] = (byte)value; } + public int AbilityH { get => data[0x1A]; set => data[0x1A] = (byte)value; } - public int EscapeRate { get => Data[0x1B]; set => Data[0x1B] = (byte)value; } - public int FormStatsIndex { get => ReadUInt16LittleEndian(Data.AsSpan(0x1C)); set => WriteUInt16LittleEndian(Data.AsSpan(0x1C), (ushort)value); } - public int FormSprite { get => ReadUInt16LittleEndian(Data.AsSpan(0x1E)); set => WriteUInt16LittleEndian(Data.AsSpan(0x1E), (ushort)value); } - public byte FormCount { get => Data[0x20]; set => Data[0x20] = value; } - public int Color { get => Data[0x21] & 0x3F; set => Data[0x21] = (byte)((Data[0x21] & 0xC0) | (value & 0x3F)); } - public bool SpriteFlip { get => ((Data[0x21] >> 6) & 1) == 1; set => Data[0x21] = (byte)((Data[0x21] & ~0x40) | (value ? 0x40 : 0)); } - public bool SpriteForm { get => ((Data[0x21] >> 7) & 1) == 1; set => Data[0x21] = (byte)((Data[0x21] & ~0x80) | (value ? 0x80 : 0)); } + public int EscapeRate { get => data[0x1B]; set => data[0x1B] = (byte)value; } + public int FormStatsIndex { get => ReadUInt16LittleEndian(data.AsSpan(0x1C)); set => WriteUInt16LittleEndian(data.AsSpan(0x1C), (ushort)value); } + public int FormSprite { get => ReadUInt16LittleEndian(data.AsSpan(0x1E)); set => WriteUInt16LittleEndian(data.AsSpan(0x1E), (ushort)value); } + public byte FormCount { get => data[0x20]; set => data[0x20] = value; } + public int Color { get => data[0x21] & 0x3F; set => data[0x21] = (byte)((data[0x21] & 0xC0) | (value & 0x3F)); } + public bool SpriteFlip { get => ((data[0x21] >> 6) & 1) == 1; set => data[0x21] = (byte)((data[0x21] & ~0x40) | (value ? 0x40 : 0)); } + public bool SpriteForm { get => ((data[0x21] >> 7) & 1) == 1; set => data[0x21] = (byte)((data[0x21] & ~0x80) | (value ? 0x80 : 0)); } - public int BaseEXP { get => ReadUInt16LittleEndian(Data.AsSpan(0x22)); set => WriteUInt16LittleEndian(Data.AsSpan(0x22), (ushort)value); } - public int Height { get => ReadUInt16LittleEndian(Data.AsSpan(0x24)); set => WriteUInt16LittleEndian(Data.AsSpan(0x24), (ushort)value); } - public int Weight { get => ReadUInt16LittleEndian(Data.AsSpan(0x26)); set => WriteUInt16LittleEndian(Data.AsSpan(0x26), (ushort)value); } + public int BaseEXP { get => ReadUInt16LittleEndian(data.AsSpan(0x22)); set => WriteUInt16LittleEndian(data.AsSpan(0x22), (ushort)value); } + public int Height { get => ReadUInt16LittleEndian(data.AsSpan(0x24)); set => WriteUInt16LittleEndian(data.AsSpan(0x24), (ushort)value); } + public int Weight { get => ReadUInt16LittleEndian(data.AsSpan(0x26)); set => WriteUInt16LittleEndian(data.AsSpan(0x26), (ushort)value); } public int AbilityCount => 3; public int GetIndexOfAbility(int abilityID) => abilityID == Ability1 ? 0 : abilityID == Ability2 ? 1 : abilityID == AbilityH ? 2 : -1; diff --git a/pkNX.Structures/Personal/Interfaces/IMovesInfo.cs b/pkNX.Structures/Personal/Interfaces/IMovesInfo.cs index 338c1c1f..d2d046c8 100644 --- a/pkNX.Structures/Personal/Interfaces/IMovesInfo.cs +++ b/pkNX.Structures/Personal/Interfaces/IMovesInfo.cs @@ -1,8 +1,6 @@ namespace pkNX.Structures; -public interface IMovesInfo -{ -} +public interface IMovesInfo; public interface IMovesInfo_v1 : IMovesInfo { diff --git a/pkNX.Structures/Personal/Interfaces/IPersonalEgg.cs b/pkNX.Structures/Personal/Interfaces/IPersonalEgg.cs index 14523934..4ded2875 100644 --- a/pkNX.Structures/Personal/Interfaces/IPersonalEgg.cs +++ b/pkNX.Structures/Personal/Interfaces/IPersonalEgg.cs @@ -32,9 +32,7 @@ public interface IPersonalEgg_SWSH : IPersonalEgg_v1 ushort HatchedSpecies { get; set; } } -public interface IPersonalEgg_PLA : IPersonalEgg_SWSH -{ -} +public interface IPersonalEgg_PLA : IPersonalEgg_SWSH; public static class PersonalEggExtensions { diff --git a/pkNX.Structures/Personal/Interfaces/IPersonalInfo.cs b/pkNX.Structures/Personal/Interfaces/IPersonalInfo.cs index bcef5e92..bbe890e5 100644 --- a/pkNX.Structures/Personal/Interfaces/IPersonalInfo.cs +++ b/pkNX.Structures/Personal/Interfaces/IPersonalInfo.cs @@ -5,7 +5,7 @@ namespace pkNX.Structures; /// /// Base interface that can be used for any version. This should not contain variables that are not present in every game /// -public interface IPersonalInfo : IBaseStat, IEffortValueYield, IPersonalType, IPersonalEgg, IPersonalTraits, IPersonalAbility, IPersonalMisc, IPersonalItems, IPersonalFormInfo { } +public interface IPersonalInfo : IBaseStat, IEffortValueYield, IPersonalType, IPersonalEgg, IPersonalTraits, IPersonalAbility, IPersonalMisc, IPersonalItems, IPersonalFormInfo; public interface IPersonalInfoBin { @@ -32,19 +32,19 @@ public static void SetBits(ReadOnlySpan bits, Span data) /// /// Version one /// -public interface IPersonalInfo_v1 : IPersonalInfoBin, IPersonalInfo, IPersonalEgg_v1, IMovesInfo_v1 { } +public interface IPersonalInfo_v1 : IPersonalInfoBin, IPersonalInfo, IPersonalEgg_v1, IMovesInfo_v1; /// /// Version 2 adds `SpecialTutors` to moves /// -public interface IPersonalInfo_v2 : IPersonalInfoBin, IPersonalInfo, IPersonalEgg_v1, IMovesInfo_B2W2 { } +public interface IPersonalInfo_v2 : IPersonalInfoBin, IPersonalInfo, IPersonalEgg_v1, IMovesInfo_B2W2; // Game specific PersonalInfo interfaces -public interface IPersonalInfoBW : IPersonalInfo_v1 { } -public interface IPersonalInfoXY : IPersonalInfo_v1 { } -public interface IPersonalInfoB2W2 : IPersonalInfo_v2 { } -public interface IPersonalInfoORAS : IPersonalInfo_v2 { } +public interface IPersonalInfoBW : IPersonalInfo_v1; +public interface IPersonalInfoXY : IPersonalInfo_v1; +public interface IPersonalInfoB2W2 : IPersonalInfo_v2; +public interface IPersonalInfoORAS : IPersonalInfo_v2; public interface IPersonalInfoSM : IPersonalInfo_v2 { int SpecialZ_Item { get; set; } @@ -71,9 +71,7 @@ public interface IPersonalInfoPLA : IPersonalInfo, IPersonalEgg_PLA, IMovesInfo_ bool IsRegionalForm { get; set; } // byte ushort RegionalFormIndex { get; set; } // ushort } -public interface IPersonalInfoSV : IPersonalInfo, IPersonalEgg_SWSH -{ -} +public interface IPersonalInfoSV : IPersonalInfo, IPersonalEgg_SWSH; public static class IPersonalInfoExt { diff --git a/pkNX.Structures/Text/TextConfig.cs b/pkNX.Structures/Text/TextConfig.cs index 28962ee6..897ba3ba 100644 --- a/pkNX.Structures/Text/TextConfig.cs +++ b/pkNX.Structures/Text/TextConfig.cs @@ -8,14 +8,13 @@ namespace pkNX.Structures; /// /// Version specific text parsing configuration object to interact with text variable codes. /// -public class TextConfig +public class TextConfig(GameVersion game) { internal static readonly TextConfig Default = new(GameVersion.Any); - private static readonly char[] _trim_hex = { '0', 'x' }; - private readonly TextVariableCode[] Variables; + private static readonly char[] _trim_hex = ['0', 'x']; + private readonly TextVariableCode[] Variables = TextVariableCode.GetVariables(game); public IEnumerable GetVariableList() => Variables.Select(z => $"{z.Code:X4}={z.Name}"); - public TextConfig(GameVersion game) => Variables = TextVariableCode.GetVariables(game); private TextVariableCode? GetCode(string name) => Array.Find(Variables, v => v.Name == name); private TextVariableCode? GetName(int value) => Array.Find(Variables, v => v.Code == value); diff --git a/pkNX.Structures/Text/TextFile.cs b/pkNX.Structures/Text/TextFile.cs index db1fafef..3f9db9f1 100644 --- a/pkNX.Structures/Text/TextFile.cs +++ b/pkNX.Structures/Text/TextFile.cs @@ -57,7 +57,7 @@ public TextFile(IEnumerable lines, TextConfig? config = null, bool remap private ushort LineCount { get => ReadUInt16LittleEndian(Data.AsSpan(0x02)); set => WriteUInt16LittleEndian(Data.AsSpan(0x02), value); } private uint TotalLength { get => ReadUInt32LittleEndian(Data.AsSpan(0x04)); set => WriteUInt32LittleEndian(Data.AsSpan(0x04), value); } private uint InitialKey { get => ReadUInt32LittleEndian(Data.AsSpan(0x08)); set => WriteUInt32LittleEndian(Data.AsSpan(0x08), value); } // Always 0x00000000 - private uint SectionDataOffset { get => ReadUInt32LittleEndian(Data.AsSpan(0x10)); set => WriteUInt32LittleEndian(Data.AsSpan(0x10), value); } // Always 0x0010 + private uint SectionDataOffset { get => ReadUInt32LittleEndian(Data.AsSpan(0x0C)); set => WriteUInt32LittleEndian(Data.AsSpan(0x0C), value); } // Always 0x0010 private uint SectionLength { get => ReadUInt32LittleEndian(Data.AsSpan((int)SectionDataOffset)); set => WriteUInt32LittleEndian(Data.AsSpan((int)SectionDataOffset), value); } private TextLine[] LineOffsets @@ -238,7 +238,8 @@ private static byte[] GetLineData(TextConfig config, bool remap, ReadOnlySpan rubyValues = []; + GetRubyValues(rubyText.ToString(), remap, rubyValues); foreach (ushort v in rubyValues) bw.Write(v); i += 1 + rubyText.Length; @@ -409,42 +410,54 @@ private static IEnumerable GetVariableValues(TextConfig config, List GetRubyValues(string ruby, bool remap) + private static void GetRubyValues(ReadOnlySpan ruby, bool remap, List vals) { - string[] split = ruby.Split('|'); - if (split.Length < 2) + var split1 = ruby.IndexOf('|'); + if (split1 < 0) throw new ArgumentException($"Incorrectly formatted ruby text: {ruby}"); - string baseText1 = split[0]; - string rubyText = split[1]; - string baseText2 = split.Length < 3 ? baseText1 : split[2]; + ReadOnlySpan baseText1 = ruby[..split1]; + ruby = ruby[(split1 + 1)..]; + var split2 = ruby.IndexOf('|'); + ReadOnlySpan rubyText, baseText2; + if (split2 < 0) + { + rubyText = ruby; + baseText2 = baseText1; + } + else + { + rubyText = ruby[..split2]; + baseText2 = ruby[(split2 + 1)..]; + } if (baseText1.Length != baseText2.Length) throw new ArgumentException($"Incorrectly formatted ruby text: {ruby}"); - var vals = new List + vals.Add(KEY_VARIABLE); + vals.Add(Convert.ToUInt16(3 + baseText1.Length + rubyText.Length)); + vals.Add(KEY_TEXTRUBY); + vals.Add(Convert.ToUInt16(baseText1.Length)); + vals.Add(Convert.ToUInt16(rubyText.Length)); + + ToU16(baseText1, remap, vals); + ToU16(rubyText, remap, vals); + ToU16(baseText2, remap, vals); + static void ToU16(ReadOnlySpan text, bool remap, List vals) { - KEY_VARIABLE, - Convert.ToUInt16(3 + baseText1.Length + rubyText.Length), - KEY_TEXTRUBY, - Convert.ToUInt16(baseText1.Length), - Convert.ToUInt16(rubyText.Length), - }; - vals.AddRange(baseText1.Select(val => Convert.ToUInt16(TryRemapChar(val, remap)))); - vals.AddRange(rubyText.Select(val => Convert.ToUInt16(TryRemapChar(val, remap)))); - vals.AddRange(baseText2.Select(val => Convert.ToUInt16(TryRemapChar(val, remap)))); - return vals; + foreach (var c in text) + vals.Add(TryRemapChar(c, remap)); + } } - private static IEnumerable GetVariableParameters(TextConfig config, ReadOnlySpan text) + private static void GetVariableParameters(TextConfig config, ReadOnlySpan text, List vals) { - var vals = new List(); int bracket = text.IndexOf('('); bool noArgs = bracket < 0; var variable = noArgs ? text : text[..bracket]; @@ -480,7 +493,6 @@ private static IEnumerable GetVariableParameters(TextConfig config, Read vals.Add(1); vals.Add(varVal); } - return vals; } // Exposed Methods diff --git a/pkNX.Structures/Text/TextVariableCode.cs b/pkNX.Structures/Text/TextVariableCode.cs index d1889e66..ba571429 100644 --- a/pkNX.Structures/Text/TextVariableCode.cs +++ b/pkNX.Structures/Text/TextVariableCode.cs @@ -31,7 +31,7 @@ public static TextVariableCode[] GetVariables(GameVersion game) } private static readonly TextVariableCode[] XY = - { + [ new(0xFF00, "COLOR"), new(0x0100, "TRNAME"), new(0x0101, "PKNAME"), @@ -80,10 +80,10 @@ public static TextVariableCode[] GetVariables(GameVersion game) new(0x0206, "NUM7"), new(0x0207, "NUM8"), new(0x0208, "NUM9"), - }; + ]; private static readonly TextVariableCode[] AO = - { + [ new(0xFF00, "COLOR"), new(0x0100, "TRNAME"), new(0x0101, "PKNAME"), @@ -132,10 +132,10 @@ public static TextVariableCode[] GetVariables(GameVersion game) new(0x0206, "NUM7"), new(0x0207, "NUM8"), new(0x0208, "NUM9"), - }; + ]; private static readonly TextVariableCode[] SM = - { + [ new(0xFF00, "COLOR"), new(0x0100, "TRNAME"), new(0x0101, "PKNAME"), @@ -184,10 +184,10 @@ public static TextVariableCode[] GetVariables(GameVersion game) new(0x0206, "NUM7"), new(0x0207, "NUM8"), new(0x0208, "NUM9"), - }; + ]; private static readonly TextVariableCode[] GG = - { + [ new(0xFF00, "COLOR"), new(0x0100, "TRNAME"), new(0x0101, "PKNAME"), @@ -236,5 +236,5 @@ public static TextVariableCode[] GetVariables(GameVersion game) new(0x0206, "NUM7"), new(0x0207, "NUM8"), new(0x0208, "NUM9"), - }; + ]; } diff --git a/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs b/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs index 68800d3c..c096d1d3 100644 --- a/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs +++ b/pkNX.Structures/VsTrainer/3DS/TrData6AO.cs @@ -2,12 +2,11 @@ namespace pkNX.Structures; -public sealed class TrData6AO : TrData6 +public sealed class TrData6AO(byte[] data) : TrData6(data) { private const int Size = 0x18; public override int SIZE => Size; - public TrData6AO() : base(new byte[Size]) { } - public TrData6AO(byte[] data) : base(data) { } + public TrData6AO() : this(new byte[Size]) { } protected override int Format { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } public override int Class { get => BitConverter.ToUInt16(Data, 0x02); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x02); } diff --git a/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs b/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs index 2f4df9b6..39fefc8c 100644 --- a/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs +++ b/pkNX.Structures/VsTrainer/3DS/TrData6XY.cs @@ -2,12 +2,11 @@ namespace pkNX.Structures; -public sealed class TrData6XY : TrData6 +public sealed class TrData6XY(byte[] data) : TrData6(data) { private const int Size = 0x14; public override int SIZE => Size; - public TrData6XY() : base(new byte[Size]) { } - public TrData6XY(byte[] data) : base(data) { } + public TrData6XY() : this(new byte[Size]) { } protected override int Format { get => Data[0x00]; set => Data[0x00] = (byte) value; } public override int Class { get => Data[0x01]; set => Data[0x01] = (byte)value; } diff --git a/pkNX.Structures/VsTrainer/Base/IAwakened.cs b/pkNX.Structures/VsTrainer/Base/IAwakened.cs index 22d7efe5..64233001 100644 --- a/pkNX.Structures/VsTrainer/Base/IAwakened.cs +++ b/pkNX.Structures/VsTrainer/Base/IAwakened.cs @@ -114,5 +114,5 @@ public static void SetSuggestedAwakenedValues(this IAwakened a, StatPKM pk) } } - public static int[] AVs(this IAwakened a) => new[] {a.AV_HP, a.AV_ATK, a.AV_DEF, a.AV_SPA, a.AV_SPD, a.AV_SPE}; + public static int[] AVs(this IAwakened a) => [a.AV_HP, a.AV_ATK, a.AV_DEF, a.AV_SPA, a.AV_SPD, a.AV_SPE]; } diff --git a/pkNX.Structures/VsTrainer/Base/TrainerClass.cs b/pkNX.Structures/VsTrainer/Base/TrainerClass.cs index 128cd5fd..143a5fca 100644 --- a/pkNX.Structures/VsTrainer/Base/TrainerClass.cs +++ b/pkNX.Structures/VsTrainer/Base/TrainerClass.cs @@ -1,11 +1,9 @@ namespace pkNX.Structures; -public abstract class TrainerClass +public abstract class TrainerClass(byte[] data) { - protected TrainerClass(byte[] data) => Data = data; - public abstract int SIZE { get; } - protected readonly byte[] Data; + protected readonly byte[] Data = data; public virtual int Gender { get; set; } public virtual int Multi { get; set; } diff --git a/pkNX.Structures/VsTrainer/Base/TrainerData.cs b/pkNX.Structures/VsTrainer/Base/TrainerData.cs index c1354697..1045997d 100644 --- a/pkNX.Structures/VsTrainer/Base/TrainerData.cs +++ b/pkNX.Structures/VsTrainer/Base/TrainerData.cs @@ -1,9 +1,9 @@ namespace pkNX.Structures; -public abstract class TrainerData +public abstract class TrainerData(byte[] trData) { public abstract int SIZE { get; } - protected byte[] Data; + protected byte[] Data = trData; public abstract int Class { get; set; } public abstract BattleMode Mode { get; set; } @@ -22,5 +22,4 @@ public abstract class TrainerData public bool HasAllyTrainer => (AI & 8) != 0; public byte[] Write() => Data; - protected TrainerData(byte[] trData) => Data = trData; } diff --git a/pkNX.Structures/VsTrainer/Base/TrainerPoke.cs b/pkNX.Structures/VsTrainer/Base/TrainerPoke.cs index ec160e51..685cd7d6 100644 --- a/pkNX.Structures/VsTrainer/Base/TrainerPoke.cs +++ b/pkNX.Structures/VsTrainer/Base/TrainerPoke.cs @@ -1,9 +1,8 @@ namespace pkNX.Structures; -public abstract class TrainerPoke : StatPKM, IMoveset +public abstract class TrainerPoke(byte[] data) : StatPKM, IMoveset { - protected byte[] Data; - protected TrainerPoke(byte[] data) => Data = data; + protected byte[] Data = data; public abstract int Friendship { get; set; } @@ -27,13 +26,13 @@ public abstract class TrainerPoke : StatPKM, IMoveset public int[] Moves { - get => new[] { Move1, Move2, Move3, Move4 }; + get => [Move1, Move2, Move3, Move4]; set { if (value?.Length != 4) return; Move1 = value[0]; Move2 = value[1]; Move3 = value[2]; Move4 = value[3]; } } public int[] IVs { - get => new[] { IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD }; + get => [IV_HP, IV_ATK, IV_DEF, IV_SPE, IV_SPA, IV_SPD]; set { if (value?.Length != 6) return; @@ -44,7 +43,7 @@ public int[] IVs public int[] EVs { - get => new[] { EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD }; + get => [EV_HP, EV_ATK, EV_DEF, EV_SPE, EV_SPA, EV_SPD]; set { if (value?.Length != 6) return; diff --git a/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs b/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs index e631a34e..be540e71 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerClass7b.cs @@ -1,10 +1,9 @@ namespace pkNX.Structures; -public class TrainerClass7b : TrainerClass +public class TrainerClass7b(byte[] data) : TrainerClass(data) { private const int Size = 0x24; public sealed override int SIZE => Size; - public TrainerClass7b(byte[] data) : base(data) { } public TrainerClass7b() : this(new byte[Size]) { } public byte Unk_0x00 { get => Data[0]; set => Data[0] = value; } diff --git a/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs b/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs index 7231f85e..40bc070b 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerClass8.cs @@ -2,7 +2,7 @@ namespace pkNX.Structures; -public class TrainerClass8 : TrainerClass +public class TrainerClass8(byte[] data) : TrainerClass(data) { // 4 bytes used // 4 bytes unused (align?) @@ -12,7 +12,6 @@ public class TrainerClass8 : TrainerClass private const int Size = 280; public sealed override int SIZE => 280; - public TrainerClass8(byte[] data) : base(data) { } public TrainerClass8() : this(new byte[Size]) { } public byte Unk_0x00 { get => Data[0]; set => Data[0] = value; } // bool? diff --git a/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs b/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs index ab3c1014..b6f0c162 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerData7b.cs @@ -2,12 +2,11 @@ namespace pkNX.Structures; -public sealed class TrainerData7b : TrainerData +public sealed class TrainerData7b(byte[] data) : TrainerData(data) { private const int Size = 0x17; public override int SIZE => Size; - public TrainerData7b() : base(new byte[Size]) { } - public TrainerData7b(byte[] data) : base(data) { } + public TrainerData7b() : this(new byte[Size]) { } public override int Class { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } public override BattleMode Mode { get => (BattleMode)Data[2]; set => Data[2] = (byte)value; } // Not sure diff --git a/pkNX.Structures/VsTrainer/GG/TrainerData8.cs b/pkNX.Structures/VsTrainer/GG/TrainerData8.cs index 242ef909..f9f49ffc 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerData8.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerData8.cs @@ -2,12 +2,11 @@ namespace pkNX.Structures; -public sealed class TrainerData8 : TrainerData +public sealed class TrainerData8(byte[] data) : TrainerData(data) { private const int Size = 0x14; public override int SIZE => Size; public TrainerData8() : this(new byte[Size]) { } - public TrainerData8(byte[] data) : base(data) { } public override int Class { get => BitConverter.ToUInt16(Data, 0x00); set => BitConverter.GetBytes((ushort)value).CopyTo(Data, 0x00); } public override BattleMode Mode { get => (BattleMode)Data[2]; set => Data[2] = (byte)value; } // Not sure diff --git a/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs b/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs index 8406dcbd..e23595cd 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerPoke7b.cs @@ -4,12 +4,11 @@ namespace pkNX.Structures; -public class TrainerPoke7b : TrainerPoke, IAwakened +public class TrainerPoke7b(byte[] data) : TrainerPoke(data), IAwakened { public const int SIZE = 0x28; public override TrainerPoke Clone() => new TrainerPoke7b((byte[])Write().Clone()); public TrainerPoke7b() : this(new byte[SIZE]) { } - public TrainerPoke7b(byte[] data) : base(data) { } public static TrainerPoke7b[] ReadTeam(byte[] data, TrainerData _) => data.GetArray((_, offset) => new TrainerPoke7b(data.Slice(offset, SIZE)), SIZE); public static byte[] WriteTeam(IList team, TrainerData _) => team.SelectMany(z => z.Write()).ToArray(); @@ -86,14 +85,14 @@ public ushort[] CalculateStatsBeluga(IPersonalInfo p) int friend = Friendship; // stats +10% depending on friendship! int scalar = (int)(((friend / 255.0f / 10.0f) + 1.0f) * 100.0f); ushort[] Stats = - { + [ (ushort)(AV_HP + GetStat(p.HP, IV_HP, level) + 10 + level), (ushort)(AV_ATK + (scalar * GetStat(p.ATK, IV_ATK, level, nature, 0) / 100)), (ushort)(AV_DEF + (scalar * GetStat(p.DEF, IV_DEF, level, nature, 1) / 100)), (ushort)(AV_SPE + (scalar * GetStat(p.SPE, IV_SPE, level, nature, 4) / 100)), (ushort)(AV_SPA + (scalar * GetStat(p.SPA, IV_SPA, level, nature, 2) / 100)), (ushort)(AV_SPD + (scalar * GetStat(p.SPD, IV_SPD, level, nature, 3) / 100)), - }; + ]; if (Species == 292) Stats[0] = 1; return Stats; @@ -136,7 +135,7 @@ private static int AmplifyStat(int nature, int index, int initial) } private static readonly sbyte[] AbilityAmpTable = - { + [ 0, 0, 0, 0, 0, // Hardy 1,-1, 0, 0, 0, // Lonely 1, 0, 0, 0,-1, // Brave @@ -162,5 +161,5 @@ private static int AmplifyStat(int nature, int index, int initial) 0, 0, 0, 1,-1, // Sassy 0, 0,-1, 1, 0, // Careful 0, 0, 0, 0, 0, // Quirky - }; + ]; } diff --git a/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs b/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs index 886cf5fb..a6001dd8 100644 --- a/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs +++ b/pkNX.Structures/VsTrainer/GG/TrainerPoke8.cs @@ -4,12 +4,11 @@ namespace pkNX.Structures; -public class TrainerPoke8 : TrainerPoke +public class TrainerPoke8(byte[] data) : TrainerPoke(data) { //sub_7101452DB0 public const int SIZE = 0x20; public TrainerPoke8() : this(new byte[SIZE]) { } - public TrainerPoke8(byte[] data) : base(data) { } public override TrainerPoke Clone() => new TrainerPoke8((byte[])Data.Clone()); public static TrainerPoke8[] ReadTeam(byte[] data, TrainerData _) => data.GetArray((_, offset) => new TrainerPoke8(data.Slice(offset, SIZE)), SIZE); diff --git a/pkNX.Structures/VsTrainer/VsTrainer.cs b/pkNX.Structures/VsTrainer/VsTrainer.cs index b102b930..a1163e9c 100644 --- a/pkNX.Structures/VsTrainer/VsTrainer.cs +++ b/pkNX.Structures/VsTrainer/VsTrainer.cs @@ -2,14 +2,12 @@ namespace pkNX.Structures; -public class VsTrainer +public class VsTrainer(TrainerData self) { public int ID { get; set; } public string Name { get; set; } = string.Empty; - public TrainerData Self { get; set; } + public TrainerData Self { get; set; } = self; public readonly List Team = new(6); - public VsTrainer(TrainerData self) => Self = self; - public TrainerClass GetClass(IList list) => list[Self.Class]; } diff --git a/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystemPathTest.cs b/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystemPathTest.cs index f593fa9f..086aab14 100644 --- a/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystemPathTest.cs +++ b/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystemPathTest.cs @@ -13,7 +13,7 @@ namespace pkNX.Tests; /// public class FileSystemPathTest { - private FileSystemPath[] _paths = { root, directoryA, fileA, directoryB, fileB }; + private FileSystemPath[] _paths = [root, directoryA, fileA, directoryB, fileB]; private IEnumerable Directories { get { return _paths.Where(p => p.IsDirectory); } } private IEnumerable Files { get { return _paths.Where(p => p.IsFile); } } @@ -232,7 +232,7 @@ public void CompareToTest() foreach (var pa in _paths) { foreach (var pb in _paths) - Assert.Equal(Math.Sign(pa.CompareTo(pb)), Math.Sign(string.Compare(pa.ToString(), pb.ToString(), StringComparison.Ordinal))); + Assert.Equal(Math.Sign(pa.CompareTo(pb)), Math.Sign(string.CompareOrdinal(pa, pb))); } } diff --git a/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystems/PhysicalFSTests.cs b/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystems/PhysicalFSTests.cs index 9672a5f0..7e4af8a1 100644 --- a/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystems/PhysicalFSTests.cs +++ b/pkNX.Tests/pkNX.Tests.FileSystem/VFS/FileSystems/PhysicalFSTests.cs @@ -104,10 +104,8 @@ public void CreateFile_Empty() } Assert.Equal([], File.ReadAllBytes(AbsFilePath_W)); - using (var stream = FileSystem.OpenFile(FilePath_W)) - { - Assert.Equal([], stream.ReadAllBytes()); - } + using var stream = FileSystem.OpenFile(FilePath_W); + Assert.Equal([], stream.ReadAllBytes()); } /* @@ -163,10 +161,8 @@ public void CreateFile_Empty() [Fact] public void OpenFile_ReadOnly() { - using (var stream = FileSystem.OpenFile(FilePath_R, FileMode.Open, FileAccess.Read)) - { - Assert.Equal("asdf"u8.ToArray(), stream.ReadAllBytes()); - } + using var stream = FileSystem.OpenFile(FilePath_R, FileMode.Open, FileAccess.Read); + Assert.Equal("asdf"u8.ToArray(), stream.ReadAllBytes()); } [Fact] diff --git a/pkNX.Tests/pkNX.Tests.Trinity/SceneTests.cs b/pkNX.Tests/pkNX.Tests.Trinity/SceneTests.cs index 14938240..7459cb5f 100644 --- a/pkNX.Tests/pkNX.Tests.Trinity/SceneTests.cs +++ b/pkNX.Tests/pkNX.Tests.Trinity/SceneTests.cs @@ -10,7 +10,7 @@ public class SceneTests [Fact] public void TestSceneDump() { - const string file = @""; + const string file = ""; if (!File.Exists(file)) return; @@ -20,8 +20,8 @@ public void TestSceneDump() [Fact] public void TestFolderDump() { - const string dir = @""; // input - SceneDumper.Bucket = @""; // output + const string dir = ""; // input + SceneDumper.Bucket = ""; // output SceneDumper.ThrowOnUnknownType = false; var files = Directory.EnumerateFiles(dir, "*", SearchOption.AllDirectories); foreach (var file in files) diff --git a/pkNX.WinForms/App.xaml.cs b/pkNX.WinForms/App.xaml.cs index 69bea8c7..16f4d058 100644 --- a/pkNX.WinForms/App.xaml.cs +++ b/pkNX.WinForms/App.xaml.cs @@ -7,7 +7,7 @@ namespace pkNX.WinForms; /// /// Interaction logic for App.xaml /// -public partial class App +public sealed partial class App { private App() { diff --git a/pkNX.WinForms/Controls/EncounterTableEditor8a.cs b/pkNX.WinForms/Controls/EncounterTableEditor8a.cs index a578dfec..2d68a1a0 100644 --- a/pkNX.WinForms/Controls/EncounterTableEditor8a.cs +++ b/pkNX.WinForms/Controls/EncounterTableEditor8a.cs @@ -8,7 +8,7 @@ namespace pkNX.WinForms.Controls; public partial class EncounterTableEditor8a : UserControl { - public IList Tables = Array.Empty(); + public IList Tables = []; public EncounterTableEditor8a() => InitializeComponent(); @@ -32,16 +32,10 @@ public void LoadTable(IList table, string path) CB_Encounters.SelectedIndex = 0; } - private class ComboItem + private class ComboItem(string text, EncounterTable value) { - public ComboItem(string text, EncounterTable value) - { - Text = text; - Value = value; - } - - public string Text { get; } - public EncounterTable Value { get; } + public string Text { get; } = text; + public EncounterTable Value { get; } = value; } private void CB_Encounters_SelectedIndexChanged(object sender, EventArgs e) @@ -86,7 +80,7 @@ private void B_CloneTableEntry_Click(object sender, EventArgs e) if (obj is not EncounterSlot slotToClone) return; var encounterTable = (EncounterTable)PG_Encounters.SelectedObject; - encounterTable.Table = encounterTable.Table.Concat(new[] { new EncounterSlot(slotToClone) }).ToArray(); + encounterTable.Table = encounterTable.Table.Concat([new EncounterSlot(slotToClone)]).ToArray(); PG_Encounters.Refresh(); } diff --git a/pkNX.WinForms/Controls/EvolutionEntry.xaml.cs b/pkNX.WinForms/Controls/EvolutionEntry.xaml.cs index b1223d9f..b4e98c9d 100644 --- a/pkNX.WinForms/Controls/EvolutionEntry.xaml.cs +++ b/pkNX.WinForms/Controls/EvolutionEntry.xaml.cs @@ -111,7 +111,7 @@ private static string[] GetArgs(EvolutionTypeArgumentType type) { return type switch { - EvolutionTypeArgumentType.NoArg => new[] { "None" }, + EvolutionTypeArgumentType.NoArg => ["None"], EvolutionTypeArgumentType.Items => UIStaticSources.ItemsList, EvolutionTypeArgumentType.Moves => UIStaticSources.MovesList, EvolutionTypeArgumentType.Species => UIStaticSources.SpeciesList, diff --git a/pkNX.WinForms/Controls/EvolutionRow.cs b/pkNX.WinForms/Controls/EvolutionRow.cs index 615837a5..282ccec4 100644 --- a/pkNX.WinForms/Controls/EvolutionRow.cs +++ b/pkNX.WinForms/Controls/EvolutionRow.cs @@ -75,7 +75,7 @@ public void SaveEvolution() private static readonly string[] EvoMethods = Enum.GetNames(typeof(EvolutionType)); private static readonly string[] Levels = Enumerable.Range(0, 100 + 1).Select(z => z.ToString()).ToArray(); private static readonly string[] Stats = Enumerable.Range(0, 255 + 1).Select(z => z.ToString()).ToArray(); - private static readonly string[] None = { "" }; + private static readonly string[] None = [""]; private static string[] GetArgs(EvolutionTypeArgumentType type) { diff --git a/pkNX.WinForms/Controls/EvolutionRow8a.cs b/pkNX.WinForms/Controls/EvolutionRow8a.cs index 69f2de51..39469788 100644 --- a/pkNX.WinForms/Controls/EvolutionRow8a.cs +++ b/pkNX.WinForms/Controls/EvolutionRow8a.cs @@ -17,7 +17,7 @@ public partial class EvolutionRow8a : UserControl private static readonly string[] EvoMethods = Enum.GetNames(typeof(EvolutionType)); private static readonly string[] Levels = Enumerable.Range(0, 100 + 1).Select(z => z.ToString()).ToArray(); private static readonly string[] Stats = Enumerable.Range(0, 255 + 1).Select(z => z.ToString()).ToArray(); - private static readonly string[] None = { "" }; + private static readonly string[] None = [""]; private Structures.FlatBuffers.Arceus.EvolutionEntry? current; private EvolutionTypeArgumentType oldMethod; diff --git a/pkNX.WinForms/Controls/LandmarkEditor8a.cs b/pkNX.WinForms/Controls/LandmarkEditor8a.cs index 9eb8da97..638f11e2 100644 --- a/pkNX.WinForms/Controls/LandmarkEditor8a.cs +++ b/pkNX.WinForms/Controls/LandmarkEditor8a.cs @@ -8,7 +8,7 @@ namespace pkNX.WinForms.Controls; public partial class LandmarkEditor8a : UserControl { - public IList Spawners = Array.Empty(); + public IList Spawners = []; public LandmarkEditor8a() => InitializeComponent(); @@ -32,16 +32,10 @@ public void LoadTable(IList table, string path) CB_Encounters.SelectedIndex = 0; } - private class ComboItem + private class ComboItem(string text, LandmarkItemSpawn value) { - public ComboItem(string text, LandmarkItemSpawn value) - { - Text = text; - Value = value; - } - - public string Text { get; } - public LandmarkItemSpawn Value { get; } + public string Text { get; } = text; + public LandmarkItemSpawn Value { get; } = value; } private void CB_Encounters_SelectedIndexChanged(object sender, EventArgs e) diff --git a/pkNX.WinForms/Controls/PlacementSpawnerEditor8a.cs b/pkNX.WinForms/Controls/PlacementSpawnerEditor8a.cs index c01f7a25..6d35efde 100644 --- a/pkNX.WinForms/Controls/PlacementSpawnerEditor8a.cs +++ b/pkNX.WinForms/Controls/PlacementSpawnerEditor8a.cs @@ -8,7 +8,7 @@ namespace pkNX.WinForms.Controls; public partial class PlacementSpawnerEditor8a : UserControl { - public IList Spawners = Array.Empty(); + public IList Spawners = []; public PlacementSpawnerEditor8a() => InitializeComponent(); @@ -32,16 +32,10 @@ public void LoadTable(IList table, string path) CB_Encounters.SelectedIndex = 0; } - private class ComboItem + private class ComboItem(string text, T value) { - public ComboItem(string text, T value) - { - Text = text; - Value = value; - } - - public string Text { get; } - public T Value { get; } + public string Text { get; } = text; + public T Value { get; } = value; } private void CB_Encounters_SelectedIndexChanged(object sender, EventArgs e) diff --git a/pkNX.WinForms/Controls/StatEditor.cs b/pkNX.WinForms/Controls/StatEditor.cs index 7b31c504..3c2f15aa 100644 --- a/pkNX.WinForms/Controls/StatEditor.cs +++ b/pkNX.WinForms/Controls/StatEditor.cs @@ -12,10 +12,10 @@ public partial class StatEditor : UserControl public StatEditor() { InitializeComponent(); - tb_iv = new[] { TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPEIV, TB_SPAIV, TB_SPDIV }; - tb_ev = new[] { TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPAEV, TB_SPDEV }; - tb_av = new[] { TB_HPAV, TB_ATKAV, TB_DEFAV, TB_SPEAV, TB_SPAAV, TB_SPDAV }; - labarray = new[] { Label_ATK, Label_DEF, Label_SPE, Label_SPA, Label_SPD }; + tb_iv = [TB_HPIV, TB_ATKIV, TB_DEFIV, TB_SPEIV, TB_SPAIV, TB_SPDIV]; + tb_ev = [TB_HPEV, TB_ATKEV, TB_DEFEV, TB_SPEEV, TB_SPAEV, TB_SPDEV]; + tb_av = [TB_HPAV, TB_ATKAV, TB_DEFAV, TB_SPEAV, TB_SPAAV, TB_SPDAV]; + labarray = [Label_ATK, Label_DEF, Label_SPE, Label_SPA, Label_SPD]; } public void Initialize(string[] types) @@ -66,8 +66,8 @@ public void UpdateStats() Stat_SPD.Text = stats[5].ToString(); Stat_SPE.Text = stats[3].ToString(); - TB_IVTotal.Text = tb_iv.Select(z => Util.ToInt32(z.Text)).Sum().ToString(); - TB_EVTotal.Text = tb_ev.Select(z => Util.ToInt32(z.Text)).Sum().ToString(); + TB_IVTotal.Text = tb_iv.Sum(z => Util.ToInt32(z.Text)).ToString(); + TB_EVTotal.Text = tb_ev.Sum(z => Util.ToInt32(z.Text)).ToString(); if (PKM is IAwakened s) TB_AVTotal.Text = s.AwakeningSum().ToString(); diff --git a/pkNX.WinForms/Dumping/GameDumperPLA.cs b/pkNX.WinForms/Dumping/GameDumperPLA.cs index e1015b59..47561a38 100644 --- a/pkNX.WinForms/Dumping/GameDumperPLA.cs +++ b/pkNX.WinForms/Dumping/GameDumperPLA.cs @@ -18,17 +18,15 @@ namespace pkNX.WinForms; -public class GameDumperPLA +public class GameDumperPLA(GameManagerPLA rom) { - private readonly GameManagerPLA ROM; - public GameDumperPLA(GameManagerPLA rom) => ROM = rom; public string DumpFolder { get { - var parent = Directory.GetParent(ROM.PathRomFS); + var parent = Directory.GetParent(rom.PathRomFS); if (parent is null) - throw new DirectoryNotFoundException($"Unable to find parent directory of {ROM.PathRomFS}"); + throw new DirectoryNotFoundException($"Unable to find parent directory of {rom.PathRomFS}"); return Path.Combine(parent.FullName, "Dump"); } } @@ -57,7 +55,7 @@ private string GetPath(string parent, string path) public void DumpPersonal() { - var data = ROM.GetFile(GameFile.PersonalStats)[0]; + var data = rom.GetFile(GameFile.PersonalStats)[0]; /*var obj = FlatBufferConverter.DeserializeFrom(data); var test = PersonalConverter.GetBin(obj); var path = GetPath("personal_la"); @@ -70,16 +68,16 @@ public void DumpPersonal() public void DumpPokeInfo() { - var s = ROM.GetStrings(TextName.SpeciesNames); + var s = rom.GetStrings(TextName.SpeciesNames); - var lrd = ROM.GetFile(GameFile.Learnsets)[0]; + var lrd = rom.GetFile(GameFile.Learnsets)[0]; var lr = FlatBufferConverter.DeserializeFrom(lrd); - var evd = ROM.GetFile(GameFile.Evolutions)[0]; + var evd = rom.GetFile(GameFile.Evolutions)[0]; var ev = FlatBufferConverter.DeserializeFrom(evd); - var pt = new PersonalTable8LA(ROM.GetFile(GameFile.PersonalStats)); + var pt = new PersonalTable8LA(rom.GetFile(GameFile.PersonalStats)); var altForms = pt.GetFormList(s); var entryNames = pt.GetPersonalEntryList(altForms, s, out _, out _); - var moveNames = ROM.GetStrings(TextName.MoveNames); + var moveNames = rom.GetStrings(TextName.MoveNames); var pd = new PersonalDumperPLA { @@ -90,13 +88,13 @@ public void DumpPokeInfo() ExpGroups = Enum.GetNames(typeof(EXPGroup)), Evos = ev.Table, - Abilities = ROM.GetStrings(TextName.AbilityNames), - Items = ROM.GetStrings(TextName.ItemNames), + Abilities = rom.GetStrings(TextName.AbilityNames), + Items = rom.GetStrings(TextName.ItemNames), Moves = moveNames, - Types = ROM.GetStrings(TextName.TypeNames), - Species = ROM.GetStrings(TextName.SpeciesNames), - ZukanA = ROM.GetStrings(TextName.PokedexEntry1), - ZukanB = ROM.GetStrings(TextName.PokedexEntry2), + Types = rom.GetStrings(TextName.TypeNames), + Species = rom.GetStrings(TextName.SpeciesNames), + ZukanA = rom.GetStrings(TextName.PokedexEntry1), + ZukanB = rom.GetStrings(TextName.PokedexEntry2), TMIndexes = Legal.TMHM_SWSH, }; @@ -116,8 +114,8 @@ public void DumpPokeInfo() private void DumpMoveUsers(IPersonalTable pt, Learnset lr) { List Users = []; - var moves = ROM.GetStrings(TextName.MoveNames); - var spec = ROM.GetStrings(TextName.SpeciesNames); + var moves = rom.GetStrings(TextName.MoveNames); + var spec = rom.GetStrings(TextName.SpeciesNames); var shop = Legal.MoveShop8_LA; for (int i = 0; i < moves.Length; i++) { @@ -152,11 +150,11 @@ private static string GetSpeciesMove(ReadOnlySpan spec, LearnsetMeta x, return $"{spec[x.Species]}{(x.Form == 0 ? "" : $"-{x.Form}")} @ {level}"; } - private static readonly string[] ahtbext = { ".tbl", ".hsh" }; + private static readonly string[] ahtbext = [".tbl", ".hsh"]; public void DumpAHTB() { - var files = Directory.EnumerateFiles(ROM.PathRomFS, "*", SearchOption.AllDirectories) + var files = Directory.EnumerateFiles(rom.PathRomFS, "*", SearchOption.AllDirectories) .Where(z => ahtbext.Contains(Path.GetExtension(z))); var result = new HashSet(); @@ -185,7 +183,7 @@ public void DumpAHTB() } } - var paks = Directory.EnumerateFiles(ROM.PathRomFS, "*", SearchOption.AllDirectories) + var paks = Directory.EnumerateFiles(rom.PathRomFS, "*", SearchOption.AllDirectories) .Where(z => Path.GetExtension(z) == ".gfpak"); foreach (var f in paks) { @@ -232,19 +230,19 @@ public void DumpAHTB() public void DumpDrops() { - var names = ROM.GetStrings(TextName.ItemNames); - var field = Path.Combine(ROM.PathRomFS, "bin", "pokemon", "data", "poke_drop_item.bin"); + var names = rom.GetStrings(TextName.ItemNames); + var field = Path.Combine(rom.PathRomFS, "bin", "pokemon", "data", "poke_drop_item.bin"); var fieldItems = FlatBufferConverter.DeserializeFrom(field).Table.Select(z => z.Dump(names)); File.WriteAllLines(GetPath("DropItems.txt"), fieldItems); - var battle = Path.Combine(ROM.PathRomFS, "bin", "pokemon", "data", "poke_drop_item_battle.bin"); + var battle = Path.Combine(rom.PathRomFS, "bin", "pokemon", "data", "poke_drop_item_battle.bin"); var battleItems = FlatBufferConverter.DeserializeFrom(battle).Table.Select(z => z.Dump(names)); File.WriteAllLines(GetPath("BattleDropItems.txt"), battleItems); } public void DumpItems() { - var items = ROM.GetFile(GameFile.ItemStats); + var items = rom.GetFile(GameFile.ItemStats); var file = items[0]; var array = Item8a.GetArray(file); var groups = array.GroupBy(z => z.Pouch); @@ -256,7 +254,7 @@ public void DumpItems() File.WriteAllText(path, string.Join(", ", IDs.Select(z => $"{z:000}"))); } - var names = ROM.GetStrings(TextName.ItemNames); + var names = rom.GetStrings(TextName.ItemNames); var lines = TableUtil.GetNamedTypeTable(array, names, "Items"); var table = GetPath("ItemData.txt"); var bin = GetPath("ItemData.bin"); @@ -266,10 +264,10 @@ public void DumpItems() public void DumpMoves() { - var dir = Path.Combine(ROM.PathRomFS, "bin", "pml", "waza"); + var dir = Path.Combine(rom.PathRomFS, "bin", "pml", "waza"); var files = Directory.GetFiles(dir); var moves = FlatBufferConverter.DeserializeFrom(files); - var names = ROM.GetStrings(TextName.MoveNames); + var names = rom.GetStrings(TextName.MoveNames); var lines = TableUtil.GetNamedTypeTable(moves, names, "Moves"); var table = GetPath("MoveData.txt"); File.WriteAllText(table, lines); @@ -280,8 +278,8 @@ public void DumpMoves() File.WriteAllText(pppath, str); // get dummied moves - var moveNames = ROM.GetStrings(TextName.MoveNames); - var moveDesc = ROM.GetStrings(TextName.MoveFlavor); + var moveNames = rom.GetStrings(TextName.MoveNames); + var moveDesc = rom.GetStrings(TextName.MoveFlavor); var tuple = moveNames .Select((z, i) => new { Name = z, Desc = moveDesc[i], Index = i }) @@ -298,9 +296,9 @@ public void DumpMoves() public void DumpLearnsetBinary() { - var data = ROM.GetFile(GameFile.Learnsets)[0]; + var data = rom.GetFile(GameFile.Learnsets)[0]; var obj = FlatBufferConverter.DeserializeFrom(data); - var pt = new PersonalTable8LA(ROM.GetFile(GameFile.PersonalStats)); + var pt = new PersonalTable8LA(rom.GetFile(GameFile.PersonalStats)); var result = new byte[pt.Table.Length][]; var mastery = new byte[pt.Table.Length][]; for (int i = 0; i < result.Length; i++) @@ -344,9 +342,9 @@ public void DumpLearnsetBinary() public void DumpEvolutionBinary() { // format matches past gen and PKHeX's expected format - var data = ROM.GetFilteredFolder(GameFile.Evolutions)[0]; + var data = rom.GetFilteredFolder(GameFile.Evolutions)[0]; var obj = FlatBufferConverter.DeserializeFrom(data); - var pt = new PersonalTable8LA(ROM.GetFile(GameFile.PersonalStats)); + var pt = new PersonalTable8LA(rom.GetFile(GameFile.PersonalStats)); var result = new byte[pt.Table.Length][]; for (int i = 0; i < result.Length; i++) result[i] = []; @@ -369,8 +367,8 @@ public void DumpEvolutionBinary() public void DumpGifts() { - var speciesNames = ROM.GetStrings(TextName.SpeciesNames); - var data = ROM.GetFile(GameFile.EncounterTableGift)[0]; + var speciesNames = rom.GetStrings(TextName.SpeciesNames); + var data = rom.GetFile(GameFile.EncounterTableGift)[0]; var gifts = FlatBufferConverter.DeserializeFrom(data); var table = TableUtil.GetTable(gifts.Table); var fn = GetPath("Gifts.txt"); @@ -382,8 +380,8 @@ public void DumpGifts() public void DumpStatic() { - var speciesNames = ROM.GetStrings(TextName.SpeciesNames); - var data = ROM.GetFile(GameFile.EncounterTableStatic)[0]; + var speciesNames = rom.GetStrings(TextName.SpeciesNames); + var data = rom.GetFile(GameFile.EncounterTableStatic)[0]; var statics = FlatBufferConverter.DeserializeFrom(data); var lines = new List(); @@ -407,20 +405,20 @@ public void DumpStatic() public void DumpWilds() { - var speciesName = ROM.GetStrings(TextName.SpeciesNames); + var speciesName = rom.GetStrings(TextName.SpeciesNames); Dictionary map = GetPlaceNameMap(); - var multdata = ROM.GetFile(GameFile.EncounterRateTable)[0]; + var multdata = rom.GetFile(GameFile.EncounterRateTable)[0]; var multipliers = FlatBufferConverter.DeserializeFrom(multdata); - var miscdata = ROM.GetFile(GameFile.PokeMisc)[0]; + var miscdata = rom.GetFile(GameFile.PokeMisc)[0]; var misc = FlatBufferConverter.DeserializeFrom(miscdata); - var nhoGroup_b = ROM.GetFile(GameFile.NewHugeGroup)[0]; + var nhoGroup_b = rom.GetFile(GameFile.NewHugeGroup)[0]; var nhoGroup = FlatBufferConverter.DeserializeFrom(nhoGroup_b); - var nhoGroupL_b = ROM.GetFile(GameFile.NewHugeGroupLottery)[0]; + var nhoGroupL_b = rom.GetFile(GameFile.NewHugeGroupLottery)[0]; var nhoGroupL = FlatBufferConverter.DeserializeFrom(nhoGroupL_b); - var resident = (GFPack)ROM.GetFile(GameFile.Resident); + var resident = (GFPack)rom.GetFile(GameFile.Resident); var bin_settings = resident.GetDataFullPath("bin/field/resident/AreaSettings.bin"); var settings = FlatBufferConverter.DeserializeFrom(bin_settings); @@ -510,7 +508,7 @@ public void DumpWilds() public void DumpResident() { - var resident = (GFPack)ROM.GetFile(GameFile.Resident); + var resident = (GFPack)rom.GetFile(GameFile.Resident); var bin_settings = resident.GetDataFullPath("bin/field/resident/AreaSettings.bin"); var settings = FlatBufferConverter.DeserializeFrom(bin_settings); var dir = GetPath("Resident"); @@ -524,7 +522,7 @@ public void DumpResident() continue; if (!s.Contains('/')) continue; - if (File.Exists(Path.Combine(ROM.PathRomFS, s))) + if (File.Exists(Path.Combine(rom.PathRomFS, s))) continue; try @@ -552,7 +550,7 @@ public void DumpResident() public void DumpPlacement() { - var resident = (GFPack)ROM.GetFile(GameFile.Resident); + var resident = (GFPack)rom.GetFile(GameFile.Resident); var bin_settings = resident.GetDataFullPath("bin/field/resident/AreaSettings.bin"); var settings = FlatBufferConverter.DeserializeFrom(bin_settings); @@ -627,9 +625,9 @@ public void DumpPlacement() private Dictionary GetPlaceNameMap() { var map = new Dictionary(); - var place_names = ROM.GetStrings(TextName.metlist_00000); + var place_names = rom.GetStrings(TextName.metlist_00000); - var scriptFolder = new FolderContainer(((FolderContainer)ROM.GetFile(GameFile.StoryText)).FilePath!); + var scriptFolder = new FolderContainer(((FolderContainer)rom.GetFile(GameFile.StoryText)).FilePath!); scriptFolder.Initialize(); var locationNames = scriptFolder.GetFileData("place_name.tbl")!; @@ -768,7 +766,7 @@ private void DumpVisualizationData(AreaInstance area) public void DumpOutbreak() { - var file = ROM.GetFile(GameFile.Outbreak).FilePath; + var file = rom.GetFile(GameFile.Outbreak).FilePath; var result = FlatDumper.GetTable(file!, z => z.Table); File.WriteAllText(GetPath("massOutbreak.txt"), result); @@ -783,7 +781,7 @@ public void DumpDex() { DumpDexSummarySpecies(); - var dexResearchPath = Path.Combine(ROM.PathRomFS, "bin", "appli", "pokedex", "res_table", "pokedex_research_task_table.bin"); + var dexResearchPath = Path.Combine(rom.PathRomFS, "bin", "appli", "pokedex", "res_table", "pokedex_research_task_table.bin"); var dexResearchBin = File.ReadAllBytes(dexResearchPath); var dexResearch = FlatBufferConverter.DeserializeFrom(dexResearchBin); @@ -796,7 +794,7 @@ public void DumpDex() private void DumpResearchTasks(PokedexResearchTable dexResearch) { - var pt = new PersonalTable8LA(ROM.GetFile(GameFile.PersonalStats)); + var pt = new PersonalTable8LA(rom.GetFile(GameFile.PersonalStats)); var result = new byte[pt.Table.Max(p => p.DexIndexRegional)][]; for (int i = 0; i < result.Length; i++) result[i] = []; @@ -915,8 +913,8 @@ ushort GetDexIndex(ushort species) private void DumpDexSummarySpecies() { - var pt = new PersonalTable8LA(ROM.GetFile(GameFile.PersonalStats)); - var s = ROM.GetStrings(TextName.SpeciesNames); + var pt = new PersonalTable8LA(rom.GetFile(GameFile.PersonalStats)); + var s = rom.GetStrings(TextName.SpeciesNames); var dex = new List(); var dexit = new List(); @@ -952,8 +950,8 @@ public void DumpFlavorText() { IEnumerable Zip(TextName name, TextName flavor) { - var n = ROM.GetStrings(name); - var f = ROM.GetStrings(flavor); + var n = rom.GetStrings(name); + var f = rom.GetStrings(flavor); return n.Select((z, i) => $"{z}\t{f[i].Replace("\\n", " ")}"); } @@ -970,10 +968,10 @@ IEnumerable Zip(TextName name, TextName flavor) File.WriteAllLines(p3, l3); } - private static readonly string[] LanguageCodes = { "ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2" }; + private static readonly string[] LanguageCodes = ["ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2"]; private static readonly string[] LanguageNames = - { + [ "カタカナ", "漢字", "English", @@ -984,17 +982,17 @@ IEnumerable Zip(TextName name, TextName flavor) "한국", "汉字简化方案", "漢字簡化方案", - }; + ]; private void ChangeLanguage(int index) { - ROM.Language = index; - GamePath.Initialize(ROM.Game, ROM.Language); + rom.Language = index; + GamePath.Initialize(rom.Game, rom.Language); } public void DumpStrings() { - int lang = ROM.Language; + int lang = rom.Language; var indexes = new[] { 0, 2, 3, 4, 5, 6, 7, 8, 9 }; for (int i = 0; i < indexes.Length; i++) { @@ -1024,7 +1022,7 @@ private void DumpStrings(string code, string name, int index) void DumpStringSet(TextName t, string file) { - var strings = ROM.GetStrings(t); + var strings = rom.GetStrings(t); var fn = $"text_{file}_{code}.txt"; var folder = Path.Combine(code, fn); @@ -1036,7 +1034,7 @@ void DumpStringSet(TextName t, string file) public void DumpScriptID() { - var file = Path.Combine(ROM.PathRomFS, "bin", "event", "script_id_record_release.bin"); + var file = Path.Combine(rom.PathRomFS, "bin", "event", "script_id_record_release.bin"); var text = FlatDumper.GetTable(file, z => z.Table); var path = GetPath("scriptCommands.txt"); File.WriteAllText(path, text); @@ -1044,7 +1042,7 @@ public void DumpScriptID() public void DumpEventTriggers() { - var eventTriggerDir = Path.Combine(ROM.PathRomFS, "bin", "event", "event_progress", "trigger"); + var eventTriggerDir = Path.Combine(rom.PathRomFS, "bin", "event", "event_progress", "trigger"); var eventTriggerFiles = Directory.EnumerateFiles(eventTriggerDir, "*", SearchOption.AllDirectories).Where(p => Path.GetExtension(p) == ".bin"); const string outFolder = "event_trigger"; @@ -1083,7 +1081,7 @@ public void DumpEventTriggers() public void DumpMoveShop() { - var file = ROM.GetFile(GameFile.MoveShop).FilePath; + var file = rom.GetFile(GameFile.MoveShop).FilePath; var result = FlatDumper.GetTable(file!, z => z.Table); File.WriteAllText(GetPath("MoveShop.csv"), result); } diff --git a/pkNX.WinForms/Dumping/GameDumperSV.cs b/pkNX.WinForms/Dumping/GameDumperSV.cs index dd50d261..d76ac2b8 100644 --- a/pkNX.WinForms/Dumping/GameDumperSV.cs +++ b/pkNX.WinForms/Dumping/GameDumperSV.cs @@ -20,15 +20,13 @@ namespace pkNX.WinForms; -public class GameDumperSV +public class GameDumperSV(GameManagerSV rom) { - private readonly GameManagerSV ROM; - public GameDumperSV(GameManagerSV rom) => ROM = rom; public string DumpFolder { get { - var parent = Directory.GetParent(ROM.PathRomFS) ?? throw new DirectoryNotFoundException($"Unable to find parent directory of {ROM.PathRomFS}"); + var parent = Directory.GetParent(rom.PathRomFS) ?? throw new DirectoryNotFoundException($"Unable to find parent directory of {rom.PathRomFS}"); return Path.Combine(parent.FullName, "Dump"); } } @@ -40,7 +38,7 @@ public string DumpFolder /// Message string language names/folders which contain the text localizations. /// private static readonly string[] LanguageEnglishNames = - { + [ "JPN", "JPN_KANJI", "English", @@ -51,17 +49,17 @@ public string DumpFolder "Korean", "Simp_Chinese", "Trad_Chinese", - }; + ]; private string[] GetCommonText(string name, string lang, TextConfig cfg) { - var data = ROM.GetPackedFile($"message/dat/{lang}/common/{name}.dat"); + var data = rom.GetPackedFile($"message/dat/{lang}/common/{name}.dat"); return new TextFile(data, cfg).Lines; } private AHTB GetCommonAHTB(string name, string lang) { - var data = ROM.GetPackedFile($"message/dat/{lang}/common/{name}.tbl"); + var data = rom.GetPackedFile($"message/dat/{lang}/common/{name}.tbl"); return new AHTB(data); } @@ -237,8 +235,8 @@ public void DumpPersonal() const string personalPath = "avalon/data/personal_array.bin"; Dump(personalPath, z => z.Table); - var perbin = ROM.GetPackedFile(personalPath); - var pt = new PersonalTable9SV(new FakeContainer(new[] { perbin })); + var perbin = rom.GetPackedFile(personalPath); + var pt = new PersonalTable9SV(new FakeContainer([perbin])); var bin = pt.Write(); var path2 = GetPath("pkhex", "personal_sv"); @@ -268,7 +266,7 @@ public void DumpPersonal() private void RipPersonal(PersonalTable9SV pt, string lang) { - var cfg = new TextConfig(ROM.Game); + var cfg = new TextConfig(rom.Game); string[] GetText(string name) => GetCommonText(name, lang, cfg); var specNames = GetText("monsname"); var moveNames = GetText("wazaname"); @@ -422,7 +420,7 @@ static List Insert(IList learn, sbyte level, { var list = learn.ToList(); list.Add(new PersonalInfoMove { Level = level, Move = (ushort)move }); - return list.OrderBy(z => z.Level).ToList(); + return [.. list.OrderBy(z => z.Level)]; } static byte[] Write(IList fbLearnset) @@ -470,7 +468,7 @@ private void DumpGrow() { // FlatBuffer with a single field: uint[101][8] // (8 inlined fields, with each having 101 fields). Same exp growth curve as prior games. - var growTable = ROM.GetPackedFile("avalon/data/growTable.bin").AsSpan(); + var growTable = rom.GetPackedFile("avalon/data/growTable.bin").AsSpan(); for (int i = 0; i < 8; i++) { // Just read the inline structs as bytes out to individual files. @@ -644,7 +642,7 @@ public void DumpBalloon() public void DumpEncounters() { - var dumper = new EncounterDumperSV(ROM); + var dumper = new EncounterDumperSV(rom); var path = GetPath("encounters"); var cfg = new TextConfig(GameVersion.SV); var specNamesInternal = GetCommonText("monsname", "English", cfg); @@ -709,9 +707,9 @@ public void DumpRaid() } var outPath = GetPath("pkhex"); - TeraRaidRipper.DumpRaids(ROM, mainRaids, outPath, "raidTotal.txt", "encounter_gem_paldea.pkl"); - TeraRaidRipper.DumpRaids(ROM, su1Raids, outPath, "raidTotalKitakami.txt", "encounter_gem_kitakami.pkl"); - TeraRaidRipper.DumpRaids(ROM, su2Raids, outPath, "raidTotalBlueberry.txt", "encounter_gem_blueberry.pkl"); + TeraRaidRipper.DumpRaids(rom, mainRaids, outPath, "raidTotal.txt", "encounter_gem_paldea.pkl"); + TeraRaidRipper.DumpRaids(rom, su1Raids, outPath, "raidTotalKitakami.txt", "encounter_gem_kitakami.pkl"); + TeraRaidRipper.DumpRaids(rom, su2Raids, outPath, "raidTotalBlueberry.txt", "encounter_gem_blueberry.pkl"); } public void DumpMoves() @@ -841,7 +839,7 @@ public void DumpTrainers() Dump("world/data/trainer/trdata/trdata_array.bfbs", z => z.Table); Dump("world/data/trainer/trenv/trenv_array.bfbs", z => z.Table); Dump("world/data/trainer/trtype/trtype_array.bfbs", z => z.Table); - DumpX("world/data/trainer/trdata/trdata_array.bfbs", z => z.Table, z => new[] { z.Poke1, z.Poke2, z.Poke3, z.Poke4, z.Poke5, z.Poke6 }); + DumpX("world/data/trainer/trdata/trdata_array.bfbs", z => z.Table, z => [z.Poke1, z.Poke2, z.Poke3, z.Poke4, z.Poke5, z.Poke6]); } public void DumpCooking() @@ -875,7 +873,7 @@ public void DumpCooking() foreach (var lang in LanguageEnglishNames) { var types = GetCommonText("typename", lang, config); - var data = ROM.GetPackedFile("world/data/cooking/FoodPowerCombo/FoodPowerCombo_array.bin"); + var data = rom.GetPackedFile("world/data/cooking/FoodPowerCombo/FoodPowerCombo_array.bin"); var fb = FlatBufferConverter.DeserializeFrom(data); var table = fb.Table; var path = GetPath(lang, "foodCombo.txt"); @@ -974,14 +972,14 @@ private void DumpClubroom() private TTable Get(ulong hash) where TTable : class, IFlatBufferSerializable { - var bin = ROM.GetPackedFile(hash); + var bin = rom.GetPackedFile(hash); return Get(bin); } private TTable Get(string f) where TTable : class, IFlatBufferSerializable { - var bin = ROM.GetPackedFile(f.Replace("bfbs", "bin")); + var bin = rom.GetPackedFile(f.Replace("bfbs", "bin")); return Get(bin); } @@ -991,7 +989,7 @@ private TTable Get(string f) where TTable : class, IFlatBufferSerializable where TEntry : notnull { - var bin = ROM.GetPackedFile(f.Replace("bfbs", "bin")); + var bin = rom.GetPackedFile(f.Replace("bfbs", "bin")); var path = GetPath("raw", f.Replace('/', Path.DirectorySeparatorChar)); DumpSel(sel, prefix, bin, path); } @@ -1012,7 +1010,7 @@ private TTable Get(string f) where TEntry : class where TSub : notnull { - var bin = ROM.GetPackedFile(f.Replace("bfbs", "bin")); + var bin = rom.GetPackedFile(f.Replace("bfbs", "bin")); var flat = FlatBufferConverter.DeserializeFrom(bin); var path = GetPath("raw", f.Replace('/', Path.DirectorySeparatorChar)); @@ -1032,7 +1030,7 @@ private TTable Get(string f) private void DumpJson(string f) where T : class, IFlatBufferSerializable { - var bin = ROM.GetPackedFile(f.Replace("bfbs", "bin")); + var bin = rom.GetPackedFile(f.Replace("bfbs", "bin")); var flat = FlatBufferConverter.DeserializeFrom(bin); var path = GetPath("raw", f.Replace('/', Path.DirectorySeparatorChar)); @@ -1373,7 +1371,7 @@ private void DumpPackedFile(string f) if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); - var data = ROM.GetPackedFile(f); + var data = rom.GetPackedFile(f); File.WriteAllBytes(path, data); var ext = Path.GetExtension(f); @@ -1388,7 +1386,7 @@ private void DumpPackedFile(string f) public void DumpHashReflectionBFBS() { ulong[] files = - { + [ 0x6B3C7A393C4806BB, 0xABA6B518253AEEEB, 0xCC942F5FDA362FF3, @@ -1398,10 +1396,10 @@ public void DumpHashReflectionBFBS() 0xDB862D9BC4E09F63, 0xDB0A4CEB9BE77E1E, 0x2C432AF938EDCF99, - }; + ]; foreach (var f in files) { - if (!ROM.HasFile(f)) + if (!rom.HasFile(f)) continue; var path = GetPath("hashFile", f.ToString("X16")); @@ -1409,7 +1407,7 @@ public void DumpHashReflectionBFBS() if (!Directory.Exists(dir)) Directory.CreateDirectory(dir); - var data = ROM.GetPackedFile(f); + var data = rom.GetPackedFile(f); File.WriteAllBytes(path, data); try { @@ -1425,18 +1423,18 @@ public void DumpHashReflectionBFBS() public void DumpArchives() { - TrinityPakExtractor.DumpArchives(ROM.PathRomFS, GetPath(DumpArchive)); + TrinityPakExtractor.DumpArchives(rom.PathRomFS, GetPath(DumpArchive)); Debug.WriteLine("Loaded"); } public void DumpDistributionRaids(string path) { - TeraRaidRipper.DumpDistributionRaids(ROM, path); + TeraRaidRipper.DumpDistributionRaids(rom, path); } public void DumpDeliveryOutbreaks(string path) { var dump = GetPath("encounters"); - MassOutbreakRipper.DumpDeliveryOutbreaks(ROM, path, dump); + MassOutbreakRipper.DumpDeliveryOutbreaks(rom, path, dump); } } diff --git a/pkNX.WinForms/Dumping/GameDumperSWSH.cs b/pkNX.WinForms/Dumping/GameDumperSWSH.cs index cf1bd60d..e1cde857 100644 --- a/pkNX.WinForms/Dumping/GameDumperSWSH.cs +++ b/pkNX.WinForms/Dumping/GameDumperSWSH.cs @@ -12,17 +12,15 @@ namespace pkNX.WinForms; -public class GameDumperSWSH +public class GameDumperSWSH(GameManagerSWSH rom) { - private readonly GameManagerSWSH ROM; - public GameDumperSWSH(GameManagerSWSH rom) => ROM = rom; public string DumpFolder { get { - var parent = Directory.GetParent(ROM.PathRomFS); + var parent = Directory.GetParent(rom.PathRomFS); if (parent is null) - throw new DirectoryNotFoundException($"Unable to find parent directory of {ROM.PathRomFS}"); + throw new DirectoryNotFoundException($"Unable to find parent directory of {rom.PathRomFS}"); return Path.Combine(parent.FullName, "Dump"); } } @@ -52,8 +50,8 @@ private string GetPath(string parent, string path) public void DumpDummiedMoves() { // get dummied moves - var moveNames = ROM.GetStrings(TextName.MoveNames); - var moveDesc = ROM.GetStrings(TextName.MoveFlavor); + var moveNames = rom.GetStrings(TextName.MoveNames); + var moveDesc = rom.GetStrings(TextName.MoveFlavor); var dummy = moveDesc[237]; // hidden power is kill var tuple = moveNames @@ -67,33 +65,33 @@ public void DumpDummiedMoves() public void DumpPokeInfo() { - var s = ROM.GetStrings(TextName.SpeciesNames); + var s = rom.GetStrings(TextName.SpeciesNames); - var eggdata = ROM.GetFilteredFolder(GameFile.EggMoves); + var eggdata = rom.GetFilteredFolder(GameFile.EggMoves); var egg = EggMoves7.GetArray(eggdata.GetFiles().Result); - var pt = ROM.Data.PersonalData; + var pt = rom.Data.PersonalData; var altForms = pt.GetFormList(s); var entryNames = pt.GetPersonalEntryList(altForms, s, out _, out _); - var moveNames = ROM.GetStrings(TextName.MoveNames); + var moveNames = rom.GetStrings(TextName.MoveNames); var pd = new PersonalDumper { Colors = Enum.GetNames(typeof(PokeColor)), EggGroups = Enum.GetNames(typeof(EggGroup)), EntryEggMoves = egg, - EntryLearnsets = ROM.Data.LevelUpData.LoadAll(), + EntryLearnsets = rom.Data.LevelUpData.LoadAll(), EntryNames = entryNames, ExpGroups = Enum.GetNames(typeof(EXPGroup)), - Evos = ROM.Data.EvolutionData.LoadAll(), + Evos = rom.Data.EvolutionData.LoadAll(), - Abilities = ROM.GetStrings(TextName.AbilityNames), - Items = ROM.GetStrings(TextName.ItemNames), + Abilities = rom.GetStrings(TextName.AbilityNames), + Items = rom.GetStrings(TextName.ItemNames), Moves = moveNames, - Types = ROM.GetStrings(TextName.TypeNames), - Species = ROM.GetStrings(TextName.SpeciesNames), - ZukanA = ROM.GetStrings(TextName.PokedexEntry1), - ZukanB = ROM.GetStrings(TextName.PokedexEntry2), + Types = rom.GetStrings(TextName.TypeNames), + Species = rom.GetStrings(TextName.SpeciesNames), + ZukanA = rom.GetStrings(TextName.PokedexEntry1), + ZukanB = rom.GetStrings(TextName.PokedexEntry2), TMIndexes = Legal.TMHM_SWSH, TRIndexes = Legal.TR_SWSH, }; @@ -109,11 +107,11 @@ public void DumpPokeInfo() File.WriteAllLines(outLearn, moveLines); } - private static readonly string[] ahtbext = { ".tbl", ".hsh" }; + private static readonly string[] ahtbext = [".tbl", ".hsh"]; public void DumpAHTB() { - var files = Directory.EnumerateFiles(ROM.PathRomFS, "*", SearchOption.AllDirectories) + var files = Directory.EnumerateFiles(rom.PathRomFS, "*", SearchOption.AllDirectories) .Where(z => ahtbext.Contains(Path.GetExtension(z))); var result = new HashSet(); @@ -142,7 +140,7 @@ public void DumpAHTB() } } - var paks = Directory.EnumerateFiles(ROM.PathRomFS, "*", SearchOption.AllDirectories) + var paks = Directory.EnumerateFiles(rom.PathRomFS, "*", SearchOption.AllDirectories) .Where(z => Path.GetExtension(z) == ".gfpak"); foreach (var f in paks) { @@ -205,9 +203,9 @@ private TrainerEditor GetTrainerEditor() ReadTrainer = data => new TrainerData8(data), ReadTeam = TrainerPoke8.ReadTeam, WriteTeam = TrainerPoke8.WriteTeam, - TrainerData = ROM.GetFilteredFolder(GameFile.TrainerSpecData), - TrainerPoke = ROM.GetFilteredFolder(GameFile.TrainerSpecPoke), - TrainerClass = ROM.GetFilteredFolder(GameFile.TrainerSpecClass), + TrainerData = rom.GetFilteredFolder(GameFile.TrainerSpecData), + TrainerPoke = rom.GetFilteredFolder(GameFile.TrainerSpecPoke), + TrainerClass = rom.GetFilteredFolder(GameFile.TrainerSpecClass), }; editor.Initialize(); return editor; @@ -215,10 +213,10 @@ private TrainerEditor GetTrainerEditor() public void DumpTrainers() { - var trc = ROM.GetStrings(TextName.TrainerClasses); - var trn = ROM.GetStrings(TextName.TrainerNames); - var m = ROM.GetStrings(TextName.MoveNames); - var s = ROM.GetStrings(TextName.SpeciesNames); + var trc = rom.GetStrings(TextName.TrainerClasses); + var trn = rom.GetStrings(TextName.TrainerNames); + var m = rom.GetStrings(TextName.MoveNames); + var s = rom.GetStrings(TextName.SpeciesNames); var tr = GetTrainerEditor(); var result = new List(); @@ -239,7 +237,7 @@ public void DumpTrainers() for (int j = 0; j < t.Team.Count; j++) { IEnumerable moves = t.Team[j].Moves.Where(z => z != 0).Select(z => m[z]).ToArray(); - if (!moves.Any()) moves = new[] { "Default Level Up" }; + if (!moves.Any()) moves = ["Default Level Up"]; int form = t.Team[j].Form; var formstr = form != 0 ? $"-{form}" : ""; var str = $"{j + 1}: Lv{t.Team[j].Level:00} {s[t.Team[j].Species]}{formstr} : {string.Join(" / ", moves)}"; @@ -257,8 +255,8 @@ public void DumpTrainers() public void DumpBattleTower() { - var pk_table_path = ROM.GetFile(GameFile.FacilityPokeNormal)[0]; - var tr_table_path = ROM.GetFile(GameFile.FacilityTrainerNormal)[0]; + var pk_table_path = rom.GetFile(GameFile.FacilityPokeNormal)[0]; + var tr_table_path = rom.GetFile(GameFile.FacilityTrainerNormal)[0]; var pokes = FlatBufferConverter.DeserializeFrom(pk_table_path); var trainers = FlatBufferConverter.DeserializeFrom(tr_table_path); @@ -271,7 +269,7 @@ public void DumpBattleTower() public void DumpItems() { - var items = ROM.GetFile(GameFile.ItemStats); + var items = rom.GetFile(GameFile.ItemStats); var file = items[0]; var array = Item8.GetArray(file); var groups = array.GroupBy(z => z.Pouch); @@ -283,7 +281,7 @@ public void DumpItems() File.WriteAllText(path, string.Join(", ", IDs.Select(z => $"{z:000}"))); } - var names = ROM.GetStrings(TextName.ItemNames); + var names = rom.GetStrings(TextName.ItemNames); var lines = TableUtil.GetNamedTypeTable(array, names, "Items"); var table = GetPath("ItemData.txt"); var bin = GetPath("ItemData.bin"); @@ -293,10 +291,10 @@ public void DumpItems() public void DumpMoves() { - var dir = Path.Combine(ROM.PathRomFS, "bin", "pml", "waza"); + var dir = Path.Combine(rom.PathRomFS, "bin", "pml", "waza"); var files = Directory.GetFiles(dir); var moves = FlatBufferConverter.DeserializeFrom(files); - var names = ROM.GetStrings(TextName.MoveNames); + var names = rom.GetStrings(TextName.MoveNames); var lines = TableUtil.GetNamedTypeTable(moves, names, "Moves"); var table = GetPath("MoveData.txt"); File.WriteAllText(table, lines); @@ -304,7 +302,7 @@ public void DumpMoves() public void DumpLearnsetBinary() { - var data = ROM.Data.LevelUpData.LoadAll() + var data = rom.Data.LevelUpData.LoadAll() .Cast().Select(z => z.WriteAsLearn6()).ToArray(); var mini = MiniUtil.PackMini(data, "ss"); var bin = GetPath(Path.Combine("bin", "lvlmove_swsh.pkl")); @@ -314,7 +312,7 @@ public void DumpLearnsetBinary() public void DumpEggBinary() { // format matches past gen and PKHeX's expected format - var data = ROM.GetFilteredFolder(GameFile.EggMoves).GetFiles().Result; + var data = rom.GetFilteredFolder(GameFile.EggMoves).GetFiles().Result; var mini = MiniUtil.PackMini(data, "ss"); var bin = GetPath(Path.Combine("bin", "eggmove_swsh.pkl")); File.WriteAllBytes(bin, mini); @@ -323,7 +321,7 @@ public void DumpEggBinary() public void DumpEvolutionBinary() { // format matches past gen and PKHeX's expected format - var data = ROM.GetFilteredFolder(GameFile.Evolutions).GetFiles().Result; + var data = rom.GetFilteredFolder(GameFile.Evolutions).GetFiles().Result; var mini = MiniUtil.PackMini(data, "ss"); var bin = GetPath(Path.Combine("bin", "evos_ss.pkl")); File.WriteAllBytes(bin, mini); @@ -331,8 +329,8 @@ public void DumpEvolutionBinary() public void DumpGifts() { - var speciesNames = ROM.GetStrings(TextName.SpeciesNames); - var data = ROM.GetFile(GameFile.EncounterTableGift)[0]; + var speciesNames = rom.GetStrings(TextName.SpeciesNames); + var data = rom.GetFile(GameFile.EncounterTableGift)[0]; var gifts = FlatBufferConverter.DeserializeFrom(data); var table = TableUtil.GetTable(gifts.Table); var fn = GetPath("Gifts.txt"); @@ -344,8 +342,8 @@ public void DumpGifts() public void DumpStatic() { - var speciesNames = ROM.GetStrings(TextName.SpeciesNames); - var data = ROM.GetFile(GameFile.EncounterTableStatic)[0]; + var speciesNames = rom.GetStrings(TextName.SpeciesNames); + var data = rom.GetFile(GameFile.EncounterTableStatic)[0]; var statics = FlatBufferConverter.DeserializeFrom(data); var table = TableUtil.GetTable(statics.Table); var fn = GetPath("StaticEncounters.txt"); @@ -357,14 +355,14 @@ public void DumpStatic() public void DumpWilds() { - var wildpak = ROM.GetFile(GameFile.NestData)[0]; + var wildpak = rom.GetFile(GameFile.NestData)[0]; var data_table = new GFPack(wildpak); var encount_sw = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("encount_k.bin")); var encount_symbol_sw = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("encount_symbol_k.bin")); var encount_sh = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("encount_t.bin")); var encount_symbol_sh = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("encount_symbol_t.bin")); - var species = ROM.GetStrings(TextName.SpeciesNames); + var species = rom.GetStrings(TextName.SpeciesNames); var zones = SWSHInfo.Zones; var subtables = Enum.GetNames(typeof(SWSHEncounterType)).Select(z => z.Replace("_", " ")).ToArray(); @@ -381,9 +379,9 @@ public void DumpWilds() public void DumpPlacement() { - var statics = FlatBufferConverter.DeserializeFrom(ROM.GetFile(GameFile.EncounterTableStatic)[0]); - var placement = new GFPack(ROM.GetFile(GameFile.Placement)[0]); - var species_names = ROM.GetStrings(TextName.SpeciesNames); + var statics = FlatBufferConverter.DeserializeFrom(rom.GetFile(GameFile.EncounterTableStatic)[0]); + var placement = new GFPack(rom.GetFile(GameFile.Placement)[0]); + var species_names = rom.GetStrings(TextName.SpeciesNames); var weathers = Enum.GetNames(typeof(SWSHEncounterType)).Select(z => z.Replace("_", " ")).ToArray(); var area_names = new AHTB(placement.GetDataFileName("AreaNameHashTable.tbl")).ToDictionary(); var zone_names = new AHTB(placement.GetDataFileName("ZoneNameHashTable.tbl")).ToDictionary(); @@ -425,10 +423,10 @@ public void DumpPlacement() public void DumpNestEntries() { - var speciesNames = ROM.GetStrings(TextName.SpeciesNames); - var itemNames = ROM.GetStrings(TextName.ItemNames); - var moveNames = ROM.GetStrings(TextName.MoveNames); - var wildpak = ROM.GetFile(GameFile.NestData)[0]; + var speciesNames = rom.GetStrings(TextName.SpeciesNames); + var itemNames = rom.GetStrings(TextName.ItemNames); + var moveNames = rom.GetStrings(TextName.MoveNames); + var wildpak = rom.GetFile(GameFile.NestData)[0]; var data_table = new GFPack(wildpak); var nest_encounts = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("nest_hole_encount.bin")); // var nest_levels = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("nest_hole_level.bin")); @@ -451,7 +449,7 @@ public void DumpNestEntries() File.WriteAllLines(path2, result); } - var common = nestHex[0].Intersect(nestHex[1]).Where(z => z.StartsWith(" ")).Distinct(); + var common = nestHex[0].Intersect(nestHex[1]).Where(z => z.StartsWith(' ')).Distinct(); var sword = nestHex[0].Where(z => !nestHex[1].Contains(z)).Distinct(); var shield = nestHex[1].Where(z => !nestHex[0].Contains(z)).Distinct(); @@ -469,15 +467,15 @@ public void DumpNestEntries() public void DumpGalarDex() { - var pt = ROM.Data.PersonalData; - var s = ROM.GetStrings(TextName.SpeciesNames); + var pt = rom.Data.PersonalData; + var s = rom.GetStrings(TextName.SpeciesNames); var galar = new List(); var armor = new List(); var crown = new List(); var dexit = new List(); var foreign = new List(); - for (int i = 1; i <= ROM.Info.MaxSpeciesID; i++) + for (int i = 1; i <= rom.Info.MaxSpeciesID; i++) { var p = (IPersonalInfoSWSH)pt[i]; bool any = false; @@ -523,8 +521,8 @@ public void DumpFlavorText() { IEnumerable Zip(TextName name, TextName flavor) { - var n = ROM.GetStrings(name); - var f = ROM.GetStrings(flavor); + var n = rom.GetStrings(name); + var f = rom.GetStrings(flavor); return n.Select((z, i) => $"{z}\t{f[i].Replace("\\n", " ")}"); } @@ -543,9 +541,9 @@ IEnumerable Zip(TextName name, TextName flavor) public void DumpEggEntries() { - var eggdata = ROM.GetFilteredFolder(GameFile.EggMoves).GetFiles().Result; + var eggdata = rom.GetFilteredFolder(GameFile.EggMoves).GetFiles().Result; var egg = EggMoves7.GetArray(eggdata); - var moves = ROM.GetStrings(TextName.MoveNames); + var moves = rom.GetStrings(TextName.MoveNames); var lines = egg.Select((z, i) => $"{i:000}\t{z.FormTableIndex:0000}\t{string.Join(", ", z.Moves.Select(m => moves[m]))}"); var bin = GetPath(Path.Combine("eggEntries.txt")); File.WriteAllLines(bin, lines); @@ -553,13 +551,13 @@ public void DumpEggEntries() public void DumpMaxDens() { - var file = ROM.GetFile(GameFile.DynamaxDens)[0]; + var file = rom.GetFile(GameFile.DynamaxDens)[0]; var encounters = FlatBufferConverter.DeserializeFrom(file); var lines = TableUtil.GetTable(encounters.Table); var table = GetPath("MaxDens.txt"); File.WriteAllText(table, lines); - var names = ROM.GetStrings(TextName.SpeciesNames); + var names = rom.GetStrings(TextName.SpeciesNames); var pkhex = encounters.Table.Select(z => z.GetSummary(names)); File.WriteAllText(GetPath("MaxDens_hex.txt"), string.Join(Environment.NewLine, pkhex)); } @@ -583,10 +581,10 @@ public static byte[] GetDistributionContents(string path, out int index) public void DumpDistributionNestEntries(string path) { - var speciesNames = ROM.GetStrings(TextName.SpeciesNames); - var itemNames = ROM.GetStrings(TextName.ItemNames); - var moveNames = ROM.GetStrings(TextName.MoveNames); - var wildpak = ROM.GetFile(GameFile.NestData)[0]; + var speciesNames = rom.GetStrings(TextName.SpeciesNames); + var itemNames = rom.GetStrings(TextName.ItemNames); + var moveNames = rom.GetStrings(TextName.MoveNames); + var wildpak = rom.GetFile(GameFile.NestData)[0]; var data_table = new GFPack(wildpak); var nest_drops = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("nest_hole_drop_rewards.bin")); var nest_bonus = FlatBufferConverter.DeserializeFrom(data_table.GetDataFileName("nest_hole_bonus_rewards.bin")); @@ -643,7 +641,7 @@ void DumpDistIfExists(string filePath, string dest) File.WriteAllLines(path2, result); } - var common = nestHex[0].Intersect(nestHex[1]).Where(z => z.StartsWith(" ")).Distinct(); + var common = nestHex[0].Intersect(nestHex[1]).Where(z => z.StartsWith(' ')).Distinct(); var sword = nestHex[0].Where(z => !nestHex[1].Contains(z)).Distinct(); var shield = nestHex[1].Where(z => !nestHex[0].Contains(z)).Distinct(); @@ -684,7 +682,7 @@ private void DumpHexCrystal(NestHoleCrystalEncounterArchive dai_encounts, string File.WriteAllLines(path2, result); } - var common = nestHex[0].Intersect(nestHex[1]).Where(z => z.StartsWith(" ")).Distinct(); + var common = nestHex[0].Intersect(nestHex[1]).Where(z => z.StartsWith(' ')).Distinct(); var sword = nestHex[0].Where(z => !nestHex[1].Contains(z)).Distinct(); var shield = nestHex[1].Where(z => !nestHex[0].Contains(z)).Distinct(); @@ -693,11 +691,11 @@ private void DumpHexCrystal(NestHoleCrystalEncounterArchive dai_encounts, string File.WriteAllLines(GetPath("hex_nestCrystalShield.txt"), shield); } - private static readonly int[] LanguageIndexes = { 0, 2, 3, 4, 5, 6, 7, 8, 9 }; - private static readonly string[] LanguageCodes = { "ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2" }; + private static ReadOnlySpan LanguageIndexes => [0, 2, 3, 4, 5, 6, 7, 8, 9]; + private static readonly string[] LanguageCodes = ["ja", "en", "fr", "it", "de", "es", "ko", "zh", "zh2"]; private static readonly string[] LanguageNames = - { + [ "カタカナ", "漢字", "English", @@ -708,11 +706,11 @@ private void DumpHexCrystal(NestHoleCrystalEncounterArchive dai_encounts, string "한국", "汉字简化方案", "漢字簡化方案", - }; + ]; private string[] GetStoryLines(string str) { - var strpath = ((FolderContainer)ROM[GameFile.StoryText]).FilePath; + var strpath = ((FolderContainer)rom[GameFile.StoryText]).FilePath; if (strpath is null) throw new ArgumentException("StoryText not found in ROM"); var file = Path.Combine(strpath, str); @@ -722,13 +720,13 @@ private string[] GetStoryLines(string str) private void ChangeLanguage(int index) { - ROM.Language = index; - ROM.ResetText(); + rom.Language = index; + rom.ResetText(); } public void DumpStrings() { - int lang = ROM.Language; + int lang = rom.Language; var indexes = new[] { 0, 2, 3, 4, 5, 6, 7, 8, 9 }; for (int i = 0; i < indexes.Length; i++) { @@ -758,7 +756,7 @@ private void DumpStrings(string code, string name, int index) void DumpStringSet(TextName t, string file) { - var strings = ROM.GetStrings(t); + var strings = rom.GetStrings(t); var fn = $"text_{file}_{code}.txt"; var folder = Path.Combine(code, fn); @@ -770,7 +768,7 @@ void DumpStringSet(TextName t, string file) public void DumpFormNames() { - int lang = ROM.Language; + int lang = rom.Language; for (int i = 0; i < LanguageIndexes.Length; i++) { var code = LanguageCodes[i]; @@ -787,7 +785,7 @@ private void DumpForms(string code, string name, int index) Console.WriteLine($"Dumping strings for {name}."); ChangeLanguage(index); - var strings = ROM.GetStrings(TextName.Forms); + var strings = rom.GetStrings(TextName.Forms); var indexes = new[] { @@ -834,7 +832,7 @@ private void DumpForms(string code, string name, int index) public void DumpRibbonNames() { - int lang = ROM.Language; + int lang = rom.Language; var indexes = new[] { 0, 2, 3, 4, 5, 6, 7, 8, 9 }; for (int i = 0; i < indexes.Length; i++) { @@ -852,7 +850,7 @@ private void DumpRibbonNames(string code, string name, int index) Console.WriteLine($"Dumping strings for {name}."); ChangeLanguage(index); - var strings = ROM.GetStrings(TextName.RibbonMark); + var strings = rom.GetStrings(TextName.RibbonMark); var lines = strings.Skip(148).Take(48).ToArray(); var fn = $"NewRibbonMarks_{code}.txt"; @@ -864,8 +862,8 @@ private void DumpRibbonNames(string code, string name, int index) public void DumpTrades() { - var speciesNames = ROM.GetStrings(TextName.SpeciesNames); - var data = ROM.GetFile(GameFile.EncounterTableTrade)[0]; + var speciesNames = rom.GetStrings(TextName.SpeciesNames); + var data = rom.GetFile(GameFile.EncounterTableTrade)[0]; var trades = FlatBufferConverter.DeserializeFrom(data); var table = TableUtil.GetTable(trades.Table); var fn = GetPath("Trades.txt"); @@ -874,7 +872,7 @@ public void DumpTrades() var f2 = GetPath("TradesPKHeX.txt"); File.WriteAllLines(f2, trades.Table.Select(z => z.GetSummary(speciesNames))); - int lang = ROM.Language; + int lang = rom.Language; var indexes = new[] { 0, 2, 3, 4, 5, 6, 7, 8, 9 }; for (int i = 0; i < indexes.Length; i++) { @@ -914,7 +912,7 @@ private void DumpTradeNames(string code, string name, int index) public void DumpMemoryStrings() { - int lang = ROM.Language; + int lang = rom.Language; var indexes = new[] { 0, 2, 3, 4, 5, 6, 7, 8, 9 }; for (int i = 0; i < indexes.Length; i++) { diff --git a/pkNX.WinForms/Dumping/MassOutbreakRipper.cs b/pkNX.WinForms/Dumping/MassOutbreakRipper.cs index 9a9a64ad..6fba12ac 100644 --- a/pkNX.WinForms/Dumping/MassOutbreakRipper.cs +++ b/pkNX.WinForms/Dumping/MassOutbreakRipper.cs @@ -94,6 +94,9 @@ private static void DumpDeliveryOutbreakData(IFileInternal ROM, string path) EncounterIndex = Encounters.Count; } + private const ulong LastDistribution2 = 2023120801; + private const ulong FirstDistribution = 20230929001; // oddball which didn't use XX for day (instead ###) + private static void ExportPickle(string dump, IEnumerable encounters) { var dest = Path.Combine(dump, "encounter_outbreak_paldea.pkl"); @@ -108,7 +111,7 @@ private static void ExportPickle(string dump, IEnumerable encou foreach (var (range, permit) in ordered) { // pre-3.0.0 BCAT - if ((enc.Parent.Poke.ID < 2023120801 || enc.Parent.Poke.ID == 20230929001) && enc.MetBase == 170) + if (enc.Parent.Poke.ID is (< LastDistribution2) or FirstDistribution && enc.MetBase == 170) continue; WriteEncounter(enc, bw, range, permit); } @@ -166,7 +169,7 @@ private static void ScanAssertions(params DeliveryOutbreakPokeDataArray[] obs) { foreach (var o in ob.Table) { - if (o.EnableRarePercentage && o.RarePercentage == 100.0f) // Likely will never be 100%, so if we ever see this, change the check to assert that instead. + if (o is { EnableRarePercentage: true, RarePercentage: 100.0f }) // Likely will never be 100%, so if we ever see this, change the check to assert that instead. throw new Exception($"Elevated shiny rate {o.RarePercentage}%!"); if (o.EnableScaleRange) throw new Exception($"Enforced scale range {o.MinScale}-{o.MaxScale}!"); @@ -193,7 +196,7 @@ private static void ScanAssertions(params DeliveryOutbreakPokeDataArray[] obs) { areas = areas.Where(z => z.Value.AdjustEncLv != 0) .ToDictionary(z => z.Key, z => z.Value); - areaNames = areas.Keys.ToList(); + areaNames = [.. areas.Keys]; } foreach (var point in points) { @@ -234,7 +237,7 @@ private static void ScanAssertions(params DeliveryOutbreakPokeDataArray[] obs) throw new Exception("No met flags found for encounter!"); // pre-3.0.0 BCAT - if ((e.Poke.ID < 2023120801 || e.Poke.ID == 20230929001) && e.MetBase == 170) + if (e.Poke.ID is (< LastDistribution2) or FirstDistribution && e.MetBase == 170) continue; } @@ -392,7 +395,7 @@ void TryAdd(ulong ID, short rate) ret.Add(new CachedOutbreak { ZoneID = outbreak.ZoneID, Poke = poke }); } } - return ret.ToArray(); + return [.. ret]; } private static byte[] GetDistributionContents(string path) => File.ReadAllBytes(path); @@ -476,7 +479,7 @@ private static void DumpPretty(IFileInternal ROM, string dir, bool locations) var parent = enc.Parent; // pre-3.0.0 BCAT - if ((parent.Poke.ID < 2023120801 || parent.Poke.ID == 20230929001) && parent.MetBase == 170) + if (parent.Poke.ID is (< LastDistribution2) or FirstDistribution && parent.MetBase == 170) continue; WriteParent(ROM, sw, parent); diff --git a/pkNX.WinForms/Dumping/SV/EncounterDumperSV.cs b/pkNX.WinForms/Dumping/SV/EncounterDumperSV.cs index 8b57a9c8..bb24bbff 100644 --- a/pkNX.WinForms/Dumping/SV/EncounterDumperSV.cs +++ b/pkNX.WinForms/Dumping/SV/EncounterDumperSV.cs @@ -11,15 +11,12 @@ namespace pkNX.WinForms; -public class EncounterDumperSV +public class EncounterDumperSV(IFileInternal rom) { - private readonly IFileInternal ROM; private const float tolX = 30f; private const float tolY = 30f; private const float tolZ = 30f; - public EncounterDumperSV(IFileInternal rom) => ROM = rom; - private static ReadOnlySpan AllMaps => [ PaldeaFieldIndex.Paldea, @@ -34,18 +31,18 @@ public class EncounterDumperSV if (!Directory.Exists(path)) Directory.CreateDirectory(path); - var field = new PaldeaFieldModel(ROM); - var scene = new PaldeaSceneModel(ROM, field); - var fsym = new PaldeaFixedSymbolModel(ROM); - var csym = new PaldeaCoinSymbolModel(ROM); - var mlEncPoints = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/point_data/point_data/encount_data_100000.bin")); - var alEncPoints = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/point_data/point_data/encount_data_atlantis.bin")); - var su1EncPoints = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/point_data/point_data/encount_data_su1.bin")); - var su2EncPoints = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/point_data/point_data/encount_data_su2.bin")); + var field = new PaldeaFieldModel(rom); + var scene = new PaldeaSceneModel(rom, field); + var fsym = new PaldeaFixedSymbolModel(rom); + var csym = new PaldeaCoinSymbolModel(rom); + var mlEncPoints = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/encount/point_data/point_data/encount_data_100000.bin")); + var alEncPoints = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/encount/point_data/point_data/encount_data_atlantis.bin")); + var su1EncPoints = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/encount/point_data/point_data/encount_data_su1.bin")); + var su2EncPoints = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/encount/point_data/point_data/encount_data_su2.bin")); //var lcEncPoints = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/point_data/point_data/encount_data_lc.bin")); - var pokeDataMain = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/pokedata/pokedata/pokedata_array.bin")); - var pokeDataSu1 = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/pokedata/pokedata_su1/pokedata_su1_array.bin")); - var pokeDataSu2 = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/pokedata/pokedata_su2/pokedata_su2_array.bin")); + var pokeDataMain = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/encount/pokedata/pokedata/pokedata_array.bin")); + var pokeDataSu1 = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/encount/pokedata/pokedata_su1/pokedata_su1_array.bin")); + var pokeDataSu2 = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/encount/pokedata/pokedata_su2/pokedata_su2_array.bin")); //var pokeDataLc = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/encount/pokedata/pokedata_lc/pokedata_lc_array.bfbs")); var db = new LocationDatabase(); @@ -93,8 +90,8 @@ public class EncounterDumperSV // Fixed symbols List serialized = []; - var fsymData = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/fixed_symbol/fixed_symbol_table/fixed_symbol_table_array.bin")); - var eventBattle = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/battle/eventBattlePokemon/eventBattlePokemon_array.bin")); + var fsymData = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/field/fixed_symbol/fixed_symbol_table/fixed_symbol_table_array.bin")); + var eventBattle = FlatBufferConverter.DeserializeFrom(rom.GetPackedFile("world/data/battle/eventBattlePokemon/eventBattlePokemon_array.bin")); foreach (var (game, gamePoints) in new[] { ("sl", fsym.scarletPoints), ("vl", fsym.violetPoints) }) { using var gw = File.CreateText(Path.Combine(path, $"titan_fixed_{game}.txt")); @@ -224,7 +221,7 @@ bool FindArea(AreaType type) var tableKey = entry.TableKey; var appearAreas = new List { new("PLACENAME_a_w23_d10_01", "a_w23_d10_subarea", 0, new()) }; WriteFixedSpawn(specNamesInternal, moveNames, placeNameMap, gw, tableKey, i, entry, appearAreas, []); - WriteFixedSymbol(serialized, entry, new[] { 196 }); + WriteFixedSymbol(serialized, entry, [196]); } } diff --git a/pkNX.WinForms/Dumping/SV/LocationPointDetail.cs b/pkNX.WinForms/Dumping/SV/LocationPointDetail.cs index 8dab1bf4..fb2e1307 100644 --- a/pkNX.WinForms/Dumping/SV/LocationPointDetail.cs +++ b/pkNX.WinForms/Dumping/SV/LocationPointDetail.cs @@ -3,11 +3,10 @@ namespace pkNX.Structures.FlatBuffers; -public class LocationPointDetail +public class LocationPointDetail(PointData point) { - public readonly PointData Point; + public readonly PointData Point = point; - public LocationPointDetail(PointData point) => Point = point; public float X => Point.Position.X; public float Y => Point.Position.Y; public float Z => Point.Position.Z; diff --git a/pkNX.WinForms/Dumping/SV/LocationStorage.cs b/pkNX.WinForms/Dumping/SV/LocationStorage.cs index 4f8f41f8..6206b568 100644 --- a/pkNX.WinForms/Dumping/SV/LocationStorage.cs +++ b/pkNX.WinForms/Dumping/SV/LocationStorage.cs @@ -4,12 +4,11 @@ namespace pkNX.Structures.FlatBuffers; -public class LocationStorage +public class LocationStorage(int loc, PaldeaFieldIndex fieldIndex, string areaName, AreaInfo info) { - public readonly int Location; - private readonly PaldeaFieldIndex FieldIndex; - public readonly AreaInfo AreaInfo; - public readonly string AreaName; + public readonly int Location = loc; + public readonly AreaInfo AreaInfo = info; + public readonly string AreaName = areaName; public readonly HashSet Added = []; public readonly List Slots = []; @@ -17,14 +16,6 @@ public class LocationStorage public readonly List Local = []; public readonly List Nearby = []; - public LocationStorage(int loc, PaldeaFieldIndex fieldIndex, string areaName, AreaInfo info) - { - Location = loc; - FieldIndex = fieldIndex; - AreaName = areaName; - AreaInfo = info; - } - private void Add(PaldeaEncounter slot) { var key = slot.GetHash(); @@ -36,7 +27,7 @@ private void AddCrossover(PaldeaEncounter slot, int loc) { // If slots cross over, they are necessarily in the same field if (!SlotsCrossover.TryGetValue(loc, out var s)) - SlotsCrossover[loc] = s = new LocationStorage(loc, FieldIndex, AreaName, AreaInfo); + SlotsCrossover[loc] = s = new LocationStorage(loc, fieldIndex, AreaName, AreaInfo); s.Add(slot with { CrossFromLocation = (ushort)Location }); } @@ -143,7 +134,7 @@ public void GetEncounters(EncountPokeDataArray pokeData, PaldeaSceneModel scene) { foreach (var pd in pokeData.Table) { - if (!IsAbleToSpawnAt(pd, spawner, AreaName, scene, FieldIndex)) + if (!IsAbleToSpawnAt(pd, spawner, AreaName, scene, fieldIndex)) continue; // Add encount diff --git a/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolModel.cs b/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolModel.cs index f98fc275..82ad5bc2 100644 --- a/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolModel.cs +++ b/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolModel.cs @@ -8,7 +8,7 @@ namespace pkNX.WinForms; public class PaldeaCoinSymbolModel { - public readonly List[] Points = new List[] { [], [] }; + public readonly List[] Points = [[], []]; public PaldeaCoinSymbolModel(IFileInternal ROM) { @@ -51,15 +51,12 @@ private static IEnumerable GetObjectTemplateSymbolPoints( private static PaldeaCoinSymbolPoint ParseCoinSymbolPoint(TrinityScenePoint sp, TrinityPropertySheet ps) { - switch (ps.Name) + return ps.Name switch { - case "coin_walk_symbol_point": - return new PaldeaCoinSymbolPoint(sp.Name, GetFirstNum(ps), string.Empty, sp.Position); - case "coin_box_symbol_point": - return new PaldeaCoinSymbolPoint(sp.Name, GetFirstNum(ps), GetBoxLabel(ps), sp.Position); - default: - throw new ArgumentException($"Unknown CoinSymbol PropertySheet {ps.Name}"); - } + "coin_walk_symbol_point" => new PaldeaCoinSymbolPoint(sp.Name, GetFirstNum(ps), string.Empty, sp.Position), + "coin_box_symbol_point" => new PaldeaCoinSymbolPoint(sp.Name, GetFirstNum(ps), GetBoxLabel(ps), sp.Position), + _ => throw new ArgumentException($"Unknown CoinSymbol PropertySheet {ps.Name}"), + }; } private static ulong GetFirstNum(TrinityPropertySheet ps) diff --git a/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolPoint.cs b/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolPoint.cs index 578837e0..722d8750 100644 --- a/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolPoint.cs +++ b/pkNX.WinForms/Dumping/SV/PaldeaCoinSymbolPoint.cs @@ -2,25 +2,17 @@ namespace pkNX.WinForms; -public class PaldeaCoinSymbolPoint +public class PaldeaCoinSymbolPoint(string name, ulong num, string boxLabel, PackedVec3f pos) { - public string Name; - public ulong FirstNum; - public string BoxLabel; - public PackedVec3f Position; - - public PaldeaCoinSymbolPoint(string name, ulong num, string boxLabel, PackedVec3f pos) + public string Name = name; + public ulong FirstNum = num; + public string BoxLabel = boxLabel; + public PackedVec3f Position = new() { - Name = name; - FirstNum = num; - BoxLabel = boxLabel; - Position = new PackedVec3f - { - X = pos.X, - Y = pos.Y, - Z = pos.Z, - }; - } + X = pos.X, + Y = pos.Y, + Z = pos.Z, + }; public bool IsBox => !string.IsNullOrEmpty(BoxLabel); } diff --git a/pkNX.WinForms/Dumping/SV/PaldeaFieldModel.cs b/pkNX.WinForms/Dumping/SV/PaldeaFieldModel.cs index 0a257a34..c64dbc40 100644 --- a/pkNX.WinForms/Dumping/SV/PaldeaFieldModel.cs +++ b/pkNX.WinForms/Dumping/SV/PaldeaFieldModel.cs @@ -32,7 +32,7 @@ public PaldeaFieldModel(IFileInternal ROM) SubAreas[(int)PaldeaFieldIndex.Terarium] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_sub_area_su2/field_sub_area_su2_array.bin")).Table; InsideAreas[(int)PaldeaFieldIndex.Terarium] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_inside_area_su2/field_inside_area_su2_array.bin")).Table; DungeonAreas[(int)PaldeaFieldIndex.Terarium] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_dungeon_area_su2/field_dungeon_area_su2_array.bin")).Table; - FieldLocations[(int)PaldeaFieldIndex.Terarium] = new List(); //FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_location_su2/field_location_su2_array.bin")).Table; + FieldLocations[(int)PaldeaFieldIndex.Terarium] = []; //FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_location_su2/field_location_su2_array.bin")).Table; } public AreaInfo FindAreaInfo(PaldeaFieldIndex index, string name) diff --git a/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolModel.cs b/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolModel.cs index 91ba963b..80a92d70 100644 --- a/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolModel.cs +++ b/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolModel.cs @@ -10,8 +10,8 @@ namespace pkNX.WinForms; public class PaldeaFixedSymbolModel { - public readonly List[] scarletPoints = [new(), new(), new()]; - public readonly List[] violetPoints = [new(), new(), new()]; + public readonly List[] scarletPoints = [[], [], []]; + public readonly List[] violetPoints = [[], [], []]; public readonly Dictionary MultiSpawner; diff --git a/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolPoint.cs b/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolPoint.cs index 6f4501f5..d1ff7456 100644 --- a/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolPoint.cs +++ b/pkNX.WinForms/Dumping/SV/PaldeaFixedSymbolPoint.cs @@ -2,19 +2,13 @@ namespace pkNX.WinForms; -public class PaldeaFixedSymbolPoint +public class PaldeaFixedSymbolPoint(string key, PackedVec3f pos) { - public string TableKey; - public PackedVec3f Position; - - public PaldeaFixedSymbolPoint(string key, PackedVec3f pos) + public string TableKey = key; + public PackedVec3f Position = new() { - TableKey = key; - Position = new PackedVec3f - { - X = pos.X, - Y = pos.Y, - Z = pos.Z, - }; - } + X = pos.X, + Y = pos.Y, + Z = pos.Z, + }; } diff --git a/pkNX.WinForms/Dumping/SV/PaldeaSceneModel.cs b/pkNX.WinForms/Dumping/SV/PaldeaSceneModel.cs index 619ed8b0..704bbc8e 100644 --- a/pkNX.WinForms/Dumping/SV/PaldeaSceneModel.cs +++ b/pkNX.WinForms/Dumping/SV/PaldeaSceneModel.cs @@ -17,11 +17,12 @@ public enum PaldeaPointPivot public class PaldeaSceneModel { - public List[] AreaNames { get; } = [new(), new(), new()]; - public Dictionary[] AreaInfos { get; } = [new(), new(), new()]; - public Dictionary[] AreaCollisionTrees { get; } = [new(), new(), new()]; - public Dictionary[] AreaCollisionBoxes { get; } = [new(), new(), new()]; - public Dictionary[] PaldeaType { get; } = [new(), new(), new()]; + // 3 maps = Paldea, Kitakami, Blueberry + public List[] AreaNames { get; } = [[], [], []]; + public Dictionary[] AreaInfos { get; } = [[], [], []]; + public Dictionary[] AreaCollisionTrees { get; } = [[], [], []]; + public Dictionary[] AreaCollisionBoxes { get; } = [[], [], []]; + public Dictionary[] PaldeaType { get; } = [[], [], []]; public PaldeaSceneModel(IFileInternal ROM, PaldeaFieldModel field) { diff --git a/pkNX.WinForms/Dumping/TeraRaidRipper.cs b/pkNX.WinForms/Dumping/TeraRaidRipper.cs index 425941e3..c145bdd9 100644 --- a/pkNX.WinForms/Dumping/TeraRaidRipper.cs +++ b/pkNX.WinForms/Dumping/TeraRaidRipper.cs @@ -535,7 +535,7 @@ private static void DumpPretty(IFileInternal ROM, DeliveryRaidEnemyTableArray ta if (entry.Info.CaptureRate != 1) lines.Add($"\tCatchable: {capture}"); - lines.Add($"\t\tMoves:"); + lines.Add("\t\tMoves:"); lines.Add($"\t\t\t- {moves[(int)boss.Waza1.WazaId]}"); if ((int)boss.Waza2.WazaId != 0) lines.Add($"\t\t\t- {moves[(int)boss.Waza2.WazaId]}"); if ((int)boss.Waza3.WazaId != 0) lines.Add($"\t\t\t- {moves[(int)boss.Waza3.WazaId]}"); @@ -543,7 +543,7 @@ private static void DumpPretty(IFileInternal ROM, DeliveryRaidEnemyTableArray ta if (extra.PowerChargeTrigerHp != 0 && extra.PowerChargeTrigerTime != 0) { - lines.Add($"\t\tShield Activation:"); + lines.Add("\t\tShield Activation:"); lines.Add($"\t\t\t- {extra.PowerChargeTrigerHp}% HP Remaining"); lines.Add($"\t\t\t- {extra.PowerChargeTrigerTime}% Time Remaining"); } @@ -724,7 +724,7 @@ private static bool IsExtraActionValid(RaidBossExtraData action) return false; if (action.Value == 0) // no percentage set return false; - if (action.Action == RaidBossExtraActType.WAZA && action.Wazano == WazaID.WAZA_NULL) // no move set + if (action is { Action: RaidBossExtraActType.WAZA, Wazano: WazaID.WAZA_NULL }) // no move set return false; return true; } diff --git a/pkNX.WinForms/MainEditor/EditorCallableAttribute.cs b/pkNX.WinForms/MainEditor/EditorCallableAttribute.cs index 3d622502..a3c54f98 100644 --- a/pkNX.WinForms/MainEditor/EditorCallableAttribute.cs +++ b/pkNX.WinForms/MainEditor/EditorCallableAttribute.cs @@ -47,28 +47,20 @@ public static class EditorCategoryExt }; } +/// +/// Add this attribute to customize the button that will be displayed in the main editor +/// +/// The category of this editor. Add this to hide it under a sub editor button +/// The icon to display for this editor. Add this to display an icon next to the name +/// True is the editor should only be displayed when the user turned on advanced view +/// The name that should be displayed on the editor button. Leave empty for automatic conversion from the method name. [AttributeUsage(AttributeTargets.Method)] -public class EditorCallableAttribute : Attribute +public class EditorCallableAttribute(EditorCategory category = EditorCategory.Misc, IconChar icon = IconChar.None, bool advanced = false, string editorName = "") : Attribute { - public EditorCategory Category { get; } - public IconChar Icon { get; } - public bool IsAdvanced { get; } - public string EditorName { get; } - - /// - /// Add this attribute to customize the button that will be displayed in the main editor - /// - /// The category of this editor. Add this to hide it under a sub editor button - /// The icon to display for this editor. Add this to display an icon next to the name - /// True is the editor should only be displayed when the user turned on advanced view - /// The name that should be displayed on the editor button. Leave empty for automatic conversion from the method name. - public EditorCallableAttribute(EditorCategory category = EditorCategory.Misc, IconChar icon = IconChar.None, bool advanced = false, string editorName = "") - { - Category = category; - Icon = icon; - EditorName = editorName; - IsAdvanced = advanced; - } + public EditorCategory Category { get; } = category; + public IconChar Icon { get; } = icon; + public bool IsAdvanced { get; } = advanced; + public string EditorName { get; } = editorName; public bool HasCustomEditorName() => !string.IsNullOrWhiteSpace(EditorName); diff --git a/pkNX.WinForms/MainEditor/EditorGG.cs b/pkNX.WinForms/MainEditor/EditorGG.cs index 1375d1f4..b7a09a40 100644 --- a/pkNX.WinForms/MainEditor/EditorGG.cs +++ b/pkNX.WinForms/MainEditor/EditorGG.cs @@ -137,9 +137,9 @@ void Randomize() t.Nature = Nature.Random25; t.Gender = FixedGender.Random; t.Shiny = Shiny.Random; - t.RelearnMoves = new[] { 0, 0, 0, 0 }; + t.RelearnMoves = [0, 0, 0, 0]; if (t.IV_HP != -4) - t.IVs = new[] { -1, -1, -1, -1, -1, -1 }; + t.IVs = [-1, -1, -1, -1, -1, -1]; } } @@ -175,9 +175,9 @@ void Randomize() t.Nature = Nature.Random - 1; t.Gender = FixedGender.Random; t.Shiny = Shiny.Random; - t.RelearnMoves = new[] { 0, 0, 0, 0 }; + t.RelearnMoves = [0, 0, 0, 0]; if (t.IV_HP != -4) - t.IVs = new[] { -1, -1, -1, -1, -1, -1 }; + t.IVs = [-1, -1, -1, -1, -1, -1]; } } @@ -212,9 +212,9 @@ void Randomize() t.Nature = Nature.Random25; t.Gender = FixedGender.Random; t.Shiny = Shiny.Random; - t.RelearnMoves = new[] { 0, 0, 0, 0 }; + t.RelearnMoves = [0, 0, 0, 0]; if (t.IV_HP != -4) - t.IVs = new[] { -1, -1, -1, -1, -1, -1 }; + t.IVs = [-1, -1, -1, -1, -1, -1]; } } @@ -295,11 +295,11 @@ public void EditTypeChart() var nso = new NSO(data); byte[] pattern = // N2nn3pia9transport18UnreliableProtocolE - { + [ 0x4E, 0x32, 0x6E, 0x6E, 0x33, 0x70, 0x69, 0x61, 0x39, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x70, 0x6F, 0x72, 0x74, 0x31, 0x38, 0x55, 0x6E, 0x72, 0x65, 0x6C, 0x69, 0x61, 0x62, 0x6C, 0x65, 0x50, 0x72, 0x6F, 0x74, 0x6F, 0x63, 0x6F, 0x6C, 0x45, 0x00, - }; + ]; int ofs = CodePattern.IndexOfBytes(nso.DecompressedRO, pattern); if (ofs < 0) { diff --git a/pkNX.WinForms/MainEditor/EditorPLA.cs b/pkNX.WinForms/MainEditor/EditorPLA.cs index 48e3bc34..a6209c53 100644 --- a/pkNX.WinForms/MainEditor/EditorPLA.cs +++ b/pkNX.WinForms/MainEditor/EditorPLA.cs @@ -98,7 +98,7 @@ public int[] GetSpeciesBanlist() banned.Add(pi.DexIndexNational); } } - return banned.ToArray(); + return [.. banned]; } public int GetRandomForm(int spec) @@ -217,7 +217,7 @@ public void EditMiscSpeciesInfoRaw() public void EditGift() { var names = ROM.GetStrings(TextName.SpeciesNames); - PopFlat(GameFile.EncounterTableGift, "Gift Encounter Editor", z => z.Table, (z, _) => $"{names[z.Species]}{(z.Form == 0 ? "" : $"-{z.Form}")} @ Lv. {z.Level}", entries => Randomize(entries)); + PopFlat(GameFile.EncounterTableGift, "Gift Encounter Editor", z => z.Table, (z, _) => $"{names[z.Species]}{(z.Form == 0 ? "" : $"-{z.Form}")} @ Lv. {z.Level}", Randomize); void Randomize(IEnumerable arr) { @@ -289,7 +289,7 @@ public void EditAreaWeather() public void EditStaticEncounter() { var names = ROM.GetStrings(TextName.SpeciesNames); - PopFlat(GameFile.EncounterTableStatic, "Static Encounter Editor", z => z.Table, (z, _) => $"{z.EncounterName} ({GetDetail(z, names)})", entries => Randomize(entries)); + PopFlat(GameFile.EncounterTableStatic, "Static Encounter Editor", z => z.Table, (z, _) => $"{z.EncounterName} ({GetDetail(z, names)})", Randomize); static string GetDetail(EventEncount z, string[] names) { @@ -632,7 +632,7 @@ public void EditThrowPermissionSetParam() public void EditThrowableParam() { var itemNames = ROM.GetStrings(TextName.ItemNames); - PopFlat(GameFile.ThrowableParam, "Throwable Param Editor", z => z.Table, (z, _) => $"{itemNames[z.ItemID]} ({z.ItemID})", null, t => { t.AddEntry(0); }); + PopFlat(GameFile.ThrowableParam, "Throwable Param Editor", z => z.Table, (z, _) => $"{itemNames[z.ItemID]} ({z.ItemID})", null, t => t.AddEntry(0)); } [EditorCallable(EditorCategory.Items)] diff --git a/pkNX.WinForms/MainEditor/EditorSWSH.cs b/pkNX.WinForms/MainEditor/EditorSWSH.cs index 8714d629..f01c9055 100644 --- a/pkNX.WinForms/MainEditor/EditorSWSH.cs +++ b/pkNX.WinForms/MainEditor/EditorSWSH.cs @@ -188,11 +188,11 @@ public void NotWorking_EditTypeChart() var nso = new NSO(data); byte[] pattern = // N2nn3pia9transport18UnreliableProtocolE - { + [ 0x4E, 0x32, 0x6E, 0x6E, 0x33, 0x70, 0x69, 0x61, 0x39, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x70, 0x6F, 0x72, 0x74, 0x31, 0x38, 0x55, 0x6E, 0x72, 0x65, 0x6C, 0x69, 0x61, 0x62, 0x6C, 0x65, 0x50, 0x72, 0x6F, 0x74, 0x6F, 0x63, 0x6F, 0x6C, 0x45, 0x00, - }; + ]; int ofs = CodePattern.IndexOfBytes(nso.DecompressedRO, pattern); if (ofs < 0) { @@ -249,8 +249,8 @@ private void PopWildEdit(string file) if (!form.Modified) return; - var sd = FlatBufferConverter.SerializeFrom(s); - var hd = FlatBufferConverter.SerializeFrom(h); + var sd = s.SerializeFrom(); + var hd = h.SerializeFrom(); data_table.SetDataFileName($"encount_symbol_{file}.bin", sd); data_table.SetDataFileName($"encount_{file}.bin", hd); @@ -396,9 +396,9 @@ void Randomize() t.Nature = (int)Nature.Random25; t.Gender = (int)FixedGender.Random; t.ShinyLock = (int)Shiny.Random; - t.Moves = new[] { 0, 0, 0, 0 }; + t.Moves = [0, 0, 0, 0]; if (t.IVHP != -4 && t.IVs.Any(z => z != 31)) - t.IVs = new[] { -1, -1, -1, -1, -1, -1 }; + t.IVs = [-1, -1, -1, -1, -1, -1]; } } @@ -587,7 +587,7 @@ void Randomize() t.Gender = (byte)FixedGender.Random; t.ShinyLock = (int)Shiny.Random; if (t.IVHP != -4 && t.IVs.Any(z => z != 31)) - t.IVs = new[] { -1, -1, -1, -1, -1, -1 }; + t.IVs = [-1, -1, -1, -1, -1, -1]; } } @@ -618,7 +618,7 @@ void UpdateStarters() critters[2].Species = (uint)gifts[4].Species; critters[2].Form = gifts[4].Form; - var bin = FlatBufferConverter.SerializeFrom(obj); + var bin = obj.SerializeFrom(); placement.SetDataFileName(file, bin); container[0] = placement.Write(); } @@ -671,7 +671,7 @@ void Randomize() t.ShinyLock = (int)Shiny.Random; t.Relearn1 = 0; if (t.IVHP != -4 && t.IVs.Any(z => z != 31)) - t.IVs = new[] { -1, -1, -1, -1, -1, -1 }; + t.IVs = [-1, -1, -1, -1, -1, -1]; // what you trade t.RequiredSpecies = srand.GetRandomSpecies(t.RequiredSpecies); diff --git a/pkNX.WinForms/Ripper/FileRipper.cs b/pkNX.WinForms/Ripper/FileRipper.cs index 979a76a5..9b0b4cee 100644 --- a/pkNX.WinForms/Ripper/FileRipper.cs +++ b/pkNX.WinForms/Ripper/FileRipper.cs @@ -115,10 +115,8 @@ private static FileRipperResult TryLoadFile(BinaryReader br, uint header, string } } -public class FileRipperResult +public class FileRipperResult(RipResultCode code) { - public readonly RipResultCode Code; + public readonly RipResultCode Code = code; public string? ResultPath; - - public FileRipperResult(RipResultCode code) => Code = code; } diff --git a/pkNX.WinForms/Subforms/AreaEditor8a.cs b/pkNX.WinForms/Subforms/AreaEditor8a.cs index b120d488..f53d815a 100644 --- a/pkNX.WinForms/Subforms/AreaEditor8a.cs +++ b/pkNX.WinForms/Subforms/AreaEditor8a.cs @@ -96,7 +96,7 @@ private void RandomizeArea(ResidentArea area, SpeciesSettings settings) } settings.Legends = false; // Legendary encounter slot conditions require you to not have captured the Legendary in order to encounter them; ban altogether. - rand.Initialize(settings, banned.ToArray()); + rand.Initialize(settings, [.. banned]); var formRand = pt.Table.Cast() .Where(z => z.IsPresentInGame && !(Legal.BattleExclusiveForms.Contains(z.DexIndexNational) || Legal.BattleFusions.Contains(z.DexIndexNational))) diff --git a/pkNX.WinForms/Subforms/BTTE.cs b/pkNX.WinForms/Subforms/BTTE.cs index 034d5787..3884a4d1 100644 --- a/pkNX.WinForms/Subforms/BTTE.cs +++ b/pkNX.WinForms/Subforms/BTTE.cs @@ -45,7 +45,7 @@ public BTTE(GameData data, TrainerEditor editor, GameManager game) Data = data; Trainers = editor; InitializeComponent(); - pba = new[] { PB_Team1, PB_Team2, PB_Team3, PB_Team4, PB_Team5, PB_Team6 }; + pba = [PB_Team1, PB_Team2, PB_Team3, PB_Team4, PB_Team5, PB_Team6]; Stats.Personal = Personal = data.PersonalData; learn = new LearnsetRandomizer(game.Info, data.LevelUpData.LoadAll(), Personal); @@ -67,7 +67,7 @@ public BTTE(GameData data, TrainerEditor editor, GameManager game) movelist = EditorUtil.SanitizeMoveList(movelist); AIBits = Game.Info.SWSH ? new[] { CHK_AI_Basic, CHK_AI_Strong, CHK_AI_Expert, CHK_AI_Double, CHK_AI_Raid, CHK_AI_Allowance, CHK_AI_PokeChange, CHK_AI_FireGym1, CHK_AI_FireGym2, CHK_AI_Unused1, CHK_AI_Item, CHK_AI_FireGym3, CHK_AI_Unused2 } - : new[] { CHK_AI_Basic, CHK_AI_Strong, CHK_AI_Expert, CHK_AI_Double, CHK_AI_Allowance, CHK_AI_Item, CHK_AI_PokeChange, CHK_AI_Unused1 }; + : [CHK_AI_Basic, CHK_AI_Strong, CHK_AI_Expert, CHK_AI_Double, CHK_AI_Allowance, CHK_AI_Item, CHK_AI_PokeChange, CHK_AI_Unused1]; Setup(); foreach (var pb in pba) diff --git a/pkNX.WinForms/Subforms/GGWE.cs b/pkNX.WinForms/Subforms/GGWE.cs index eba11c24..5723ed2f 100644 --- a/pkNX.WinForms/Subforms/GGWE.cs +++ b/pkNX.WinForms/Subforms/GGWE.cs @@ -415,10 +415,10 @@ void ApplyRand(IList slots) public static readonly Dictionary RandomScaledRates = new() { - [01] = new[] { 100 }, - [04] = new[] { 60, 30, 7, 3 }, - [05] = new[] { 40, 30, 18, 10, 2 }, - [10] = new[] { 20, 15, 15, 10, 10, 10, 10, 5, 4, 1 }, + [01] = [100], + [04] = [60, 30, 7, 3], + [05] = [40, 30, 18, 10, 2], + [10] = [20, 15, 15, 10, 10, 10, 10, 5, 4, 1], }; private void B_Dump_Click(object sender, EventArgs e) diff --git a/pkNX.WinForms/Subforms/MapViewer8a.cs b/pkNX.WinForms/Subforms/MapViewer8a.cs index fbe8ac86..2f617d1c 100644 --- a/pkNX.WinForms/Subforms/MapViewer8a.cs +++ b/pkNX.WinForms/Subforms/MapViewer8a.cs @@ -60,16 +60,10 @@ public MapViewer8a(GameManagerPLA rom, GFPack resident) CB_Map.SelectedIndex = 1; } - private class ComboItem + private class ComboItem(string text, int value) { - public ComboItem(string text, int value) - { - Text = text; - Value = value; - } - - public string Text { get; } - public int Value { get; } + public string Text { get; } = text; + public int Value { get; } = value; } private void CB_Map_SelectedIndexChanged(object sender, EventArgs e) @@ -224,7 +218,7 @@ private static List GetSpawnerInfo(int species, AreaInstance area) return result; } - private static readonly EncounterSlot[] Unown = { new() + private static readonly EncounterSlot[] Unown = [ new() { Species = 201, Behavior1 = string.Empty, @@ -240,7 +234,7 @@ private static List GetSpawnerInfo(int species, AreaInstance area) }, Oybn = new(), }, - }; + ]; private void MapViewer8a_MouseMove(object sender, MouseEventArgs e) { @@ -269,26 +263,22 @@ private void MapViewer8a_MouseMove(object sender, MouseEventArgs e) } } -public class AreaDef +public class AreaDef( + string NameSummary, + int min, + int max, + pkNX.Structures.FlatBuffers.Vec3f position, + SpawnerType type, + IList slots, + float radius) { - public readonly string NameSummary; - public readonly int Min; - public readonly int Max; - public readonly pkNX.Structures.FlatBuffers.Vec3f Position; - public readonly SpawnerType Type; - public readonly IList Slots; - public readonly float Radius; - - public AreaDef(string NameSummary, int min, int max, pkNX.Structures.FlatBuffers.Vec3f position, SpawnerType type, IList slots, float radius) - { - this.NameSummary = NameSummary; - Min = min; - Max = max; - Position = position; - Type = type; - Slots = slots; - Radius = radius; - } + public readonly string NameSummary = NameSummary; + public readonly int Min = min; + public readonly int Max = max; + public readonly pkNX.Structures.FlatBuffers.Vec3f Position = position; + public readonly SpawnerType Type = type; + public readonly IList Slots = slots; + public readonly float Radius = radius; public string GetLine() { diff --git a/pkNX.WinForms/Subforms/ModelConverter.cs b/pkNX.WinForms/Subforms/ModelConverter.cs index 9700583f..de4835a3 100644 --- a/pkNX.WinForms/Subforms/ModelConverter.cs +++ b/pkNX.WinForms/Subforms/ModelConverter.cs @@ -757,18 +757,18 @@ private void ConvertToMesh(string sourceFileName, string resultFileName) { MeshShapeName = $"{resultFileName}_{subMeshName}_mesh_shape", MeshName = $"{resultFileName}_{subMeshName}_mesh", - VertexLayout = new VertexAttributeLayout[] - { + VertexLayout = + [ new() { Elements = inputLayout, - Size = new VertexSize[] { new() { Size = inputLayoutSize } }, + Size = [new() { Size = inputLayoutSize }], }, - }, + ], BoundingSphere = new Sphere(bounds), Bounds = bounds, IndexLayoutFormat = IndexLayoutFormat.UINT16, // Always Uint16 on all PLA pokemon models - BoneWeights = new BoneWeight[] { }, // TODO: All bones affected by the sub-mesh + some weight + BoneWeights = [], // TODO: All bones affected by the sub-mesh + some weight SubMeshes = subMeshes, }); } @@ -776,32 +776,32 @@ private void ConvertToMesh(string sourceFileName, string resultFileName) { meshBuffers.Add(new MeshBuffer { - IndexBuffer = new ByteBuffer[] { new() { Data = indexBuffer } }, - VertexBuffer = new ByteBuffer[] { new() { Data = vertexBuffer, Debug_InputLayout = new VertexAttributeLayout + IndexBuffer = [new() { Data = indexBuffer }], + VertexBuffer = [ new() { Data = vertexBuffer, Debug_InputLayout = new VertexAttributeLayout { Elements = inputLayout, - Size = new VertexSize[] { new() { Size = inputLayoutSize } }, - } } }, + Size = [new() { Size = inputLayoutSize }], + } } ], }); } } - Result.Meshes = new Mesh[] - { + Result.Meshes = + [ new() { BufferFileName = $"{resultFileName}.trmbf", Shapes = meshShapes.ToArray(), }, - }; + ]; - Result.MeshDataBuffers = new MeshBufferTable[] - { + Result.MeshDataBuffers = + [ new() { Buffers = meshBuffers.ToArray(), }, - }; + ]; } private void ConvertToMeshShape() @@ -1206,7 +1206,7 @@ public StringParameter[] BuildStringParams() // stringParams.Add(new() { PropertyBinding = "EnableLerpBaseColorEmission", StringValue = EnableLerpBaseColorEmission.ToString() }); //} - return stringParams.ToArray(); + return [.. stringParams]; } } @@ -1411,16 +1411,16 @@ private MaterialPass FromStandardShaderParams(Material8 oldMaterial) return new MaterialPass { Name = oldMaterial.Name!, - Shaders = new ShaderBinding[] - { + Shaders = + [ new () { ShaderName = "Standard", ShaderValues = newShader.BuildStringParams(), }, - }, - FloatParameters = new FloatParameter[] - { + ], + FloatParameters = + [ new() { PropertyBinding = "DiscardValue", FloatValue = 0 }, new() { PropertyBinding = "NormalHeight", FloatValue = 1 }, new() { PropertyBinding = "EmissionIntensity", FloatValue = 0 }, @@ -1446,12 +1446,12 @@ private MaterialPass FromStandardShaderParams(Material8 oldMaterial) new() { PropertyBinding = "LayerMaskScale2", FloatValue = 1 }, new() { PropertyBinding = "LayerMaskScale3", FloatValue = 1 }, new() { PropertyBinding = "LayerMaskScale4", FloatValue = 1 }, - }, + ], TextureParameters = textures, Samplers = samplers, - Float4LightParameters = Array.Empty(), // TODO - Float4Parameters = new Float4Parameter[] - { + Float4LightParameters = [], // TODO + Float4Parameters = + [ new() { PropertyBinding = "UVScaleOffset" , ColorValue = new Color4f(oldShader.UVScaleOffset) }, new() { PropertyBinding = "UVScaleOffsetNormal", ColorValue = new Color4f(oldShader.UVScaleOffsetNormal) }, new() { PropertyBinding = "BaseColorLayer1" , ColorValue = new() }, @@ -1465,23 +1465,23 @@ private MaterialPass FromStandardShaderParams(Material8 oldMaterial) new() { PropertyBinding = "EmissionColorLayer4", ColorValue = new() }, new() { PropertyBinding = "EmissionColor" , ColorValue = new() }, - }, - IntParameters = new IntParameter[] - { + ], + IntParameters = + [ new() { PropertyBinding = "CastShadow", IntValue = oldMaterial.CastShadow }, new() { PropertyBinding = "ReceiveShadow", IntValue =1 }, // TODO: might want to force this to 1 new() { PropertyBinding = "CategoryLabel", IntValue = 2 }, // TODO new() { PropertyBinding = "UVIndexLayerMask", IntValue = -1 }, // TODO - }, + ], WriteMask = new WriteMaskData(), // TODO IntExtra = new IntExtraData(), // TODO AlphaType = "Opaque", // TODO - Field05 = Array.Empty(), - Field08 = Array.Empty(), - Field10 = Array.Empty(), - Field11 = Array.Empty(), - Field12 = Array.Empty(), + Field05 = [], + Field08 = [], + Field10 = [], + Field11 = [], + Field12 = [], }; } @@ -1505,13 +1505,13 @@ private MaterialPass FromEyeShaderParams(Material8 oldMaterial) return new MaterialPass { Name = oldMaterial.Name!, - Shaders = new ShaderBinding[] - { + Shaders = + [ new() { ShaderName = "Eye", - ShaderValues = new StringParameter[] - { + ShaderValues = + [ new() { PropertyBinding = "EnableNormalMap", StringValue = "True" }, new() { PropertyBinding = "EnableParallaxMap", StringValue = "False" }, new() { PropertyBinding = "EnableMetallicMap", StringValue = "False" }, @@ -1519,26 +1519,24 @@ private MaterialPass FromEyeShaderParams(Material8 oldMaterial) new() { PropertyBinding = "EnableEmissionColorMap", StringValue = "False" }, new() { PropertyBinding = "EnableAOMap", StringValue = "True" }, new() { PropertyBinding = "NumMaterialLayer", StringValue = "1" }, - }, + ], }, - }, - FloatParameters = new FloatParameter[] - { - }, - TextureParameters = Array.Empty(), // TODO - Samplers = Array.Empty(), // TODO - Float4LightParameters = Array.Empty(), // TODO - Float4Parameters = Array.Empty(), // TODO - IntParameters = Array.Empty(), // TODO + ], + FloatParameters = [], + TextureParameters = [], // TODO + Samplers = [], // TODO + Float4LightParameters = [], // TODO + Float4Parameters = [], // TODO + IntParameters = [], // TODO WriteMask = new WriteMaskData(), // TODO IntExtra = new IntExtraData(), // TODO AlphaType = "", // TODO - Field05 = Array.Empty(), - Field08 = Array.Empty(), - Field10 = Array.Empty(), - Field11 = Array.Empty(), - Field12 = Array.Empty(), + Field05 = [], + Field08 = [], + Field10 = [], + Field11 = [], + Field12 = [], }; } @@ -1571,30 +1569,30 @@ private void ConvertToMaterial() //materialPasses.Add(FromEyeShaderParams(material)); } - Result.DefaultMaterials = new Material[] - { + Result.DefaultMaterials = + [ new() { MaterialPasses = materialPasses.ToArray(), }, - }; + ]; // TODO: Assign shiny colors - Result.MeshMaterials = new MeshMaterialWrapper[] - { + Result.MeshMaterials = + [ new() { Name = "rare", - Materials = new Material[] - { + Materials = + [ new() { Reserved00 = 0, MaterialPasses = materialPasses.ToArray(), }, - }, + ], }, - }; + ]; } private void ConvertToMultiMaterialTable(string resultFileName) @@ -1614,16 +1612,16 @@ private void ConvertToMultiMaterialTable(string resultFileName) } } - Result.MMT.Material = new MaterialTable[] - { + Result.MMT.Material = + [ new () { Name = "rare", - FileNames = new []{ $"{resultFileName}_rare.trmtr" }, + FileNames = [$"{resultFileName}_rare.trmtr"], MaterialSwitches = allShapes.ToArray(), - MaterialProperties = Array.Empty(), // TODO + MaterialProperties = [], // TODO }, - }; + ]; } private void ConvertToModel() @@ -1631,25 +1629,25 @@ private void ConvertToModel() string resultFileName = $"pm{(ushort)SWSHModel.Config.SpeciesId:0000}_00_00"; string sourceFileName = $"pm{(ushort)SWSHModel.Config.SpeciesId:0000}_00"; - Result.Model.Meshes = new FileReference[] - { + Result.Model.Meshes = + [ new() { Filename = $"{resultFileName}.trmsh" }, - }; + ]; Result.Model.Skeleton = new FileReference { Filename = $"{resultFileName}.trskl" }; - Result.Model.Materials = new[] { $"{resultFileName}.trmtr" }; + Result.Model.Materials = [$"{resultFileName}.trmtr"]; // SWSH models don't have LOD's, so we only need one - Result.Model.LODs = new LOD[] - { + Result.Model.LODs = + [ new() { Type = "Custom", - Entries = new LODIndex[] - { + Entries = + [ new() { Index = 0 }, - }, + ], }, - }; + ]; Result.Model.Bounds = SWSHModel.GFBModel.BoundingBox / 100; Result.Model.SphereBounds = new Sphere(Result.Model.Bounds!); @@ -1691,17 +1689,17 @@ private void B_Save_Click(object sender, EventArgs e) FileName = resultFileName; BasePath = Path.Combine(PokemonModelDir.FilePath!, $"bin/pokemon/pm{SpeciesId:0000}/{FileName}/"); - PokemonModelDir.AddFile(BasePath + $"{FileName}.trpokecfg", FlatBufferConverter.SerializeFrom(Result.Config)); - PokemonModelDir.AddFile(ModelPath + $"{FileName}.trmmt", FlatBufferConverter.SerializeFrom(Result.MMT)); - PokemonModelDir.AddFile(ModelPath + $"{FileName}.trmdl", FlatBufferConverter.SerializeFrom(Result.Model)); - PokemonModelDir.AddFile(ModelPath + $"{Result.Model.Skeleton.Filename}", FlatBufferConverter.SerializeFrom(Result.Skeleton)); + PokemonModelDir.AddFile(BasePath + $"{FileName}.trpokecfg", Result.Config.SerializeFrom()); + PokemonModelDir.AddFile(ModelPath + $"{FileName}.trmmt", Result.MMT.SerializeFrom()); + PokemonModelDir.AddFile(ModelPath + $"{FileName}.trmdl", Result.Model.SerializeFrom()); + PokemonModelDir.AddFile(ModelPath + $"{Result.Model.Skeleton.Filename}", Result.Skeleton.SerializeFrom()); - PokemonModelDir.AddFile(ModelPath + $"{FileName}.trpokecfg", FlatBufferConverter.SerializeFrom(Result.Config)); + PokemonModelDir.AddFile(ModelPath + $"{FileName}.trpokecfg", Result.Config.SerializeFrom()); for (var i = 0; i < Result.Model.Materials.Count; i++) { var materialName = Result.Model.Materials[i]; - PokemonModelDir.AddFile(ModelPath + $"{materialName}", FlatBufferConverter.SerializeFrom(Result.DefaultMaterials[i])); + PokemonModelDir.AddFile(ModelPath + $"{materialName}", Result.DefaultMaterials[i].SerializeFrom()); } for (var i = 0; i < Result.MeshMaterials.Length; i++) @@ -1713,20 +1711,20 @@ private void B_Save_Click(object sender, EventArgs e) var materialName = Result.MMT.Material[i].FileNames[j]; var material = Result.MeshMaterials[i].Materials[j]; - PokemonModelDir.AddFile(ModelPath + $"{materialName}", FlatBufferConverter.SerializeFrom(material)); + PokemonModelDir.AddFile(ModelPath + $"{materialName}", material.SerializeFrom()); } } for (var i = 0; i < Result.Model.Meshes.Count; i++) { var meshName = Result.Model.Meshes[i].Filename; - PokemonModelDir.AddFile(ModelPath + $"{meshName}", FlatBufferConverter.SerializeFrom(Result.Meshes[i])); + PokemonModelDir.AddFile(ModelPath + $"{meshName}", Result.Meshes[i].SerializeFrom()); } for (var i = 0; i < Result.Meshes.Length; i++) { var meshBufferName = Result.Meshes[i].BufferFileName; - PokemonModelDir.AddFile(ModelPath + $"{meshBufferName}", FlatBufferConverter.SerializeFrom(Result.MeshDataBuffers[i])); + PokemonModelDir.AddFile(ModelPath + $"{meshBufferName}", Result.MeshDataBuffers[i].SerializeFrom()); } PokemonModelDir.Dump(); diff --git a/pkNX.WinForms/Subforms/PaldeaMap.cs b/pkNX.WinForms/Subforms/PaldeaMap.cs index 30c022b5..6ced2aff 100644 --- a/pkNX.WinForms/Subforms/PaldeaMap.cs +++ b/pkNX.WinForms/Subforms/PaldeaMap.cs @@ -6,136 +6,135 @@ using pkNX.Structures.FlatBuffers.SV; using pkNX.Structures.FlatBuffers.SV.Trinity; -namespace pkNX.WinForms.Subforms +namespace pkNX.WinForms.Subforms; + +public class PaldeaMap { - public class PaldeaMap + public readonly List[] AreaNames = [[], [], []]; + private readonly Dictionary[] Areas = [[], [], []]; + public readonly Dictionary[] AreaCollisionTrees = [[], [], []]; + public readonly Dictionary[] AreaCollisionBoxes = [[], [], []]; + + private readonly IList[] MainAreas = new IList[3]; + private readonly IList[] SubAreas = new IList[3]; + private readonly IList[] InsideAreas = new IList[3]; + private readonly IList[] DungeonAreas = new IList[3]; + private readonly IList[] FieldLocations = new IList[3]; + + public PaldeaMap(GameManagerSV ROM) { - public readonly List[] AreaNames = { [], [], [] }; - private readonly Dictionary[] Areas = { [], [], [] }; - public readonly Dictionary[] AreaCollisionTrees = { [], [], [] }; - public readonly Dictionary[] AreaCollisionBoxes = { [], [], [] }; + MainAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_main_area/field_main_area_array.bin")).Table; + SubAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_sub_area/field_sub_area_array.bin")).Table; + InsideAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_inside_area/field_inside_area_array.bin")).Table; + DungeonAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_dungeon_area/field_dungeon_area_array.bin")).Table; + FieldLocations[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_location/field_location_array.bin")).Table; - private readonly IList[] MainAreas = new IList[3]; - private readonly IList[] SubAreas = new IList[3]; - private readonly IList[] InsideAreas = new IList[3]; - private readonly IList[] DungeonAreas = new IList[3]; - private readonly IList[] FieldLocations = new IList[3]; + MainAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_main_area_su1/field_main_area_su1_array.bin")).Table; + SubAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_sub_area_su1/field_sub_area_su1_array.bin")).Table; + InsideAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_inside_area_su1/field_inside_area_su1_array.bin")).Table; + DungeonAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_dungeon_area_su1/field_dungeon_area_su1_array.bin")).Table; + FieldLocations[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_location_su1/field_location_su1_array.bin")).Table; - public PaldeaMap(GameManagerSV ROM) + MainAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_main_area_su2/field_main_area_su2_array.bin")).Table; + SubAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_sub_area_su2/field_sub_area_su2_array.bin")).Table; + InsideAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_inside_area_su2/field_inside_area_su2_array.bin")).Table; + DungeonAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_dungeon_area_su2/field_dungeon_area_su2_array.bin")).Table; + FieldLocations[2] = []; // FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_location_su2/field_location_su2_array.bin")).Table; + + LoadScenes(ROM); + } + + private void LoadScenes(GameManagerSV ROM) + { + // Load default scenes + LoadScene(ROM, ROM.GetPackedFile("world/scene/parts/field/resident_event/resident_area_collision_/resident_area_collision_0.trscn"), 0); + + // Load default scenes + LoadScene(ROM, ROM.GetPackedFile("world/scene/parts/field/main/field_1/field_main/resident_event/resident_area_collision_/resident_area_collision_0.trscn"), 1); + + // Load default scenes + LoadScene(ROM, ROM.GetPackedFile("world/scene/parts/field/main/field_2/field_main/resident_event/resident_area_collision_/resident_area_collision_0.trscn"), 2); + } + + private void LoadScene(GameManagerSV ROM, byte[] collisionFile, int index) + { + var area_collision = FlatBufferConverter.DeserializeFrom(collisionFile); + + foreach (var obj in area_collision.Objects) { - MainAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_main_area/field_main_area_array.bin")).Table; - SubAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_sub_area/field_sub_area_array.bin")).Table; - InsideAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_inside_area/field_inside_area_array.bin")).Table; - DungeonAreas[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_dungeon_area/field_dungeon_area_array.bin")).Table; - FieldLocations[0] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area/field_location/field_location_array.bin")).Table; + if (obj is not { Type: "trinity_SceneObject", SubObjects.Count: > 0 }) + continue; + if (obj.SubObjects[0].Type != "trinity_CollisionComponent") + continue; - MainAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_main_area_su1/field_main_area_su1_array.bin")).Table; - SubAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_sub_area_su1/field_sub_area_su1_array.bin")).Table; - InsideAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_inside_area_su1/field_inside_area_su1_array.bin")).Table; - DungeonAreas[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_dungeon_area_su1/field_dungeon_area_su1_array.bin")).Table; - FieldLocations[1] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su1/field_location_su1/field_location_su1_array.bin")).Table; + var sceneObject = FlatBufferConverter.DeserializeFrom(obj.Data); + var trcData = obj.SubObjects[0].Data; + var trc = FlatBufferConverter.DeserializeFrom(trcData); + var collisionComponent = trc.Component.CollisionComponent; - MainAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_main_area_su2/field_main_area_su2_array.bin")).Table; - SubAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_sub_area_su2/field_sub_area_su2_array.bin")).Table; - InsideAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_inside_area_su2/field_inside_area_su2_array.bin")).Table; - DungeonAreas[2] = FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_dungeon_area_su2/field_dungeon_area_su2_array.bin")).Table; - FieldLocations[2] = new List(); // FlatBufferConverter.DeserializeFrom(ROM.GetPackedFile("world/data/field/area_su2/field_location_su2/field_location_su2_array.bin")).Table; + AreaNames[index].Add(sceneObject.ObjectName); + var areaInfo = FindAreaInfo(index, sceneObject.ObjectName); - LoadScenes(ROM); - } - - private void LoadScenes(GameManagerSV ROM) - { - // Load default scenes - LoadScene(ROM, ROM.GetPackedFile("world/scene/parts/field/resident_event/resident_area_collision_/resident_area_collision_0.trscn"), 0); - - // Load default scenes - LoadScene(ROM, ROM.GetPackedFile("world/scene/parts/field/main/field_1/field_main/resident_event/resident_area_collision_/resident_area_collision_0.trscn"), 1); - - // Load default scenes - LoadScene(ROM, ROM.GetPackedFile("world/scene/parts/field/main/field_2/field_main/resident_event/resident_area_collision_/resident_area_collision_0.trscn"), 2); - } - - private void LoadScene(GameManagerSV ROM, byte[] collisionFile, int index) - { - var area_collision = FlatBufferConverter.DeserializeFrom(collisionFile); - - foreach (var obj in area_collision.Objects) + var shape = collisionComponent.Shape; + if (shape.TryGet(out Box? box)) { - if (obj is not { Type: "trinity_SceneObject", SubObjects.Count: > 0 }) - continue; - if (obj.SubObjects[0].Type != "trinity_CollisionComponent") - continue; - - var sceneObject = FlatBufferConverter.DeserializeFrom(obj.Data); - var trcData = obj.SubObjects[0].Data; - var trc = FlatBufferConverter.DeserializeFrom(trcData); - var collisionComponent = trc.Component.CollisionComponent; - - AreaNames[index].Add(sceneObject.ObjectName); - var areaInfo = FindAreaInfo(index, sceneObject.ObjectName); - - var shape = collisionComponent.Shape; - if (shape.TryGet(out Box? box)) + // Box collision, obj.ObjectPosition.Field_02 is pos, box.Field_01 is size of box + AreaCollisionBoxes[index][sceneObject.ObjectName] = new BoxCollision9 { - // Box collision, obj.ObjectPosition.Field_02 is pos, box.Field_01 is size of box - AreaCollisionBoxes[index][sceneObject.ObjectName] = new BoxCollision9 - { - Position = sceneObject.ObjectPosition.Field02, - Size = box!.Field01, - }; - } - - if (shape.TryGet(out Havok? havok)) - { - var havokData = ROM.GetPackedFile(havok!.TrcolFilePath); - AreaCollisionTrees[index][sceneObject.ObjectName] = HavokCollision.ParseAABBTree(havokData); - } - - Areas[index][sceneObject.ObjectName] = new AreaDef9 - { - SceneObject = sceneObject, - CollisionComponent = collisionComponent, - Info = areaInfo, + Position = sceneObject.ObjectPosition.Field02, + Size = box!.Field01, }; } - } - public AreaInfo FindAreaInfo(int index, string name) - { - foreach (var area in MainAreas[index]) + if (shape.TryGet(out Havok? havok)) { - if (area.Name == name) - return area.Info; + var havokData = ROM.GetPackedFile(havok!.TrcolFilePath); + AreaCollisionTrees[index][sceneObject.ObjectName] = HavokCollision.ParseAABBTree(havokData); } - foreach (var area in SubAreas[index]) + + Areas[index][sceneObject.ObjectName] = new AreaDef9 { - if (area.Name == name) - return area.Info; - } - foreach (var area in InsideAreas[index]) - { - if (area.Name == name) - return area.Info; - } - foreach (var area in DungeonAreas[index]) - { - if (area.Name == name) - return area.Info; - } - foreach (var area in FieldLocations[index]) - { - if (area.Name == name) - return area.Info; - } - throw new ArgumentException($"Unknown area {name}"); + SceneObject = sceneObject, + CollisionComponent = collisionComponent, + Info = areaInfo, + }; } } - public class AreaDef9 + public AreaInfo FindAreaInfo(int index, string name) { - public required TrinitySceneObject SceneObject; - public required CollisionComponent CollisionComponent; - public required AreaInfo Info; + foreach (var area in MainAreas[index]) + { + if (area.Name == name) + return area.Info; + } + foreach (var area in SubAreas[index]) + { + if (area.Name == name) + return area.Info; + } + foreach (var area in InsideAreas[index]) + { + if (area.Name == name) + return area.Info; + } + foreach (var area in DungeonAreas[index]) + { + if (area.Name == name) + return area.Info; + } + foreach (var area in FieldLocations[index]) + { + if (area.Name == name) + return area.Info; + } + throw new ArgumentException($"Unknown area {name}"); } } + +public class AreaDef9 +{ + public required TrinitySceneObject SceneObject; + public required CollisionComponent CollisionComponent; + public required AreaInfo Info; +} diff --git a/pkNX.WinForms/Subforms/PokeDataUI.cs b/pkNX.WinForms/Subforms/PokeDataUI.cs index 6a28cca8..44f61e96 100644 --- a/pkNX.WinForms/Subforms/PokeDataUI.cs +++ b/pkNX.WinForms/Subforms/PokeDataUI.cs @@ -24,10 +24,10 @@ public PokeDataUI(PokeEditor editor, GameManager rom, GameData data) Data = data; InitializeComponent(); - helditem_boxes = new[] { CB_HeldItem1, CB_HeldItem2, CB_HeldItem3 }; - ability_boxes = new[] { CB_Ability1, CB_Ability2, CB_Ability3 }; - typing_boxes = new[] { CB_Type1, CB_Type2 }; - eggGroup_boxes = new[] { CB_EggGroup1, CB_EggGroup2 }; + helditem_boxes = [CB_HeldItem1, CB_HeldItem2, CB_HeldItem3]; + ability_boxes = [CB_Ability1, CB_Ability2, CB_Ability3]; + typing_boxes = [CB_Type1, CB_Type2]; + eggGroup_boxes = [CB_EggGroup1, CB_EggGroup2]; items = ROM.GetStrings(TextName.ItemNames); movelist = ROM.GetStrings(TextName.MoveNames); @@ -338,7 +338,7 @@ public void LoadPersonal(IPersonalInfo pkm) if (pkm is IMovesInfo_SWSH mitr) // if SWSH, the second half is just TRs { for (int i = 0; i < halfList; i++) - CLB_TM.SetItemChecked((i + halfList), mitr.TR[i]); // Bitflags for TR + CLB_TM.SetItemChecked(i + halfList, mitr.TR[i]); // Bitflags for TR } else { @@ -497,7 +497,7 @@ public void SaveLearnset() _ = int.TryParse(level, out var lv); levels.Add(Math.Min(100, lv)); } - pkm.Update(moves.ToArray(), levels.ToArray()); + pkm.Update([.. moves], [.. levels]); } public void LoadEvolutions(EvolutionSet s) diff --git a/pkNX.WinForms/Subforms/PokeDataUI8a.cs b/pkNX.WinForms/Subforms/PokeDataUI8a.cs index 3a0012ed..985ee20e 100644 --- a/pkNX.WinForms/Subforms/PokeDataUI8a.cs +++ b/pkNX.WinForms/Subforms/PokeDataUI8a.cs @@ -58,10 +58,10 @@ public PokeDataUI8a(PokeEditor8a editor, GameManager rom, GameData8a data) B_NextPokemon.Focus(); - helditem_boxes = new[] { CB_HeldItem1, CB_HeldItem2, CB_HeldItem3 }; - ability_boxes = new[] { CB_Ability1, CB_Ability2, CB_Ability3 }; - typing_boxes = new[] { CB_Type1, CB_Type2 }; - eggGroup_boxes = new[] { CB_EggGroup1, CB_EggGroup2 }; + helditem_boxes = [CB_HeldItem1, CB_HeldItem2, CB_HeldItem3]; + ability_boxes = [CB_Ability1, CB_Ability2, CB_Ability3]; + typing_boxes = [CB_Type1, CB_Type2]; + eggGroup_boxes = [CB_EggGroup1, CB_EggGroup2]; items = ROM.GetStrings(TextName.ItemNames); movelist = ROM.GetStrings(TextName.MoveNames); diff --git a/pkNX.WinForms/Subforms/SSWE.cs b/pkNX.WinForms/Subforms/SSWE.cs index cf1f3b03..2be1bdcb 100644 --- a/pkNX.WinForms/Subforms/SSWE.cs +++ b/pkNX.WinForms/Subforms/SSWE.cs @@ -32,7 +32,7 @@ public SSWE(GameManagerSWSH rom, EncounterArchive sym, EncounterArchive hid) species[0] = ""; EncounterList8.SpeciesNames = species; - SL = new[] { SL_0, SL_1, SL_2, SL_3, SL_4, SL_5, SL_6, SL_7, SL_8, SL_9, SL_10 }; + SL = [SL_0, SL_1, SL_2, SL_3, SL_4, SL_5, SL_6, SL_7, SL_8, SL_9, SL_10]; foreach (var z in SL) z.Initialize(); @@ -41,16 +41,10 @@ public SSWE(GameManagerSWSH rom, EncounterArchive sym, EncounterArchive hid) LoadLocations(); } - private class LocationHash + private class LocationHash(ulong hash, string loc) { - public ulong Hash { get; } - public string LocationName { get; } - - public LocationHash(ulong hash, string loc) - { - Hash = hash; - LocationName = loc; - } + public ulong Hash { get; } = hash; + public string LocationName { get; } = loc; } public bool Modified { get; private set; } @@ -203,10 +197,10 @@ void ApplyRand(IList slots) public static readonly Dictionary RandomScaledRates = new() { - [01] = new byte[] { 100 }, - [04] = new byte[] { 60, 30, 7, 3 }, - [05] = new byte[] { 40, 30, 18, 10, 2 }, - [10] = new byte[] { 20, 15, 15, 10, 10, 10, 10, 5, 4, 1 }, + [01] = [100], + [04] = [60, 30, 7, 3], + [05] = [40, 30, 18, 10, 2], + [10] = [20, 15, 15, 10, 10, 10, 10, 5, 4, 1], }; private void TC_Tables_DrawItem(object sender, DrawItemEventArgs e) diff --git a/pkNX.WinForms/Subforms/TextEditor.cs b/pkNX.WinForms/Subforms/TextEditor.cs index 12ad3f5d..6e1367a4 100644 --- a/pkNX.WinForms/Subforms/TextEditor.cs +++ b/pkNX.WinForms/Subforms/TextEditor.cs @@ -68,7 +68,7 @@ private void B_Import_Click(object sender, EventArgs e) public static void ExportTextFile(string fileName, bool newline, TextContainer lineData) { using var ms = new MemoryStream(); - ms.Write(new byte[] { 0xFF, 0xFE }, 0, 2); // Write Unicode BOM + ms.Write([0xFF, 0xFE], 0, 2); // Write Unicode BOM using (TextWriter tw = new StreamWriter(ms, new UnicodeEncoding())) { for (int i = 0; i < lineData.Length; i++) @@ -138,7 +138,7 @@ private bool ImportTextFiles(string fileName) i++; } i--; - textLines[ctr++] = Lines.ToArray(); + textLines[ctr++] = [.. Lines]; } // Error Check @@ -316,7 +316,7 @@ private void B_Randomize_Click(object sender, EventArgs e) } // Shuffle up - string[] pool = strings.ToArray(); + string[] pool = [.. strings]; Util.Shuffle(pool); // Apply Text diff --git a/pkNX.WinForms/Subforms/TypeChart.cs b/pkNX.WinForms/Subforms/TypeChart.cs index fe003a2e..13597f56 100644 --- a/pkNX.WinForms/Subforms/TypeChart.cs +++ b/pkNX.WinForms/Subforms/TypeChart.cs @@ -77,7 +77,7 @@ private void UpdateLabel(int X, int Y, int value) } private readonly string[] effects = - { + [ "has no effect!", "", "is not very effective.", @@ -87,7 +87,7 @@ private void UpdateLabel(int X, int Y, int value) "", "", "is super effective!", - }; + ]; public static void GetCoordinate(Control sender, MouseEventArgs e, out int X, out int Y) { @@ -101,7 +101,7 @@ public static void GetCoordinate(Control sender, MouseEventArgs e, out int X, ou public static byte ToggleEffectiveness(byte currentValue, bool increase) { - byte[] vals = { 0, 2, 4, 8 }; + byte[] vals = [0, 2, 4, 8]; int curIndex = Array.IndexOf(vals, currentValue); if (curIndex < 0) return currentValue; diff --git a/pkNX.WinForms/Themes/LeftMarginMultiplierConverter.cs b/pkNX.WinForms/Themes/LeftMarginMultiplierConverter.cs index f850b2e8..78d7b35d 100644 --- a/pkNX.WinForms/Themes/LeftMarginMultiplierConverter.cs +++ b/pkNX.WinForms/Themes/LeftMarginMultiplierConverter.cs @@ -4,23 +4,22 @@ using System.Windows.Controls; using System.Windows.Data; -namespace DarkBlendTheme +namespace DarkBlendTheme; + +public class LeftMarginMultiplierConverter : IValueConverter { - public class LeftMarginMultiplierConverter : IValueConverter + public double Length { get; set; } + + public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { - public double Length { get; set; } + if (value is not TreeViewItem item) + return new Thickness(0); - public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) - { - if (value is not TreeViewItem item) - return new Thickness(0); + return new Thickness(Length * item.GetDepth(), 0, 0, 0); + } - return new Thickness(Length * item.GetDepth(), 0, 0, 0); - } - - public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) - { - throw new NotImplementedException(); - } + public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) + { + throw new NotImplementedException(); } } diff --git a/pkNX.WinForms/Themes/TreeViewItemExtensions.cs b/pkNX.WinForms/Themes/TreeViewItemExtensions.cs index 82d3d30a..946ab85e 100644 --- a/pkNX.WinForms/Themes/TreeViewItemExtensions.cs +++ b/pkNX.WinForms/Themes/TreeViewItemExtensions.cs @@ -1,38 +1,30 @@ -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; using System.Windows.Media; -namespace DarkBlendTheme +namespace DarkBlendTheme; + +public static class TreeViewItemExtensions { - public static class TreeViewItemExtensions + public static int GetDepth(this TreeViewItem item) { - public static int GetDepth(this TreeViewItem item) + while (GetParent(item) is { } parent) { - TreeViewItem parent; - while ((parent = GetParent(item)) != null) - { - return GetDepth(parent) + 1; - } - return 0; + return GetDepth(parent) + 1; } + return 0; + } - private static TreeViewItem GetParent(TreeViewItem item) + private static TreeViewItem? GetParent(DependencyObject item) + { + var parent = VisualTreeHelper.GetParent(item); + + while (parent is not (TreeViewItem or TreeView)) { - var parent = VisualTreeHelper.GetParent(item); - - while (!(parent is TreeViewItem || parent is TreeView)) - { - if (parent == null) return null; - parent = VisualTreeHelper.GetParent(parent); - } - return parent as TreeViewItem; + if (parent == null) + return null; + parent = VisualTreeHelper.GetParent(parent); } + return parent as TreeViewItem; } } diff --git a/pkNX.WinForms/UI/MainWindow.xaml.cs b/pkNX.WinForms/UI/MainWindow.xaml.cs index 56e06f4b..777b7e0f 100644 --- a/pkNX.WinForms/UI/MainWindow.xaml.cs +++ b/pkNX.WinForms/UI/MainWindow.xaml.cs @@ -43,7 +43,7 @@ public partial class MainWindow public static readonly DependencyProperty CategoriesProperty = DependencyProperty.Register( nameof(Categories), typeof(EditorButtonData[]), typeof(MainWindow), new PropertyMetadata(Array.Empty())); - private static readonly string[] SupportedLanguages = { + private static readonly string[] SupportedLanguages = [ "カタカナ", "漢字", "English", @@ -54,7 +54,7 @@ public partial class MainWindow "한국", "汉字简化方案", "漢字簡化方案", - }; + ]; public EditorButtonData[] Categories { @@ -140,12 +140,8 @@ private void OpenPath(string path, GameVersion gameOverride = GameVersion.Any) else OpenFile(path); } - catch (Exception ex) + catch (Exception ex) when (!Debugger.IsAttached) { - // Rethrow to have a better debugging experience - if (Debugger.IsAttached) - throw; - WinFormsUtil.Error($"Failed to open -- {path}", ex.Message); } } @@ -196,12 +192,8 @@ private void OpenFolder(string path, GameVersion gameOverride) editor.Initialize(); LoadROM(editor); } - catch (Exception ex) + catch (Exception ex) when (!Debugger.IsAttached) { - // Rethrow to have a better debugging experience - if (Debugger.IsAttached) - throw; - var msg = "Failed to initialize ROM data." + Environment.NewLine + "Please ensure your dump is correctly set up, with updated patches merged in (if applicable)."; var stack = ex.StackTrace ?? string.Empty; @@ -243,7 +235,7 @@ private void LoadEditorButtons(EditorCategory category = EditorCategory.None) categories.AddRange(Editor!.GetControls(category, Settings.DisplayAdvanced).OrderBy(x => x.Title)); - Categories = categories.ToArray(); + Categories = [.. categories]; AdjustWindowSize(); @@ -259,8 +251,8 @@ private void CenterWindowOnScreen() var source = PresentationSource.FromVisual(this); var dpi = source?.CompositionTarget?.TransformFromDevice.M11 ?? 1.0; - Left = dpi * area.Left + (dpi * area.Width - Width) / 2; - Top = dpi * area.Top + (dpi * area.Height - Height) / 2; + Left = (dpi * area.Left) + (((dpi * area.Width) - Width) / 2); + Top = (dpi * area.Top) + (((dpi * area.Height) - Height) / 2); } private void AdjustWindowSize() @@ -281,8 +273,8 @@ private void AdjustWindowSize() double titleHeight = (SystemParameters.WindowCaptionHeight + SystemParameters.ResizeFrameHorizontalBorderHeight) * 1.5; double verticalBorderWidth = Math.Ceiling((SystemParameters.ResizeFrameVerticalBorderWidth + SystemParameters.FixedFrameVerticalBorderWidth) * 2) + 4; - Width = containerHorizontalMargin + columns * wp + verticalBorderWidth; - Height = SP_Header.Height + containerVerticalMargin + rows * hp + titleHeight; + Width = containerHorizontalMargin + (columns * wp) + verticalBorderWidth; + Height = SP_Header.Height + containerVerticalMargin + (rows * hp) + titleHeight; UpdateLayout(); diff --git a/pkNX.WinForms/UI/UIStaticSources.cs b/pkNX.WinForms/UI/UIStaticSources.cs index b51c9d4b..44003db9 100644 --- a/pkNX.WinForms/UI/UIStaticSources.cs +++ b/pkNX.WinForms/UI/UIStaticSources.cs @@ -2,35 +2,34 @@ using pkNX.Structures; using System; -namespace pkNX.WinForms +namespace pkNX.WinForms; + +public static class UIStaticSources { - public static class UIStaticSources + public static readonly string[] EvolutionMethods = Enum.GetNames(typeof(EvolutionType)); + public static readonly string[] EggGroups = Enum.GetNames(typeof(EggGroup)); + public static readonly string[] PokeColors = Enum.GetNames(typeof(PokeColor)); + public static readonly string[] EXPGroups = Enum.GetNames(typeof(EXPGroup)); + public static string[] SpeciesList = []; + public static string[] FormsList = []; + public static string[] SpeciesClassificationsList = []; + public static string[] ItemsList = []; + public static string[] AbilitiesList = []; + public static string[] MovesList = []; + public static string[] TypesList = []; + + public static void SetupForGame(GameManager ROM) { - public static readonly string[] EvolutionMethods = Enum.GetNames(typeof(EvolutionType)); - public static readonly string[] EggGroups = Enum.GetNames(typeof(EggGroup)); - public static readonly string[] PokeColors = Enum.GetNames(typeof(PokeColor)); - public static readonly string[] EXPGroups = Enum.GetNames(typeof(EXPGroup)); - public static string[] SpeciesList = []; - public static string[] FormsList = []; - public static string[] SpeciesClassificationsList = []; - public static string[] ItemsList = []; - public static string[] AbilitiesList = []; - public static string[] MovesList = []; - public static string[] TypesList = []; + if (ROM.Game == GameVersion.SV) + return; // SV doesn't support these file mappings yet - public static void SetupForGame(GameManager ROM) - { - if (ROM.Game == GameVersion.SV) - return; // SV doesn't support these file mappings yet - - SpeciesList = ROM.GetStrings(TextName.SpeciesNames); - FormsList = ROM.GetStrings(TextName.Forms); - ItemsList = ROM.GetStrings(TextName.ItemNames); - MovesList = ROM.GetStrings(TextName.MoveNames); - MovesList = EditorUtil.SanitizeMoveList(MovesList); - TypesList = ROM.GetStrings(TextName.TypeNames); - AbilitiesList = ROM.GetStrings(TextName.AbilityNames); - SpeciesClassificationsList = ROM.GetStrings(TextName.SpeciesClassifications); - } + SpeciesList = ROM.GetStrings(TextName.SpeciesNames); + FormsList = ROM.GetStrings(TextName.Forms); + ItemsList = ROM.GetStrings(TextName.ItemNames); + MovesList = ROM.GetStrings(TextName.MoveNames); + MovesList = EditorUtil.SanitizeMoveList(MovesList); + TypesList = ROM.GetStrings(TextName.TypeNames); + AbilitiesList = ROM.GetStrings(TextName.AbilityNames); + SpeciesClassificationsList = ROM.GetStrings(TextName.SpeciesClassifications); } } diff --git a/pkNX.WinForms/UI/WPFTextEditor.xaml.cs b/pkNX.WinForms/UI/WPFTextEditor.xaml.cs index adf31507..7e3271da 100644 --- a/pkNX.WinForms/UI/WPFTextEditor.xaml.cs +++ b/pkNX.WinForms/UI/WPFTextEditor.xaml.cs @@ -6,12 +6,10 @@ using System.Globalization; using System.IO; using System.Linq; -using System.Reflection.Metadata.Ecma335; using System.Runtime.CompilerServices; using System.Text; using System.Windows; using System.Windows.Controls; -using System.Windows.Data; using System.Windows.Input; using pkNX.Containers; using pkNX.Containers.VFS; @@ -123,7 +121,7 @@ public WPFTextEditor(TextEditorMode mode, TextConfig? config = null) private bool ImportTextFiles(string fileName) { - bool ValidateSeparatorIndex(int nextSeparator, int lineNumber, ReadOnlySpan line) + static bool ValidateSeparatorIndex(int nextSeparator, int lineNumber, ReadOnlySpan line) { if (nextSeparator != -1) return true; @@ -207,7 +205,7 @@ bool ValidateSeparatorIndex(int nextSeparator, int lineNumber, ReadOnlySpan|]+", RegexOptions.Compiled); + public Regex AllowedChars = MyRegex(); + + [GeneratedRegex("[^\\/:*?\"<>|]+", RegexOptions.Compiled)] + private static partial Regex MyRegex(); public bool IsInEditMode { @@ -165,7 +168,7 @@ public EditableTextBlockAdorner(EditableTextBlock adornedElement) _textBox.SetBinding(TextBox.TextProperty, binding); _textBox.AcceptsReturn = true; _textBox.MaxLength = adornedElement.MaxLength; - _textBox.PreviewTextInput += (obj, e) => { e.Handled = !adornedElement.AllowedChars.IsMatch(e.Text); }; + _textBox.PreviewTextInput += (obj, e) => e.Handled = !adornedElement.AllowedChars.IsMatch(e.Text); _textBox.PreviewKeyDown += TextBox_PreviewKeyDown; _textBox.Width = adornedElement.Width; _textBox.Height = adornedElement.Height; diff --git a/pkNX.WinForms/Utils/FormsIconHelper.cs b/pkNX.WinForms/Utils/FormsIconHelper.cs index e405c7b5..fd5e29dc 100644 --- a/pkNX.WinForms/Utils/FormsIconHelper.cs +++ b/pkNX.WinForms/Utils/FormsIconHelper.cs @@ -16,11 +16,11 @@ private static int UniCode(this TEnum icon) } private static readonly string[] FontTitles = - { + [ "Font Awesome 6 Free Regular", // fa-regular-400.ttf "Font Awesome 6 Free Solid", // fa-solid-900.ttf "Font Awesome 6 Brands Regular", // fa-brands-400.ttf - }; + ]; private static readonly Typeface[] Typefaces = typeof(IconHelper).Assembly.LoadTypefaces("fonts", FontTitles); diff --git a/pkNX.WinForms/Utils/MultiSelectTreeView.cs b/pkNX.WinForms/Utils/MultiSelectTreeView.cs index da7c930b..17c9f224 100644 --- a/pkNX.WinForms/Utils/MultiSelectTreeView.cs +++ b/pkNX.WinForms/Utils/MultiSelectTreeView.cs @@ -11,16 +11,10 @@ namespace pkNX.WinForms; -public class SelectedItemsChangedEventArgs : EventArgs +public class SelectedItemsChangedEventArgs(IList oldSelection, IList newSelection) : EventArgs { - public IList OldSelection { get; private set; } - public IList NewSelection { get; private set; } - - public SelectedItemsChangedEventArgs(IList oldSelection, IList newSelection) - { - OldSelection = oldSelection; - NewSelection = newSelection; - } + public IList OldSelection { get; private set; } = oldSelection; + public IList NewSelection { get; private set; } = newSelection; } public delegate void SelectedItemsChangedEventHandler(object sender, SelectedItemsChangedEventArgs e); @@ -100,7 +94,7 @@ protected override void OnPreviewMouseDown(MouseButtonEventArgs e) base.OnPreviewMouseDown(e); // If clicking on a tree branch expander... - if (e.OriginalSource is Shape || e.OriginalSource is Grid || e.OriginalSource is Border) + if (e.OriginalSource is Shape or Grid or Border) return; var item = GetTreeViewItemClicked((FrameworkElement)e.OriginalSource); diff --git a/pkNX.WinForms/Utils/NotifyObservableCollection.cs b/pkNX.WinForms/Utils/NotifyObservableCollection.cs index e2fb3871..898b53fd 100644 --- a/pkNX.WinForms/Utils/NotifyObservableCollection.cs +++ b/pkNX.WinForms/Utils/NotifyObservableCollection.cs @@ -78,7 +78,7 @@ public void RemoveRange(IEnumerable collection) /// public void Replace(T item) { - ReplaceRange(new[] { item }); + ReplaceRange([item]); } /// diff --git a/pkNX.WinForms/Utils/NumericTextBox.cs b/pkNX.WinForms/Utils/NumericTextBox.cs index 4a0d7431..7515d298 100644 --- a/pkNX.WinForms/Utils/NumericTextBox.cs +++ b/pkNX.WinForms/Utils/NumericTextBox.cs @@ -14,7 +14,7 @@ public enum NumericTextBoxMode Double, } -public class NumericTextBox : TextBox +public partial class NumericTextBox : TextBox { public static readonly DependencyProperty MinValueProperty = DependencyProperty.Register(nameof(MinValue), typeof(double), typeof(NumericTextBox), new PropertyMetadata(double.NegativeInfinity)); @@ -35,8 +35,11 @@ public class NumericTextBox : TextBox // Use this to check for value changes public event EventHandler EvaluatedValueChanged; - private readonly Regex doubleChars = new(@"[^\d.\-*^%\+/()]+", RegexOptions.Compiled); - private readonly Regex intChars = new(@"[^\d-*^%\+/()]+", RegexOptions.Compiled); + private readonly Regex doubleChars = RexexChar(); + + private readonly Regex intChars = RegexInt(); + [GeneratedRegex(@"[^\d.\-*^%\+/()]+", RegexOptions.Compiled)] private static partial Regex RexexChar(); + [GeneratedRegex(@"[^\d-*^%\+/()]+", RegexOptions.Compiled)] private static partial Regex RegexInt(); private static readonly string textFormat = "0.##"; @@ -45,7 +48,7 @@ public NumericTextBox() SetResourceReference(StyleProperty, typeof(TextBox)); Text = EvaluatedValue.ToString(textFormat, CultureInfo.InvariantCulture); - PreviewTextInput += (obj, e) => { e.Handled = !IsTextAllowed(e.Text); }; + PreviewTextInput += (obj, e) => e.Handled = !IsTextAllowed(e.Text); PreviewKeyDown += OnPreviewKeyDown; LostFocus += OnLostFocus; TextChanged += OnTextChanged; diff --git a/pkNX.WinForms/Utils/Utils.cs b/pkNX.WinForms/Utils/Utils.cs index 408d0536..90fcd30f 100644 --- a/pkNX.WinForms/Utils/Utils.cs +++ b/pkNX.WinForms/Utils/Utils.cs @@ -14,17 +14,17 @@ namespace pkNX.WinForms; // Source: https://stackoverflow.com/questions/21750824/how-to-convert-a-string-to-a-mathematical-expression-programmatically -public class StringToFormula +public static class StringToFormula { - private static readonly string[] operators = { "-", "+", "/", "%", "*", "^" }; - private static readonly Func[] operations = { + private static readonly string[] operators = ["-", "+", "/", "%", "*", "^"]; + private static readonly Func[] operations = [ (a1, a2) => a1 - a2, (a1, a2) => a1 + a2, (a1, a2) => a1 / a2, (a1, a2) => a1 % a2, (a1, a2) => a1 * a2, Math.Pow, - }; + ]; public static bool TryEval(string expression, out double value) { @@ -43,8 +43,8 @@ public static bool TryEval(string expression, out double value) public static double Eval(string expression) { List tokens = GetTokens(expression); - Stack operandStack = new Stack(); - Stack operatorStack = new Stack(); + var operandStack = new Stack(); + var operatorStack = new Stack(); int tokenIndex = 0; while (tokenIndex < tokens.Count) @@ -78,7 +78,7 @@ public static double Eval(string expression) { operandStack.Push(double.Parse(token, CultureInfo.InvariantCulture)); } - tokenIndex += 1; + tokenIndex++; } while (operatorStack.Count > 0) @@ -93,48 +93,39 @@ public static double Eval(string expression) private static string GetSubExpression(IReadOnlyList tokens, ref int index) { - StringBuilder subExpr = new StringBuilder(); + var subExpr = new StringBuilder(); int parenlevels = 1; - index += 1; + index++; while (index < tokens.Count && parenlevels > 0) { string token = tokens[index]; if (tokens[index] == "(") - { - parenlevels += 1; - } - - if (tokens[index] == ")") - { - parenlevels -= 1; - } + parenlevels++; + else if (tokens[index] == ")") + parenlevels--; if (parenlevels > 0) - { subExpr.Append(token); - } - index += 1; + index++; } - if ((parenlevels > 0)) - { + if (parenlevels > 0) throw new ArgumentException("Mis-matched parentheses in expression"); - } return subExpr.ToString(); } private static List GetTokens(string expression) { - string operators = "()^*/%+-"; + const string operators = "()^*/%+-"; List tokens = []; StringBuilder sb = new(); foreach (char c in expression.Replace(" ", string.Empty)) { - if (operators.IndexOf(c) >= 0) + if (operators.Contains(c)) { - if ((sb.Length > 0)) + if (sb.Length > 0) { tokens.Add(sb.ToString()); sb.Length = 0; @@ -189,46 +180,18 @@ public static IconChar FromFileExtension(string fileExtension) { fileExtension = fileExtension.Replace(".", "").ToLowerInvariant(); // Make sure it doesn't contain a dot - switch (fileExtension) // Only add icons for supported extensions + return fileExtension switch // Only add icons for supported extensions { - case "obj": - case "fbx": - return IconChar.Shapes; - case "vox": - return IconChar.Th; - case "txt": - case "json": - return IconChar.FileAlt; - case "zip": - return IconChar.FileArchive; - case "wav": - return IconChar.FileAudio; - case "jpg": - case "jpeg": - case "png": - case "tga": - case "bmp": - case "psd": - case "gif": - case "hdr": - case "pic": - return IconChar.FileImage; - case "cs": - case "cpp": - case "hpp": - case "h": - return IconChar.FileCode; - case "fx": - case "ps": - case "vs": - case "hs": - case "ds": - case "gs": - case "comp": - return IconChar.FileCode; // Shaders - default: - return IconChar.File; - } + "obj" or "fbx" => IconChar.Shapes, + "vox" => IconChar.Th, + "txt" or "json" => IconChar.FileAlt, + "zip" => IconChar.FileArchive, + "wav" => IconChar.FileAudio, + "jpg" or "jpeg" or "png" or "tga" or "bmp" or "psd" or "gif" or "hdr" or "pic" => IconChar.FileImage, + "cs" or "cpp" or "hpp" or "h" => IconChar.FileCode, + "fx" or "ps" or "vs" or "hs" or "ds" or "gs" or "comp" => IconChar.FileCode,// Shaders + _ => IconChar.File, + }; } public static bool HasChildren(this DependencyObject? depObj) @@ -372,7 +335,7 @@ public static void FocusParent(this FrameworkElement element) } private static readonly string[] SizeSuffixes = - { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" }; + ["bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; public static string FormatByteString(long value, int decimalPlaces = 1) { if (decimalPlaces < 0) { throw new ArgumentOutOfRangeException(nameof(decimalPlaces)); } @@ -396,7 +359,7 @@ public static string FormatByteString(long value, int decimalPlaces = 1) if (Math.Round(adjustedSize, decimalPlaces) < 1000) return string.Format("{0:n" + decimalPlaces + "} {1}", adjustedSize, SizeSuffixes[mag]); - mag += 1; + mag++; adjustedSize /= 1024; return string.Format("{0:n" + decimalPlaces + "} {1}", adjustedSize, SizeSuffixes[mag]); @@ -436,18 +399,17 @@ public static void CopyFile(string sourceFilePath, string destinationFilePath, b if (!overwrite) { - FileInfo source = new FileInfo(sourceFilePath); + var source = new FileInfo(sourceFilePath); - var caption = "Overwrite file"; - var msg = string.Format("A file with the name \"{0}\" already exists in the folder: \"{1}\"\nWould you like to overwrite the file?", - source.Name, source.DirectoryName); + const string caption = "Overwrite file"; + var msg = $"A file with the name \"{source.Name}\" already exists in the folder: \"{source.DirectoryName}\"\nWould you like to overwrite the file?"; overwrite = MessageBox.Show(msg, caption, MessageBoxButton.YesNo, MessageBoxImage.Warning) == MessageBoxResult.Yes; } if (overwrite) { - FileUtils.RemoveReadOnly(destinationFilePath); + RemoveReadOnly(destinationFilePath); File.Copy(sourceFilePath, destinationFilePath, true); } } @@ -458,12 +420,12 @@ public static void CopyFileToDirectory(string sourceFilePath, string destination if (sourceFilePath == destinationDirPath) return; - FileInfo source = new FileInfo(sourceFilePath); + var source = new FileInfo(sourceFilePath); if (!source.Exists) - throw new DirectoryNotFoundException(string.Format("Source file does not exist: {0}", sourceFilePath)); + throw new DirectoryNotFoundException($"Source file does not exist: {sourceFilePath}"); if (!Directory.Exists(destinationDirPath)) - throw new DirectoryNotFoundException(string.Format("Destination directory does not exist: {0}", destinationDirPath)); + throw new DirectoryNotFoundException($"Destination directory does not exist: {destinationDirPath}"); CopyFile(sourceFilePath, destinationDirPath + "/" + source.Name); } @@ -472,10 +434,10 @@ public static void CopyDirectory(string sourceDirPath, string destinationDirPath { DirectoryInfo source = new DirectoryInfo(sourceDirPath); if (!source.Exists) - throw new DirectoryNotFoundException(string.Format("Source directory does not exist: {0}", sourceDirPath)); + throw new DirectoryNotFoundException($"Source directory does not exist: {sourceDirPath}"); if (!Directory.Exists(destinationDirPath)) - throw new DirectoryNotFoundException(string.Format("Destination directory does not exist: {0}", destinationDirPath)); + throw new DirectoryNotFoundException($"Destination directory does not exist: {destinationDirPath}"); string newDirPath = destinationDirPath + "/" + source.Name; @@ -499,18 +461,11 @@ public static class ColorUtils { public static readonly double RGBToDouble = 0.0039215686274509803921568627451; - public struct RGB + public struct RGB(double r, double g, double b) { - public double R { get; set; } - public double G { get; set; } - public double B { get; set; } - - public RGB(double r, double g, double b) - { - R = r; - G = g; - B = b; - } + public double R { get; set; } = r; + public double G { get; set; } = g; + public double B { get; set; } = b; public static RGB FromColor(Color color) { @@ -528,18 +483,11 @@ public Color ToColor(byte alpha) } }; - public struct HSV + public struct HSV(double h, double s, double v) { - public double H { get; set; } - public double S { get; set; } - public double V { get; set; } - - public HSV(double h, double s, double v) - { - H = h; - S = s; - V = v; - } + public double H { get; set; } = h; + public double S { get; set; } = s; + public double V { get; set; } = v; }; public static RGB HSVtoRGB(HSV hsv) @@ -581,7 +529,7 @@ public static HSV RGBToHSV(RGB rgb) double delta = max - min; - HSV hsv = new HSV + var hsv = new HSV { V = max, }; @@ -598,9 +546,9 @@ public static HSV RGBToHSV(RGB rgb) if (rgb.R == max) hsv.H = (rgb.G - rgb.B) / delta; // between yellow & magenta else if (rgb.G == max) - hsv.H = 2 + (rgb.B - rgb.R) / delta; // between cyan & yellow + hsv.H = 2 + ((rgb.B - rgb.R) / delta); // between cyan & yellow else - hsv.H = 4 + (rgb.R - rgb.G) / delta; // between magenta & cyan + hsv.H = 4 + ((rgb.R - rgb.G) / delta); // between magenta & cyan hsv.H *= 60; // degrees if (hsv.H < 0)