| 14 | } |
| 15 | |
| 16 | void CEffectManager::AddEffect(CGameEffect *effect) |
| 17 | { |
| 18 | switch (effect->EffectType) |
| 19 | { |
| 20 | case EF_MOVING: |
| 21 | case EF_STAY_AT_POS: |
| 22 | case EF_DRAG: |
| 23 | { |
| 24 | if (effect->EffectType == EF_MOVING) |
| 25 | { |
| 26 | CGameObject *obj = g_World->FindWorldObject(effect->DestSerial); |
| 27 | if (obj != nullptr) |
| 28 | { |
| 29 | obj = obj->GetTopObject(); |
| 30 | |
| 31 | if (obj != nullptr) |
| 32 | { |
| 33 | effect->DestX = obj->GetX(); |
| 34 | effect->DestY = obj->GetY(); |
| 35 | effect->DestZ = obj->GetZ(); |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | CGameEffectMoving *moving = (CGameEffectMoving *)effect; |
| 40 | |
| 41 | if (moving->GetX() == moving->DestX && moving->GetY() == moving->DestY && |
| 42 | moving->GetZ() == moving->DestZ) |
| 43 | { |
| 44 | if (moving->Explode) |
| 45 | { |
| 46 | EFFECT_TYPE type = EF_STAY_AT_POS; |
| 47 | |
| 48 | if (obj != nullptr) |
| 49 | { |
| 50 | type = EF_STAY_AT_SOURCE; |
| 51 | } |
| 52 | |
| 53 | CreateExplodeEffect(moving, type); |
| 54 | } |
| 55 | |
| 56 | delete effect; |
| 57 | |
| 58 | return; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | if (effect->EffectType != EF_STAY_AT_POS) |
| 63 | { |
| 64 | CGameEffectDrag *effectDrag = (CGameEffectDrag *)effect; |
| 65 | effectDrag->OffsetX = 0; |
| 66 | effectDrag->OffsetY = 0; |
| 67 | } |
| 68 | |
| 69 | Add(effect); |
| 70 | |
| 71 | g_MapManager.AddRender(effect); |
| 72 | |
| 73 | effect->Update(nullptr); |
no test coverage detected