Updated demos to use DALi clang-format
[platform/core/uifw/dali-demo.git] / examples / fpp-game / game-entity.cpp
1 /*
2  * Copyright (c) 2020 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include "game-entity.h"
19 #include "game-renderer.h"
20
21 GameEntity::GameEntity(const char* name)
22 {
23   mActor = Dali::Actor::New();
24   mActor.SetProperty(Dali::Actor::Property::NAME, name);
25 }
26
27 GameEntity::~GameEntity()
28 {
29 }
30
31 void GameEntity::UpdateRenderer()
32 {
33   if(mActor.GetRendererCount())
34   {
35     Dali::Renderer currentRenderer = mActor.GetRendererAt(0);
36     if(currentRenderer == mGameRenderer.GetRenderer())
37     {
38       return;
39     }
40     mActor.RemoveRenderer(currentRenderer);
41   }
42   if(mGameRenderer.GetRenderer())
43   {
44     mActor.AddRenderer(mGameRenderer.GetRenderer());
45   }
46 }
47
48 GameRenderer& GameEntity::GetGameRenderer()
49 {
50   return mGameRenderer;
51 }
52
53 Dali::Actor& GameEntity::GetActor()
54 {
55   return mActor;
56 }
57
58 void GameEntity::SetLocation(const Dali::Vector3& loc)
59 {
60   mActor.SetProperty(Dali::Actor::Property::POSITION, loc);
61 }
62
63 void GameEntity::SetRotation(const Dali::Quaternion& rot)
64 {
65   mActor.SetProperty(Dali::Actor::Property::ORIENTATION, rot);
66 }
67
68 void GameEntity::SetScale(const Dali::Vector3& scale)
69 {
70   mActor.SetProperty(Dali::Actor::Property::SCALE, scale);
71 }
72
73 void GameEntity::SetSize(const Dali::Vector3& size)
74 {
75   mActor.SetProperty(Dali::Actor::Property::SIZE, size);
76 }