(NDK) Added NodeComponent
Former-commit-id: 61b970c31a12a1b128e72c4754590528b6c1b4d6
This commit is contained in:
parent
46d125d205
commit
1bd45731cd
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#ifndef NDK_COMPONENTS_NODECOMPONENT_HPP
|
||||||
|
#define NDK_COMPONENTS_NODECOMPONENT_HPP
|
||||||
|
|
||||||
|
#include <Nazara/Utility/Node.hpp>
|
||||||
|
#include <NDK/Component.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
class Entity;
|
||||||
|
|
||||||
|
class NDK_API NodeComponent : public Component<NodeComponent>, public NzNode
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NodeComponent() = default;
|
||||||
|
~NodeComponent() = default;
|
||||||
|
|
||||||
|
void SetParent(Entity* entity, bool keepDerived = false);
|
||||||
|
|
||||||
|
static ComponentIndex componentIndex;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include <NDK/Components/NodeComponent.inl>
|
||||||
|
|
||||||
|
#endif // NDK_COMPONENTS_NODECOMPONENT_HPP
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <Nazara/Core/Error.hpp>
|
||||||
|
#include <NDK/Entity.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
inline void NodeComponent::SetParent(Entity* entity, bool keepDerived)
|
||||||
|
{
|
||||||
|
if (entity)
|
||||||
|
{
|
||||||
|
NazaraAssert(entity->HasComponent<NodeComponent>(), "Entity must have a NodeComponent");
|
||||||
|
|
||||||
|
NzNode::SetParent(entity->GetComponent<NodeComponent>(), keepDerived);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SetParent(nullptr, keepDerived);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
// Copyright (C) 2015 Jérôme Leclercq
|
||||||
|
// This file is part of the "Nazara Development Kit"
|
||||||
|
// For conditions of distribution and use, see copyright notice in Prerequesites.hpp
|
||||||
|
|
||||||
|
#include <NDK/Components/NodeComponent.hpp>
|
||||||
|
|
||||||
|
namespace Ndk
|
||||||
|
{
|
||||||
|
ComponentIndex NodeComponent::componentIndex = 0;
|
||||||
|
}
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include <Nazara/Utility/Utility.hpp>
|
#include <Nazara/Utility/Utility.hpp>
|
||||||
#include <NDK/Algorithm.hpp>
|
#include <NDK/Algorithm.hpp>
|
||||||
#include <NDK/BaseSystem.hpp>
|
#include <NDK/BaseSystem.hpp>
|
||||||
|
#include <NDK/Components/NodeComponent.hpp>
|
||||||
|
|
||||||
namespace Ndk
|
namespace Ndk
|
||||||
{
|
{
|
||||||
|
|
@ -44,6 +45,7 @@ namespace Ndk
|
||||||
BaseSystem::Initialize();
|
BaseSystem::Initialize();
|
||||||
|
|
||||||
// Composants
|
// Composants
|
||||||
|
InitializeComponent<NodeComponent>("NdkNode");
|
||||||
|
|
||||||
NazaraNotice("Initialized: SDK");
|
NazaraNotice("Initialized: SDK");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue