Basic mutability framework
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "MinimalEngine.h"
|
||||
#include "Math/Transform.h"
|
||||
#include "Scene/Util.h"
|
||||
#include "ThreadPool.h"
|
||||
|
||||
namespace Seele
|
||||
{
|
||||
@@ -12,11 +14,18 @@ class Component
|
||||
public:
|
||||
Component();
|
||||
virtual ~Component();
|
||||
void tick(float deltaTime);
|
||||
void launchStart();
|
||||
virtual void start() {};
|
||||
Array<Job> launchTick(float deltaTime) const;
|
||||
virtual Job tick(float deltaTime) const { co_return; }
|
||||
Array<Job> launchUpdate();
|
||||
virtual Job update() { co_return; }
|
||||
PComponent getParent();
|
||||
PActor getOwner();
|
||||
const Array<PComponent>& getChildComponents();
|
||||
void setParent(PComponent parent);
|
||||
void setOwner(PActor owner);
|
||||
void addChildComponent(PComponent component);
|
||||
virtual void notifySceneAttach(PScene scene);
|
||||
|
||||
void setWorldLocation(Vector location);
|
||||
@@ -35,7 +44,30 @@ public:
|
||||
|
||||
Transform getTransform() const;
|
||||
|
||||
template<typename ComponentType>
|
||||
RefPtr<ComponentType> getComponent()
|
||||
{
|
||||
return tryFindComponent<ComponentType>();
|
||||
}
|
||||
private:
|
||||
template<typename ComponentType>
|
||||
RefPtr<ComponentType> tryFindComponent()
|
||||
{
|
||||
for(auto child : children)
|
||||
{
|
||||
RefPtr<ComponentType> result = child.cast<ComponentType>();
|
||||
if(result != nullptr)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
result = parent->tryFindComponent<ComponentType>();
|
||||
if(result != nullptr)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
void internalSetTransform(Vector newLocation, Quaternion newRotation);
|
||||
void propagateTransformUpdate();
|
||||
void updateComponentTransform(Quaternion relativeRotationQuat);
|
||||
|
||||
Reference in New Issue
Block a user