コード例 #1
0
ファイル: ItemDrop.cs プロジェクト: ingvard/valheim-jserver
    // Token: 0x060006C4 RID: 1732 RVA: 0x00038234 File Offset: 0x00036434
    private void Start()
    {
        this.Save();
        IEquipmentVisual componentInChildren = base.gameObject.GetComponentInChildren <IEquipmentVisual>();

        if (componentInChildren != null)
        {
            componentInChildren.Setup(this.m_itemData.m_variant);
        }
    }
コード例 #2
0
ファイル: ItemStand.cs プロジェクト: ingvard/valheim-jserver
    // Token: 0x06000DE1 RID: 3553 RVA: 0x0006327C File Offset: 0x0006147C
    private void SetVisualItem(string itemName, int variant)
    {
        if (this.m_visualName == itemName && this.m_visualVariant == variant)
        {
            return;
        }
        this.m_visualName      = itemName;
        this.m_visualVariant   = variant;
        this.m_currentItemName = "";
        if (this.m_visualName == "")
        {
            UnityEngine.Object.Destroy(this.m_visualItem);
            return;
        }
        GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemName);

        if (itemPrefab == null)
        {
            ZLog.LogWarning("Missing item prefab " + itemName);
            return;
        }
        GameObject attachPrefab = this.GetAttachPrefab(itemPrefab);

        if (attachPrefab == null)
        {
            ZLog.LogWarning("Failed to get attach prefab for item " + itemName);
            return;
        }
        ItemDrop component = itemPrefab.GetComponent <ItemDrop>();

        this.m_currentItemName = component.m_itemData.m_shared.m_name;
        Transform attach = this.GetAttach(component.m_itemData);

        this.m_visualItem = UnityEngine.Object.Instantiate <GameObject>(attachPrefab, attach.position, attach.rotation, attach);
        this.m_visualItem.transform.localPosition = attachPrefab.transform.localPosition;
        this.m_visualItem.transform.localRotation = attachPrefab.transform.localRotation;
        IEquipmentVisual componentInChildren = this.m_visualItem.GetComponentInChildren <IEquipmentVisual>();

        if (componentInChildren != null)
        {
            componentInChildren.Setup(this.m_visualVariant);
        }
    }
コード例 #3
0
    // Token: 0x060002CF RID: 719 RVA: 0x00016B58 File Offset: 0x00014D58
    protected GameObject AttachItem(int itemHash, int variant, Transform joint, bool enableEquipEffects = true)
    {
        GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash);

        if (itemPrefab == null)
        {
            ZLog.Log(string.Concat(new object[]
            {
                "Missing attach item: ",
                itemHash,
                "  ob:",
                base.gameObject.name,
                "  joint:",
                joint ? joint.name : "none"
            }));
            return(null);
        }
        GameObject gameObject = null;
        int        childCount = itemPrefab.transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            Transform child = itemPrefab.transform.GetChild(i);
            if (child.gameObject.name == "attach" || child.gameObject.name == "attach_skin")
            {
                gameObject = child.gameObject;
                break;
            }
        }
        if (gameObject == null)
        {
            return(null);
        }
        GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject);

        gameObject2.SetActive(true);
        this.CleanupInstance(gameObject2);
        if (enableEquipEffects)
        {
            this.EnableEquipedEffects(gameObject2);
        }
        if (gameObject.name == "attach_skin")
        {
            gameObject2.transform.SetParent(this.m_bodyModel.transform.parent);
            gameObject2.transform.localPosition = Vector3.zero;
            gameObject2.transform.localRotation = Quaternion.identity;
            foreach (SkinnedMeshRenderer skinnedMeshRenderer in gameObject2.GetComponentsInChildren <SkinnedMeshRenderer>())
            {
                skinnedMeshRenderer.rootBone = this.m_bodyModel.rootBone;
                skinnedMeshRenderer.bones    = this.m_bodyModel.bones;
            }
        }
        else
        {
            gameObject2.transform.SetParent(joint);
            gameObject2.transform.localPosition = Vector3.zero;
            gameObject2.transform.localRotation = Quaternion.identity;
        }
        IEquipmentVisual componentInChildren = gameObject2.GetComponentInChildren <IEquipmentVisual>();

        if (componentInChildren != null)
        {
            componentInChildren.Setup(variant);
        }
        return(gameObject2);
    }
コード例 #4
0
    // Token: 0x060002CE RID: 718 RVA: 0x000168D4 File Offset: 0x00014AD4
    private List <GameObject> AttachArmor(int itemHash, int variant = -1)
    {
        GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemHash);

        if (itemPrefab == null)
        {
            ZLog.Log(string.Concat(new object[]
            {
                "Missing attach item: ",
                itemHash,
                "  ob:",
                base.gameObject.name
            }));
            return(null);
        }
        List <GameObject> list = new List <GameObject>();
        int childCount         = itemPrefab.transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            Transform child = itemPrefab.transform.GetChild(i);
            if (child.gameObject.name.StartsWith("attach_"))
            {
                string     text = child.gameObject.name.Substring(7);
                GameObject gameObject;
                if (text == "skin")
                {
                    gameObject = UnityEngine.Object.Instantiate <GameObject>(child.gameObject, this.m_bodyModel.transform.position, this.m_bodyModel.transform.parent.rotation, this.m_bodyModel.transform.parent);
                    gameObject.SetActive(true);
                    foreach (SkinnedMeshRenderer skinnedMeshRenderer in gameObject.GetComponentsInChildren <SkinnedMeshRenderer>())
                    {
                        skinnedMeshRenderer.rootBone = this.m_bodyModel.rootBone;
                        skinnedMeshRenderer.bones    = this.m_bodyModel.bones;
                    }
                    foreach (Cloth cloth in gameObject.GetComponentsInChildren <Cloth>())
                    {
                        if (this.m_clothColliders.Length != 0)
                        {
                            if (cloth.capsuleColliders.Length != 0)
                            {
                                List <CapsuleCollider> list2 = new List <CapsuleCollider>(this.m_clothColliders);
                                list2.AddRange(cloth.capsuleColliders);
                                cloth.capsuleColliders = list2.ToArray();
                            }
                            else
                            {
                                cloth.capsuleColliders = this.m_clothColliders;
                            }
                        }
                    }
                }
                else
                {
                    Transform transform = Utils.FindChild(this.m_visual.transform, text);
                    if (transform == null)
                    {
                        ZLog.LogWarning("Missing joint " + text + " in item " + itemPrefab.name);
                        goto IL_268;
                    }
                    gameObject = UnityEngine.Object.Instantiate <GameObject>(child.gameObject);
                    gameObject.SetActive(true);
                    gameObject.transform.SetParent(transform);
                    gameObject.transform.localPosition = Vector3.zero;
                    gameObject.transform.localRotation = Quaternion.identity;
                }
                if (variant >= 0)
                {
                    IEquipmentVisual componentInChildren = gameObject.GetComponentInChildren <IEquipmentVisual>();
                    if (componentInChildren != null)
                    {
                        componentInChildren.Setup(variant);
                    }
                }
                this.CleanupInstance(gameObject);
                this.EnableEquipedEffects(gameObject);
                list.Add(gameObject);
            }
            IL_268 :;
        }
        return(list);
    }