Beispiel #1
0
        public LYRagdoll Enable(GameObject obj_)
        {
            string name = obj_.name.ToLower();

            name = name.Replace("(clone)", "");

            LYRagdoll rd = obj_.GetComponentInChildren <LYRagdoll>();

            if (rd != null)
            {
                rd.enabled = true;
                return(rd);
            }

            templateItemD template = GetTemplateItem(name);

            if (template == null)
            {
                return(null);
            }
            ItemD item = template != null?GetNodeItemByTemplateName(template.templateName) : GetNodeItemDByObj(obj_);

            if (item == null)
            {
                return(null);
            }

            rd = obj_.AddComponent <LYRagdoll>();
            rd.LoadFromNode(item, template);
            rd.OnEnable();

            return(rd);
        }
Beispiel #2
0
        public void EnableByNodeItem(GameObject obj_, string nodeItemName_)
        {
            LYRagdoll rd = obj_.GetComponentInChildren <LYRagdoll>();

            if (rd != null)
            {
                rd.enabled = false;
            }

            ItemD item = GetNodeItemByTemplateName(nodeItemName_);

            if (item == null)
            {
                return;
            }

            if (rd == null)
            {
                rd = obj_.AddComponent <LYRagdoll>();
            }
            rd.LoadFromNode(item, null);
            rd.OnEnable();
        }