Merge branch 'fix-resetrace-cleanup'
This commit is contained in:
commit
927bda1bbc
7 changed files with 336 additions and 37 deletions
|
|
@ -463,7 +463,7 @@ namespace RacesOfValheim
|
||||||
if (EnvMan.instance != null && EnvMan.IsDay() && !isTransformingSequence &&
|
if (EnvMan.instance != null && EnvMan.IsDay() && !isTransformingSequence &&
|
||||||
Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertMistFormRoutine());
|
RunFormRoutine(RevertMistFormRoutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same rule for a night-only bat: a form the sun forbids cannot be kept through the
|
// Same rule for a night-only bat: a form the sun forbids cannot be kept through the
|
||||||
|
|
@ -474,7 +474,7 @@ namespace RacesOfValheim
|
||||||
EnvMan.instance != null && EnvMan.IsDay())
|
EnvMan.instance != null && EnvMan.IsDay())
|
||||||
{
|
{
|
||||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_morning_sun_drives_bat_back"));
|
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_morning_sun_drives_bat_back"));
|
||||||
StartCoroutine(RevertToHumanRoutine());
|
RunFormRoutine(RevertToHumanRoutine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -565,7 +565,7 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (IsTransformed)
|
if (IsTransformed)
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertToHumanRoutine());
|
RunFormRoutine(RevertToHumanRoutine());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -580,18 +580,73 @@ namespace RacesOfValheim
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StartCoroutine(TransformIntoBatRoutine(rules));
|
RunFormRoutine(TransformIntoBatRoutine(rules));
|
||||||
|
}
|
||||||
|
|
||||||
|
// The one bat or mist routine in flight, if any. Kept so ResetRace can stop it: a
|
||||||
|
// TransformIntoBatRoutine left running through a reset finishes its 1.1s gesture and
|
||||||
|
// turns a freshly reset Human into a bat.
|
||||||
|
private Coroutine formRoutine;
|
||||||
|
|
||||||
|
private void RunFormRoutine(System.Collections.IEnumerator routine)
|
||||||
|
{
|
||||||
|
formRoutine = StartCoroutine(routine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drops bat and mist form on the spot for ResetRace: no puff, no tween, nothing left
|
||||||
|
/// running. ForceRevert is no use there - it skips a form that is still mid-gesture, and
|
||||||
|
/// its coroutine would still be shrinking the body back after the reset has finished.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if there was a form to drop.</returns>
|
||||||
|
public bool HardResetForReset()
|
||||||
|
{
|
||||||
|
Player player = Player.m_localPlayer;
|
||||||
|
if (player == null) return false;
|
||||||
|
|
||||||
|
if (formRoutine != null)
|
||||||
|
{
|
||||||
|
StopCoroutine(formRoutine);
|
||||||
|
formRoutine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hadMist = mistTransformation != null || player.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode());
|
||||||
|
bool hadBat = IsTransformed || isTransformingSequence;
|
||||||
|
|
||||||
|
// Also clears isTransformingSequence and puts the transform back to scale 1, which
|
||||||
|
// covers a reset caught halfway through the bat's shrink.
|
||||||
|
HardResetBatForm();
|
||||||
|
|
||||||
|
if (hadMist)
|
||||||
|
{
|
||||||
|
if (mistTransformation != null)
|
||||||
|
{
|
||||||
|
Destroy(mistTransformation);
|
||||||
|
mistTransformation = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform playerVisual = player.transform.Find("Visual");
|
||||||
|
PlayerVisualHider.Show(playerVisual, "aswid-reset-mist");
|
||||||
|
if (playerVisual != null) playerVisual.localScale = Vector3.one;
|
||||||
|
|
||||||
|
player.GetSEMan().RemoveStatusEffect("SE_MistForm".GetStableHashCode(), true);
|
||||||
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
|
if (nview != null && nview.IsValid()) nview.GetZDO().Set("Aswid_IsMistForm", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
isTransformingSequence = false;
|
||||||
|
return hadBat || hadMist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ForceRevert()
|
public void ForceRevert()
|
||||||
{
|
{
|
||||||
if (IsTransformed && !isTransformingSequence)
|
if (IsTransformed && !isTransformingSequence)
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertToHumanRoutine());
|
RunFormRoutine(RevertToHumanRoutine());
|
||||||
}
|
}
|
||||||
if (Player.m_localPlayer != null && Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()) && !isTransformingSequence)
|
if (Player.m_localPlayer != null && Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()) && !isTransformingSequence)
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertMistFormRoutine());
|
RunFormRoutine(RevertMistFormRoutine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -745,11 +800,11 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode()))
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertMistFormRoutine());
|
RunFormRoutine(RevertMistFormRoutine());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
StartCoroutine(TransformIntoMistRoutine());
|
RunFormRoutine(TransformIntoMistRoutine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ namespace RacesOfValheim {
|
||||||
|
|
||||||
if (isTransformed)
|
if (isTransformed)
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertToHumanRoutine());
|
RunFormRoutine(RevertToHumanRoutine());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ namespace RacesOfValheim {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StartCoroutine(TransformIntoWolfRoutine(rules));
|
RunFormRoutine(TransformIntoWolfRoutine(rules));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -256,11 +256,63 @@ namespace RacesOfValheim {
|
||||||
return "$rov_msg_fenrir_formname_fenrir";
|
return "$rov_msg_fenrir_formname_fenrir";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The one transform or revert routine in flight, if any, so ResetRace can stop it. A
|
||||||
|
// revert left to finish on its own lands its cooldown after the reset has already swept
|
||||||
|
// the status effects, and the next Fenrir starts locked out.
|
||||||
|
private Coroutine formRoutine;
|
||||||
|
|
||||||
|
private void RunFormRoutine(IEnumerator routine)
|
||||||
|
{
|
||||||
|
formRoutine = StartCoroutine(routine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drops whatever form is up, immediately, for ResetRace: no poof, no message, and no
|
||||||
|
/// cooldown - ExecuteReversion hands one out, which is right for a form running out and
|
||||||
|
/// wrong for a player leaving the race.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if there was a form to drop.</returns>
|
||||||
|
public bool HardResetForReset()
|
||||||
|
{
|
||||||
|
Player player = Player.m_localPlayer;
|
||||||
|
if (player == null) return false;
|
||||||
|
|
||||||
|
if (formRoutine != null)
|
||||||
|
{
|
||||||
|
StopCoroutine(formRoutine);
|
||||||
|
formRoutine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hadForm = isTransformed || isTransformingSequence || currentTransformation != null;
|
||||||
|
if (hadForm)
|
||||||
|
{
|
||||||
|
if (currentTransformation != null) Destroy(currentTransformation);
|
||||||
|
currentTransformation = null;
|
||||||
|
DestroyAllForms();
|
||||||
|
|
||||||
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
|
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_FenrirForm", "");
|
||||||
|
|
||||||
|
PlayerVisualHider.Show(player.transform.Find("Visual"), "fenrir-reset");
|
||||||
|
|
||||||
|
player.GetSEMan().RemoveStatusEffect("SE_FenrirForm".GetStableHashCode());
|
||||||
|
player.GetSEMan().RemoveStatusEffect("SE_CultistForm".GetStableHashCode());
|
||||||
|
player.GetSEMan().RemoveStatusEffect("SE_WolfForm".GetStableHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
isTransformed = false;
|
||||||
|
isTransformingSequence = false;
|
||||||
|
activeRules = null;
|
||||||
|
revertMessage = null;
|
||||||
|
sunSicknessTimer = 0f;
|
||||||
|
return hadForm;
|
||||||
|
}
|
||||||
|
|
||||||
public void ForceRevert()
|
public void ForceRevert()
|
||||||
{
|
{
|
||||||
if (isTransformed && !isTransformingSequence)
|
if (isTransformed && !isTransformingSequence)
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertToHumanRoutine());
|
RunFormRoutine(RevertToHumanRoutine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using HarmonyLib;
|
||||||
using Jotunn.Configs;
|
using Jotunn.Configs;
|
||||||
using Jotunn.Entities;
|
using Jotunn.Entities;
|
||||||
using Jotunn.Managers;
|
using Jotunn.Managers;
|
||||||
|
using Jotunn.Utils;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI; // Added for UI
|
using UnityEngine.UI; // Added for UI
|
||||||
|
|
||||||
|
|
@ -99,6 +100,20 @@ namespace RacesOfValheim
|
||||||
Player player = Player.m_localPlayer;
|
Player player = Player.m_localPlayer;
|
||||||
if (player == null) return;
|
if (player == null) return;
|
||||||
|
|
||||||
|
// What the reset actually took off, printed at the end so it can be read in the console.
|
||||||
|
var removed = new System.Collections.Generic.List<string>();
|
||||||
|
|
||||||
|
// Forms first, before any status effect goes. Taking a form's effect away without
|
||||||
|
// undoing the form leaves the body hidden (bat, mist, drake, wolf, Muspell, Ravager)
|
||||||
|
// or oversized (True Form), and several races only ever look at their form from an
|
||||||
|
// Update that returns early for anyone who is not of that race any more.
|
||||||
|
if (AswidRace.Instance != null && AswidRace.Instance.HardResetForReset()) removed.Add("form: Aswid bat/mist");
|
||||||
|
if (FenrirRace.Instance != null && FenrirRace.Instance.HardResetForReset()) removed.Add("form: Fenrir");
|
||||||
|
if (SkadiRace.Instance != null && SkadiRace.Instance.HardResetForReset()) removed.Add("form: Skadi drake");
|
||||||
|
if (TrolRace.Instance != null && TrolRace.Instance.HardResetForReset()) removed.Add("form: Trol True Form");
|
||||||
|
if (TrentaMuspell.HardResetForReset(player)) removed.Add("form: Trenta Muspell");
|
||||||
|
if (SvermRavagerForm.HardResetForReset(player)) removed.Add("form: Sverm Ravager");
|
||||||
|
|
||||||
RemovePermanentRaceEquipment(player);
|
RemovePermanentRaceEquipment(player);
|
||||||
|
|
||||||
player.m_customData.Remove("Race");
|
player.m_customData.Remove("Race");
|
||||||
|
|
@ -120,21 +135,23 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_FenrirCurse".GetStableHashCode());
|
// Every status effect this mod registers, rather than a list kept by hand: the hand
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_AswidStats".GetStableHashCode());
|
// list was missing the True Form and both of its cooldowns, Bat and Mist Form, the
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_SkeletonStats".GetStableHashCode());
|
// Skeleton's resurrect cooldown and most of Skadi's, and the next effect anyone adds
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_SkadiStats".GetStableHashCode());
|
// would have been missing too. The forms were dropped above, so taking their effects
|
||||||
player.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode());
|
// away here no longer leaves a body hidden or blown up.
|
||||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.StatsSE.GetStableHashCode());
|
SEMan seman = player.GetSEMan();
|
||||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.OverchargeSE.GetStableHashCode());
|
foreach (CustomStatusEffect custom in ModRegistry.GetStatusEffects(PluginGUID))
|
||||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.OverchargeCdSE.GetStableHashCode());
|
{
|
||||||
player.GetSEMan().RemoveStatusEffect(DvergarConfig.RunicPingCdSE.GetStableHashCode());
|
StatusEffect se = custom?.StatusEffect;
|
||||||
player.GetSEMan().RemoveStatusEffect(TrentaConfig.StatsSE.GetStableHashCode());
|
if (se == null) continue;
|
||||||
player.GetSEMan().RemoveStatusEffect(TrentaConfig.PurpleRainCdSE.GetStableHashCode());
|
|
||||||
player.GetSEMan().RemoveStatusEffect(TrentaConfig.PortalCdSE.GetStableHashCode());
|
int hash = se.name.GetStableHashCode();
|
||||||
player.GetSEMan().RemoveStatusEffect(SvermConfig.StatsSE.GetStableHashCode());
|
if (!seman.HaveStatusEffect(hash)) continue;
|
||||||
player.GetSEMan().RemoveStatusEffect(SvermConfig.RavagerSE.GetStableHashCode());
|
|
||||||
player.GetSEMan().RemoveStatusEffect(SvermConfig.RavagerCdSE.GetStableHashCode());
|
seman.RemoveStatusEffect(hash, true);
|
||||||
|
removed.Add(se.name);
|
||||||
|
}
|
||||||
|
|
||||||
// COLD, which is not one of ours at all - and that is exactly why it has to go.
|
// COLD, which is not one of ours at all - and that is exactly why it has to go.
|
||||||
//
|
//
|
||||||
|
|
@ -161,9 +178,21 @@ namespace RacesOfValheim
|
||||||
// Only after the ZDO above already says "Human" - see the class doc comment.
|
// Only after the ZDO above already says "Human" - see the class doc comment.
|
||||||
RaceItemCleanup.PurgeForeignRaceItems(player);
|
RaceItemCleanup.PurgeForeignRaceItems(player);
|
||||||
|
|
||||||
|
// Normal size. The Trol, the Skeleton past Fader and the self-sizing races all scale
|
||||||
|
// either the player or its Visual, and each puts its own size back only from code that
|
||||||
|
// may not run again now the race has changed. The next race sets its own size anyway.
|
||||||
|
player.transform.localScale = Vector3.one;
|
||||||
|
GameObject visual = Traverse.Create(player).Field("m_visual").GetValue<GameObject>();
|
||||||
|
if (visual != null) visual.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
string summary = removed.Count == 0
|
||||||
|
? "[ResetRace] Nothing race-specific was left on the player."
|
||||||
|
: "[ResetRace] Removed: " + string.Join(", ", removed);
|
||||||
|
Jotunn.Logger.LogInfo(summary);
|
||||||
|
if (Console.instance != null) Console.instance.Print(summary);
|
||||||
|
|
||||||
if (Instance != null)
|
if (Instance != null)
|
||||||
{
|
{
|
||||||
if (FenrirRace.Instance != null) FenrirRace.Instance.ForceRevert();
|
|
||||||
Instance.ShowRaceSelectionMenu();
|
Instance.ShowRaceSelectionMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -247,7 +247,7 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
formExpireTime = 0f;
|
formExpireTime = 0f;
|
||||||
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dragon_form_fades"));
|
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dragon_form_fades"));
|
||||||
StartCoroutine(RevertToHumanRoutine());
|
RunFormRoutine(RevertToHumanRoutine());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -687,7 +687,7 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (isTransformed)
|
if (isTransformed)
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertToHumanRoutine());
|
RunFormRoutine(RevertToHumanRoutine());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -707,7 +707,7 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
|
|
||||||
activeRules = rules;
|
activeRules = rules;
|
||||||
StartCoroutine(TransformRoutine(rules));
|
RunFormRoutine(TransformRoutine(rules));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector3 GetFormScale(SkadiProgression.FormType form)
|
private Vector3 GetFormScale(SkadiProgression.FormType form)
|
||||||
|
|
@ -914,6 +914,57 @@ namespace RacesOfValheim
|
||||||
if (se != null) se.m_ttl = seconds;
|
if (se != null) se.m_ttl = seconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The one transform or revert routine in flight, if any, so ResetRace can stop it.
|
||||||
|
private Coroutine formRoutine;
|
||||||
|
|
||||||
|
private void RunFormRoutine(System.Collections.IEnumerator routine)
|
||||||
|
{
|
||||||
|
formRoutine = StartCoroutine(routine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drops the drake form on the spot for ResetRace. Update bails out on its first line for
|
||||||
|
/// anyone who is not a Skadi, so once the race changes nothing in this class ever looks at
|
||||||
|
/// the form again - a Skadi reset in drake form stayed a drake for good. No message and no
|
||||||
|
/// cooldown here, unlike ExecuteReversion.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if there was a form to drop.</returns>
|
||||||
|
public bool HardResetForReset()
|
||||||
|
{
|
||||||
|
Player player = Player.m_localPlayer;
|
||||||
|
if (player == null) return false;
|
||||||
|
|
||||||
|
if (formRoutine != null)
|
||||||
|
{
|
||||||
|
StopCoroutine(formRoutine);
|
||||||
|
formRoutine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hadForm = isTransformed || isTransformingSequence || currentTransformation != null;
|
||||||
|
if (hadForm)
|
||||||
|
{
|
||||||
|
if (currentTransformation != null) Destroy(currentTransformation);
|
||||||
|
currentTransformation = null;
|
||||||
|
foreach (var f in player.GetComponentsInChildren<DrakeFormBehavior>(true)) Destroy(f.gameObject);
|
||||||
|
|
||||||
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
|
if (nview != null && nview.IsValid())
|
||||||
|
{
|
||||||
|
nview.GetZDO().Set("Skadi_Form", "");
|
||||||
|
nview.GetZDO().Set("RacesOfValheim_SkadiForm", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerVisualHider.Show(player.transform.Find("Visual"), "skadi-reset");
|
||||||
|
player.GetSEMan().RemoveStatusEffect("SE_SkadiForm".GetStableHashCode(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
isTransformed = false;
|
||||||
|
isTransformingSequence = false;
|
||||||
|
formExpireTime = 0f;
|
||||||
|
activeRules = null;
|
||||||
|
return hadForm;
|
||||||
|
}
|
||||||
|
|
||||||
private void ExecuteReversion()
|
private void ExecuteReversion()
|
||||||
{
|
{
|
||||||
Transform playerVisual = Player.m_localPlayer.transform.Find("Visual");
|
Transform playerVisual = Player.m_localPlayer.transform.Find("Visual");
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (SvermRace.Instance != null)
|
if (SvermRace.Instance != null)
|
||||||
{
|
{
|
||||||
SvermRace.Instance.StartCoroutine(EnterRoutine(player));
|
formRoutine = SvermRace.Instance.StartCoroutine(EnterRoutine(player));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -342,12 +342,42 @@ namespace RacesOfValheim
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The enter or exit routine in flight, if any, so ResetRace can stop it. An ExitRoutine
|
||||||
|
// left running finishes with Exit(spendCooldown: true), which puts the cooldown back on
|
||||||
|
// after the reset has swept it.
|
||||||
|
private static Coroutine formRoutine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drops Ravager Strain on the spot for ResetRace, and forgets its cooldown: nextAllowedAt
|
||||||
|
/// is a static the status effect sweep never touches, so without this a player who left
|
||||||
|
/// the Sverm and came back stayed locked out of the form with no timer in the HUD.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if there was a form to drop.</returns>
|
||||||
|
public static bool HardResetForReset(Player player)
|
||||||
|
{
|
||||||
|
if (player == null) return false;
|
||||||
|
|
||||||
|
if (formRoutine != null && SvermRace.Instance != null)
|
||||||
|
{
|
||||||
|
SvermRace.Instance.StopCoroutine(formRoutine);
|
||||||
|
}
|
||||||
|
formRoutine = null;
|
||||||
|
|
||||||
|
bool hadForm = IsActive || transforming || exiting || model != null;
|
||||||
|
if (IsActive || model != null) Exit(player, spendCooldown: false);
|
||||||
|
|
||||||
|
transforming = false;
|
||||||
|
exiting = false;
|
||||||
|
nextAllowedAt = 0f;
|
||||||
|
return hadForm;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>Kicks off the graceful exit (shrink, then Exit) if there is a host to run it on.</summary>
|
/// <summary>Kicks off the graceful exit (shrink, then Exit) if there is a host to run it on.</summary>
|
||||||
private static void RunExit(Player player, bool spendCooldown, string message)
|
private static void RunExit(Player player, bool spendCooldown, string message)
|
||||||
{
|
{
|
||||||
if (SvermRace.Instance != null)
|
if (SvermRace.Instance != null)
|
||||||
{
|
{
|
||||||
SvermRace.Instance.StartCoroutine(ExitRoutine(player, spendCooldown, message));
|
formRoutine = SvermRace.Instance.StartCoroutine(ExitRoutine(player, spendCooldown, message));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,11 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (IsTransformed)
|
if (IsTransformed)
|
||||||
{
|
{
|
||||||
TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
formRoutine = TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TrentaRace.Instance.StartCoroutine(TransformRoutine(player));
|
formRoutine = TrentaRace.Instance.StartCoroutine(TransformRoutine(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,10 +68,51 @@ namespace RacesOfValheim
|
||||||
{
|
{
|
||||||
if (IsTransformed && !isTransformingSequence)
|
if (IsTransformed && !isTransformingSequence)
|
||||||
{
|
{
|
||||||
TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
formRoutine = TrentaRace.Instance.StartCoroutine(RevertRoutine(player));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The one transform or revert routine in flight, if any, so ResetRace can stop it.
|
||||||
|
private static Coroutine formRoutine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drops the Muspell on the spot for ResetRace. ForceRevert would get there too, from
|
||||||
|
/// TrentaRace.Update, but a frame and a half-second tween later - after ResetRace has
|
||||||
|
/// already reopened the menu - and not at all if the reset lands mid-gesture.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if there was a form to drop.</returns>
|
||||||
|
public static bool HardResetForReset(Player player)
|
||||||
|
{
|
||||||
|
if (player == null) return false;
|
||||||
|
|
||||||
|
if (formRoutine != null && TrentaRace.Instance != null)
|
||||||
|
{
|
||||||
|
TrentaRace.Instance.StopCoroutine(formRoutine);
|
||||||
|
}
|
||||||
|
formRoutine = null;
|
||||||
|
|
||||||
|
bool hadForm = IsTransformed || isTransformingSequence || currentTransformation != null;
|
||||||
|
if (hadForm)
|
||||||
|
{
|
||||||
|
if (currentTransformation != null) Object.Destroy(currentTransformation);
|
||||||
|
currentTransformation = null;
|
||||||
|
|
||||||
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
|
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_MuspellForm", false);
|
||||||
|
|
||||||
|
Transform playerVisual = player.transform.Find("Visual");
|
||||||
|
if (playerVisual != null)
|
||||||
|
{
|
||||||
|
playerVisual.localScale = Vector3.one;
|
||||||
|
playerVisual.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IsTransformed = false;
|
||||||
|
isTransformingSequence = false;
|
||||||
|
return hadForm;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called by Purple Rain instead of its usual staff_summon trigger whenever Muspell is
|
/// Called by Purple Rain instead of its usual staff_summon trigger whenever Muspell is
|
||||||
/// active - The Elder's own root-summon gesture, played on the transformation clone's
|
/// active - The Elder's own root-summon gesture, played on the transformation clone's
|
||||||
|
|
|
||||||
|
|
@ -206,11 +206,52 @@ namespace RacesOfValheim
|
||||||
bool isTrueFormActive = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode());
|
bool isTrueFormActive = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode());
|
||||||
if (wasTrueFormActive && !isTrueFormActive && !isTransforming)
|
if (wasTrueFormActive && !isTrueFormActive && !isTransforming)
|
||||||
{
|
{
|
||||||
StartCoroutine(RevertTrueFormRoutine());
|
RunFormRoutine(RevertTrueFormRoutine());
|
||||||
}
|
}
|
||||||
wasTrueFormActive = isTrueFormActive;
|
wasTrueFormActive = isTrueFormActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The one grow or shrink routine in flight, if any, so ResetRace can stop it.
|
||||||
|
private Coroutine formRoutine;
|
||||||
|
|
||||||
|
private void RunFormRoutine(System.Collections.IEnumerator routine)
|
||||||
|
{
|
||||||
|
formRoutine = StartCoroutine(routine);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drops True Form on the spot for ResetRace. Update returns on its first line for anyone
|
||||||
|
/// who is not a Trol, so its auto-revert never saw the form end. wasTrueFormActive is the
|
||||||
|
/// part that would bite later: left true, the next time this player picks Trol the first
|
||||||
|
/// Update reads it as a form that just ran out and hands out a True Form cooldown.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if there was a form to drop.</returns>
|
||||||
|
public bool HardResetForReset()
|
||||||
|
{
|
||||||
|
Player player = Player.m_localPlayer;
|
||||||
|
if (player == null) return false;
|
||||||
|
|
||||||
|
if (formRoutine != null)
|
||||||
|
{
|
||||||
|
StopCoroutine(formRoutine);
|
||||||
|
formRoutine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
int trueFormHash = "SE_TrolTrueForm".GetStableHashCode();
|
||||||
|
bool hadForm = isTransforming || wasTrueFormActive || player.GetSEMan().HaveStatusEffect(trueFormHash);
|
||||||
|
if (hadForm)
|
||||||
|
{
|
||||||
|
player.GetSEMan().RemoveStatusEffect(trueFormHash, true);
|
||||||
|
|
||||||
|
ZNetView nview = player.GetComponent<ZNetView>();
|
||||||
|
if (nview != null && nview.IsValid()) nview.GetZDO().Set(Trol_PlayerUpdate_Patch.TrueFormKey, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
isTransforming = false;
|
||||||
|
wasTrueFormActive = false;
|
||||||
|
return hadForm;
|
||||||
|
}
|
||||||
|
|
||||||
private void TryTrueForm()
|
private void TryTrueForm()
|
||||||
{
|
{
|
||||||
if (BossProgressionManager.GetCurrentProgressionState() < 5) return; // Requires Moder
|
if (BossProgressionManager.GetCurrentProgressionState() < 5) return; // Requires Moder
|
||||||
|
|
@ -239,7 +280,7 @@ namespace RacesOfValheim
|
||||||
|
|
||||||
if (!isTransforming)
|
if (!isTransforming)
|
||||||
{
|
{
|
||||||
StartCoroutine(TransformToTrueFormRoutine());
|
RunFormRoutine(TransformToTrueFormRoutine());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue