private void OnChangeAuthor(RecordableIdentity identity, ushort author, bool hasAuthority) { // if (!CacheRecordableIdentity.isSyncComplete) return; if (CacheRigidbody && !defaultIsKinematic) { if (!hasAuthority) { CacheRigidbody.isKinematic = true; } else { CacheRigidbody.isKinematic = false; } } if (hasAuthority) { //受け取った速度を設定 if (CacheRigidbody) { CacheRigidbody.velocity = recVelocity; CacheRigidbody.angularVelocity = recvAnglerVelicity; } //所有権変更後はすぐパケットを送る ForceUpdateTransfrom(); } }
private void Awake() { CacheTransform = transform; CacheRigidbody = GetComponent <Rigidbody> (); CacheRecordableIdentity = GetComponent <RecordableIdentity> (); if (CacheRigidbody) { defaultIsKinematic = CacheRigidbody.isKinematic; } }
internal virtual void Initialize() { if (isInitialized) { return; } isInitialized = true; cacheRecordableIdentity = GetComponent <RecordableIdentity> (); if (m_componentIndex == 255) { m_componentIndex = cacheRecordableIdentity.AddRecordableBehaviour(this); } }
/// <summary> /// ReserveNetIdで確保したNetIDでidentityを登録する /// このメソッド単体でSpawn処理は行わないので、それぞれのclientでIdentityを生成した後で実行すること /// </summary> public static void RegisterIdentity(RecordableIdentity identity, ushort netId, ushort author) { if (identity == null) { return; } while (identity.netId >= Instance.m_identityList.Count) { Instance.m_identityList.Add(null); } Instance.m_identityList[identity.netId] = identity; identity.m_netId = netId; identity.SetAuthor(author); identity.SyncComplete(); }
internal void RequestChangeAuthorInGroup(RecordableIdentity identity, ushort author) { if (identity == null) { Debug.LogError($"identity={identity} is null"); return; } if (!m_identityList.Contains(identity)) { Debug.LogError($"identity={identity} is not found in group"); return; } if (GamePacketManager.IsLeader) { identity.SetAuthor(author); } else { SendPacketChangeAuthor(identity.netId, author); } }
/// <summary> /// Hostに問い合わせて問題なければAuthorを変更する /// </summary> public static void RequestChangeAuthor(RecordableIdentity identity, ushort author) { if (identity == null) { return; } if (identity.sceneHash == 0) { Instance.RequestChangeAuthorInGroup(identity, author); } else { if (m_recordableSceneIdentitTable.TryGetValue(identity.sceneHash, out RecordableSceneIdentity sceneIdentity)) { sceneIdentity.RequestChangeAuthorInGroup(identity, author); } else { Debug.LogError($"sceneHash = {identity.sceneHash} is not found"); return; } } }
/// <summary> /// Hostに問い合わせて問題なければAuthorを変更する /// </summary> public void RequestChangeAuthorInScene(RecordableIdentity identity, ushort author) { RequestChangeAuthorInGroup(identity, author); }