CSEngine
Loading...
Searching...
No Matches
SComponent.h
1#pragma once
2
3#include "../SObject.h"
4#include <string>
5#include <map>
6#include <utility>
7#include "../Object/SGameObject.h"
8#include "SISComponent.h"
9#include "../Util/ComponentDef.h"
10#include "../Util/VariableBinder.h"
11#include "../Manager/ReflectionMgr.h"
12#include "../Object/Base/ReflectionObject.h"
13
14
15namespace CSE {
16
17 class SGameObject;
18
19 class SComponent : public SObject, public virtual SISComponent, public VariableBinder, public ReflectionObject {
20 public:
21
22 explicit SComponent(std::string classType, SGameObject* gameObject) : ReflectionObject(std::move(classType)),
23 gameObject(gameObject) {
24 }
25
26 explicit SComponent(SGameObject* gameObject) : gameObject(gameObject) {
27 }
28
29 SComponent(const SComponent& src) : SISComponent(src) {
30 gameObject = src.gameObject;
31 isEnable = src.isEnable;
32 SetClassType(src.GetClassType());
33 }
34
35
36 ~SComponent() override = default;
37
38 void Start() override {}
39
40 virtual SComponent* Clone(SGameObject* object) {
41 return nullptr;
42 }
43
44 virtual void CopyReference(SComponent* src, std::map<SGameObject*, SGameObject*> lists_obj,
45 std::map<SComponent*, SComponent*> lists_comp) {}
46
47 virtual auto GetComponent() -> SObject* {
48 return this;
49 }
50
51 void SetValue(std::string name_str, Arguments value) override {}
52
53 std::string PrintValue() const override { return {}; }
54
55 void SetGameObject(SGameObject* object) {
56 gameObject = object;
57 }
58
59 virtual SGameObject* GetGameObject() const {
60 return gameObject;
61 }
62
63
64 virtual bool GetIsEnable() const {
65 return isEnable;
66 }
67
68
69 virtual void SetIsEnable(bool is_enable) {
70 isEnable = is_enable;
71 }
72
73 protected:
74 SGameObject* gameObject = nullptr;
75 bool isEnable = true;
76
77 };
78
79}
void SetValue(std::string name_str, Arguments value) override
Definition SComponent.h:51