Esempio n. 1
0
 private void OnDestroy()
 {
     if (AttachedOn != null)
     {
         AttachedOn.GetComponent <EntityEventHandler>().Death.RemoveListener(On_SocketDeath);
     }
 }
Esempio n. 2
0
        public void SetState(PieceState state)
        {
            if (!m_Initialized)
            {
                Awake();
            }

            if (state == PieceState.Preview)
            {
                SetMaterials(m_PreviewMat);

                foreach (var col in m_Colliders)
                {
                    if (col)
                    {
                        col.enabled = false;
                    }
                    else
                    {
                        Debug.LogError("A collider was found null in the collider list!", this);
                    }
                }

                foreach (var socket in m_Sockets)
                {
                    socket.gameObject.SetActive(false);
                }
            }
            else if (state == PieceState.Placed)
            {
                SetMaterials(m_InitialMaterials);

                foreach (var col in m_Colliders)
                {
                    col.enabled = true;
                }

                foreach (var socket in m_Sockets)
                {
                    socket.gameObject.SetActive(true);
                }

                if (m_CheckStability && AttachedOn != null)
                {
                    //print(AttachedOn);
                    var eventHandler = AttachedOn.GetComponent <EntityEventHandler>();
                    if (eventHandler != null)
                    {
                        eventHandler.Death.AddListener(On_SocketDeath);
                    }
                }
            }

            m_State = state;
        }