// Copyright (c) 2012-2021 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Content/Content.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Content/AssetReference.h" #include "../Asset.h" /// /// Assets Container allows to load collection of assets and keep references to them. /// class AssetsContainer : public Array> { public: /// /// Loads an asset. /// /// The asset id. /// Loaded asset of null. template T* LoadAsync(const Guid& id) { for (auto& e : *this) { if (e.GetID() == id) return (T*)e.Get(); } auto asset = Content::LoadAsync(id); if (asset) { Add(asset); } return asset; } /// /// Release all referenced assets. /// void ReleaseAll() { Resize(0); } };