Merge branch 'fix-fenrir-claws' into main
This commit is contained in:
commit
22d547d7f6
1 changed files with 23 additions and 0 deletions
|
|
@ -74,6 +74,24 @@ namespace RacesOfValheim
|
||||||
/// The roster. Kept here rather than in RacesOfValheim.Awake so the whole feature is this
|
/// The roster. Kept here rather than in RacesOfValheim.Awake so the whole feature is this
|
||||||
/// file plus one short file per race, and adding a third clawed race is one line - not one
|
/// file plus one short file per race, and adding a third clawed race is one line - not one
|
||||||
/// line here and another one three hundred lines away in the plugin's startup.
|
/// line here and another one three hundred lines away in the plugin's startup.
|
||||||
|
///
|
||||||
|
/// A BACKSTOP ONLY - EnsureRegistered is what actually fills this list, and it has to be.
|
||||||
|
/// This constructor cannot be trusted to register a race that is still being constructed,
|
||||||
|
/// and one of them always is:
|
||||||
|
///
|
||||||
|
/// FenrirRace.CreateModAssets touches FenrirClaws.Instance
|
||||||
|
/// -> the CLR begins FenrirClaws' static init: Instance = new FenrirClaws()
|
||||||
|
/// -> constructing a derived type runs the BASE type's static ctor first, i.e. this one
|
||||||
|
/// -> this one reads FenrirClaws.Instance... which is still null, because the static
|
||||||
|
/// init that will assign it is the thing waiting on us
|
||||||
|
/// -> Register(null) returns silently, and the Fenrir is left out of the roster for the
|
||||||
|
/// rest of the session: For() never matches it, so Maintain never runs, so the
|
||||||
|
/// Cursed Claws are never issued and never do their damage.
|
||||||
|
///
|
||||||
|
/// It bit the Fenrir and not the Aswid purely because FenrirRace.CreateModAssets runs
|
||||||
|
/// first in RacesOfValheim.CreateAllModAssets - whichever race gets there first is the one
|
||||||
|
/// that is half-built when this runs. Register(this) in EnsureRegistered closes it for
|
||||||
|
/// good: `this` is a live object by definition, so there is nothing to be null.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static RaceClawSet()
|
static RaceClawSet()
|
||||||
{
|
{
|
||||||
|
|
@ -146,6 +164,11 @@ namespace RacesOfValheim
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void EnsureRegistered()
|
public void EnsureRegistered()
|
||||||
{
|
{
|
||||||
|
// BEFORE the early return, and before anything else: this is the one place the roster
|
||||||
|
// is filled reliably. See the static constructor for why it cannot do this itself.
|
||||||
|
// Idempotent, so calling it on every tick as well as at startup costs nothing.
|
||||||
|
Register(this);
|
||||||
|
|
||||||
if (registered) return;
|
if (registered) return;
|
||||||
|
|
||||||
if (ObjectDB.instance != null && ObjectDB.instance.GetItemPrefab(ItemName) != null)
|
if (ObjectDB.instance != null && ObjectDB.instance.GetItemPrefab(ItemName) != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue