
using System;
using UnityEngine;

namespace ShipDecorations
{
  public class DoorColliderScript : MonoBehaviour
  {
    private int inside = 0;

    private void OnTriggerEnter(Collider c)
    {
      if ((c.gameObject.layer == 26) || (c.gameObject.layer == 8 && c.GetComponent<NetworkView>().isMine))
      {
        inside++;

        gameObject.transform.parent.GetChild(0).gameObject.SetActive(false);
        gameObject.transform.parent.GetChild(1).gameObject.SetActive(true);
        gameObject.GetComponent<BoxCollider>().size = new Vector3(1.55f, 1, 1);
        gameObject.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/bloo"), Menuu.soundLevel / 10f);
      }
    }

    private void OnTriggerExit(Collider c)
    {
      if ((c.gameObject.layer == 26) || (c.gameObject.layer == 8 && c.GetComponent<NetworkView>().isMine))
      {
        inside--;
        if (inside <= 0)
        {
          inside = 0;
          gameObject.transform.parent.GetChild(0).gameObject.SetActive(true);
          gameObject.transform.parent.GetChild(1).gameObject.SetActive(false);
          gameObject.GetComponent<BoxCollider>().size = new Vector3(1, 1, 1);
          gameObject.GetComponent<AudioSource>().PlayOneShot((AudioClip)Resources.Load("Au/bloo"), Menuu.soundLevel / 10f);
        }
      }
    }
  }
}
