public void Equip(EquipAssetExample asset) { var equipType = asset.equipType; EquipHook howToEquip = equippables.Find(x => x.type == equipType); var skeletonData = skeletonDataAsset.GetSkeletonData(true); int slotIndex = skeletonData.FindSlotIndex(howToEquip.slot); var attachment = GenerateAttachmentFromEquipAsset(asset, slotIndex, howToEquip.templateSkin, howToEquip.templateAttachment); target.Equip(slotIndex, howToEquip.templateAttachment, attachment); }
public void Equip(int index) { EquipHook hook = equippables[index]; var skeletonData = skeletonDataAsset.GetSkeletonData(true); int slotIndex = skeletonData.FindSlotIndex(hook.slot); var attachment = GenerateAttachmentFromEquipAsset(hook, slotIndex, hook.templateSkin, hook.templateAttachment); target.Equip(slotIndex, hook.templateAttachment, attachment); Done(); }
Attachment GenerateAttachmentFromEquipAsset(EquipHook asset, int slotIndex, string templateSkinName, string templateAttachmentName) { Attachment attachment; cachedAttachments.TryGetValue(asset, out attachment); if (attachment == null) { var skeletonData = skeletonDataAsset.GetSkeletonData(true); var templateSkin = skeletonData.FindSkin(templateSkinName); Attachment templateAttachment = templateSkin.GetAttachment(slotIndex, templateAttachmentName); attachment = templateAttachment.GetRemappedClone(asset.sprite, sourceMaterial, premultiplyAlpha: this.applyPMA); cachedAttachments.Add(asset, attachment); // Cache this value for next time this asset is used. } return(attachment); }