Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwBaseItem.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NWN.Native.API;
Expand Down Expand Up @@ -371,15 +372,16 @@ public IEnumerable<DamageType> WeaponType
/// Resolves a <see cref="NwBaseItem"/> from a <see cref="BaseItemType"/>.
/// </summary>
/// <param name="itemType">The item type to resolve.</param>
/// <returns>The associated <see cref="NwBaseItem"/> instance. Null if the base item type is invalid.</returns>
public static NwBaseItem? FromItemType(BaseItemType itemType)
/// <returns>The associated <see cref="NwBaseItem"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if itemType is not a value defined in baseitems.2da.</exception>
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);
}

/// <summary>
Expand Down
12 changes: 7 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwClass.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
Expand Down Expand Up @@ -336,15 +337,16 @@ public IReadOnlyList<ClassSpellGainList> SpellKnownTable
/// Resolves a <see cref="NwClass"/> from a <see cref="Anvil.API.ClassType"/>.
/// </summary>
/// <param name="classType">The class type to resolve.</param>
/// <returns>The associated <see cref="NwClass"/> instance. Null if the class type is invalid.</returns>
public static NwClass? FromClassType(ClassType classType)
/// <returns>The associated <see cref="NwClass"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if classType is not a value defined in classes.2da.</exception>
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);
}

/// <summary>
Expand Down
12 changes: 7 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwDomain.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NWN.Native.API;
Expand Down Expand Up @@ -70,15 +71,16 @@ internal NwDomain(byte domainId, CNWDomain domainInfo)
/// Resolves a <see cref="NwDomain"/> from a <see cref="Domain"/>.
/// </summary>
/// <param name="domainType">The domain type to resolve.</param>
/// <returns>The associated <see cref="NwDomain"/> instance. Null if the domain type is invalid.</returns>
public static NwDomain? FromDomainType(Domain domainType)
/// <returns>The associated <see cref="NwDomain"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if domainType is not a value defined in domains.2da.</exception>
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);
}

/// <summary>
Expand Down
11 changes: 6 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwFaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,21 @@ internal NwFaction(CNWSFaction faction)
/// Resolves a <see cref="NwFaction"/> from a <see cref="StandardFaction"/>.
/// </summary>
/// <param name="factionType">The faction type to resolve.</param>
/// <returns>The associated <see cref="NwFaction"/> instance. Null if the faction type is invalid.</returns>
public static NwFaction? FromStandardFaction(StandardFaction factionType)
/// <returns>The associated <see cref="NwFaction"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if factionType is not defined in the module faction list.</exception>
public static NwFaction FromStandardFaction(StandardFaction factionType)
{
return FromFactionId((int)factionType);
return FromFactionId((int)factionType)!;
}

public static bool operator ==(NwFaction? left, NwFaction? right)
{
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)
Expand Down
12 changes: 7 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwFeat.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
Expand Down Expand Up @@ -189,15 +190,16 @@ public IReadOnlyList<NwFeat> RequiredFeatsSome
/// Resolves a <see cref="NwFeat"/> from a <see cref="Anvil.API.Feat"/>.
/// </summary>
/// <param name="featType">The feat type to resolve.</param>
/// <returns>The associated <see cref="NwFeat"/> instance. Null if the feat type is invalid.</returns>
public static NwFeat? FromFeatType(Feat featType)
/// <returns>The associated <see cref="NwFeat"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if featType is not a value defined in feats.2da.</exception>
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);
}

/// <summary>
Expand Down
12 changes: 7 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwRace.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using NWN.Native.API;

Expand Down Expand Up @@ -120,15 +121,16 @@ internal NwRace(ushort raceId, CNWRace raceInfo)
/// Resolves a <see cref="NwRace"/> from a <see cref="Anvil.API.RacialType"/>.
/// </summary>
/// <param name="racialType">The racial type to resolve.</param>
/// <returns>The associated <see cref="NwRace"/> instance. Null if the racial type is invalid.</returns>
public static NwRace? FromRacialType(RacialType racialType)
/// <returns>The associated <see cref="NwRace"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if racialType is not a value defined in racialtypes.2da.</exception>
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);
}

/// <summary>
Expand Down
12 changes: 7 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwSkill.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Linq;
using NWN.Native.API;

Expand Down Expand Up @@ -80,15 +81,16 @@ internal NwSkill(byte skillId, CNWSkill skillInfo)
/// Resolves a <see cref="NwSkill"/> from a <see cref="Anvil.API.Skill"/>.
/// </summary>
/// <param name="skillType">The skill type to resolve.</param>
/// <returns>The associated <see cref="NwSkill"/> instance. Null if the skill type is invalid.</returns>
public static NwSkill? FromSkillType(Skill skillType)
/// <returns>The associated <see cref="NwSkill"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if skillType is not a value defined in skills.2da.</exception>
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);
}
}
}
11 changes: 6 additions & 5 deletions NWN.Anvil/src/main/API/Ruleset/NwSpell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -303,15 +303,16 @@ public SpellComponents SpellComponents
/// Resolves a <see cref="NwSpell"/> from a <see cref="Anvil.API.Spell"/>.
/// </summary>
/// <param name="spellType">The spell type to resolve.</param>
/// <returns>The associated <see cref="NwSpell"/> instance. Null if the spell type is invalid.</returns>
public static NwSpell? FromSpellType(Spell spellType)
/// <returns>The associated <see cref="NwSpell"/> instance.</returns>
/// <exception cref="ArgumentOutOfRangeException">Thrown if spellType is not a value defined in spells.2da.</exception>
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);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Loading