MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / UpdateTypeData

Method UpdateTypeData

src/Ext/Techno/Body.Update.cpp:491–912  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489}
490
491void TechnoExt::ExtData::UpdateTypeData(TechnoTypeClass* pCurrentType)
492{
493 auto const pThis = this->OwnerObject();
494 auto const pOldType = this->TypeExtData->OwnerObject();
495 auto const pOldTypeExt = TechnoTypeExt::ExtMap.Find(pOldType);
496 auto const pOwner = pThis->Owner;
497 auto& pSlaveManager = pThis->SlaveManager;
498 auto& pSpawnManager = pThis->SpawnManager;
499 auto& pCaptureManager = pThis->CaptureManager;
500 auto& pTemporalImUsing = pThis->TemporalImUsing;
501 auto& pAirstrike = pThis->Airstrike;
502
503 // Cache the new type data
504 this->PreviousType = pOldType;
505 this->TypeExtData = TechnoTypeExt::ExtMap.Find(pCurrentType);
506 auto const pNewTypeExt = this->TypeExtData;
507
508 this->UpdateSelfOwnedAttachEffects();
509
510 // Recreate Laser Trails
511 if (this->LaserTrails.size())
512 this->LaserTrails.clear();
513
514 for (auto const& entry : this->TypeExtData->LaserTrailData)
515 {
516 this->LaserTrails.emplace_back(entry.GetType(), pOwner, entry.FLH, entry.IsOnTurret);
517 }
518
519 // Reset AutoDeath Timer
520 if (this->AutoDeathTimer.HasStarted())
521 this->AutoDeathTimer.Stop();
522
523 // Reset PassengerDeletion Timer
524 if (this->PassengerDeletionTimer.IsTicking() && pNewTypeExt->PassengerDeletionType && pNewTypeExt->PassengerDeletionType->Rate <= 0)
525 this->PassengerDeletionTimer.Stop();
526
527 // Remove from tracked AutoDeath objects if no longer has AutoDeath
528 if (pOldTypeExt->AutoDeath_Behavior.isset() && !pNewTypeExt->AutoDeath_Behavior.isset())
529 {
530 auto& vec = ScenarioExt::Global()->AutoDeathObjects;
531 vec.erase(std::remove(vec.begin(), vec.end(), this), vec.end());
532 }
533
534 // Remove from harvesters list if no longer a harvester.
535 if (pOldTypeExt->Harvester_Counted)
536 {
537 if (!pNewTypeExt->Harvester_Counted)
538 {
539 auto& vec = HouseExt::ExtMap.Find(pOwner)->OwnedCountedHarvesters;
540 vec.erase(std::remove(vec.begin(), vec.end(), pThis), vec.end());
541 }
542 }
543 // Add to harvesters list if it's a harvester.
544 else if (pNewTypeExt->Harvester_Counted)
545 {
546 HouseExt::ExtMap.Find(pOwner)->OwnedCountedHarvesters.push_back(pThis);
547 }
548

Callers 2

OnEarlyUpdateMethod · 0.95
ConvertToTypeMethod · 0.80

Calls 13

issetMethod · 0.80
eraseMethod · 0.80
ReceiveDamageMethod · 0.80
FreeUnitMethod · 0.80
FindMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45
GetTypeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
RemoveMethod · 0.45

Tested by

no test coverage detected