void Skin_attachAll (const Skin* self, Skeleton* skeleton, const Skin* oldSkin) { const _Entry *entry = SUB_CAST(_Internal, oldSkin) ->entries; while (entry) { Slot *slot = skeleton->slots[entry->slotIndex]; if (slot->attachment == entry->attachment) { Attachment *attachment = Skin_getAttachment(self, entry->slotIndex, entry->name); if (attachment) Slot_setAttachment(slot, attachment); } entry = entry->next; } }
int Skeleton_setAttachment (Skeleton* self, const char* slotName, const char* attachmentName) { int i; for (i = 0; i < self->slotCount; ++i) { Slot *slot = self->slots[i]; if (strcmp(slot->data->name, slotName) == 0) { Attachment* attachment = Skeleton_getAttachmentForSlotIndex(self, i, attachmentName); if (!attachment) return 0; Slot_setAttachment(slot, attachment); return 1; } } return 0; }
void Slot_setToSetupPose (Slot* self) { Attachment* attachment = 0; self->r = self->data->r; self->g = self->data->g; self->b = self->data->b; self->a = self->data->a; if (self->data->attachmentName) { /* Find slot index. */ int i; for (i = 0; i < self->skeleton->data->slotCount; ++i) { if (self->data == self->skeleton->data->slots[i]) { attachment = Skeleton_getAttachmentForSlotIndex(self->skeleton, i, self->data->attachmentName); break; } } } Slot_setAttachment(self, attachment); }