chore(release): v1.4.21 - dragon form multiplayer sync, Sverm Ravager networking, dorsal spine fix
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
6499eb71df
commit
e7325e4d25
12 changed files with 303 additions and 10 deletions
|
|
@ -310,6 +310,141 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// ─── Ravager Strain (remote observers) ──────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// Mirrors SvermRavagerForm.Enter/Exit for every OTHER client, the same way
|
||||
/// Skadi_MultiplayerVisuals_Patch mirrors SkadiRace's dragon forms. SvermRavagerForm itself
|
||||
/// only ever touches Player.m_localPlayer - Tick(), Enter() and RavagerFormBehavior are all
|
||||
/// built around it - so without this an observer's client never knew the form was up at
|
||||
/// all: no model, no hidden human body, nothing standing in for the Brute.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")]
|
||||
public static class Sverm_RavagerRemoteVisuals_Patch
|
||||
{
|
||||
private const string RemoteModelName = "SvermRavagerRemoteModel";
|
||||
|
||||
public static void Postfix(VisEquipment __instance)
|
||||
{
|
||||
if (__instance == null || !__instance.m_isPlayer) return;
|
||||
|
||||
Player player = __instance.GetComponent<Player>();
|
||||
if (player == null || player.IsOwner()) return; // Local player: SvermRavagerForm handles itself.
|
||||
|
||||
if (!SvermVisuals.IsSvermPlayer(player)) return;
|
||||
|
||||
ZNetView nview = player.GetComponent<ZNetView>();
|
||||
if (nview == null || !nview.IsValid()) return;
|
||||
|
||||
bool active = nview.GetZDO().GetBool(SvermRavagerForm.ActiveKey, false);
|
||||
Transform existing = player.transform.Find(RemoteModelName);
|
||||
Transform playerVisual = player.transform.Find("Visual");
|
||||
|
||||
if (!active)
|
||||
{
|
||||
if (existing != null)
|
||||
{
|
||||
Object.Destroy(existing.gameObject);
|
||||
PlayerVisualHider.Show(playerVisual, "sverm-ravager-remote-revert");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (existing == null)
|
||||
{
|
||||
GameObject model = SvermRavagerForm.SpawnRemoteModel(player.transform);
|
||||
if (model != null)
|
||||
{
|
||||
model.name = RemoteModelName;
|
||||
model.AddComponent<RemoteRavagerAnimator>();
|
||||
}
|
||||
}
|
||||
|
||||
PlayerVisualHider.Hide(playerVisual, "sverm-ravager-remote");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RemoteSkadiAnimator's counterpart for the Ravager Strain: locomotion off the replicated
|
||||
/// Character, plus the bite/ram/slam/taunt trigger RavagerFormBehavior publishes through
|
||||
/// SvermRavagerForm.PublishAttackTrigger. LateUpdate re-hides the player's own Visual every
|
||||
/// frame for the same reason RavagerFormBehavior does on the local client - any nearby
|
||||
/// equipment rebuild (VisEquipment's own refresh path) makes a hidden body visible again.
|
||||
/// </summary>
|
||||
public class RemoteRavagerAnimator : MonoBehaviour
|
||||
{
|
||||
private Animator anim;
|
||||
private Player player;
|
||||
private ZNetView nview;
|
||||
private bool hasForwardSpeed;
|
||||
private bool hasOnGround;
|
||||
|
||||
// Seeded from the ZDO's current value in Start, not "", so a trigger left over from an
|
||||
// earlier Ravager Strain on this same player does not replay the instant this
|
||||
// component is built.
|
||||
private string lastAttackTrigger;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
anim = GetComponentInChildren<Animator>();
|
||||
player = GetComponentInParent<Player>();
|
||||
nview = player != null ? player.GetComponent<ZNetView>() : null;
|
||||
|
||||
if (anim != null)
|
||||
{
|
||||
foreach (AnimatorControllerParameter p in anim.parameters)
|
||||
{
|
||||
if (p.type == AnimatorControllerParameterType.Float && p.name == "forward_speed") hasForwardSpeed = true;
|
||||
else if (p.type == AnimatorControllerParameterType.Bool && p.name == "onGround") hasOnGround = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
lastAttackTrigger = nview.GetZDO().GetString(SvermRavagerForm.AttackTriggerKey, "");
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (player == null) return;
|
||||
PlayerVisualHider.Hide(player.transform.Find("Visual"), "sverm-ravager-remote");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (anim == null || player == null) return;
|
||||
|
||||
if (hasForwardSpeed)
|
||||
{
|
||||
Vector3 vel = player.GetVelocity();
|
||||
vel.y = 0f;
|
||||
anim.SetFloat("forward_speed", vel.magnitude);
|
||||
}
|
||||
|
||||
if (hasOnGround) anim.SetBool("onGround", player.IsOnGround());
|
||||
|
||||
if (nview == null || !nview.IsValid()) return;
|
||||
|
||||
string current = nview.GetZDO().GetString(SvermRavagerForm.AttackTriggerKey, "");
|
||||
if (string.IsNullOrEmpty(current) || current == lastAttackTrigger) return;
|
||||
|
||||
lastAttackTrigger = current;
|
||||
|
||||
int seqAt = current.LastIndexOf('#');
|
||||
string trigger = seqAt >= 0 ? current.Substring(0, seqAt) : current;
|
||||
|
||||
foreach (AnimatorControllerParameter p in anim.parameters)
|
||||
{
|
||||
if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger)
|
||||
{
|
||||
anim.SetTrigger(trigger);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Spawn ───────────────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue