| 163 | } |
| 164 | |
| 165 | bool GameObjectBentLaser::Update(size_t id, int length, float width)LNOEXCEPT |
| 166 | { |
| 167 | GameObject* p = LPOOL.GetPooledObject(id); |
| 168 | if (!p) |
| 169 | return false; |
| 170 | if (length <= 1) |
| 171 | { |
| 172 | LERROR("lstgBentLaserData: ���IJ���length"); |
| 173 | return false; |
| 174 | } |
| 175 | |
| 176 | // �Ƴ�����Ľڵ㣬��֤������length��Χ�� |
| 177 | while (m_Queue.IsFull() || m_Queue.Size() >= (size_t)length) |
| 178 | { |
| 179 | LaserNode tLastPop; |
| 180 | m_Queue.Pop(tLastPop); |
| 181 | |
| 182 | // �����ܳ��� |
| 183 | if (!m_Queue.IsEmpty()) |
| 184 | { |
| 185 | LaserNode tFront = m_Queue.Front(); |
| 186 | m_fLength -= (tLastPop.pos - tFront.pos).Length(); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | // �����½ڵ� |
| 191 | if (m_Queue.Size() < (size_t)length) |
| 192 | { |
| 193 | LaserNode tNode; |
| 194 | tNode.pos.Set((float)p->x, (float)p->y); |
| 195 | tNode.half_width = width / 2.f; |
| 196 | m_Queue.Push(tNode); |
| 197 | |
| 198 | // �����ܳ��� |
| 199 | if (m_Queue.Size() > 1) |
| 200 | { |
| 201 | LaserNode& tNodeLast = m_Queue.Back(); |
| 202 | LaserNode& tNodeBeforeLast = m_Queue[m_Queue.Size() - 2]; |
| 203 | m_fLength += (tNodeBeforeLast.pos - tNodeLast.pos).Length(); |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | return true; |
| 208 | } |
| 209 | |
| 210 | void GameObjectBentLaser::Release()LNOEXCEPT |
| 211 | { |