diff --git a/Dependencies/IACore b/Dependencies/IACore index ada777c..8e2e118 160000 --- a/Dependencies/IACore +++ b/Dependencies/IACore @@ -1 +1 @@ -Subproject commit ada777c758d322389f9dbc7457ed774f62360ec3 +Subproject commit 8e2e118dd51b56786a9ae0dda33a7e3ec208ce24 diff --git a/Src/IAEngine/imp/cpp/Components/Collider.cpp b/Src/IAEngine/imp/cpp/Components/Collider.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Src/IAEngine/imp/cpp/Components/ParticleRenderer.cpp b/Src/IAEngine/imp/cpp/Components/ParticleRenderer.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Src/IAEngine/imp/cpp/Components/SpriteRenderer.cpp b/Src/IAEngine/imp/cpp/Components/SpriteRenderer.cpp index b047e99..a8a1902 100644 --- a/Src/IAEngine/imp/cpp/Components/SpriteRenderer.cpp +++ b/Src/IAEngine/imp/cpp/Components/SpriteRenderer.cpp @@ -12,12 +12,6 @@ namespace ia::iae { } - Handle SpriteRendererComponent::AddTexture(IN RefPtr texture) - { - m_textures.pushBack(texture); - return m_textures.size() - 1; - } - Handle SpriteRendererComponent::AddAnimation(IN CONST Animation &animation) { IA_RELEASE_ASSERT(!animation.Keys.empty()); @@ -25,26 +19,6 @@ namespace ia::iae return m_animations.size() - 1; } - Handle SpriteRendererComponent::AddAnimation(IN initializer_list frames, IN INT32 frameDuration, - IN BOOL shouldLoop) - { - Animation anim; - anim.ShouldLoop = shouldLoop; - for (const auto &idx : frames) - anim.Keys.pushBack(AnimationKeyFrame{.Duration = frameDuration, .TextureHandle = idx}); - return AddAnimation(anim); - } - - Handle SpriteRendererComponent::AddAnimation(IN INT32 startFrame, IN INT32 endFrame, IN INT32 frameDuration, - IN BOOL shouldLoop) - { - Animation anim; - anim.ShouldLoop = shouldLoop; - for (INT32 i = startFrame; i < endFrame; i++) - anim.Keys.pushBack(AnimationKeyFrame{.Duration = frameDuration, .TextureHandle = i}); - return AddAnimation(anim); - } - VOID SpriteRendererComponent::BakeAnimations() { for (auto &anim : m_animations) @@ -55,14 +29,6 @@ namespace ia::iae } if (m_animations.size()) SetActiveAnimation(0); - else - SetActiveTexture(0); - } - - VOID SpriteRendererComponent::SetActiveTexture(IN Handle texture) - { - IA_RELEASE_ASSERT((texture != INVALID_HANDLE) && (texture < m_textures.size())); - m_currentAnimationState.TextureHandle = texture; } VOID SpriteRendererComponent::SetActiveAnimation(IN Handle animation) @@ -85,9 +51,7 @@ namespace ia::iae VOID SpriteRendererComponent::Draw() { const auto &animFrame = m_currentAnimationState; - if (animFrame.TextureHandle == INVALID_HANDLE) - return; - m_textures[animFrame.TextureHandle]->Draw( + animFrame.Texture->Draw( m_node->GetPosition() + animFrame.Position, m_node->GetScale() * animFrame.Scale, m_node->GetRotation().Z + animFrame.Rotation.Z, m_isFlippedH, m_isFlippedV, animFrame.ColorOverlay); } diff --git a/Src/IAEngine/imp/cpp/Components/StackedCollider.cpp b/Src/IAEngine/imp/cpp/Components/StackedCollider.cpp new file mode 100644 index 0000000..e69de29 diff --git a/Src/IAEngine/imp/cpp/IAEngine.cpp b/Src/IAEngine/imp/cpp/IAEngine.cpp index cd6e3bd..8fa1cdd 100644 --- a/Src/IAEngine/imp/cpp/IAEngine.cpp +++ b/Src/IAEngine/imp/cpp/IAEngine.cpp @@ -1,7 +1,7 @@ #include #include -#include #include +#include #include #include diff --git a/Src/IAEngine/inc/IAEngine/Components/Collider.hpp b/Src/IAEngine/inc/IAEngine/Components/Collider.hpp new file mode 100644 index 0000000..e69de29 diff --git a/Src/IAEngine/inc/IAEngine/Components/ParticleRenderer.hpp b/Src/IAEngine/inc/IAEngine/Components/ParticleRenderer.hpp new file mode 100644 index 0000000..e69de29 diff --git a/Src/IAEngine/inc/IAEngine/Components/SpriteRenderer.hpp b/Src/IAEngine/inc/IAEngine/Components/SpriteRenderer.hpp index 2db0026..35b4e84 100644 --- a/Src/IAEngine/inc/IAEngine/Components/SpriteRenderer.hpp +++ b/Src/IAEngine/inc/IAEngine/Components/SpriteRenderer.hpp @@ -32,7 +32,7 @@ namespace ia::iae iam::Vec3f Scale{1.0f, 1.0f, 1.0f}; iam::Vec4f ColorOverlay{1.0f, 1.0f, 1.0f, 1.0f}; BOOL ShouldInterpolate{}; - INT32 TextureHandle{INVALID_HANDLE}; + RefPtr Texture; }; struct Animation @@ -44,14 +44,10 @@ namespace ia::iae public: SpriteRendererComponent(IN Node *node); - Handle AddTexture(IN RefPtr texture); Handle AddAnimation(IN CONST Animation &animation); - Handle AddAnimation(IN initializer_list frames, IN INT32 frameDuration, IN BOOL shouldLoop); - Handle AddAnimation(IN INT32 startFrame, IN INT32 endFrame, IN INT32 frameDuration, IN BOOL shouldLoop); VOID BakeAnimations(); - VOID SetActiveTexture(IN Handle texture); VOID SetActiveAnimation(IN Handle animation); public: @@ -68,7 +64,6 @@ namespace ia::iae Animation m_activeAnimation{}; Handle m_activeAnimationHandle{INVALID_HANDLE}; Vector m_animations; - Vector> m_textures; AnimationKeyFrame m_currentAnimationState{}; AnimationKeyFrame m_nextAnimationKeyFrame{}; AnimationKeyFrame m_prevAnimationKeyFrame{}; diff --git a/Src/IAEngine/inc/IAEngine/Components/StackedCollider.hpp b/Src/IAEngine/inc/IAEngine/Components/StackedCollider.hpp new file mode 100644 index 0000000..e69de29 diff --git a/Src/IAEngine/inc/IAEngine/IAEngine.hpp b/Src/IAEngine/inc/IAEngine/IAEngine.hpp index 3a05752..ca37e96 100644 --- a/Src/IAEngine/inc/IAEngine/IAEngine.hpp +++ b/Src/IAEngine/inc/IAEngine/IAEngine.hpp @@ -19,6 +19,7 @@ #include #include #include +#include namespace ia::iae { @@ -45,6 +46,9 @@ namespace ia::iae VOID EndFrame(); BOOL ShouldClose(); + template + _class_type* RegisterResourceManager(); + public: RefPtr CreateScene(); @@ -63,5 +67,13 @@ namespace ia::iae FLOAT32 m_updateTimer{}; RefPtr m_activeScene{}; CONST RefPtr m_context; + RefPtr m_resourceManager; }; + + template + _class_type* Engine::RegisterResourceManager() + { + m_resourceManager = MakeRefPtr<_class_type>(this); + return (_class_type*)m_resourceManager.get(); + } } // namespace ia::iae \ No newline at end of file diff --git a/Src/IAEngine/inc/IAEngine/ResourceManager.hpp b/Src/IAEngine/inc/IAEngine/ResourceManager.hpp index 2e911c2..53cdf51 100644 --- a/Src/IAEngine/inc/IAEngine/ResourceManager.hpp +++ b/Src/IAEngine/inc/IAEngine/ResourceManager.hpp @@ -44,9 +44,7 @@ namespace ia::iae protected: Engine *CONST m_engine; - private: ResourceManager(IN Engine *engine); - friend class Engine; }; } // namespace ia::iae \ No newline at end of file