Beispiel #1
0
 private void Piece_Awake(On.Piece.orig_Awake orig, Piece self)
 {
     orig(self);
     if (self.m_nview && self.m_nview.IsValid())
     {
         MoveableBaseSync.InitPiece(self);
     }
 }
Beispiel #2
0
        internal void SetSupport(PulleySupport pulleySupport)
        {
#if DEBUG
            Jotunn.Logger.LogWarning(GetInstanceID() + ": Setting support for pulley @ " + this.transform.position + " " + gameObject.GetInstanceID() + ": " + pulleySupport.GetInstanceID());
#endif
            m_support = pulleySupport;
            if (!m_baseRoot)
            {
                GameObject       baseSyncObject   = Object.Instantiate(PrefabManager.Instance.GetPrefab(PulleyManager.MoveableBaseSyncName), transform.position, transform.rotation);
                MoveableBaseSync moveableBaseSync = baseSyncObject.GetComponent <MoveableBaseSync>();
                moveableBaseSync.AddNewPiece(GetComponent <Piece>());
            }
        }
Beispiel #3
0
 public void OnBaseRootDestroy(MoveableBaseSync destroyingSync)
 {
     if (ZNetScene.instance && ZNetScene.instance.m_netSceneRoot)
     {
         for (int i = 0; i < m_pieces.Count; i++)
         {
             Piece piece = m_pieces[i];
             if ((bool)piece)
             {
                 AddInactivePiece(m_nview.m_zdo.m_uid, piece);
             }
         }
         List <Player> allPlayers = Player.GetAllPlayers();
         for (int j = 0; j < allPlayers.Count; j++)
         {
             if (allPlayers[j] && allPlayers[j].transform.parent == transform)
             {
                 allPlayers[j].transform.SetParent(ZNetScene.instance.m_netSceneRoot.transform);
             }
         }
     }
 }
Beispiel #4
0
        public static void InitPiece(Piece piece)
        {
            Rigidbody componentInChildren = piece.GetComponentInChildren <Rigidbody>();

            if (componentInChildren && !componentInChildren.isKinematic)
            {
                Jotunn.Logger.LogInfo("Ignoring rigidbody: " + piece);
                return;
            }
            ZDOID zDOID = piece.m_nview.m_zdo.GetZDOID(MBParentHash);

            if (zDOID == ZDOID.None)
            {
                return;
            }
#if DEBUG
            Jotunn.Logger.LogInfo("Piece (" + piece.m_nview.m_zdo.m_uid + ") has Parent: " + zDOID);
#endif
            GameObject gameObject = ZNetScene.instance.FindInstance(zDOID);
            if ((bool)gameObject)
            {
                MoveableBaseSync component = gameObject.GetComponent <MoveableBaseSync>();
                if (component && component.m_baseRoot)
                {
                    component.ActivatePiece(piece);
                }
#if DEBUG
                else
                {
                    Jotunn.Logger.LogWarning("ZDOID Saved MoveableBaseSync has no MoveableBaseSync: " + component + " " + component.transform.position);
                }
#endif
            }
            else
            {
                AddInactivePiece(zDOID, piece);
            }
        }