Port CInstanceBase::AddDamageEffect/ProcessDamage: damage packets queue per actor and show one digit-effect burst per update, dodge/block show the miss effect. Add CEffectManager::SetEffectTextures and CFlyingManager::CreateIndexedFly for the indexed fly types, and reset the damage target on GC_PHASE loading. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
69 lines
1.9 KiB
C++
69 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "EffectData.h"
|
|
#include "eter_render/RenderCommands3D.h"
|
|
#include <vector>
|
|
#include <memory>
|
|
#include <cstdint>
|
|
|
|
namespace ava2 {
|
|
|
|
struct ParticleState {
|
|
float pos[3] = {0.0f, 0.0f, 0.0f};
|
|
float last_pos[3] = {0.0f, 0.0f, 0.0f};
|
|
float vel[3] = {0.0f, 0.0f, 0.0f};
|
|
float life = 0.0f;
|
|
float max_life = 1.0f;
|
|
float rot = 0.0f;
|
|
float rot_speed = 0.0f;
|
|
float scale[2] = {1.0f, 1.0f};
|
|
float color[4] = {1.0f, 1.0f, 1.0f, 1.0f}; // RGBA [0..1]
|
|
uint8_t frame_index = 0;
|
|
};
|
|
|
|
struct EmitterInstance {
|
|
float local_time = 0.0f;
|
|
uint32_t emitted_count = 0;
|
|
float emission_accumulator = 0.0f;
|
|
std::vector<ParticleState> particles;
|
|
};
|
|
|
|
class EffectInstance {
|
|
public:
|
|
EffectInstance(std::shared_ptr<EffectData> data);
|
|
~EffectInstance();
|
|
|
|
void SetPosition(float x, float y, float z);
|
|
void SetRotation(float yaw, float pitch, float roll);
|
|
void SetGlobalMatrix(const float* mat16);
|
|
|
|
void Update(float dt);
|
|
void BuildDrawCommands(const float* viewMatrix, const float* projMatrix, const float* cameraPos, std::vector<Render3DDraw>& outDraws);
|
|
|
|
bool IsAlive() const { return m_isAlive; }
|
|
void Kill() { m_isAlive = false; }
|
|
std::shared_ptr<EffectData> GetData() const { return m_data; }
|
|
|
|
private:
|
|
std::shared_ptr<EffectData> m_data;
|
|
bool m_isAlive = true;
|
|
float m_age = 0.0f;
|
|
|
|
float m_position[3] = {0.0f, 0.0f, 0.0f};
|
|
float m_rotation[3] = {0.0f, 0.0f, 0.0f};
|
|
float m_matrix[16] = {
|
|
1.0f, 0.0f, 0.0f, 0.0f,
|
|
0.0f, 1.0f, 0.0f, 0.0f,
|
|
0.0f, 0.0f, 1.0f, 0.0f,
|
|
0.0f, 0.0f, 0.0f, 1.0f
|
|
};
|
|
bool m_hasCustomMatrix = false;
|
|
|
|
std::vector<EmitterInstance> m_emitters;
|
|
// CParticleSystemInstance m_kVct_pkImgInst: the texture list is taken when the instance is created,
|
|
// so CEffectManager::SetEffectTextures only affects instances created after it.
|
|
std::vector<std::vector<std::string>> m_textures;
|
|
};
|
|
|
|
} // namespace ava2
|