Beispiel #1
0
        internal static bool Prefix(VRRig __instance, float red, float green, float blue)
        {
            var controller = __instance.gameObject.GetComponent <ICustomCosmeticsController>();

            if (controller == null)
            {
                return(true);
            }

            controller.SetColor(red, green, blue);

            Photon.Pun.PhotonView photView = __instance.photonView;
            if (photView != null)
            {
                __instance.playerText.text = __instance.NormalizeName(true, photView.Owner.NickName);
            }
            else if (__instance.showName)
            {
                __instance.playerText.text = PlayerPrefs.GetString("playerName");
            }

            return(false);

            /*
             * if (controller != null)
             * {
             *      controller.SetColor(red, green, blue);
             * }
             * var boolean = controller?.CurrentMaterial?.Descriptor.CustomColors ?? true;
             * return boolean;
             */
        }
        public static bool Prefix(bool isLeftHand, float tapVolume, VRRig __instance)
        {
            if (!Enabled)
            {
                return(true);
            }

            if (SoundClip == null)
            {
                return(false);
            }

            if (!_inited)
            {
                Init(__instance.leftHandPlayer, __instance.rightHandPlayer);
            }

            if (isLeftHand)
            {
                __instance.leftHandPlayer.volume = tapVolume;
                __instance.leftHandPlayer.pitch  = 1.3f;
                __instance.leftHandPlayer.PlayOneShot(SoundClip);
                return(false);
            }
            __instance.rightHandPlayer.volume = tapVolume;
            __instance.rightHandPlayer.PlayOneShot(SoundClip);
            return(false);
        }
Beispiel #3
0
 // Start is called before the first frame update
 void Start()
 {
     photonView  = GetComponent <PhotonView>();
     animator    = GetComponent <Animator>();
     vrRig       = GetComponent <VRRig>();
     previousPos = vrRig.head.vrTarget.position;
 }
Beispiel #4
0
        internal static void Postfix(VRRig __instance)
        {
            Photon.Realtime.Player player = __instance.photonView?.Owner;

            Plugin.Log($"GorillaCosmetics: Creating CustomCosmeticsController for {player?.NickName ?? "SELF"}");
            __instance.gameObject.AddComponent <CustomCosmeticsController>();
        }
        internal static void ChangeHat(VRRig __instance)
        {
            Transform existingHat = __instance.head.rigTarget.Find("Hat");

            if (existingHat != null)
            {
                existingHat.parent = null;
                existingHat.gameObject.SetActive(false);
                UnityEngine.Object.Destroy(existingHat.gameObject);
            }
            if (IsLocalPlayer(__instance) || GorillaCosmetics.applyHatsToOtherPlayers.Value)
            {
                GorillaHat hat = AssetLoader.SelectedHat();
                if (hat != null && hat.Hat != null)
                {
                    GameObject hatObject = UnityEngine.Object.Instantiate(hat.Hat);
                    hatObject.name = "Hat";
                    hatObject.transform.SetParent(__instance.head.rigTarget);
                    hatObject.transform.localScale    = new Vector3(0.25f, 0.25f, 0.25f);
                    hatObject.transform.localPosition = new Vector3(0f, 0.365f, 0.04f);
                    hatObject.transform.localRotation = Quaternion.identity;
                    hatObject.transform.Rotate(new Vector3(0, 90, 10));
                }
            }
        }
 public static bool IsLocalPlayer(VRRig rig)
 {
     if (rig.isOfflineVRRig || rig.isMyPlayer || rig.photonView.IsMine)
     {
         return(true);
     }
     return(false);
 }
Beispiel #7
0
 public Player FindPlayerforVRRig(VRRig vRRig)
 {
     if (vRRig.photonView != null && vRRig.photonView.Owner != null)
     {
         return(vRRig.photonView.Owner);
     }
     return(null);
 }
 public static void RefreshPlayer(VRRig __instance)
 {
     if (__instance)
     {
         ChangeMaterial(__instance, __instance.currentMatIndex);
         ChangeHat(__instance);
     }
 }
Beispiel #9
0
    // Start is called before the first frame update
    void Start()
    {
        tr          = GetComponent <Transform>();
        animator    = GetComponent <Animator>();
        vrRig       = GetComponent <VRRig>();
        previousPos = vrRig.head.vrTarget.position;

        ch_rail01 = GameObject.Find("상호작용지점").transform.Find("ch_rail01");
        ch_rail02 = GameObject.Find("상호작용지점").transform.Find("ch_rail02");
        ch_rail03 = GameObject.Find("상호작용지점").transform.Find("ch_rail03");
    }
Beispiel #10
0
        internal static void Prefix(VRRig __instance, out bool __state, ref int materialIndex)
        {
            bool reset      = false;
            var  controller = __instance.gameObject.GetComponent <ICustomCosmeticsController>();

            if (controller != null && materialIndex == 0)
            {
                reset         = true;
                materialIndex = controller.MatIndex;
            }

            __state = reset;
        }
Beispiel #11
0
 private void setVRRigAndBodyParts()
 {
     trackVRRig = true;
     if (isLocalPlayer)
     {
         GameObject VRRig = GameObject.Find("[CameraRig]");
         if (VRRig != null)
         {
             myVRRig    = VRRig.GetComponent <VRRig>();
             trackVRRig = true;
         }
         else
         {
             Debug.LogWarning("BodyAttachment Failed: No CameraRig Found!"); trackVRRig = false;
         }
     }
     head       = this.transform.GetChild(1).gameObject;
     body       = this.transform.GetChild(0).gameObject;
     bow        = this.transform.GetChild(2).gameObject;
     deadFilter = this.transform.GetChild(3).gameObject;
 }
 public static void ChangeMaterial(VRRig __instance, int materialIndex)
 {
     if (materialIndex == 0 && (IsLocalPlayer(__instance) || GorillaCosmetics.applyToOtherPlayers.Value))
     {
         // default mat
         GorillaMaterial material = AssetLoader.SelectedMaterial();
         if (material != null && material.Material != null)
         {
             Material instantiatedMat = UnityEngine.Object.Instantiate(material.Material);
             if (material.Descriptor.CustomColors)
             {
                 Color color = new Color(PlayerPrefs.GetFloat("redValue"), PlayerPrefs.GetFloat("greenValue"), PlayerPrefs.GetFloat("blueValue"));
                 instantiatedMat.color = color;
             }
             __instance.mainSkin.material = instantiatedMat;
             try
             {
                 Debug.Log($"Changed the skin of {__instance.photonView.Owner.UserId}");
             }
             catch
             {
                 Debug.Log("Couldn't find name of user.");
             }
         }
     }
     else if (materialIndex > 0 && (IsLocalPlayer(__instance) || GorillaCosmetics.applyInfectedToOtherPlayers.Value))
     {
         GorillaMaterial material = AssetLoader.SelectedInfectedMaterial();
         if (material != null && material.Material != null)
         {
             Material instantiatedMat = UnityEngine.Object.Instantiate(material.Material);
             if (material.Descriptor.CustomColors)
             {
                 instantiatedMat.color = __instance.mainSkin.material.color;
             }
             __instance.mainSkin.material = instantiatedMat;
         }
     }
 }
        void Start()
        {
            rig = GetComponent <VRRig>();

            var tempMatArray = rig.materialsToChangeTo;

            rig.materialsToChangeTo = new Material[tempMatArray.Length + 1];

            for (int index = 0; index < tempMatArray.Length; index++)
            {
                rig.materialsToChangeTo[index] = tempMatArray[index];
            }

            MatIndex        = rig.materialsToChangeTo.Length - 1;
            defaultMaterial = rig.materialsToChangeTo[0];
            rig.materialsToChangeTo[MatIndex] = tempMatArray[0];

            Player player = rig.photonView?.Owner;

            if (player != null)
            {
                Plugin.CosmeticsNetworker.OnPlayerPropertiesUpdate(player, player.CustomProperties);
            }
        }
Beispiel #14
0
 internal static void Postfix(VRRig __instance, in bool __state)
Beispiel #15
0
 private void Awake()
 {
     this.myVRRig = this.GetComponent <VRRig>();
 }
Beispiel #16
0
 private static void Postfix(VRRig __instance)
 {
     CosmeticUtils.ChangeMaterial(__instance, __instance.setMatIndex);
 }
Beispiel #17
0
 private static void Postfix(VRRig __instance, int materialIndex)
 {
     CosmeticUtils.ChangeMaterial(__instance, materialIndex);
 }
 private static void Postfix(VRRig __instance)
 {
     CosmeticUtils.ChangeHat(__instance);
 }
 //methods
 void Start()
 {
     myVRRig  = this.GetComponent <VRRig>();
     teleport = this.GetComponent <Teleport>();
     menu     = this.transform.GetChild(3).GetComponent <MenuSystem>();
 }