#pragma once
#include "Entity.h"
//颗粒实体：光尾
class PeLightTail :
    public Entity
{
public:
    PeLightTail(std::weak_ptr<Entity> target, int section = 20, float tail_width = 2);
    void SetColor(UINT8 r, UINT8 g, UINT8 b);
    void SetAlphaDiv(float alphaDiv);
    void SetLeaveTimer(int disappearTime);
    void SetLeaveFunc(bool (*LeaveFunc)(std::weak_ptr<Entity>));
    void SetAllAlpha(float alpha);
    void Leave();
    void Step() override;
    void DeltaTime(float deltaTime) override;//绘制更新
private:
    //拖尾的头移动到一个新位置
    void HeadMoveNewPos(XMVECTOR pos);
    //计算每个点的坐标
    void CalcPos();
    std::weak_ptr<Entity> target;
    int section;//分段数量
    std::list<XMVECTOR> track;//目标移动轨迹
    std::vector<XMVECTOR> tempTrack;//vector化
    std::list<XMVECTOR> trackVec;//每个点的向量
    std::vector<XMVECTOR> tempTrackVec;//vector化
    std::list<XMVECTOR> trackVecAverage;//每个点的平均向量
    std::list<XMVECTOR> verticalVec;//每个点的垂直向量
    std::vector<XMVECTOR> tempVerticalVec;//vector化
    std::vector<XMVECTOR> track_finally;//轨道
    float tail_width;//尾巴宽度
    UINT8 r, g, b;//颜色
    float alphaDiv = 8.0f;
    float allAlpha = 1.0f;
    int triNum;//三角形数量
    bool readyDestory = false;
    int readyDestory_counter;
    int disappear_time_counter = -1;//消失计时器
    XMVECTOR tailLastPos;
    //其他
    bool (*LeaveFunc)(std::weak_ptr<Entity> e) = nullptr;
    int leaveStateID = 0;
    std::vector<PenVertex> fillList_set;
    std::vector<PenVertex> fillList_set_last;
};

