static void CharacterVisuals_EquipVisuals_Post(ref bool[] __state, ref EquipmentSlot.EquipmentSlotIDs _slotID, ref ArmorVisuals _visuals) { #region quit if (_armorSlotsToHide == ArmorSlots.None) { return; } #endregion // hide chosen pieces of armor if (ShouldArmorSlotBeHidden(_slotID)) { _visuals.Hide(); } // restore original hide flags _visuals.HideFace = __state[0]; _visuals.HideHair = __state[1]; _visuals.DisableDefaultVisuals = __state[2]; }
public void SetItemVisualPrefab(Item item, Transform origVisuals, Transform newVisuals, Vector3 position_offset, Vector3 rotation_offset, bool SetSpecialPrefab = false, bool HelmetHideFace = false, bool HelmetHideHair = false) { // clone the visual prefab so we can modify it without affecting the original item //origVisuals.gameObject.SetActive(false); //Transform clone = Instantiate(origVisuals); //DontDestroyOnLoad(clone); //clone.gameObject.SetActive(false); Vector3 origPos = Vector3.zero; Vector3 origRot = Vector3.zero; // set up our new model GameObject newModel = Instantiate(newVisuals.gameObject); // if we're setting an Armor Special (worn armor) prefab, handle that logic if (item is Armor && SetSpecialPrefab) { origPos = origVisuals.transform.position; origRot = origVisuals.transform.rotation.eulerAngles; ArmorVisuals visuals = newModel.AddComponent <ArmorVisuals>(); if ((item as Armor).EquipSlot == EquipmentSlot.EquipmentSlotIDs.Helmet) { visuals.HideFace = HelmetHideFace; visuals.HideHair = HelmetHideHair; } foreach (MeshRenderer mesh in newModel.GetComponents <MeshRenderer>()) { DestroyImmediate(mesh); } } else // setting a normal prefab. disable the original mesh first. { foreach (Transform child in newVisuals) { // only the actual item visuals will have both of these components. this will not disable particle fx or anything else. if (child.GetComponent <BoxCollider>() && child.GetComponent <MeshRenderer>()) { origPos = child.transform.position; origRot = child.transform.rotation.eulerAngles; child.gameObject.SetActive(false); break; } } } // position / rotation stuff // if user set it to -1-1-1, just use orig values if (position_offset == new Vector3(-1, -1, -1)) { newModel.transform.position = origPos; } else { newModel.transform.position = position_offset; } if (rotation_offset == new Vector3(-1, -1, -1)) { newModel.transform.rotation = Quaternion.Euler(origRot); } else { newModel.transform.rotation = Quaternion.Euler(rotation_offset); } if (SetSpecialPrefab) { item.SpecialVisualPrefabDefault = newModel.transform; } else { item.VisualPrefab = newModel.transform; } }
static bool CharacterVisuals_EquipVisuals_Pre(ref bool[] __state, ref EquipmentSlot.EquipmentSlotIDs _slotID, ref ArmorVisuals _visuals) { #region quit if (_armorSlotsToHide == ArmorSlots.None) { return(true); } #endregion // save original hide flags for postfix __state = new bool[3]; __state[0] = _visuals.HideFace; __state[1] = _visuals.HideHair; __state[2] = _visuals.DisableDefaultVisuals; // override hide flags if (ShouldArmorSlotBeHidden(_slotID)) { _visuals.HideFace = false; _visuals.HideHair = false; _visuals.DisableDefaultVisuals = false; } return(true); }