/
Mr.Stalin
/
FOnline-Engine
Обзор
Документация
Войти
/
Mr.Stalin
/
FOnline-Engine
Код
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
Source/Client/ParticleSprites.h
111 строк
5 KB
cvet
Draw tuning (#191)
25 июл 2026, 00:16
Не верифицирован
25 июл 2026, 00:16
4c7b1ac
Код
Авторство
О чём код?
// __________ ___ ______ _ // / ____/ __ \____ / (_)___ ___ / ____/___ ____ _(_)___ ___ // / /_ / / / / __ \/ / / __ \/ _ \ / __/ / __ \/ __ `/ / __ \/ _ ` // / __/ / /_/ / / / / / / / / / __/ / /___/ / / / /_/ / / / / / __/ // /_/ \____/_/ /_/_/_/_/ /_/\___/ /_____/_/ /_/\__, /_/_/ /_/\___/ // /____/ // FOnline Engine // https://fonline.ru // https://github.com/cvet/fonline // // MIT License // // Copyright (c) 2006 - 2026, Anton Tsvetinskiy aka cvet <cvet@tut.by> // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. // #pragma once #include "Common.h" #include "DefaultSprites.h" #include "SpriteManager.h" FO_BEGIN_NAMESPACE class ParticleSpriteFactory; class ParticleSprite final : public AtlasSprite { public: explicit ParticleSprite(ptr<SpriteManager> spr_mngr, isize32 size, ipos32 offset, ptr<TextureAtlas> atlas, unique_del_ptr<TextureAtlasLayout::Allocation> atlas_allocation, frect32 atlas_rect, ptr<ParticleSpriteFactory> factory, unique_ptr<ParticleSystem>&& particle, bool draw_in_scene); ParticleSprite(const ParticleSprite&) = delete; ParticleSprite(ParticleSprite&&) noexcept = default; auto operator=(const ParticleSprite&) = delete; auto operator=(ParticleSprite&&) noexcept -> ParticleSprite& = delete; ~ParticleSprite() override = default; [[nodiscard]] auto IsHitTest(ipos32 pos) const -> bool override; [[nodiscard]] auto IsCopyable() const -> bool override { return false; } [[nodiscard]] auto IsDirectDraw() const -> bool override { return _drawInScene; } [[nodiscard]] auto GetParticle() -> ptr<ParticleSystem> { return _particle; } [[nodiscard]] auto IsPlaying() const -> bool override { return _particle->IsActive(); } auto PlayWithSeed(int32_t seed) -> bool; void SetDrawInScene(bool draw_in_scene); void Prewarm() override; void SetTime(float32_t normalized_time) override; void SetDir(mdir dir) override; void Play(hstring anim_name, bool looped, bool reversed) override; void Stop() override; auto Update() -> bool override; void DrawToAtlas(); void DrawInScene(fpos32 scene_pos, float32_t depth) const override; private: void ApplyAtlasSetup() const; ptr<ParticleSpriteFactory> _factory; bool _drawInScene {}; mutable bool _prewarmPending {}; float32_t _lookDirAngle {}; mutable unique_ptr<ParticleSystem> _particle; }; class ParticleSpriteFactory : public SpriteFactory { friend class ParticleSprite; public: ParticleSpriteFactory(ptr<SpriteManager> spr_mngr, ptr<RenderSettings> settings, ptr<EffectManager> effect_mngr, ptr<GameTimer> game_time, ptr<HashResolver> hash_resolver); ParticleSpriteFactory(const ParticleSpriteFactory&) = delete; ParticleSpriteFactory(ParticleSpriteFactory&&) noexcept = delete; auto operator=(const ParticleSpriteFactory&) = delete; auto operator=(ParticleSpriteFactory&&) noexcept -> ParticleSpriteFactory& = delete; ~ParticleSpriteFactory() override = default; [[nodiscard]] auto GetExtensions() const -> vector<string> override; auto LoadSprite(hstring path, AtlasType atlas_type) -> shared_ptr<Sprite> override; void RetryFailedLoads() override; void InvalidateResource(hstring path) override; private: auto LoadTexture(hstring path) -> pair<nptr<RenderTexture>, frect32>; void DrawParticleToAtlas(ptr<ParticleSprite> particle_spr); ptr<SpriteManager> _sprMngr; ptr<RenderSettings> _settings; ParticleManager _particleMngr; unordered_map<hstring, shared_ptr<AtlasSprite>> _loadedParticleTextures {}; vector<ptr<RenderTarget>> _rtIntermediate {}; }; FO_END_NAMESPACE