Esempio n. 1
0
        public AttachmentPointNode GetHeldAttachmentPointNode(AttachmentNode attachmentNode)
        {
            //Debug.Log(gameObject.name + ".CharacterEquipmentManager.GetHeldAttachmentPointNode()");
            if (attachmentNode.UseUniversalAttachment == false)
            {
                AttachmentPointNode attachmentPointNode = new AttachmentPointNode();
                attachmentPointNode.TargetBone       = attachmentNode.HoldableObject.TargetBone;
                attachmentPointNode.Position         = attachmentNode.HoldableObject.Position;
                attachmentPointNode.Rotation         = attachmentNode.HoldableObject.Rotation;
                attachmentPointNode.RotationIsGlobal = attachmentNode.HoldableObject.RotationIsGlobal;
                return(attachmentPointNode);
            }
            else
            {
                // find unit profile, find prefab profile, find universal attachment profile, find universal attachment node
                if (unitController?.CharacterUnit?.BaseCharacter?.UnitProfile?.UnitPrefabProps?.AttachmentProfile != null)
                {
                    if (unitController.CharacterUnit.BaseCharacter.UnitProfile.UnitPrefabProps.AttachmentProfile.AttachmentPointDictionary.ContainsKey(attachmentNode.UnsheathedAttachmentName))
                    {
                        return(unitController.CharacterUnit.BaseCharacter.UnitProfile.UnitPrefabProps.AttachmentProfile.AttachmentPointDictionary[attachmentNode.UnsheathedAttachmentName]);
                    }
                }
            }

            return(null);
        }
Esempio n. 2
0
        public void SheathObject(GameObject go, AttachmentNode attachmentNode, GameObject searchObject)
        {
            if (searchObject == null)
            {
                //Debug.Log(gameObject + ".CharacterEquipmentManager.SheathObject(): searchObject is null");
                return;
            }
            if (attachmentNode == null || attachmentNode.HoldableObject == null)
            {
                //Debug.Log(gameObject + ".CharacterEquipmentManager.SheathObject(): MyHoldableObjectName is empty");
                return;
            }
            if (go == null)
            {
                //Debug.Log(gameObject + ".CharacterEquipmentManager.SheathObject(): gameObject is null is null");
                return;
            }
            AttachmentPointNode attachmentPointNode = GetSheathedAttachmentPointNode(attachmentNode);

            if (attachmentPointNode != null)
            {
                Transform targetBone = searchObject.transform.FindChildByRecursive(attachmentPointNode.TargetBone);
                if (targetBone != null)
                {
                    //Debug.Log(gameObject + ".CharacterEquipmentManager.SheathObject(): targetBone is NOT null: " + holdableObject.MySheathedTargetBone);
                    go.transform.parent           = targetBone;
                    go.transform.localPosition    = attachmentPointNode.Position;
                    go.transform.localEulerAngles = attachmentPointNode.Rotation;
                }
                else
                {
                    //Debug.Log(gameObject + ".CharacterEquipmentManager.SheathObject(): targetBone is null: " + holdableObject.MySheathedTargetBone);
                }
            }
        }
Esempio n. 3
0
        public void HoldObject(GameObject go, AttachmentNode attachmentNode, GameObject searchObject)
        {
            //public void HoldObject(GameObject go, PrefabProfile holdableObject, GameObject searchObject) {
            //Debug.Log(gameObject + ".CharacterEquipmentManager.HoldObject(" + go.name + ", " + holdableObjectName + ", " + searchObject.name + ")");
            if (attachmentNode == null || attachmentNode.HoldableObject == null || go == null || searchObject == null)
            {
                //Debug.Log(gameObject + ".CharacterEquipmentManager.HoldObject(): MyHoldableObjectName is empty");
                return;
            }

            AttachmentPointNode attachmentPointNode = GetHeldAttachmentPointNode(attachmentNode);

            if (attachmentPointNode != null && attachmentPointNode.TargetBone != null && attachmentPointNode.TargetBone != string.Empty)
            {
                Transform targetBone = searchObject.transform.FindChildByRecursive(attachmentPointNode.TargetBone);
                if (targetBone != null)
                {
                    //Debug.Log(gameObject + ".CharacterEquipmentManager.HoldObject(): targetBone: " + targetBone + "; position: " + holdableObject.MyPosition + "; holdableObject.MyPhysicalRotation: " + holdableObject.MyRotation);
                    go.transform.parent        = targetBone;
                    go.transform.localPosition = attachmentPointNode.Position;
                    if (attachmentPointNode.RotationIsGlobal)
                    {
                        go.transform.rotation = Quaternion.LookRotation(targetBone.transform.forward) * Quaternion.Euler(attachmentPointNode.Rotation);
                    }
                    else
                    {
                        go.transform.localEulerAngles = attachmentPointNode.Rotation;
                    }
                }
                else
                {
                    Debug.Log("CharacterEquipmentManager.HoldObject(): Unable to find target bone : " + attachmentPointNode.TargetBone);
                }
            }
            else
            {
                // disabled message because some equipment (like quivers) does not have held attachment points intentionally because it should stay in the same place in combat
                //Debug.Log(gameObject + ".CharacterEquipmentManager.HoldObject(): Unable to get attachment point " + attachmentNode.UnsheathedAttachmentName);
            }
        }
Esempio n. 4
0
 public AttachmentPointNode GetSheathedAttachmentPointNode(AttachmentNode attachmentNode)
 {
     if (attachmentNode.UseUniversalAttachment == false)
     {
         AttachmentPointNode attachmentPointNode = new AttachmentPointNode();
         attachmentPointNode.TargetBone = attachmentNode.HoldableObject.SheathedTargetBone;
         attachmentPointNode.Position   = attachmentNode.HoldableObject.SheathedPosition;
         attachmentPointNode.Rotation   = attachmentNode.HoldableObject.SheathedRotation;
         return(attachmentPointNode);
     }
     else
     {
         // find unit profile, find prefab profile, find universal attachment profile, find universal attachment node
         if (unitController?.CharacterUnit?.BaseCharacter?.UnitProfile?.UnitPrefabProps?.AttachmentProfile != null)
         {
             if (unitController.CharacterUnit.BaseCharacter.UnitProfile.UnitPrefabProps.AttachmentProfile.AttachmentPointDictionary.ContainsKey(attachmentNode.PrimaryAttachmentName))
             {
                 return(unitController.CharacterUnit.BaseCharacter.UnitProfile.UnitPrefabProps.AttachmentProfile.AttachmentPointDictionary[attachmentNode.PrimaryAttachmentName]);
             }
         }
         else if (attachmentProfile != null)
         {
             if (attachmentProfile.AttachmentPointDictionary.ContainsKey(attachmentNode.PrimaryAttachmentName))
             {
                 return(attachmentProfile.AttachmentPointDictionary[attachmentNode.PrimaryAttachmentName]);
             }
         }
         else
         {
             // enable for troubleshooting only.  It gets spammy with beast units that don't have attachments.
             //Debug.Log(gameObject.name + ".CharacterEquipmentManager.GetSheathedAttachmentPointNode(): could not get attachment profile from prefabprofile");
         }
     }
     // enable for troubleshooting only.  It gets spammy with beast units that don't have attachments.
     //Debug.Log("CharacterEquipmentManager.GetSheathedAttachmentPointNode(): Unable to return attachment point node!");
     return(null);
 }