more player sync stuff
This commit is contained in:
@@ -16,6 +16,7 @@ using System.IO;
|
||||
using BoneSync.Data;
|
||||
using StressLevelZero.Interaction;
|
||||
using UnhollowerBaseLib;
|
||||
using BoneSync.Patching;
|
||||
|
||||
|
||||
namespace BoneSync.Player
|
||||
@@ -72,6 +73,7 @@ namespace BoneSync.Player
|
||||
|
||||
public void UpdatePlayerSync(PlayerSyncInfo playerSyncInfo)
|
||||
{
|
||||
//MelonLogger.Msg("Updating player sync for " + _ownerId);
|
||||
playerRig.transform.position = playerSyncInfo.rootPos;
|
||||
|
||||
headTransform.ApplySimpleTransform(playerSyncInfo.headPos);
|
||||
@@ -82,6 +84,19 @@ namespace BoneSync.Player
|
||||
SetFingerCurl(Handedness.RIGHT, playerSyncInfo.rightHandFingerCurl);
|
||||
}
|
||||
|
||||
public void UpdatePose(Handedness hand, int index)
|
||||
{
|
||||
Il2CppStringArray handPoses = PlayerScripts.playerHandPoses;
|
||||
if (handPoses.Count < index + 1)
|
||||
return;
|
||||
UpdatePose(hand, handPoses[index]);
|
||||
}
|
||||
|
||||
public void UpdatePose(Handedness hand, string pose) => characterAnimationManager?.SetHandPose(hand, pose);
|
||||
|
||||
public void UpdatePoseRadius(Handedness hand, float radius) => characterAnimationManager?.SetCylinderRadius(hand, radius);
|
||||
|
||||
|
||||
public static PlayerSyncInfo? GetLocalSyncInfo()
|
||||
{
|
||||
GameObject localPlayerRig = GameObject.Find("[RigManager (Default Brett)]/[SkeletonRig (GameWorld Brett)]");
|
||||
@@ -110,15 +125,25 @@ namespace BoneSync.Player
|
||||
rightHandPos = new SimpleSyncTransform(localRightHandTransform),
|
||||
//leftHandFingerCurl = new SimpleFingerCurl(PlayerScripts.playerLeftHand.fingerCurl),
|
||||
//rightHandFingerCurl = new SimpleFingerCurl(PlayerScripts.playerRightHand.fingerCurl)
|
||||
poseIndexLeft = SkeletonHandPatches.poseIndexLeft,
|
||||
poseIndexRight = SkeletonHandPatches.poseIndexRight,
|
||||
poseRadiusLeft = SkeletonHandPatches.radiusLeft,
|
||||
poseRadiusRight = SkeletonHandPatches.radiusRight
|
||||
|
||||
};
|
||||
|
||||
if (PlayerScripts.playerLeftHand)
|
||||
playerSyncInfo.leftHandFingerCurl = new SimpleFingerCurl(PlayerScripts.playerLeftHand.fingerCurl);
|
||||
if (PlayerScripts.playerRightHand)
|
||||
playerSyncInfo.rightHandFingerCurl = new SimpleFingerCurl(PlayerScripts.playerRightHand.fingerCurl);
|
||||
|
||||
return playerSyncInfo;
|
||||
}
|
||||
|
||||
private static void SendLocalPlayerSync()
|
||||
{
|
||||
if (!BoneSync.lobby.IsConnected()) return;
|
||||
//MelonLogger.Msg("Sending local player sync");
|
||||
PlayerSyncInfo? playerSyncInfo = GetLocalSyncInfo();
|
||||
if (!playerSyncInfo.HasValue) return;
|
||||
PlayerSyncMessage playerSyncMessage = new PlayerSyncMessage(playerSyncInfo.Value);
|
||||
@@ -129,7 +154,7 @@ namespace BoneSync.Player
|
||||
{
|
||||
if (_playerRigs.ContainsKey(ownerId))
|
||||
{
|
||||
MelonLogger.Msg("PlayerRig already exists for " + ownerId);
|
||||
//MelonLogger.Msg("PlayerRig already exists for " + ownerId);
|
||||
return _playerRigs[ownerId];
|
||||
}
|
||||
|
||||
@@ -138,10 +163,9 @@ namespace BoneSync.Player
|
||||
MelonLogger.Msg("playerRepBundle is null! Did you forget to load the bundle?");
|
||||
return null;
|
||||
}
|
||||
PlayerScripts.GetPlayerScripts();
|
||||
//PlayerScripts.GetPlayerScripts();
|
||||
|
||||
PlayerRig rig = new PlayerRig(ownerId);
|
||||
rig.EnsurePlayerRig();
|
||||
return rig;
|
||||
}
|
||||
|
||||
@@ -157,7 +181,7 @@ namespace BoneSync.Player
|
||||
if (playerRig != null) return;
|
||||
|
||||
playerRig = GameObject.Instantiate(rigBundle.LoadAsset<GameObject>("PlayerRep"));
|
||||
playerRig.name = "PlayerRep (" + _ownerId + ")";
|
||||
playerRig.name = "PlayerRep";
|
||||
|
||||
body = playerRig.GetComponentInChildren<SLZ_Body>();
|
||||
characterAnimationManager = playerRig.GetComponentInChildren<CharacterAnimationManager>();
|
||||
@@ -191,7 +215,11 @@ namespace BoneSync.Player
|
||||
body.FullBodyUpdate(repInputVel, Vector3.zero);
|
||||
body.ArtToBlender.UpdateBlender();
|
||||
}
|
||||
catch { }
|
||||
catch (Exception e)
|
||||
{
|
||||
MelonLogger.Warning("Failed to update player rig " + _ownerId);
|
||||
MelonLogger.Warning(e.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -201,6 +229,14 @@ namespace BoneSync.Player
|
||||
_ownerId = id;
|
||||
}
|
||||
|
||||
public static void OnPlayerSync(PlayerSyncMessage playerSyncMessage)
|
||||
{
|
||||
//MelonLogger.Msg("Player Sync Received " + playerSyncMessage.senderId);
|
||||
PlayerRig playerRig = PlayerRig.GetPlayerRig(playerSyncMessage.senderId);
|
||||
if (playerRig == null) return;
|
||||
playerRig.UpdatePlayerSync(playerSyncMessage.playerSyncInfo);
|
||||
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user