CSEngine
Loading...
Searching...
No Matches
Skeleton.h
1//
2// Created by ounols on 19. 1. 20.
3//
4
5#pragma once
6
7#include "../../Manager/ResMgr.h"
8#include "Joint.h"
9
10namespace CSE {
11
12 class Skeleton : public SResource {
13 public:
14 Skeleton() {
15 SetUndestroyable(true);
16 }
17
18 Skeleton(int jointCount, Joint* headJoint) : m_jointCount(jointCount), m_headJoint(headJoint) {
19 SetUndestroyable(true);
20
21 }
22
23 ~Skeleton() override {
24 Exterminate();
25 }
26
27 void SetJoint(int jointCount, Joint* headJoint) {
28 m_jointCount = jointCount;
29 m_headJoint = headJoint;
30 }
31
32
33 int getJointCount() const {
34 if (!isLoaded()) return -1;
35 return m_jointCount;
36 }
37
38 void setJointCount(int jointCount) {
39 Skeleton::m_jointCount = jointCount;
40 }
41
42 Joint* getHeadJoint() const {
43 if (!isLoaded()) return nullptr;
44 return m_headJoint;
45 }
46
47 void setHeadJoint(Joint* headJoint) {
48 Skeleton::m_headJoint = headJoint;
49 }
50
51 void Exterminate() override {
52 SAFE_DELETE(m_headJoint);
53 }
54
55 protected:
56 void Init(const AssetMgr::AssetReference* asset) override {
57 return;
58 }
59
60 private:
61 bool isLoaded() const {
62 return m_jointCount > 0 && m_headJoint != nullptr;
63 }
64
65 private:
66 int m_jointCount;
67 Joint* m_headJoint = nullptr;
68 };
69
70}