diff --git a/SM64Lib.LIBMIO0/MIO0.cs b/SM64Lib.LIBMIO0/MIO0.cs index f94338d..2d59c29 100644 --- a/SM64Lib.LIBMIO0/MIO0.cs +++ b/SM64Lib.LIBMIO0/MIO0.cs @@ -93,7 +93,7 @@ public class MIO0 public static byte[] mio0_decode(byte[] mio0_buf) { - MIO0_Header head = new MIO0_Header(); + MIO0_Header head = new(); uint bytes_written = 0; int bit_idx = 0; int comp_idx = 0; diff --git a/SM64Lib.N64Graphics/TextureFormat.cs b/SM64Lib.N64Graphics/TextureFormat.cs index 7e447fb..c41f820 100644 --- a/SM64Lib.N64Graphics/TextureFormat.cs +++ b/SM64Lib.N64Graphics/TextureFormat.cs @@ -9,7 +9,7 @@ public class TextureFormats { public static Bitmap createColorTexture(Color color) { - Bitmap tex = new Bitmap(1, 1); + Bitmap tex = new(1, 1); Graphics.FromImage(tex).Clear(color); return tex; } @@ -306,7 +306,7 @@ public class TextureFormats public static Bitmap decode1BPP(byte[] data, int width, int height) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= (width * height) / 8) // Sanity Check { int len = (width * height) / 8; @@ -332,7 +332,7 @@ public class TextureFormats { Console.WriteLine("Texture size = (" + width + "x" + height + ")"); Console.WriteLine("data.Length = (" + data.Length + ")"); - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= width * height * 4) // Sanity Check { @@ -358,7 +358,7 @@ public class TextureFormats public static Bitmap decodeRGBA16(byte[] data, int width, int height) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= width * height * 2) // Sanity Check { BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height), @@ -385,7 +385,7 @@ public class TextureFormats public static Bitmap decodeIA16(byte[] data, int width, int height) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= width * height * 2) // Sanity Check { BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height), @@ -410,7 +410,7 @@ public class TextureFormats public static Bitmap decodeIA8(byte[] data, int width, int height) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= width * height) // Sanity Check { BitmapData bitmapData = tex.LockBits(new Rectangle(0, 0, width, height), @@ -435,7 +435,7 @@ public class TextureFormats } public static Bitmap decodeIA4(byte[] data, int width, int height) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= (width * height) / 2) // Sanity Check { @@ -469,7 +469,7 @@ public class TextureFormats } public static Bitmap decodeI8(byte[] data, int width, int height) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= width * height) // Sanity Check { @@ -496,7 +496,7 @@ public class TextureFormats } public static Bitmap decodeI4(byte[] data, int width, int height) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= (width * height) / 2) // Sanity Check { @@ -531,7 +531,7 @@ public class TextureFormats public static Bitmap decodeCI4(byte[] data, int width, int height, ushort[] palette) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= (width * height) / 2) // Sanity Check { @@ -565,7 +565,7 @@ public class TextureFormats public static Bitmap decodeCI8(byte[] data, int width, int height, ushort[] palette) { - Bitmap tex = new Bitmap(width, height); + Bitmap tex = new(width, height); if (data.Length >= width * height) // Sanity Check { diff --git a/SM64Lib/ASM/CustomAsmArea.cs b/SM64Lib/ASM/CustomAsmArea.cs index dbff10b..f560387 100644 --- a/SM64Lib/ASM/CustomAsmArea.cs +++ b/SM64Lib/ASM/CustomAsmArea.cs @@ -15,8 +15,7 @@ public class CustomAsmArea { get { - if (config == null) - config = new CustomAsmAreaConfig(); + config ??= new CustomAsmAreaConfig(); return config; } } diff --git a/SM64Lib/ASM/CustomAsmBank.cs b/SM64Lib/ASM/CustomAsmBank.cs index 33450a5..2195b4c 100644 --- a/SM64Lib/ASM/CustomAsmBank.cs +++ b/SM64Lib/ASM/CustomAsmBank.cs @@ -8,7 +8,7 @@ public class CustomAsmBank { public CustomAsmBankConfig Config { get; } [JsonIgnore] - public List Areas { get; } = new List(); + public List Areas { get; } = []; public CustomAsmBank() : this(new CustomAsmBankConfig()) { diff --git a/SM64Lib/ASM/CustomAsmBankConfig.cs b/SM64Lib/ASM/CustomAsmBankConfig.cs index 63df9ef..4c65ec5 100644 --- a/SM64Lib/ASM/CustomAsmBankConfig.cs +++ b/SM64Lib/ASM/CustomAsmBankConfig.cs @@ -9,7 +9,7 @@ public class CustomAsmBankConfig public static int DefaultRomStartAddress { get; internal set; } = 0x1206000; public static int DefaultRamStartAddress { get; internal set; } = 0x406000; - public List Areas { get; } = new List(); + public List Areas { get; } = []; public int MaxLength { get; set; } = -1; [JsonProperty] public int Length { get; internal set; } = -1; diff --git a/SM64Lib/Behaviors/Behavior.cs b/SM64Lib/Behaviors/Behavior.cs index 5af431b..e78b5cc 100644 --- a/SM64Lib/Behaviors/Behavior.cs +++ b/SM64Lib/Behaviors/Behavior.cs @@ -12,7 +12,7 @@ namespace SM64Lib.Behaviors; public class Behavior { - private readonly Dictionary knownCustomAsmCommands = new Dictionary(); + private readonly Dictionary knownCustomAsmCommands = []; [JsonProperty] public BehaviorConfig Config { get; private set; } @@ -20,7 +20,7 @@ public class Behavior public Behaviorscript Script { get; private set; } public int CollisionPointer { get; set; } public bool EnableCollisionPointer { get; set; } - public List BehaviorAddressDestinations { get; set; } = new List(); + public List BehaviorAddressDestinations { get; set; } = []; [JsonIgnore] public long Length @@ -72,7 +72,7 @@ public class Behavior { if (Script != null) Script.Close(); - Script = new Behaviorscript(); + Script = []; } public bool Read(BinaryData data, int address) @@ -154,7 +154,7 @@ public class Behavior if (cmdStartLoop is not null) iInsert = cmdStartLoopIndex; else - iInsert = (int)Script.Count - 2; + iInsert = Script.Count - 2; } if (knownCustomAsmCommands.ContainsKey(link.CustomAsmAreaConfig)) diff --git a/SM64Lib/Behaviors/BehaviorBank.cs b/SM64Lib/Behaviors/BehaviorBank.cs index 1abfb8d..e48bddb 100644 --- a/SM64Lib/Behaviors/BehaviorBank.cs +++ b/SM64Lib/Behaviors/BehaviorBank.cs @@ -11,7 +11,7 @@ namespace SM64Lib.Behaviors; public class BehaviorBank { public BehaviorBankConfig Config { get; private set; } - public List Behaviors { get; } = new List(); + public List Behaviors { get; } = []; [JsonIgnore] public long Length @@ -36,8 +36,10 @@ public class BehaviorBank private void ReadBank(SegmentedBank seg, int offset, bool isVanilla) { - var data = new BinaryStreamData(seg.Data); - data.Position = offset; + var data = new BinaryStreamData(seg.Data) + { + Position = offset + }; ReadBank(data, isVanilla, seg.Length, (sbyte)seg.BankID); } @@ -69,7 +71,7 @@ public class BehaviorBank void readBehavior(BehaviorConfig config) { int bankOffset; - Behavior behav = new Behavior(config); + Behavior behav = new(config); if (isVanilla) { @@ -108,8 +110,10 @@ public class BehaviorBank { var addressUpdates = new Dictionary(); var segStartAddress = seg.BankAddress | offset; - var data = new BinaryStreamData(seg.Data); - data.Position = offset; + var data = new BinaryStreamData(seg.Data) + { + Position = offset + }; if (Behaviors.Any()) { diff --git a/SM64Lib/Behaviors/BehaviorBankConfig.cs b/SM64Lib/Behaviors/BehaviorBankConfig.cs index 218f4b9..23c33f1 100644 --- a/SM64Lib/Behaviors/BehaviorBankConfig.cs +++ b/SM64Lib/Behaviors/BehaviorBankConfig.cs @@ -6,7 +6,7 @@ namespace SM64Lib.Behaviors; public class BehaviorBankConfig { public bool IsVanilla { get; set; } = true; - public List BehaviorConfigs { get; } = new List(); + public List BehaviorConfigs { get; } = []; [JsonProperty(nameof(Enabled))] private bool enabled = false; diff --git a/SM64Lib/Behaviors/BehaviorConfig.cs b/SM64Lib/Behaviors/BehaviorConfig.cs index 944d915..11e02a3 100644 --- a/SM64Lib/Behaviors/BehaviorConfig.cs +++ b/SM64Lib/Behaviors/BehaviorConfig.cs @@ -17,7 +17,7 @@ public class BehaviorConfig public string Name { get; set; } = string.Empty; public int FixedLength { get; set; } = -1; public int ExpectedLength { get; set; } = -1; - public List CustomAsmLinks { get; } = new List(); + public List CustomAsmLinks { get; } = []; public BehaviorParamsInfo ParamsInfo { get; } = new BehaviorParamsInfo(); public Behavior FindBehavior() diff --git a/SM64Lib/Behaviors/BehaviorParamInfo.cs b/SM64Lib/Behaviors/BehaviorParamInfo.cs index 30fb7eb..43e0b32 100644 --- a/SM64Lib/Behaviors/BehaviorParamInfo.cs +++ b/SM64Lib/Behaviors/BehaviorParamInfo.cs @@ -6,5 +6,5 @@ public class BehaviorParamInfo { public string Name { get; set; } = string.Empty; public string Description { get; set; } = string.Empty; - public List Values { get; } = new List(); + public List Values { get; } = []; } diff --git a/SM64Lib/Behaviors/Script/Behaviorscript.cs b/SM64Lib/Behaviors/Script/Behaviorscript.cs index d016b68..d3fb427 100644 --- a/SM64Lib/Behaviors/Script/Behaviorscript.cs +++ b/SM64Lib/Behaviors/Script/Behaviorscript.cs @@ -98,7 +98,7 @@ public class Behaviorscript : BehaviorscriptCommandCollection public BehaviorscriptCommand FirstOfType(BehaviorscriptCommandTypes cmdType) { - return (BehaviorscriptCommand)this.FirstOrDefault(n => n.CommandType == cmdType); + return this.FirstOrDefault(n => n.CommandType == cmdType); } } \ No newline at end of file diff --git a/SM64Lib/Configuration/CollisionBasicConfig.cs b/SM64Lib/Configuration/CollisionBasicConfig.cs index 38ee63c..6291653 100644 --- a/SM64Lib/Configuration/CollisionBasicConfig.cs +++ b/SM64Lib/Configuration/CollisionBasicConfig.cs @@ -6,8 +6,7 @@ namespace SM64Lib.Configuration; public class CollisionBasicConfig { - private List collisionTypesWithParams = new List() - { 4, 14, 44, 36, 37, 39, 45 }; + private List collisionTypesWithParams = [4, 14, 44, 36, 37, 39, 45]; [JsonProperty("CollisionTypesWithParamsV2", ObjectCreationHandling = ObjectCreationHandling.Replace)] public List CollisionTypesWithParams diff --git a/SM64Lib/Configuration/CustomModelConfig.cs b/SM64Lib/Configuration/CustomModelConfig.cs index 89b3842..5ab8954 100644 --- a/SM64Lib/Configuration/CustomModelConfig.cs +++ b/SM64Lib/Configuration/CustomModelConfig.cs @@ -14,7 +14,7 @@ public class CustomModelConfig [JsonConverter(typeof(UniquieIDStringJsonConverter))] public UniquieID ID { get; set; } = new(); public string Name { get; set; } = string.Empty; - public List CollisionPointerDestinations { get; private set; } = new List(); + public List CollisionPointerDestinations { get; private set; } = []; public CustomModel FindModel() { diff --git a/SM64Lib/Configuration/LevelAreaConfig.cs b/SM64Lib/Configuration/LevelAreaConfig.cs index 338c0a6..1a683eb 100644 --- a/SM64Lib/Configuration/LevelAreaConfig.cs +++ b/SM64Lib/Configuration/LevelAreaConfig.cs @@ -5,5 +5,5 @@ namespace SM64Lib.Configuration; public class LevelAreaConfig { public string AreaName { get; set; } - public Dictionary ScrollingNames { get; set; } = new Dictionary(); + public Dictionary ScrollingNames { get; set; } = []; } \ No newline at end of file diff --git a/SM64Lib/Configuration/LevelConfig.cs b/SM64Lib/Configuration/LevelConfig.cs index 8743b88..9582251 100644 --- a/SM64Lib/Configuration/LevelConfig.cs +++ b/SM64Lib/Configuration/LevelConfig.cs @@ -7,7 +7,7 @@ public class LevelConfig public string LevelName { get; set; } public bool EnableLocalObjectBank { get; set; } = false; public ObjectModelConfig LocalObjectBank { get; set; } = new ObjectModelConfig(); - public Dictionary AreaConfigs { get; private set; } = new Dictionary(); + public Dictionary AreaConfigs { get; private set; } = []; public LevelAreaConfig GetLevelAreaConfig(byte areaID) { diff --git a/SM64Lib/Configuration/MusicConfiguration.cs b/SM64Lib/Configuration/MusicConfiguration.cs index 03ac8b2..92735bc 100644 --- a/SM64Lib/Configuration/MusicConfiguration.cs +++ b/SM64Lib/Configuration/MusicConfiguration.cs @@ -4,5 +4,5 @@ namespace SM64Lib.Configuration; public class MusicConfiguration { - public List SqeuenceNames { get; private set; } = new List(); + public List SqeuenceNames { get; private set; } = []; } \ No newline at end of file diff --git a/SM64Lib/Configuration/ObjectModelConfig.cs b/SM64Lib/Configuration/ObjectModelConfig.cs index f2bb2ad..3149af0 100644 --- a/SM64Lib/Configuration/ObjectModelConfig.cs +++ b/SM64Lib/Configuration/ObjectModelConfig.cs @@ -4,7 +4,7 @@ namespace SM64Lib.Configuration; public class ObjectModelConfig { - public Dictionary CustomObjectConfigs { get; private set; } = new Dictionary(); + public Dictionary CustomObjectConfigs { get; private set; } = []; public CustomModelConfig GetCustomObjectConfig(int id) { diff --git a/SM64Lib/Configuration/RomConfig.cs b/SM64Lib/Configuration/RomConfig.cs index c590005..5a91b27 100644 --- a/SM64Lib/Configuration/RomConfig.cs +++ b/SM64Lib/Configuration/RomConfig.cs @@ -13,7 +13,7 @@ namespace SM64Lib.Configuration; public class RomConfig { // Levels - public Dictionary LevelConfigs { get; } = new Dictionary(); + public Dictionary LevelConfigs { get; } = []; // Global Banks [JsonProperty("GlobalObjectBankConfig")] @@ -33,14 +33,14 @@ public class RomConfig // Other public ScrollTexConfig ScrollTexConfig { get; set; } = new ScrollTexConfig(); - public ObjectBankDataListCollection ObjectBankInfoData { get; } = new ObjectBankDataListCollection(); + public ObjectBankDataListCollection ObjectBankInfoData { get; } = []; public NPCConfig NPCConfig { get; } = new NPCConfig(); public CollisionBasicConfig CollisionBaseConfig { get; } = new CollisionBasicConfig(); /// /// Contains custom configuration that isn't used by SM64Lib. E.g. Extra Object Combos. /// - public Dictionary CustomConfigs { get; } = new Dictionary(); + public Dictionary CustomConfigs { get; } = []; // F e a t u r e s diff --git a/SM64Lib/Data/BinaryData.cs b/SM64Lib/Data/BinaryData.cs index 6523a04..24cba26 100644 --- a/SM64Lib/Data/BinaryData.cs +++ b/SM64Lib/Data/BinaryData.cs @@ -27,10 +27,7 @@ public abstract class BinaryData : IDisposable { get { - if (_writer is null) - { - _writer = new BinaryWriter(BaseStream); - } + _writer ??= new BinaryWriter(BaseStream); return _writer; } @@ -40,10 +37,7 @@ public abstract class BinaryData : IDisposable { get { - if (_reader is null) - { - _reader = new BinaryReader(BaseStream); - } + _reader ??= new BinaryReader(BaseStream); return _reader; } diff --git a/SM64Lib/FilePathsConfiguration.cs b/SM64Lib/FilePathsConfiguration.cs index 92448f7..e71c376 100644 --- a/SM64Lib/FilePathsConfiguration.cs +++ b/SM64Lib/FilePathsConfiguration.cs @@ -19,7 +19,7 @@ public class FilePathsConfiguration // F I E L D S - private readonly Dictionary dic = new Dictionary(); + private readonly Dictionary dic = []; // P R O P E R T I E S diff --git a/SM64Lib/Geolayout/Geolayout.cs b/SM64Lib/Geolayout/Geolayout.cs index bd5c2ca..81d6971 100644 --- a/SM64Lib/Geolayout/Geolayout.cs +++ b/SM64Lib/Geolayout/Geolayout.cs @@ -13,11 +13,11 @@ public class Geolayout [JsonProperty] private int IndexForGeopointers = -1; - public Geolayoutscript Geolayoutscript { get; set; } = new Geolayoutscript(); + public Geolayoutscript Geolayoutscript { get; set; } = []; public CameraPresets CameraPreset { get; set; } = CameraPresets.OpenCamera; public EnvironmentEffects EnvironmentEffect { get; set; } = default; - public List GeopointerOffsets { get; set; } = new List(); - public List Geopointers { get; set; } = new List(); + public List GeopointerOffsets { get; set; } = []; + public List Geopointers { get; set; } = []; public int NewGeoOffset { get; set; } = 0; public bool Closed { get; set; } = false; public ObjectShadow ObjectShadow { get; set; } = new ObjectShadow(); @@ -54,7 +54,7 @@ public class Geolayout private List GetGeopointersFromGeolayoutScript(Geolayoutscript script) { - List geopointers = new List(); + List geopointers = []; int geolayoutCommandIndex = 0; var curMdlScale = System.Numerics.Vector3.One; var curMdlOffset = System.Numerics.Vector3.Zero; @@ -157,7 +157,7 @@ public class Geolayout Geolayoutscript.Clear(); Geopointers.Clear(); GeopointerOffsets.Clear(); - Geolayoutscript = new Geolayoutscript(); + Geolayoutscript = []; ObjectShadow = new ObjectShadow(); CameraFrustrum = new CameraFrustrum(); } diff --git a/SM64Lib/Geolayout/Script/GeolayoutCommandFunctions.cs b/SM64Lib/Geolayout/Script/GeolayoutCommandFunctions.cs index f33ef06..1187879 100644 --- a/SM64Lib/Geolayout/Script/GeolayoutCommandFunctions.cs +++ b/SM64Lib/Geolayout/Script/GeolayoutCommandFunctions.cs @@ -161,10 +161,12 @@ namespace SM64Lib.Geolayout.Script public static Vector3 GetOffset(ref GeolayoutCommand command) { command.Position = 2; - var value = new Vector3(); - value.X = command.ReadInt16(); - value.Y = command.ReadInt16(); - value.Z = command.ReadInt16(); + var value = new Vector3 + { + X = command.ReadInt16(), + Y = command.ReadInt16(), + Z = command.ReadInt16() + }; command.Position = 0; return value; } @@ -204,9 +206,11 @@ namespace SM64Lib.Geolayout.Script public static Vector3 GetOffset(ref GeolayoutCommand command) { command.Position = 2; - var value = new Vector3(); - value.X = command.ReadInt16(); - value.Y = command.ReadInt16(); + var value = new Vector3 + { + X = command.ReadInt16(), + Y = command.ReadInt16() + }; command.Position += 2; value.Z = command.ReadInt16(); command.Position = 0; diff --git a/SM64Lib/Geolayout/Script/Geolayoutscript.cs b/SM64Lib/Geolayout/Script/Geolayoutscript.cs index fb7da9a..77a7f54 100644 --- a/SM64Lib/Geolayout/Script/Geolayoutscript.cs +++ b/SM64Lib/Geolayout/Script/Geolayoutscript.cs @@ -9,7 +9,7 @@ namespace SM64Lib.Geolayout.Script; public class Geolayoutscript : GeolayoutCommandCollection { - public List GeopointerOffsets = new List(); + public List GeopointerOffsets = []; public Geolayoutscript() { @@ -43,8 +43,10 @@ public class Geolayoutscript : GeolayoutCommandCollection GeopointerOffsets.Clear(); if (segBank is null) return; - var data = new BinaryStreamData(segBank.Data); - data.Position = offset; + var data = new BinaryStreamData(segBank.Data) + { + Position = offset + }; var tb = new List(); GeolayoutCommandTypes cb = default; int subNodeIndex = 0; diff --git a/SM64Lib/Level/Level.cs b/SM64Lib/Level/Level.cs index bc5f105..88df309 100644 --- a/SM64Lib/Level/Level.cs +++ b/SM64Lib/Level/Level.cs @@ -28,9 +28,9 @@ public abstract class Level internal LevelscriptCommand LastGobCmdSegLoad { get; set; } = null; internal LevelscriptCommand LastLobCmdSegLoad { get; set; } = null; [JsonIgnore] - internal Dictionary MyObjectBanks { get; private set; } = new Dictionary(); - public Levelscript Levelscript { get; set; } = new Levelscript(); - public List Areas { get; private set; } = new List(); + internal Dictionary MyObjectBanks { get; private set; } = []; + public Levelscript Levelscript { get; set; } = []; + public List Areas { get; private set; } = []; public ushort LevelID { get; set; } = 0; public LevelBG Background { get; private set; } = new LevelBG(); public bool ActSelector { get; set; } = false; @@ -217,7 +217,7 @@ public abstract class Level public LevelscriptCommand GetDefaultPositionCmd() { - return (LevelscriptCommand)Levelscript.FirstOrDefault(n => n.CommandType == LevelscriptCommandTypes.DefaultPosition); + return Levelscript.FirstOrDefault(n => n.CommandType == LevelscriptCommandTypes.DefaultPosition); } public void ChangeObjectBankData(byte bankID, ObjectBankData newObd) diff --git a/SM64Lib/Level/LevelArea.cs b/SM64Lib/Level/LevelArea.cs index eb491c9..e1812d0 100644 --- a/SM64Lib/Level/LevelArea.cs +++ b/SM64Lib/Level/LevelArea.cs @@ -21,15 +21,15 @@ public abstract class LevelArea // A u t o P r o p e r t i e s - public SpecialBoxList SpecialBoxes { get; private set; } = new SpecialBoxList(); - public List ScrollingTextures { get; private set; } = new List(); - public List Objects { get; private set; } = new List(); - public List MacroObjects { get; private set; } = new List(); - public List Warps { get; private set; } = new List(); - public List WarpsForGame { get; private set; } = new List(); + public SpecialBoxList SpecialBoxes { get; private set; } = []; + public List ScrollingTextures { get; private set; } = []; + public List Objects { get; private set; } = []; + public List MacroObjects { get; private set; } = []; + public List Warps { get; private set; } = []; + public List WarpsForGame { get; private set; } = []; public ShowMessage ShowMessage { get; private set; } = new ShowMessage(); public AreaBG Background { get; private set; } = new AreaBG(); - public LevelscriptCommandCollection Levelscript { get; set; } = new LevelscriptCommandCollection(); + public LevelscriptCommandCollection Levelscript { get; set; } = []; public Geolayout.Geolayout Geolayout { get; set; } = new Geolayout.Geolayout(SM64Lib.Geolayout.Geolayout.NewScriptCreationMode.None); public Geolayout.TerrainTypes TerrainType { get; set; } = SM64Lib.Geolayout.TerrainTypes.NoramlA; public byte BGMusic { get; set; } = 0; @@ -80,7 +80,7 @@ public abstract class LevelArea { if (cmd.CommandType == LevelscriptCommandTypes.AreaCollision) { - CollisionPointerRet = Convert.ToInt32(clAreaCollision.GetAreaCollision((LevelscriptCommand)cmd)); + CollisionPointerRet = Convert.ToInt32(clAreaCollision.GetAreaCollision(cmd)); } } @@ -96,7 +96,7 @@ public abstract class LevelArea { if (cmd.CommandType == LevelscriptCommandTypes.AreaCollision) { - clAreaCollision.SetAreaCollision((LevelscriptCommand)cmd, Convert.ToUInt32(value)); + clAreaCollision.SetAreaCollision(cmd, Convert.ToUInt32(value)); } } } diff --git a/SM64Lib/Level/LevelManager.cs b/SM64Lib/Level/LevelManager.cs index bda2a30..e6cc97a 100644 --- a/SM64Lib/Level/LevelManager.cs +++ b/SM64Lib/Level/LevelManager.cs @@ -42,7 +42,7 @@ public class LevelManager : ILevelManager lvl.Closed = false; // Lade Levelscript - lvl.Levelscript = new Levelscript(); + lvl.Levelscript = []; lvl.Levelscript.Read(rommgr, Convert.ToInt32(segAddress)); // Erstelle Areas / Lade Einstellungen @@ -57,9 +57,11 @@ public class LevelManager : ILevelManager { case LevelscriptCommandTypes.StartArea: AreaOnFly = true; - tArea = new RMLevelArea(); - tArea.AreaID = clStartArea.GetAreaID(c); - tArea.GeolayoutOffset = clStartArea.GetSegGeolayoutAddr(c); // - bank0x19.BankAddress + bank0x19.RomStart + tArea = new RMLevelArea + { + AreaID = clStartArea.GetAreaID(c), + GeolayoutOffset = clStartArea.GetSegGeolayoutAddr(c) // - bank0x19.BankAddress + bank0x19.RomStart + }; tArea.Geolayout.Read(rommgr, Convert.ToInt32(tArea.GeolayoutOffset)); break; case LevelscriptCommandTypes.EndOfArea: @@ -490,9 +492,9 @@ public class LevelManager : ILevelManager uint curFirstBank0xEOffset = 0; // Add Objects and Warps to new Levelscript - lvlScript0E = new Levelscript(); + lvlScript0E = []; firstBank0xE = rommgr.SetSegBank(0xE, Convert.ToInt32(curOff), 0); - areaobjwarpoffsetdic = new Dictionary(); + areaobjwarpoffsetdic = []; foreach (LevelArea a in lvl.Areas) { areaobjwarpoffsetdic.Add(a.AreaID, (uint)(firstBank0xE.BankAddress + curFirstBank0xEOffset)); @@ -574,7 +576,7 @@ public class LevelManager : ILevelManager if (!foundCmdShowMsg && tArea.ShowMessage.Enabled) { var cmdShowMsg = new LevelscriptCommand($"30 04 00 {tArea.ShowMessage.DialogID.ToString("X2")}"); - cmdsToInsertAt.Add((LevelscriptCommand)c, cmdShowMsg); + cmdsToInsertAt.Add(c, cmdShowMsg); } foundCmdShowMsg = false; @@ -585,44 +587,44 @@ public class LevelManager : ILevelManager case LevelscriptCommandTypes.AreaMusic: { - clAreaMusic.SetMusicID((LevelscriptCommand)c, lvl.Areas[CurrentAreaIndex].BGMusic); + clAreaMusic.SetMusicID(c, lvl.Areas[CurrentAreaIndex].BGMusic); break; } case LevelscriptCommandTypes.AreaMusicSimple: { - clAreaMusicSimple.SetMusicID((LevelscriptCommand)c, lvl.Areas[CurrentAreaIndex].BGMusic); + clAreaMusicSimple.SetMusicID(c, lvl.Areas[CurrentAreaIndex].BGMusic); break; } case LevelscriptCommandTypes.Tarrain: { - clTerrian.SetTerrainType((LevelscriptCommand)c, (byte)lvl.Areas[CurrentAreaIndex].TerrainType); + clTerrian.SetTerrainType(c, (byte)lvl.Areas[CurrentAreaIndex].TerrainType); break; } case LevelscriptCommandTypes.LoadRomToRam: { - var switchExpr2 = clLoadRomToRam.GetSegmentedID((LevelscriptCommand)c); + var switchExpr2 = clLoadRomToRam.GetSegmentedID(c); switch (switchExpr2) { case 0xE: // Bank 0xE - clLoadRomToRam.SetRomStart((LevelscriptCommand)c, firstBank0xE.RomStart); - clLoadRomToRam.SetRomEnd((LevelscriptCommand)c, firstBank0xE.RomEnd); + clLoadRomToRam.SetRomStart(c, firstBank0xE.RomStart); + clLoadRomToRam.SetRomEnd(c, firstBank0xE.RomEnd); break; case 0xA: - cmdBgSegLoad = (LevelscriptCommand)c; + cmdBgSegLoad = c; break; case 0x7: if (lvl.LastGobCmdSegLoad == c) { - cmdGobSegLoad = (LevelscriptCommand)c; + cmdGobSegLoad = c; } break; case 0x9: if (lvl.LastLobCmdSegLoad == c) { - cmdLobSegLoad = (LevelscriptCommand)c; + cmdLobSegLoad = c; } break; } @@ -634,12 +636,12 @@ public class LevelManager : ILevelManager { if ((bool)tArea?.ShowMessage.Enabled && !foundCmdShowMsg) { - clShowDialog.SetDialogID((LevelscriptCommand)c, tArea.ShowMessage.DialogID); + clShowDialog.SetDialogID(c, tArea.ShowMessage.DialogID); foundCmdShowMsg = true; } else { - cmdsToRemove.Add((LevelscriptCommand)c); + cmdsToRemove.Add(c); } break; @@ -647,14 +649,14 @@ public class LevelManager : ILevelManager case LevelscriptCommandTypes.JumpToSegAddr: { - int bankID = clJumpToSegAddr.GetSegJumpAddr((LevelscriptCommand)c) >> 24; + int bankID = clJumpToSegAddr.GetSegJumpAddr(c) >> 24; switch (bankID) { case 0x7: - cmdGobJump = (LevelscriptCommand)c; + cmdGobJump = c; break; case 0x9: - cmdLobJump = (LevelscriptCommand)c; + cmdLobJump = c; break; } break; @@ -666,7 +668,7 @@ public class LevelManager : ILevelManager foreach (var e in areaobjwarpindextoinsertdic.OrderByDescending(n => n.Value)) { uint segStartAddr = areaobjwarpoffsetdic[e.Key]; - lvl.Levelscript.Insert(e.Value, new LevelscriptCommand(new byte[] { 0x6, 8, 0, 0, Convert.ToByte((long)(segStartAddr >> 24) & (long)0xFF), Convert.ToByte((long)(segStartAddr >> 16) & (long)0xFF), Convert.ToByte((long)(segStartAddr >> 8) & (long)0xFF), Convert.ToByte((long)segStartAddr & (long)0xFF) })); + lvl.Levelscript.Insert(e.Value, new LevelscriptCommand(new byte[] { 0x6, 8, 0, 0, Convert.ToByte(segStartAddr >> 24 & (long)0xFF), Convert.ToByte(segStartAddr >> 16 & (long)0xFF), Convert.ToByte(segStartAddr >> 8 & (long)0xFF), Convert.ToByte(segStartAddr & (long)0xFF) })); } // Lösche Commands diff --git a/SM64Lib/Level/SM64EditorLevelManager.cs b/SM64Lib/Level/SM64EditorLevelManager.cs index 09a21f0..8e08530 100644 --- a/SM64Lib/Level/SM64EditorLevelManager.cs +++ b/SM64Lib/Level/SM64EditorLevelManager.cs @@ -41,7 +41,7 @@ public class SM64EditorLevelManager : ILevelManager lvl.Closed = false; // Lade Levelscript - lvl.Levelscript = new Levelscript(); + lvl.Levelscript = []; lvl.Levelscript.Read(rommgr, Convert.ToInt32(segAddress)); // Erstelle Areas / Lade Einstellungen @@ -59,8 +59,7 @@ public class SM64EditorLevelManager : ILevelManager { AreaOnFly = true; tArea = new SM64ELevelArea(); - if (firstArea is null) - firstArea = tArea; + firstArea ??= tArea; tArea.AreaID = clStartArea.GetAreaID(c); tArea.GeolayoutOffset = clStartArea.GetSegGeolayoutAddr(c); tArea.Geolayout.Read(rommgr, Convert.ToInt32(tArea.GeolayoutOffset)); diff --git a/SM64Lib/Level/Script/Levelscript.cs b/SM64Lib/Level/Script/Levelscript.cs index ad42085..70015d6 100644 --- a/SM64Lib/Level/Script/Levelscript.cs +++ b/SM64Lib/Level/Script/Levelscript.cs @@ -167,10 +167,8 @@ public class Levelscript : LevelscriptCommandCollection } else { - if (fs is null) - fs = new FileStream(rommgr.RomFile, FileMode.Open, FileAccess.Read); - if (brfs is null) - brfs = new BinaryReader(fs); + fs ??= new FileStream(rommgr.RomFile, FileMode.Open, FileAccess.Read); + brfs ??= new BinaryReader(fs); s = fs; br = brfs; } diff --git a/SM64Lib/Level/Script/LevelscriptCommandFunctions.cs b/SM64Lib/Level/Script/LevelscriptCommandFunctions.cs index ecd86eb..25d2844 100644 --- a/SM64Lib/Level/Script/LevelscriptCommandFunctions.cs +++ b/SM64Lib/Level/Script/LevelscriptCommandFunctions.cs @@ -113,10 +113,12 @@ namespace SM64Lib.Levels.Script public static Vector3 GetPosition(LevelscriptCommand Command) { Command.Position = 4; - var Pos = new Vector3(); - Pos.X = Command.ReadInt16(); - Pos.Y = Command.ReadInt16(); - Pos.Z = Command.ReadInt16(); + var Pos = new Vector3 + { + X = Command.ReadInt16(), + Y = Command.ReadInt16(), + Z = Command.ReadInt16() + }; Command.Position = 0; return Pos; } @@ -133,10 +135,12 @@ namespace SM64Lib.Levels.Script public static Vector3 GetRotation(LevelscriptCommand Command) { Command.Position = 10; - var Rot = new Vector3(); - Rot.X = Command.ReadInt16(); - Rot.Y = Command.ReadInt16(); - Rot.Z = Command.ReadInt16(); + var Rot = new Vector3 + { + X = Command.ReadInt16(), + Y = Command.ReadInt16(), + Z = Command.ReadInt16() + }; Command.Position = 0; return Rot; } @@ -153,11 +157,13 @@ namespace SM64Lib.Levels.Script public static ObjBParams GetParams(LevelscriptCommand Command) { Command.Position = 16; - var Params = new ObjBParams(); - Params.BParam1 = Command.ReadByte(); - Params.BParam2 = Command.ReadByte(); - Params.BParam3 = Command.ReadByte(); - Params.BParam4 = Command.ReadByte(); + var Params = new ObjBParams + { + BParam1 = Command.ReadByte(), + BParam2 = Command.ReadByte(), + BParam3 = Command.ReadByte(), + BParam4 = Command.ReadByte() + }; Command.Position = 0; return Params; } @@ -498,10 +504,12 @@ namespace SM64Lib.Levels.Script public static Vector3 GetPosition(LevelscriptCommand Command) { Command.Position = 6; - var value = new Vector3(); - value.X = Command.ReadInt16(); - value.Y = Command.ReadInt16(); - value.Z = Command.ReadInt16(); + var value = new Vector3 + { + X = Command.ReadInt16(), + Y = Command.ReadInt16(), + Z = Command.ReadInt16() + }; Command.Position = 0; return value; } diff --git a/SM64Lib/Level/SpecialBoxList.cs b/SM64Lib/Level/SpecialBoxList.cs index a74179d..dfe7844 100644 --- a/SM64Lib/Level/SpecialBoxList.cs +++ b/SM64Lib/Level/SpecialBoxList.cs @@ -37,8 +37,10 @@ public class SpecialBoxList : List while (SwapInts.SwapUInt16(br.ReadUInt16()) != 0xFFFF) { s.Position += 0x2; - var tbox = new SpecialBox(); - tbox.Type = Type; + var tbox = new SpecialBox + { + Type = Type + }; int lastpos = (int)(s.Position + 0x4); s.Position = SwapInts.SwapInt32(br.ReadInt32()) - 0x19000000 + Levelscriptstart; diff --git a/SM64Lib/Model/Collision/ColMesh.cs b/SM64Lib/Model/Collision/ColMesh.cs index b840b49..3dde7f3 100644 --- a/SM64Lib/Model/Collision/ColMesh.cs +++ b/SM64Lib/Model/Collision/ColMesh.cs @@ -4,8 +4,8 @@ namespace SM64Lib.Model.Collision; public class ColMesh { - public VertexList Vertices { get; set; } = new VertexList(); - public TriangleList Triangles { get; set; } = new TriangleList(); + public VertexList Vertices { get; set; } = []; + public TriangleList Triangles { get; set; } = []; public ColMesh[] SplitMesh() { @@ -21,8 +21,10 @@ public class ColMesh var curVertCopies = new Dictionary(); foreach (Triangle t in mesh.Triangles) { - var newTri = new Triangle(); - newTri.CollisionType = t.CollisionType; + var newTri = new Triangle + { + CollisionType = t.CollisionType + }; for (int i = 0, loopTo = t.ColParams.Length - 1; i <= loopTo; i++) newTri.ColParams[i] = t.ColParams[i]; for (int i = 0, loopTo1 = t.Vertices.Length - 1; i <= loopTo1; i++) @@ -34,10 +36,12 @@ public class ColMesh } else { - var newVert = new Vertex(); - newVert.X = v.X; - newVert.Y = v.Y; - newVert.Z = v.Z; + var newVert = new Vertex + { + X = v.X, + Y = v.Y, + Z = v.Z + }; curMesh.Vertices.Add(newVert); curVertCopies.Add(v, newVert); newTri.Vertices[i] = newVert; diff --git a/SM64Lib/Model/Collision/CollisionMap.cs b/SM64Lib/Model/Collision/CollisionMap.cs index 6c1dd78..633921e 100644 --- a/SM64Lib/Model/Collision/CollisionMap.cs +++ b/SM64Lib/Model/Collision/CollisionMap.cs @@ -17,7 +17,7 @@ public class CollisionMap : IToObject3D private int _Length = 0; public ColMesh Mesh { get; set; } = new ColMesh(); - public List SpecialBoxes { get; set; } = new List(); + public List SpecialBoxes { get; set; } = []; public void FromRom(string FileName, int RomOffset, CollisionBasicConfig config) { @@ -171,8 +171,10 @@ public class CollisionMap : IToObject3D var cs = colSettings.GetEntry(dicMatNames[f.Material]); if (!cs.IsNonSolid) { - var t = new Triangle(); - t.CollisionType = cs.CollisionType; + var t = new Triangle + { + CollisionType = cs.CollisionType + }; t.ColParams[0] = cs.CollisionParam1; t.ColParams[1] = cs.CollisionParam2; for (int i = 0, loopTo = Math.Min(f.Points.Count - 1, 2); i <= loopTo; i++) @@ -185,10 +187,12 @@ public class CollisionMap : IToObject3D } else { - v = new Vertex(); - v.X = General.KeepInInt16Range(General.Round(curVert.X * ObjSettings.Scaling)); - v.Y = General.KeepInInt16Range(General.Round(curVert.Y * ObjSettings.Scaling)); - v.Z = General.KeepInInt16Range(General.Round(curVert.Z * ObjSettings.Scaling)); + v = new Vertex + { + X = General.KeepInInt16Range(General.Round(curVert.X * ObjSettings.Scaling)), + Y = General.KeepInInt16Range(General.Round(curVert.Y * ObjSettings.Scaling)), + Z = General.KeepInInt16Range(General.Round(curVert.Z * ObjSettings.Scaling)) + }; Mesh.Vertices.Add(v); dicVertices.Add(curVert, v); } diff --git a/SM64Lib/Model/Collision/CollisionSettings.cs b/SM64Lib/Model/Collision/CollisionSettings.cs index eba04d0..b3256de 100644 --- a/SM64Lib/Model/Collision/CollisionSettings.cs +++ b/SM64Lib/Model/Collision/CollisionSettings.cs @@ -8,7 +8,7 @@ namespace SM64Lib.Model.Collision; public class CollisionSettings { - public List Entries { get; private set; } = new List(); + public List Entries { get; private set; } = []; public async Task Load(string fileName) { @@ -48,8 +48,10 @@ public class CollisionSettings } } - var ne = new Entry(); - ne.MaterialName = matName; + var ne = new Entry + { + MaterialName = matName + }; Entries.Add(ne); return ne; } diff --git a/SM64Lib/Model/Conversion/Fast3DParsing/Fast3DParser.cs b/SM64Lib/Model/Conversion/Fast3DParsing/Fast3DParser.cs index 93c64f4..f52fdc4 100644 --- a/SM64Lib/Model/Conversion/Fast3DParsing/Fast3DParser.cs +++ b/SM64Lib/Model/Conversion/Fast3DParsing/Fast3DParser.cs @@ -80,13 +80,13 @@ public class Fast3DParser case CommandTypes.ClearGeometryMode: { - curGeometryMode = curGeometryMode & ~F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd); + curGeometryMode &= ~F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd); break; } case CommandTypes.SetGeometryMode: { - curGeometryMode = curGeometryMode | F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd); + curGeometryMode |= F3D_CLEARGEOMETRYMODE.GetGeometryMode(cmd); break; } @@ -362,10 +362,12 @@ public class Fast3DParser { try { - var mat = new Material(); - mat.Wrap = new System.Numerics.Vector2(curTexWrapT, curTexWrapS); - mat.Scale = curTexScale; - mat.Color = curColor; + var mat = new Material + { + Wrap = new System.Numerics.Vector2(curTexWrapT, curTexWrapS), + Scale = curTexScale, + Color = curColor + }; var seg = GetSegBank(rommgr, curTexSegAddr, AreaID); if (seg is null) return; diff --git a/SM64Lib/Model/Conversion/Fast3DWriting/Fast3DWriter.cs b/SM64Lib/Model/Conversion/Fast3DWriting/Fast3DWriter.cs index ee77b54..af6c634 100644 --- a/SM64Lib/Model/Conversion/Fast3DWriting/Fast3DWriter.cs +++ b/SM64Lib/Model/Conversion/Fast3DWriting/Fast3DWriter.cs @@ -53,9 +53,9 @@ public class ConvertResult public States State { get; set; } = States.Successfully; public uint PtrStart { get; set; } = 0; public uint PtrVertex { get; set; } = 0; - public List PtrGeometry { get; private set; } = new List(); - public List ScrollingCommands { get; private set; } = new List(); - public Dictionary ScrollingNames { get; private set; } = new Dictionary(); + public List PtrGeometry { get; private set; } = []; + public List ScrollingCommands { get; private set; } = []; + public Dictionary ScrollingNames { get; private set; } = []; public MemoryStream Data { get; private set; } = new MemoryStream(); public enum States @@ -205,7 +205,7 @@ public class Fast3DWriter public sbyte[] indexList = new sbyte[2049]; - public List FinalVertexData { get; private set; } = new List(); + public List FinalVertexData { get; private set; } = []; public short VertexDataCount { @@ -264,7 +264,7 @@ public class Fast3DWriter } public int StartIndex { get; set; } = 0; - public List FinalVertexGroups { get; private set; } = new List(); + public List FinalVertexGroups { get; private set; } = []; public bool EnableVertexColors { @@ -344,17 +344,17 @@ public class Fast3DWriter } } - private List verts = new List(); - private List norms = new List(); - private List vertexColors = new List(); - private List uvs = new List(); - private List materials = new List(); - private List ignoreFacesWithMaterial = new List(); - private Dictionary materialBindings = new Dictionary(); - private List vertexGroups = new List(); - private List finalVertData = new List(); - private List textureBank = new List(); - private List scrollTexts = new List(); + private List verts = []; + private List norms = []; + private List vertexColors = []; + private List uvs = []; + private List materials = []; + private List ignoreFacesWithMaterial = []; + private Dictionary materialBindings = []; + private List vertexGroups = []; + private List finalVertData = []; + private List textureBank = []; + private List scrollTexts = []; private Material currentMaterial; private int currentFace = 0; private const byte GEOLAYER_SOLID = 1; @@ -365,7 +365,7 @@ public class Fast3DWriter private byte[] defaultColor = new byte[24]; private ConvertSettings settings = null; private SM64Lib.Data.BinaryData impdata = null; - private ConvertResult conRes = new ConvertResult(); + private ConvertResult conRes = new(); private readonly byte[] ColtypesWithParams = new byte[] { 14, 44, 36, 37, 39, 45 }; private uint CurSegAddress @@ -506,8 +506,8 @@ public class Fast3DWriter private void processMaterialColorAlpha(float alpha, Material mat) { - mat.Color = mat.Color & 0xFFFFFF00U; - mat.Color = mat.Color | Convert.ToByte(Convert.ToInt64(0xFF * alpha) & 0xFF); + mat.Color &= 0xFFFFFF00U; + mat.Color |= Convert.ToByte(Convert.ToInt64(0xFF * alpha) & 0xFF); if (alpha < 1.0F) { mat.Type = MaterialType.ColorTransparent; @@ -672,15 +672,12 @@ public class Fast3DWriter } // Create & Add texture entry - if (entry is null) + entry ??= new TextureEntry() { - entry = new TextureEntry() - { - Width = mat.TexWidth, - Height = mat.TexHeight, - OriginalImage = img - }; - } + Width = mat.TexWidth, + Height = mat.TexHeight, + OriginalImage = img + }; // Load Texture from File var bmp = new Bitmap(img); @@ -2104,7 +2101,7 @@ public class Fast3DWriter var dlsToCreate = new List(); var dicMatDlIDs = new Dictionary(); ProcessObject3DModel(model); - conRes.PtrStart = Convert.ToUInt32((long)CurSegAddress | impdata.Position); + conRes.PtrStart = Convert.ToUInt32(CurSegAddress | impdata.Position); importStart = Convert.ToUInt32(impdata.Position); // Write default color @@ -2136,7 +2133,7 @@ public class Fast3DWriter removeDuplicateVertices(settings.ReduceVertLevel); // Write vertices - conRes.PtrVertex = Convert.ToUInt32((long)CurSegAddress | impdata.Position); + conRes.PtrVertex = Convert.ToUInt32(CurSegAddress | impdata.Position); startVerts = Convert.ToUInt32(impdata.Position); foreach (VertexGroupList mp in vertexGroups) { @@ -2163,8 +2160,7 @@ public class Fast3DWriter dlProp = dl; } - if (dlProp is null) - dlProp = new DisplaylistProps(newLayerID); + dlProp ??= new DisplaylistProps(newLayerID); dlProp.Layer = layerID; if (!dlsToCreate.Contains(dlProp)) diff --git a/SM64Lib/Model/Fast3D/DisplayLists/DisplayList.cs b/SM64Lib/Model/Fast3D/DisplayLists/DisplayList.cs index ed1af8e..0412df1 100644 --- a/SM64Lib/Model/Fast3D/DisplayLists/DisplayList.cs +++ b/SM64Lib/Model/Fast3D/DisplayLists/DisplayList.cs @@ -8,7 +8,7 @@ namespace SM64Lib.Model.Fast3D.DisplayLists; public class DisplayList { - public DisplayListScript Script { get; private set; } = new DisplayListScript(); + public DisplayListScript Script { get; private set; } = []; public Geopointer GeoPointer { get; set; } = null; // Public Property Data As Stream = Nothing diff --git a/SM64Lib/Model/Fast3D/TextureFormatSettings.cs b/SM64Lib/Model/Fast3D/TextureFormatSettings.cs index 8a8805f..bda9d68 100644 --- a/SM64Lib/Model/Fast3D/TextureFormatSettings.cs +++ b/SM64Lib/Model/Fast3D/TextureFormatSettings.cs @@ -13,8 +13,8 @@ namespace SM64Lib.Model.Fast3D; public class TextureFormatSettings { - public List Entries { get; private set; } = new List(); - public List CustomDisplayLists { get; private set; } = new List(); + public List Entries { get; private set; } = []; + public List CustomDisplayLists { get; private set; } = []; public async Task Load(string fileName) { @@ -69,8 +69,10 @@ public class TextureFormatSettings } } - var ne = new Entry(); - ne.MaterialName = matName; + var ne = new Entry + { + MaterialName = matName + }; Entries.Add(ne); return ne; } diff --git a/SM64Lib/Model/Fast3D/TextureManager.cs b/SM64Lib/Model/Fast3D/TextureManager.cs index 443a18f..b7ad351 100644 --- a/SM64Lib/Model/Fast3D/TextureManager.cs +++ b/SM64Lib/Model/Fast3D/TextureManager.cs @@ -97,10 +97,12 @@ public static class TextureManager break; case TextureConverters.NConvert: { - var arguments = new List(); - arguments.Add("-out png"); - arguments.Add($"-resize {result.Width} {result.Height}"); - arguments.Add("-overwrite"); + var arguments = new List + { + "-out png", + $"-resize {result.Width} {result.Height}", + "-overwrite" + }; var sourceFilePath = Path.GetTempFileName(); using (var fs = new FileStream(sourceFilePath, FileMode.Create, FileAccess.ReadWrite)) diff --git a/SM64Lib/Model/ObjectModel.cs b/SM64Lib/Model/ObjectModel.cs index e5556f1..c47d46d 100644 --- a/SM64Lib/Model/ObjectModel.cs +++ b/SM64Lib/Model/ObjectModel.cs @@ -127,7 +127,7 @@ public class ObjectModel public class SaveResult { public int CollisionPointer { get; set; } = -1; - public List GeoPointers { get; set; } = new List(); + public List GeoPointers { get; set; } = []; public long Length { get; set; } = 0; } } \ No newline at end of file diff --git a/SM64Lib/Music/InstrumentSetList.cs b/SM64Lib/Music/InstrumentSetList.cs index 44ad7c3..af543cd 100644 --- a/SM64Lib/Music/InstrumentSetList.cs +++ b/SM64Lib/Music/InstrumentSetList.cs @@ -6,7 +6,7 @@ namespace SM64Lib.Music; public class InstrumentSetList { - public List Sets { get; private set; } = new List(); + public List Sets { get; private set; } = []; public int Count { diff --git a/SM64Lib/Music/MusicSequence.cs b/SM64Lib/Music/MusicSequence.cs index c07e8b7..e2d3e50 100644 --- a/SM64Lib/Music/MusicSequence.cs +++ b/SM64Lib/Music/MusicSequence.cs @@ -5,7 +5,7 @@ namespace SM64Lib.Music; public class MusicSequence { - private InstrumentSetList _InstrumentSets = new InstrumentSetList(); + private InstrumentSetList _InstrumentSets = new(); public byte[] BinaryData { get; set; } = Array.Empty(); public string Name { get; set; } = ""; diff --git a/SM64Lib/Objects/ItemBoxContents/ItemBoxContentManager.cs b/SM64Lib/Objects/ItemBoxContents/ItemBoxContentManager.cs index 4f0cc57..46b31f4 100644 --- a/SM64Lib/Objects/ItemBoxContents/ItemBoxContentManager.cs +++ b/SM64Lib/Objects/ItemBoxContents/ItemBoxContentManager.cs @@ -15,7 +15,7 @@ public class ItemBoxContentManager public ItemBoxContentManager() { - ContentTable = new ItemBoxContentTable(); + ContentTable = []; } public ItemBoxContentManager(ItemBoxContentTable table) @@ -66,7 +66,7 @@ public class ItemBoxContentManager rom.Position = 0x7C8E2; address = Convert.ToUInt32(rom.ReadUInt16()) << 16; rom.Position = 0x7C8E6; - address = address | rom.ReadUInt16(); + address |= rom.ReadUInt16(); return address; } @@ -230,8 +230,10 @@ public class ItemBoxContentManager foreach (string line in File.ReadAllLines(fileName)) { var vals = line.Split(','); - var entry = new ItemBoxContentEntry(); - entry.ID = Convert.ToByte(vals[0].Trim(), 16); + var entry = new ItemBoxContentEntry + { + ID = Convert.ToByte(vals[0].Trim(), 16) + }; vals[1] = vals[1].Trim(); entry.BParam1 = Convert.ToByte(vals[1].Substring(0, 2), 16); entry.BParam2 = Convert.ToByte(vals[1].Substring(2, 2), 16); diff --git a/SM64Lib/Objects/ModelBanks/CustomModelBank.cs b/SM64Lib/Objects/ModelBanks/CustomModelBank.cs index 0b1e9a4..b5b6ab7 100644 --- a/SM64Lib/Objects/ModelBanks/CustomModelBank.cs +++ b/SM64Lib/Objects/ModelBanks/CustomModelBank.cs @@ -14,10 +14,10 @@ namespace SM64Lib.Objects.ModelBanks; public class CustomModelBank { public ObjectModelConfig Config { get; private set; } = new ObjectModelConfig(); - public List Models { get; private set; } = new List(); + public List Models { get; private set; } = []; public SegmentedBank CurSeg { get; private set; } = null; public bool NeedToSave { get; set; } = false; - public Levelscript Levelscript { get; private set; } = new Levelscript(); + public Levelscript Levelscript { get; private set; } = []; [JsonIgnore] public int Length @@ -159,15 +159,16 @@ public class CustomModelBank // Parse Levelscript & Load Models for (int i = 0, loopTo = Levelscript.Count - 1; i <= loopTo; i++) { - LevelscriptCommand cmd = (LevelscriptCommand)Levelscript[i]; + LevelscriptCommand cmd = Levelscript[i]; switch (cmd.CommandType) { case LevelscriptCommandTypes.LoadPolygonWithGeo: - var obj = new CustomModel() { Config = config.GetCustomObjectConfig(i) }; - - // Load Model ID & Geolayout Offset - obj.ModelID = clLoadPolygonWithGeo.GetModelID(cmd); + var obj = new CustomModel + { + Config = config.GetCustomObjectConfig(i), // Load Model ID & Geolayout Offset + ModelID = clLoadPolygonWithGeo.GetModelID(cmd) + }; int geoAddr = clLoadPolygonWithGeo.GetSegAddress(cmd); obj.GeolayoutBankOffset = geoAddr & 0xFFFFFF; diff --git a/SM64Lib/Objects/ObjectBanks/CustomObjectCollection.cs b/SM64Lib/Objects/ObjectBanks/CustomObjectCollection.cs index 320fe27..4b60938 100644 --- a/SM64Lib/Objects/ObjectBanks/CustomObjectCollection.cs +++ b/SM64Lib/Objects/ObjectBanks/CustomObjectCollection.cs @@ -11,7 +11,7 @@ namespace SM64Lib.Objects.ObjectBanks; public class CustomObjectCollection { - public List CustomObjects { get; } = new List(); + public List CustomObjects { get; } = []; public void TakeoverProperties(RomManager rommgr) { diff --git a/SM64Lib/Objects/ObjectBanks/CustomObjectExportData.cs b/SM64Lib/Objects/ObjectBanks/CustomObjectExportData.cs index 10f6e83..a41a1c8 100644 --- a/SM64Lib/Objects/ObjectBanks/CustomObjectExportData.cs +++ b/SM64Lib/Objects/ObjectBanks/CustomObjectExportData.cs @@ -12,13 +12,13 @@ namespace SM64Lib.Objects.ObjectBanks; public class CustomObjectExportData { - public List CustomObjects { get; set; } = new List(); + public List CustomObjects { get; set; } = []; [JsonConverter(typeof(ComplexDictionarJsonConverter))] - public Dictionary CustomModels { get; set; } = new Dictionary(); + public Dictionary CustomModels { get; set; } = []; [JsonConverter(typeof(ComplexDictionarJsonConverter))] - public Dictionary Behaviors { get; set; } = new Dictionary(); + public Dictionary Behaviors { get; set; } = []; [JsonConverter(typeof(ComplexDictionarJsonConverter))] - public Dictionary CustomAsmAreas { get; set; } = new Dictionary(); + public Dictionary CustomAsmAreas { get; set; } = []; public EmbeddedFilesContainer EmbeddedFiles { get; set; } public PatchScript Script { get; set; } } diff --git a/SM64Lib/Objects/ObjectBanks/CustomObjectImport.cs b/SM64Lib/Objects/ObjectBanks/CustomObjectImport.cs index 3b557e8..2535222 100644 --- a/SM64Lib/Objects/ObjectBanks/CustomObjectImport.cs +++ b/SM64Lib/Objects/ObjectBanks/CustomObjectImport.cs @@ -10,13 +10,13 @@ namespace SM64Lib.Objects.ObjectBanks; public class CustomObjectImport : CustomObjectExport { [JsonIgnore] - public Dictionary DestModelBanks { get; } = new Dictionary(); + public Dictionary DestModelBanks { get; } = []; [JsonIgnore] public CustomAsmBank DestCustomAsmBank { get; set; } = null; [JsonIgnore] public BehaviorBank DestBehaviorBank { get; set; } = null; [JsonIgnore] - public List IgnoreCustomObjects { get; } = new List(); + public List IgnoreCustomObjects { get; } = []; [JsonIgnore] public bool OverwriteExistingObjecs { get; set; } = true; } diff --git a/SM64Lib/Objects/ObjectBanks/Data/ObjectBankData.cs b/SM64Lib/Objects/ObjectBanks/Data/ObjectBankData.cs index dbe08a2..3861ea5 100644 --- a/SM64Lib/Objects/ObjectBanks/Data/ObjectBankData.cs +++ b/SM64Lib/Objects/ObjectBanks/Data/ObjectBankData.cs @@ -5,8 +5,8 @@ namespace SM64Lib.Objects.ObjectBanks.Data; public class ObjectBankData { public string Name { get; set; } - public List Objects { get; private set; } = new List(); - public List Commands { get; private set; } = new List(); + public List Objects { get; private set; } = []; + public List Commands { get; private set; } = []; public ObjectBankData() { diff --git a/SM64Lib/Patching/PatchScript.cs b/SM64Lib/Patching/PatchScript.cs index f38bfeb..630c0a7 100644 --- a/SM64Lib/Patching/PatchScript.cs +++ b/SM64Lib/Patching/PatchScript.cs @@ -23,7 +23,7 @@ public class PatchProfile /// A list with scripts. /// /// - public List Scripts { get; set; } = new List(); + public List Scripts { get; set; } = []; /// /// The version of this profile. /// diff --git a/SM64Lib/Patching/PatchScriptExecuteParams.cs b/SM64Lib/Patching/PatchScriptExecuteParams.cs index 375ffa6..991e4e9 100644 --- a/SM64Lib/Patching/PatchScriptExecuteParams.cs +++ b/SM64Lib/Patching/PatchScriptExecuteParams.cs @@ -10,6 +10,6 @@ public class PatchScriptExecuteParams public RomManager RomManager { get; set; } public EmbeddedFilesContainer EmbeddedFiles { get; set; } public string ProfilePath { get; set; } - public Dictionary OtherParameters { get; set; } = new(); + public Dictionary OtherParameters { get; set; } = []; public IWin32Window WindowOwner { get; set; } } diff --git a/SM64Lib/Patching/PatchScriptManager.cs b/SM64Lib/Patching/PatchScriptManager.cs index 88fded3..7621bd6 100644 --- a/SM64Lib/Patching/PatchScriptManager.cs +++ b/SM64Lib/Patching/PatchScriptManager.cs @@ -121,8 +121,10 @@ public class PatchingManager public PatchScript XElementToScript(XElement element) { - var script = new PatchScript(); - script.Script = element.Value; + var script = new PatchScript + { + Script = element.Value + }; foreach (XAttribute attr in element.Attributes()) { var switchExpr = attr.Name; @@ -238,7 +240,7 @@ public class PatchingManager CompilationOptions compilationOptions; Compilation compilation = null; SyntaxTree syntaxTree = null; - Dictionary references = new(); + Dictionary references = []; EmitResult resultEmit = null; Assembly resultAssembly = null; diff --git a/SM64Lib/RomManager.cs b/SM64Lib/RomManager.cs index 40bf583..9fcc271 100644 --- a/SM64Lib/RomManager.cs +++ b/SM64Lib/RomManager.cs @@ -64,22 +64,22 @@ public class RomManager // F i e l d s - private readonly Dictionary segBankList = new Dictionary(); - private readonly Dictionary> areaSegBankList = new Dictionary>(); - private Dictionary dicUpdatePatches = new Dictionary(); - private RomVersion myProgramVersion = new RomVersion(); - private readonly List levelIDsToReset = new List(); - private readonly List myTextGroups = new List(); + private readonly Dictionary segBankList = []; + private readonly Dictionary> areaSegBankList = []; + private Dictionary dicUpdatePatches = []; + private RomVersion myProgramVersion = new(); + private readonly List levelIDsToReset = []; + private readonly List myTextGroups = []; private string myGameName = null; private bool programVersion_loadedVersion = false; // P r o p e r t i e s - public LevelInfoDataTabelList LevelInfoData { get; private set; } = new LevelInfoDataTabelList(); - public LevelList Levels { get; private set; } = new LevelList(); + public LevelInfoDataTabelList LevelInfoData { get; private set; } = []; + public LevelList Levels { get; private set; } = []; public string RomFile { get; set; } = string.Empty; public bool IsSM64EditorMode { get; private set; } = false; - public MusicList MusicList { get; private set; } = new MusicList(); + public MusicList MusicList { get; private set; } = []; public CustomModelBank GlobalModelBank { get; private set; } = new CustomModelBank(); public CustomAsmBank GlobalCustomAsmBank { get; private set; } = null; public BehaviorBank GlobalBehaviorBank { get; private set; } = null; @@ -347,8 +347,10 @@ public class RomManager { if (myGameName is null) { - var fs = new BinaryRom(this, FileAccess.Read); - fs.Position = 0x20; + var fs = new BinaryRom(this, FileAccess.Read) + { + Position = 0x20 + }; myGameName = Encoding.ASCII.GetString(fs.Read(0x14)).Trim(); fs.Close(); } @@ -358,8 +360,10 @@ public class RomManager set { - var fs = new BinaryRom(this, FileAccess.Write); - fs.Position = 0x20; + var fs = new BinaryRom(this, FileAccess.Write) + { + Position = 0x20 + }; foreach (byte b in Encoding.ASCII.GetBytes(value)) fs.Write(b); while (fs.Position < 0x34) @@ -381,12 +385,14 @@ public class RomManager public RomSpaceInfo GetRomSpaceInfo() { - var info = new RomSpaceInfo(); - info.MaxAvailableSpace = 0x4000000 - 0x1210000; - info.UsedLevelsSpace = Levels.Length; - info.UsedMusicSpace = MusicList.Length; - info.UsedGlobalBehaviorSpace = GlobalBehaviorBank.Length; - info.UsedGlobalModelsSpace = GlobalModelBank is object ? GlobalModelBank.Length : 0; + var info = new RomSpaceInfo + { + MaxAvailableSpace = 0x4000000 - 0x1210000, + UsedLevelsSpace = Levels.Length, + UsedMusicSpace = MusicList.Length, + UsedGlobalBehaviorSpace = GlobalBehaviorBank.Length, + UsedGlobalModelsSpace = GlobalModelBank is object ? GlobalModelBank.Length : 0 + }; return info; } @@ -539,8 +545,10 @@ public class RomManager private void WriteVersion(RomVersion newVersion) { myProgramVersion = newVersion; - var fs = new BinaryRom(this, FileAccess.ReadWrite); - fs.Position = 0x1201FF8; + var fs = new BinaryRom(this, FileAccess.ReadWrite) + { + Position = 0x1201FF8 + }; fs.Write(newVersion.DevelopmentStage << 24 | newVersion.DevelopmentBuild); fs.WriteByte(Convert.ToByte(newVersion.Version.Major)); fs.WriteByte(Convert.ToByte(newVersion.Version.Minor)); @@ -551,8 +559,10 @@ public class RomManager private RomVersion LoadVersion() { - var fs = new BinaryRom(this, FileAccess.Read); - fs.Position = 0x1201FF8; + var fs = new BinaryRom(this, FileAccess.Read) + { + Position = 0x1201FF8 + }; int devInfo = fs.ReadInt32(); byte major = fs.ReadByte(); byte minor = fs.ReadByte(); @@ -655,7 +665,7 @@ public class RomManager table.NeedToSave = false; if (prof is Text.Profiles.TextTableGroupInfo) { - needUpdateChecksum = needUpdateChecksum | ((Text.Profiles.TextTableGroupInfo)prof).Segmented.BankAddress == 0x80245000U; + needUpdateChecksum |= ((Text.Profiles.TextTableGroupInfo)prof).Segmented.BankAddress == 0x80245000U; } else if (prof is Text.Profiles.TextArrayGroupInfo) { @@ -716,23 +726,23 @@ public class RomManager try { #endif - switch (segID) - { - case 0x19: - if (IsSM64EditorMode) - lvl = new SM64ELevel(ldi.ID, ldi.Index, this); - else - lvl = new RMLevel(RomConfig.GetLevelConfig(ldi.ID), this); - LevelManager.LoadLevel(lvl, this, ldi.ID, offset); - lvl.LastRomOffset = curLvlSeg.RomStart; // Original Level - break; - default: - lvl = null; - // Dim mgr As New OriginalLevelManager - // lvl = New OriginalLevel - // mgr.LoadLevel(lvl, Me, ldi.ID, offset) - break; - } + switch (segID) + { + case 0x19: + if (IsSM64EditorMode) + lvl = new SM64ELevel(ldi.ID, ldi.Index, this); + else + lvl = new RMLevel(RomConfig.GetLevelConfig(ldi.ID), this); + LevelManager.LoadLevel(lvl, this, ldi.ID, offset); + lvl.LastRomOffset = curLvlSeg.RomStart; // Original Level + break; + default: + lvl = null; + // Dim mgr As New OriginalLevelManager + // lvl = New OriginalLevel + // mgr.LoadLevel(lvl, Me, ldi.ID, offset) + break; + } #if !DEBUG } catch (Exception) @@ -788,13 +798,16 @@ public class RomManager /// public void LoadGlobalModelBank() { - var fs = new BinaryRom(this, FileAccess.Read); - - // Read Bank Addres & Length from Rom - fs.Position = 0x120FFF0; - var seg = new SegmentedBank(0x7); - seg.RomStart = fs.ReadInt32(); - seg.RomEnd = fs.ReadInt32(); + var fs = new BinaryRom(this, FileAccess.Read) + { + // Read Bank Addres & Length from Rom + Position = 0x120FFF0 + }; + var seg = new SegmentedBank(0x7) + { + RomStart = fs.ReadInt32(), + RomEnd = fs.ReadInt32() + }; if (seg.RomStart != 0x1010101 && seg.RomStart > -1) { // Set Segmented Bank @@ -1010,8 +1023,10 @@ public class RomManager } } - var br = new BinaryRom(this, FileAccess.Read); - br.Position = 0x1200000; + var br = new BinaryRom(this, FileAccess.Read) + { + Position = 0x1200000 + }; long tCheckData = br.ReadInt64(); br.Close(); IsSM64EditorMode = new[] { 0x800800001900001C, 0x800800000E0000C4 }.Contains((ulong)tCheckData); @@ -1179,7 +1194,7 @@ public class RomManager } else { - sbl = new Dictionary(); + sbl = []; areaSegBankList.Add((byte)AreaID, sbl); } } diff --git a/SM64Lib/RomManagerInstances.cs b/SM64Lib/RomManagerInstances.cs index b258a07..6982946 100644 --- a/SM64Lib/RomManagerInstances.cs +++ b/SM64Lib/RomManagerInstances.cs @@ -4,7 +4,7 @@ namespace SM64Lib; public static class RomManagerInstances { - private static readonly List romManagers = new List(); + private static readonly List romManagers = []; public static IEnumerable CurrentInstances { diff --git a/SM64Lib/SM64Lib.csproj b/SM64Lib/SM64Lib.csproj index 73a275d..815e652 100644 --- a/SM64Lib/SM64Lib.csproj +++ b/SM64Lib/SM64Lib.csproj @@ -44,8 +44,8 @@ TRACE;RelMono - - + + diff --git a/SM64Lib/Text/Profiles/TextArrayGroupInfo.cs b/SM64Lib/Text/Profiles/TextArrayGroupInfo.cs index 59a4407..305b4df 100644 --- a/SM64Lib/Text/Profiles/TextArrayGroupInfo.cs +++ b/SM64Lib/Text/Profiles/TextArrayGroupInfo.cs @@ -4,5 +4,5 @@ namespace SM64Lib.Text.Profiles; public class TextArrayGroupInfo : TextGroupInfo { - public List Texts { get; set; } = new List(); + public List Texts { get; set; } = []; } \ No newline at end of file diff --git a/SM64Lib/Text/Profiles/TextProfileInfo.cs b/SM64Lib/Text/Profiles/TextProfileInfo.cs index e5badbc..469b42b 100644 --- a/SM64Lib/Text/Profiles/TextProfileInfo.cs +++ b/SM64Lib/Text/Profiles/TextProfileInfo.cs @@ -9,8 +9,8 @@ namespace SM64Lib.Text.Profiles; public class TextProfileInfo { public string Name { get; set; } - public List TextTableGroups { get; set; } = new List(); - public List TextArrayGroups { get; set; } = new List(); + public List TextTableGroups { get; set; } = []; + public List TextArrayGroups { get; set; } = []; public TextGroupInfo GetGroup(string name) { diff --git a/SM64Lib/Text/Profiles/TextTableGroupInfo.cs b/SM64Lib/Text/Profiles/TextTableGroupInfo.cs index 15af3ef..c7031d6 100644 --- a/SM64Lib/Text/Profiles/TextTableGroupInfo.cs +++ b/SM64Lib/Text/Profiles/TextTableGroupInfo.cs @@ -15,7 +15,7 @@ public class TextTableGroupInfo : TextGroupInfo public TextTableDialogDataInfo DialogData { get; set; } = new TextTableDialogDataInfo(); [JsonIgnore] [Browsable(false)] - public List ItemDescriptionsList { get; set; } = new List(); + public List ItemDescriptionsList { get; set; } = []; [Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))] public string ItemDescriptions diff --git a/SM64Lib/Trajectories/Trajectories.cs b/SM64Lib/Trajectories/Trajectories.cs index 1ab7f9c..aa03603 100644 --- a/SM64Lib/Trajectories/Trajectories.cs +++ b/SM64Lib/Trajectories/Trajectories.cs @@ -183,8 +183,10 @@ public class Trajectories : List data.Position = addr - (int)addrToSubstract + 0x1200000; for (int i = 1, loopTo = count; i <= loopTo; i++) { - var trajectory = new Trajectory(); - trajectory.Name = name; + var trajectory = new Trajectory + { + Name = name + }; trajectory.Read(data, (uint)(data.Position)); Add(trajectory); } @@ -212,14 +214,14 @@ public class Trajectories : List data.Position = 0xCCA6E; addr = data.ReadUInt16() << 16; data.Position = 0xCCA76; - addr = addr | data.ReadUInt16(); + addr |= data.ReadUInt16(); AddTrajectory(data, addr, TrajectoryName.RacingPenguin); // Snowman's Bottom data.Position = 0xABC9E; addr = data.ReadUInt16() << 16; data.Position = 0xABCA6; - addr = addr | data.ReadUInt16(); + addr |= data.ReadUInt16(); AddTrajectory(data, addr, TrajectoryName.SnowmansBottom); // Platform on Tracks Behavior (B.Param 2 = 0 - 8) @@ -235,42 +237,42 @@ public class Trajectories : List addr = data.ReadUInt16() << 16; data.Position = 0xA9ABC + 2; var val3 = data.ReadUInt16(); - addr = addr | val3; + addr |= val3; AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_00); // Metal Balls Generators - B.Param 2 = 01 data.Position = 0xA9AD4 + 2; addr = data.ReadUInt16() << 16; data.Position = 0xA9ADC + 2; - addr = addr | data.ReadUInt16(); + addr |= data.ReadUInt16(); AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_01); // Metal Balls Generators - B.Param 2 = 02 data.Position = 0xA9AF4 + 2; addr = data.ReadUInt16() << 16; data.Position = 0xA9AFC + 2; - addr = addr | data.ReadUInt16(); + addr |= data.ReadUInt16(); AddTrajectory(data, addr, TrajectoryName.MetalBallsGenerators_BParam2_02); // Mini-Metal Ball Generator - B.Param 2 = 03 data.Position = 0xA9B1C + 2; addr = data.ReadUInt16() << 16; data.Position += 2; - addr = addr | data.ReadUInt16(); + addr |= data.ReadUInt16(); AddTrajectory(data, addr, TrajectoryName.MiniMetalBallGenerator_BParam2_03); // Mini-Metal Ball Generator - B.Param 2 = 04 data.Position = 0xA9B1C + 2; addr = data.ReadUInt16() << 16; data.Position += 2; - addr = addr | data.ReadUInt16(); + addr |= data.ReadUInt16(); AddTrajectory(data, addr, TrajectoryName.MiniMetalBallGenerator_BParam2_04); // Mips the Rabbit data.Position = 0xB3816; addr = data.ReadUInt16() << 16; data.Position += 6; - addr = addr | data.ReadUInt16(); + addr |= data.ReadUInt16(); data.Position = 0xB371E; ushort numOfPaths = data.ReadUInt16(); AddTrajectory(data, addr, TrajectoryName.MipsTheRabbit, numOfPaths); diff --git a/SM64Lib/Trajectories/Trajectory.cs b/SM64Lib/Trajectories/Trajectory.cs index 9126f7e..8f94e4c 100644 --- a/SM64Lib/Trajectories/Trajectory.cs +++ b/SM64Lib/Trajectories/Trajectory.cs @@ -7,7 +7,7 @@ namespace SM64Lib.Trajectorys; public class Trajectory { - public List Points { get; private set; } = new List(); + public List Points { get; private set; } = []; public bool NeedToSave { get; set; } = false; public TrajectoryName Name { get; set; } = TrajectoryName.None; @@ -46,10 +46,12 @@ public class Trajectory if ((ulong)data.ReadInt64() != 0xFFFFFFFFFFFFFFFF) { data.Position -= 6; - var point = new Vector3(); - point.X = data.ReadInt16(); - point.Y = data.ReadInt16(); - point.Z = data.ReadInt16(); + var point = new Vector3 + { + X = data.ReadInt16(), + Y = data.ReadInt16(), + Z = data.ReadInt16() + }; Points.Add(point); } else