forked from gameprogcpp/code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComponent.cpp
More file actions
58 lines (50 loc) · 1.29 KB
/
Component.cpp
File metadata and controls
58 lines (50 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// ----------------------------------------------------------------
// From Game Programming in C++ by Sanjay Madhav
// Copyright (C) 2017 Sanjay Madhav. All rights reserved.
//
// Released under the BSD License
// See LICENSE in root directory for full details.
// ----------------------------------------------------------------
#include "Component.h"
#include "Actor.h"
#include "LevelLoader.h"
const char* Component::TypeNames[NUM_COMPONENT_TYPES] = {
"Component",
"AudioComponent",
"BallMove",
"BoxComponent",
"CameraComponent",
"FollowCamera",
"MeshComponent",
"MoveComponent",
"SkeletalMeshComponent",
"SpriteComponent",
"MirrorCamera",
"PointLightComponent",
"TargetComponent"
};
Component::Component(Actor* owner, int updateOrder)
:mOwner(owner)
,mUpdateOrder(updateOrder)
{
// Add to actor's vector of components
mOwner->AddComponent(this);
}
Component::~Component()
{
mOwner->RemoveComponent(this);
}
void Component::Update(float deltaTime)
{
}
void Component::OnUpdateWorldTransform()
{
}
void Component::LoadProperties(const rapidjson::Value& inObj)
{
JsonHelper::GetInt(inObj, "updateOrder", mUpdateOrder);
}
void Component::SaveProperties(rapidjson::Document::AllocatorType& alloc, rapidjson::Value& inObj) const
{
JsonHelper::AddInt(alloc, inObj, "updateOrder", mUpdateOrder);
}