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 RESOURCE_DEFINE_CONSTRUCTOR(Skeleton);
15
16 Skeleton(int jointCount, Joint* headJoint) : m_jointCount(jointCount), m_headJoint(headJoint),
17 SResource("Skeleton") {
18 SetUndestroyable(true);
19 }
20
21 ~Skeleton() override {
22 Exterminate();
23 }
24
25 void SetJoint(int jointCount, Joint* headJoint) {
26 m_jointCount = jointCount;
27 m_headJoint = headJoint;
28 }
29
30
31 int getJointCount() const {
32 if (!isLoaded()) return -1;
33 return m_jointCount;
34 }
35
36 void setJointCount(int jointCount) {
37 Skeleton::m_jointCount = jointCount;
38 }
39
40 Joint* getHeadJoint() const {
41 if (!isLoaded()) return nullptr;
42 return m_headJoint;
43 }
44
45 void setHeadJoint(Joint* headJoint) {
46 Skeleton::m_headJoint = headJoint;
47 }
48
49 void Exterminate() override {
50 SAFE_DELETE(m_headJoint);
51 }
52
53 void SetValue(std::string name_str, Arguments value) override;
54
55 std::string PrintValue() const override;
56
57 protected:
58 void Init(const AssetMgr::AssetReference* asset) override {
59 return;
60 }
61
62 private:
63 bool isLoaded() const {
64 return m_jointCount > 0 && m_headJoint != nullptr;
65 }
66
67 private:
68 int m_jointCount;
69 Joint* m_headJoint = nullptr;
70 };
71
72}
void SetValue(std::string name_str, Arguments value) override
Definition Skeleton.cpp:7