Merge branch 'main' into fix/aswid-eclipse
This commit is contained in:
commit
2d718a09ec
2 changed files with 14 additions and 25 deletions
|
|
@ -214,36 +214,26 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Spawns a sound prefab without letting it write itself into the save.
|
/// Spawns a sound prefab the way the game's own EffectList.Create does: a plain Instantiate.
|
||||||
///
|
///
|
||||||
/// SOME VANILLA SOUND PREFABS CARRY A ZNetView. "sfx_fenring_alerted" is one - the Describe
|
/// THIS USED TO WRAP THE INSTANTIATE IN ZNetView GHOST INIT, and that was wrong. Some vanilla
|
||||||
/// line below printed it, which is how this was noticed. A ZNetView that wakes with no init
|
/// sound and effect prefabs carry a ZNetView ("sfx_fenring_alerted" does), and the fear was
|
||||||
/// ZDO calls ZDOMan.CreateNewZDO at its position, marks itself persistent, stamps itself with
|
/// one persistent ZDO per play left in the save. The ones logged so far also carry
|
||||||
/// the prefab hash and registers with the scene. On a sound played every time somebody howls
|
/// TimedDestruction, which ends in ZNetScene.Destroy, and that deletes the ZDO. They are
|
||||||
/// or swings a claw, that is one persistent "there is a noise here" record per swing, saved
|
/// network effects by design, which is how other players hear them.
|
||||||
/// with the world. It is the same bug that left burnt-in torches in people's worlds; the long
|
|
||||||
/// version is on SkeletonVisuals.BorrowEffect.
|
|
||||||
///
|
///
|
||||||
/// ZNetView.StartGhostInit is the game's own answer, not ours: between the two calls a
|
/// Ghost init does not prevent the ZDO either. Read off ZNetView.Awake: it still calls
|
||||||
/// ZNetView comes up with no ZDO at all. Cheaper and far less invasive than stripping the
|
/// CreateNewZDO and only skips ZNetScene.AddInstance. That leaves the ZDO with Created=false,
|
||||||
/// component off a copy, and free on the prefabs that carry no ZNetView.
|
/// and ZNetScene.CreateObjectsSorted builds a second copy of the object from it. Vanilla
|
||||||
///
|
/// uses ghost init for zone generation, where the ZDOs are the point and the objects are not.
|
||||||
/// The finally matters. Leaving ghost init switched on because an Instantiate threw would
|
/// The switch that really yields no ZDO is m_forceDisableInit, which is for item icons and
|
||||||
/// break every ZNetView created afterwards, for the rest of the session.
|
/// inventory copies, not for anything meant to be seen or heard by others.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Spawn(GameObject prefab, Vector3 position)
|
public static void Spawn(GameObject prefab, Vector3 position)
|
||||||
{
|
{
|
||||||
if (prefab == null) return;
|
if (prefab == null) return;
|
||||||
|
|
||||||
ZNetView.StartGhostInit();
|
Object.Instantiate(prefab, position, Quaternion.identity);
|
||||||
try
|
|
||||||
{
|
|
||||||
Object.Instantiate(prefab, position, Quaternion.identity);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
ZNetView.FinishGhostInit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// NOT FOLLOWED BY A Play() CALL, and that took a while to establish. ZSFX is ticked by
|
// NOT FOLLOWED BY A Play() CALL, and that took a while to establish. ZSFX is ticked by
|
||||||
// CustomUpdate rather than Unity's Update, so it starts on a later frame: reading
|
// CustomUpdate rather than Unity's Update, so it starts on a later frame: reading
|
||||||
|
|
|
||||||
|
|
@ -81,8 +81,7 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (!audible) return;
|
if (!audible) return;
|
||||||
|
|
||||||
// Through the same ghost-init spawn as everything else here: some vanilla sound prefabs
|
// Through the same spawn as every other Fenrir sound, so a change there reaches this too.
|
||||||
// carry a ZNetView, and this one fires every time the animation comes round.
|
|
||||||
FenrirCreatureSound.Spawn(prefab, transform.position);
|
FenrirCreatureSound.Spawn(prefab, transform.position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue