File: TargetKey.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (58 lines) | stat: -rw-r--r-- 1,436 bytes parent folder | download | duplicates (3)
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
#pragma once

#include "ientity.h"
#include <sigc++/connection.h>

#include "Target.h"

namespace entity
{

class TargetKeyCollection;

/**
 * greebo: A TargetKey represents a "targetN" key of a given entity.
 * It acts as Observer for this key and maintains a reference to
 * the named Target.
 *
 * Note: An Entity can have multiple "targetN" keys, hence it can hold
 * multiple instances of this TargetKey class. They are stored in and
 * maintainted by the TargetKeyCollection container.
 *
 * Note: Each TargetKey instance can only refer to one Target.
 */
class TargetKey :
	public KeyObserver
{
private:
    TargetKeyCollection& _owner;

    std::string _curValue;

	// The target this key is pointing to (can be empty)
	TargetPtr _target;

    sigc::connection _positionChangedSignal;
public:
    TargetKey(TargetKeyCollection& owner);

	// Accessor method for the contained TargetPtr
    const TargetPtr& getTarget() const;

    // Called when the owning TargetableNode is inserted into or removed from the scene
    void onTargetManagerChanged();

	// Observes the given keyvalue
	void attachToKeyValue(EntityKeyValue& value);

	// Stops observing the given keyvalue
	void detachFromKeyValue(EntityKeyValue& value);

	// This gets called as soon as the "target" key in the spawnargs changes
	void onKeyValueChanged(const std::string& newValue) override;

private:
    void onTargetPositionChanged();
};

} // namespace entity