| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- #pragma once
- #include "../Scene/Component.h"
- namespace Atomic
- {
- /// Helper base class for user-defined game logic components that hooks up to update events and forwards them to virtual functions similar to ScriptInstance class.
- class PrefabComponent : public Component
- {
- OBJECT(PrefabComponent);
- public:
- /// Construct.
- PrefabComponent(Context* context);
- /// Destruct.
- virtual ~PrefabComponent();
- /// Register object factory.
- static void RegisterObject(Context* context);
- void SetPrefabGUID(const String& guid);
- const String& GetPrefabGUID() const { return prefabGUID_; }
- bool SavePrefab();
- void UndoPrefab();
- void BreakPrefab();
- Node* GetPrefabNode() { return prefabNode_; }
- protected:
- /// Handle scene node being assigned at creation.
- virtual void OnNodeSet(Node* node);
- private:
- void HandlePrefabChanged(StringHash eventType, VariantMap& eventData);
- void LoadPrefabNode();
- SharedPtr<Node> prefabNode_;
- String prefabGUID_;
- };
- }
|