-
Notifications
You must be signed in to change notification settings - Fork 46
/
TargetableNode.h
74 lines (55 loc) · 2.2 KB
/
TargetableNode.h
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once
#include "selectionlib.h"
#include "scene/Node.h"
#include "scene/Entity.h"
#include "TargetKeyCollection.h"
#include "RenderableTargetLines.h"
class EntityNode;
class TargetLineNode;
typedef std::shared_ptr<TargetLineNode> TargetLineNodePtr;
/**
* greebo: Each targetable entity (D3Group, Speaker, Lights, etc.) derives from
* this class.
*
* This registers itself with the contained SpawnArgs and observes its keys.
* As soon as "name" keys are encountered, the TargetManager is notified about
* the change, so that the name can be associated with a Target object.
*/
class TargetableNode :
public Entity::Observer,
public KeyObserver
{
Entity& _d3entity;
TargetKeyCollection _targetKeys;
// The current name of this entity (used for comparison in "onKeyValueChanged")
std::string _targetName;
// The node we're associated with
EntityNode& _node;
// The targetmanager of the map we're in (is nullptr if not in the scene)
ITargetManager* _targetManager;
// The actual scene representation rendering the lines
TargetLineNodePtr _targetLineNode;
public:
TargetableNode(Entity& entity, EntityNode& node);
// This might return nullptr if the node is not inserted in a scene
ITargetManager* getTargetManager();
// Connect this class with the SpawnArgs
void construct();
// Disconnect this class from the entity
void destruct();
TargetKeyCollection& getTargetKeys();
// Gets called as soon as the "name" keyvalue changes
void onKeyValueChanged(const std::string& name) override;
// Entity::Observer implementation, gets called on key insert
void onKeyInsert(const std::string& key, EntityKeyValue& value) override;
void onKeyErase(const std::string& key, EntityKeyValue& value) override;
void onKeyChange(const std::string& key, const std::string& value) override;
// scene insert/remove handling
void onInsertIntoScene(scene::IMapRootNode& root);
void onRemoveFromScene(scene::IMapRootNode& root);
void onVisibilityChanged(bool isVisibleNow);
// Invoked by the TargetKeyCollection when the number of observed has changed
void onTargetKeyCollectionChanged();
void onTransformationChanged();
void onRenderSystemChanged();
};