diff --git a/NWN.Anvil/src/main/API/Ruleset/NwBaseItem.cs b/NWN.Anvil/src/main/API/Ruleset/NwBaseItem.cs index 324f5c26c..ba00aa269 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwBaseItem.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwBaseItem.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using NWN.Native.API; @@ -371,15 +372,16 @@ public IEnumerable WeaponType /// Resolves a from a . /// /// The item type to resolve. - /// The associated instance. Null if the base item type is invalid. - public static NwBaseItem? FromItemType(BaseItemType itemType) + /// The associated instance. + /// Thrown if itemType is not a value defined in baseitems.2da. + public static NwBaseItem FromItemType(BaseItemType itemType) { - return NwRuleset.BaseItems.ElementAtOrDefault((int)itemType); + return NwRuleset.BaseItems.ElementAt((int)itemType); } - public static implicit operator NwBaseItem?(BaseItemType itemType) + public static implicit operator NwBaseItem(BaseItemType itemType) { - return NwRuleset.BaseItems.ElementAtOrDefault((int)itemType); + return NwRuleset.BaseItems.ElementAt((int)itemType); } /// diff --git a/NWN.Anvil/src/main/API/Ruleset/NwClass.cs b/NWN.Anvil/src/main/API/Ruleset/NwClass.cs index 56d1e046f..2ca5399f9 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwClass.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwClass.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -336,15 +337,16 @@ public IReadOnlyList SpellKnownTable /// Resolves a from a . /// /// The class type to resolve. - /// The associated instance. Null if the class type is invalid. - public static NwClass? FromClassType(ClassType classType) + /// The associated instance. + /// Thrown if classType is not a value defined in classes.2da. + public static NwClass FromClassType(ClassType classType) { - return NwRuleset.Classes.ElementAtOrDefault((int)classType); + return NwRuleset.Classes.ElementAt((int)classType); } - public static implicit operator NwClass?(ClassType classType) + public static implicit operator NwClass(ClassType classType) { - return NwRuleset.Classes.ElementAtOrDefault((int)classType); + return NwRuleset.Classes.ElementAt((int)classType); } /// diff --git a/NWN.Anvil/src/main/API/Ruleset/NwDomain.cs b/NWN.Anvil/src/main/API/Ruleset/NwDomain.cs index 5c514ea86..265858173 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwDomain.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwDomain.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using NWN.Native.API; @@ -70,15 +71,16 @@ internal NwDomain(byte domainId, CNWDomain domainInfo) /// Resolves a from a . /// /// The domain type to resolve. - /// The associated instance. Null if the domain type is invalid. - public static NwDomain? FromDomainType(Domain domainType) + /// The associated instance. + /// Thrown if domainType is not a value defined in domains.2da. + public static NwDomain FromDomainType(Domain domainType) { - return NwRuleset.Domains.ElementAtOrDefault((int)domainType); + return NwRuleset.Domains.ElementAt((int)domainType); } - public static implicit operator NwDomain?(Domain domainType) + public static implicit operator NwDomain(Domain domainType) { - return NwRuleset.Domains.ElementAtOrDefault((int)domainType); + return NwRuleset.Domains.ElementAt((int)domainType); } /// diff --git a/NWN.Anvil/src/main/API/Ruleset/NwFaction.cs b/NWN.Anvil/src/main/API/Ruleset/NwFaction.cs index 8faad89e3..7093329ee 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwFaction.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwFaction.cs @@ -105,10 +105,11 @@ internal NwFaction(CNWSFaction faction) /// Resolves a from a . /// /// The faction type to resolve. - /// The associated instance. Null if the faction type is invalid. - public static NwFaction? FromStandardFaction(StandardFaction factionType) + /// The associated instance. + /// Thrown if factionType is not defined in the module faction list. + public static NwFaction FromStandardFaction(StandardFaction factionType) { - return FromFactionId((int)factionType); + return FromFactionId((int)factionType)!; } public static bool operator ==(NwFaction? left, NwFaction? right) @@ -116,9 +117,9 @@ internal NwFaction(CNWSFaction faction) return Equals(left, right); } - public static implicit operator NwFaction?(StandardFaction faction) + public static implicit operator NwFaction(StandardFaction faction) { - return FromFactionId((int)faction); + return FromFactionId((int)faction)!; } public static bool operator !=(NwFaction left, NwFaction right) diff --git a/NWN.Anvil/src/main/API/Ruleset/NwFeat.cs b/NWN.Anvil/src/main/API/Ruleset/NwFeat.cs index 8cc15cdf2..1e7d22275 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwFeat.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwFeat.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Linq; @@ -189,15 +190,16 @@ public IReadOnlyList RequiredFeatsSome /// Resolves a from a . /// /// The feat type to resolve. - /// The associated instance. Null if the feat type is invalid. - public static NwFeat? FromFeatType(Feat featType) + /// The associated instance. + /// Thrown if featType is not a value defined in feats.2da. + public static NwFeat FromFeatType(Feat featType) { - return NwRuleset.Feats.ElementAtOrDefault((int)featType); + return NwRuleset.Feats.ElementAt((int)featType); } - public static implicit operator NwFeat?(Feat featType) + public static implicit operator NwFeat(Feat featType) { - return NwRuleset.Feats.ElementAtOrDefault((int)featType); + return NwRuleset.Feats.ElementAt((int)featType); } /// diff --git a/NWN.Anvil/src/main/API/Ruleset/NwRace.cs b/NWN.Anvil/src/main/API/Ruleset/NwRace.cs index 030820435..a3547ce53 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwRace.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwRace.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using NWN.Native.API; @@ -120,15 +121,16 @@ internal NwRace(ushort raceId, CNWRace raceInfo) /// Resolves a from a . /// /// The racial type to resolve. - /// The associated instance. Null if the racial type is invalid. - public static NwRace? FromRacialType(RacialType racialType) + /// The associated instance. + /// Thrown if racialType is not a value defined in racialtypes.2da. + public static NwRace FromRacialType(RacialType racialType) { - return NwRuleset.Races.ElementAtOrDefault((int)racialType); + return NwRuleset.Races.ElementAt((int)racialType); } - public static implicit operator NwRace?(RacialType racialType) + public static implicit operator NwRace(RacialType racialType) { - return NwRuleset.Races.ElementAtOrDefault((int)racialType); + return NwRuleset.Races.ElementAt((int)racialType); } /// diff --git a/NWN.Anvil/src/main/API/Ruleset/NwSkill.cs b/NWN.Anvil/src/main/API/Ruleset/NwSkill.cs index d7c188019..41f741d3f 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwSkill.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwSkill.cs @@ -1,3 +1,4 @@ +using System; using System.Linq; using NWN.Native.API; @@ -80,15 +81,16 @@ internal NwSkill(byte skillId, CNWSkill skillInfo) /// Resolves a from a . /// /// The skill type to resolve. - /// The associated instance. Null if the skill type is invalid. - public static NwSkill? FromSkillType(Skill skillType) + /// The associated instance. + /// Thrown if skillType is not a value defined in skills.2da. + public static NwSkill FromSkillType(Skill skillType) { - return NwRuleset.Skills.ElementAtOrDefault((int)skillType); + return NwRuleset.Skills.ElementAt((int)skillType); } - public static implicit operator NwSkill?(Skill skillType) + public static implicit operator NwSkill(Skill skillType) { - return NwRuleset.Skills.ElementAtOrDefault((int)skillType); + return NwRuleset.Skills.ElementAt((int)skillType); } } } diff --git a/NWN.Anvil/src/main/API/Ruleset/NwSpell.cs b/NWN.Anvil/src/main/API/Ruleset/NwSpell.cs index fbd91a772..21a499b8f 100644 --- a/NWN.Anvil/src/main/API/Ruleset/NwSpell.cs +++ b/NWN.Anvil/src/main/API/Ruleset/NwSpell.cs @@ -303,15 +303,16 @@ public SpellComponents SpellComponents /// Resolves a from a . /// /// The spell type to resolve. - /// The associated instance. Null if the spell type is invalid. - public static NwSpell? FromSpellType(Spell spellType) + /// The associated instance. + /// Thrown if spellType is not a value defined in spells.2da. + public static NwSpell FromSpellType(Spell spellType) { - return NwRuleset.Spells.ElementAtOrDefault((int)spellType); + return NwRuleset.Spells.ElementAt((int)spellType); } - public static implicit operator NwSpell?(Spell spellType) + public static implicit operator NwSpell(Spell spellType) { - return NwRuleset.Spells.ElementAtOrDefault((int)spellType); + return NwRuleset.Spells.ElementAt((int)spellType); } /// diff --git a/NWN.Anvil/src/main/API/TwoDimArray/Tables/AppearanceTableEntry.cs b/NWN.Anvil/src/main/API/TwoDimArray/Tables/AppearanceTableEntry.cs index 8c72c08d3..2b7be2285 100644 --- a/NWN.Anvil/src/main/API/TwoDimArray/Tables/AppearanceTableEntry.cs +++ b/NWN.Anvil/src/main/API/TwoDimArray/Tables/AppearanceTableEntry.cs @@ -118,9 +118,9 @@ void ITwoDimArrayEntry.InterpretEntry(TwoDimArrayEntry entry) Targetable = entry.GetBool("TARGETABLE"); } - public static implicit operator AppearanceTableEntry?(AppearanceType appearanceType) + public static implicit operator AppearanceTableEntry(AppearanceType appearanceType) { - return NwGameTables.AppearanceTable.ElementAtOrDefault((int)appearanceType); + return NwGameTables.AppearanceTable.ElementAt((int)appearanceType); } } } diff --git a/NWN.Anvil/src/main/API/TwoDimArray/Tables/EffectIconTableEntry.cs b/NWN.Anvil/src/main/API/TwoDimArray/Tables/EffectIconTableEntry.cs index 43b49bb61..f1af49819 100644 --- a/NWN.Anvil/src/main/API/TwoDimArray/Tables/EffectIconTableEntry.cs +++ b/NWN.Anvil/src/main/API/TwoDimArray/Tables/EffectIconTableEntry.cs @@ -31,9 +31,9 @@ public void InterpretEntry(TwoDimArrayEntry entry) StrRef = entry.GetStrRef("StrRef"); } - public static implicit operator EffectIconTableEntry?(EffectIcon effectIcon) + public static implicit operator EffectIconTableEntry(EffectIcon effectIcon) { - return NwGameTables.EffectIconTable.ElementAtOrDefault((int)effectIcon); + return NwGameTables.EffectIconTable.ElementAt((int)effectIcon); } } } diff --git a/NWN.Anvil/src/main/API/TwoDimArray/Tables/ItemPropertyTableEntry.cs b/NWN.Anvil/src/main/API/TwoDimArray/Tables/ItemPropertyTableEntry.cs index 613eb8ae1..bf72a25ba 100644 --- a/NWN.Anvil/src/main/API/TwoDimArray/Tables/ItemPropertyTableEntry.cs +++ b/NWN.Anvil/src/main/API/TwoDimArray/Tables/ItemPropertyTableEntry.cs @@ -66,9 +66,9 @@ void ITwoDimArrayEntry.InterpretEntry(TwoDimArrayEntry entry) Description = entry.GetStrRef("Description"); } - public static implicit operator ItemPropertyTableEntry?(ItemPropertyType propertyType) + public static implicit operator ItemPropertyTableEntry(ItemPropertyType propertyType) { - return NwGameTables.ItemPropertyTable.ElementAtOrDefault((int)propertyType); + return NwGameTables.ItemPropertyTable.ElementAt((int)propertyType); } } } diff --git a/NWN.Anvil/src/main/API/TwoDimArray/Tables/PersistentVfxTableEntry.cs b/NWN.Anvil/src/main/API/TwoDimArray/Tables/PersistentVfxTableEntry.cs index a71a2e91e..a6dc63bec 100644 --- a/NWN.Anvil/src/main/API/TwoDimArray/Tables/PersistentVfxTableEntry.cs +++ b/NWN.Anvil/src/main/API/TwoDimArray/Tables/PersistentVfxTableEntry.cs @@ -107,9 +107,9 @@ public void InterpretEntry(TwoDimArrayEntry entry) return timeMs == null ? null : TimeSpan.FromMilliseconds(timeMs.Value); } - public static implicit operator PersistentVfxTableEntry?(PersistentVfxType vfxType) + public static implicit operator PersistentVfxTableEntry(PersistentVfxType vfxType) { - return NwGameTables.PersistentEffectTable.ElementAtOrDefault((int)vfxType); + return NwGameTables.PersistentEffectTable.ElementAt((int)vfxType); } } } diff --git a/NWN.Anvil/src/main/API/TwoDimArray/Tables/PolymorphTableEntry.cs b/NWN.Anvil/src/main/API/TwoDimArray/Tables/PolymorphTableEntry.cs index 08634dcae..71d7d3670 100644 --- a/NWN.Anvil/src/main/API/TwoDimArray/Tables/PolymorphTableEntry.cs +++ b/NWN.Anvil/src/main/API/TwoDimArray/Tables/PolymorphTableEntry.cs @@ -76,9 +76,9 @@ public void InterpretEntry(TwoDimArrayEntry entry) MergeA = entry.GetBool("MergeA"); } - public static implicit operator PolymorphTableEntry?(PolymorphType polymorphType) + public static implicit operator PolymorphTableEntry(PolymorphType polymorphType) { - return NwGameTables.PolymorphTable.ElementAtOrDefault((int)polymorphType); + return NwGameTables.PolymorphTable.ElementAt((int)polymorphType); } } } diff --git a/NWN.Anvil/src/main/API/TwoDimArray/Tables/ProgrammedEffectTableEntry.cs b/NWN.Anvil/src/main/API/TwoDimArray/Tables/ProgrammedEffectTableEntry.cs index dea174ca7..a607288e3 100644 --- a/NWN.Anvil/src/main/API/TwoDimArray/Tables/ProgrammedEffectTableEntry.cs +++ b/NWN.Anvil/src/main/API/TwoDimArray/Tables/ProgrammedEffectTableEntry.cs @@ -46,9 +46,9 @@ public void InterpretEntry(TwoDimArrayEntry entry) } } - public static implicit operator ProgrammedEffectTableEntry?(ProgFxType fxType) + public static implicit operator ProgrammedEffectTableEntry(ProgFxType fxType) { - return NwGameTables.ProgrammedEffectTable.ElementAtOrDefault((int)fxType); + return NwGameTables.ProgrammedEffectTable.ElementAt((int)fxType); } } } diff --git a/NWN.Anvil/src/main/API/TwoDimArray/Tables/VisualEffectTableEntry.cs b/NWN.Anvil/src/main/API/TwoDimArray/Tables/VisualEffectTableEntry.cs index 49e79fd42..09cae85d0 100644 --- a/NWN.Anvil/src/main/API/TwoDimArray/Tables/VisualEffectTableEntry.cs +++ b/NWN.Anvil/src/main/API/TwoDimArray/Tables/VisualEffectTableEntry.cs @@ -91,9 +91,9 @@ void ITwoDimArrayEntry.InterpretEntry(TwoDimArrayEntry entry) OrientWithObject = entry.GetBool("OrientWithObject"); } - public static implicit operator VisualEffectTableEntry?(VfxType vfxType) + public static implicit operator VisualEffectTableEntry(VfxType vfxType) { - return NwGameTables.VisualEffectTable.ElementAtOrDefault((int)vfxType); + return NwGameTables.VisualEffectTable.ElementAt((int)vfxType); } } }