| 66 | } |
| 67 | |
| 68 | bool CaptureManagerExt::CaptureUnit(CaptureManagerClass* pManager, TechnoClass* pTarget, |
| 69 | bool bRemoveFirst, AnimTypeClass* pControlledAnimType, bool silent) |
| 70 | { |
| 71 | if (CaptureManagerExt::CanCapture(pManager, pTarget)) |
| 72 | { |
| 73 | if (pManager->MaxControlNodes <= 0) |
| 74 | return false; |
| 75 | |
| 76 | if (!pManager->InfiniteMindControl) |
| 77 | { |
| 78 | if (pManager->MaxControlNodes == 1 && pManager->ControlNodes.Count == 1) |
| 79 | CaptureManagerExt::FreeUnit(pManager, pManager->ControlNodes[0]->Unit); |
| 80 | else if (pManager->ControlNodes.Count == pManager->MaxControlNodes) |
| 81 | if (bRemoveFirst) |
| 82 | CaptureManagerExt::FreeUnit(pManager, pManager->ControlNodes[0]->Unit); |
| 83 | } |
| 84 | |
| 85 | auto pControlNode = GameCreate<ControlNode>(); |
| 86 | if (pControlNode) |
| 87 | { |
| 88 | pControlNode->OriginalOwner = pTarget->Owner; |
| 89 | pControlNode->Unit = pTarget; |
| 90 | |
| 91 | pManager->ControlNodes.AddItem(pControlNode); |
| 92 | pControlNode->LinkDrawTimer.Start(RulesClass::Instance->MindControlAttackLineFrames); |
| 93 | |
| 94 | if (pTarget->SetOwningHouse(pManager->Owner->Owner, !silent)) |
| 95 | { |
| 96 | pTarget->MindControlledBy = pManager->Owner; |
| 97 | |
| 98 | pManager->DecideUnitFate(pTarget); |
| 99 | |
| 100 | auto const pBld = abstract_cast<BuildingClass*>(pTarget); |
| 101 | auto const pType = pTarget->GetTechnoType(); |
| 102 | CoordStruct location = pTarget->GetCoords(); |
| 103 | |
| 104 | if (pBld) |
| 105 | location.Z += pBld->Type->Height * Unsorted::LevelHeight; |
| 106 | else |
| 107 | location.Z += pType->MindControlRingOffset; |
| 108 | |
| 109 | if (auto const pAnimType = pControlledAnimType) |
| 110 | { |
| 111 | auto const pAnim = GameCreate<AnimClass>(pAnimType, location); |
| 112 | |
| 113 | pTarget->MindControlRingAnim = pAnim; |
| 114 | pAnim->SetOwnerObject(pTarget); |
| 115 | |
| 116 | if (pBld) |
| 117 | pAnim->ZAdjust = -1024; |
| 118 | |
| 119 | } |
| 120 | |
| 121 | return true; |
| 122 | } |
| 123 | |
| 124 | } |
| 125 | } |
nothing calls this directly
no test coverage detected