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

Method ProcessDestroyAnims

src/Ext/AnimType/Body.cpp:15–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13AnimTypeExt::ExtContainer AnimTypeExt::ExtMap;
14
15void AnimTypeExt::ProcessDestroyAnims(UnitClass* pThis, HouseClass* pKiller)
16{
17 if (!pThis)
18 return;
19
20 auto const pType = pThis->Type;
21
22 if (pType->DestroyAnim.Count > 0)
23 {
24 auto const facing = pThis->PrimaryFacing.Current().GetDir();
25 AnimTypeClass* pAnimType = nullptr;
26 auto const pTypeExt = TechnoTypeExt::ExtMap.Find(pType);
27
28 if (!pTypeExt->DestroyAnim_Random.Get())
29 {
30 int idxAnim = 0;
31
32 if (pType->DestroyAnim.Count >= 8)
33 {
34 idxAnim = pType->DestroyAnim.Count - 1;
35 if (pType->DestroyAnim.Count % 2 == 0)
36 idxAnim = static_cast<int>(static_cast<unsigned char>(facing) / 256.0 * idxAnim);
37 }
38
39 pAnimType = pType->DestroyAnim[idxAnim];
40 }
41 else
42 {
43 int const nIDx_Rand = pType->DestroyAnim.Count == 1 ?
44 0 : ScenarioClass::Instance->Random.RandomRanged(0, (pType->DestroyAnim.Count - 1));
45 pAnimType = pType->DestroyAnim[nIDx_Rand];
46
47 }
48
49 if (pAnimType)
50 {
51 auto const pAnim = GameCreate<AnimClass>(pAnimType, pThis->Location);
52
53 //auto VictimOwner = pThis->IsMindControlled() && pThis->GetOriginalOwner()
54 // ? pThis->GetOriginalOwner() : pThis->Owner;
55
56 auto const pAnimTypeExt = AnimTypeExt::ExtMap.Find(pAnim->Type);
57 auto const pAnimExt = AnimExt::ExtMap.Find(pAnim);
58
59 AnimExt::SetAnimOwnerHouseKind(pAnim, pKiller, pThis->Owner);
60
61 pAnimExt->SetInvoker(pThis);
62 pAnimExt->FromDeathUnit = true;
63
64 if (pAnimTypeExt->CreateUnit_InheritDeathFacings.Get())
65 pAnimExt->DeathUnitFacing = facing;
66
67 if (pAnimTypeExt->CreateUnit_InheritTurretFacings.Get())
68 {
69 if (pThis->HasTurret())
70 {
71 pAnimExt->DeathUnitHasTurret = true;
72 pAnimExt->DeathUnitTurretFacing = pThis->SecondaryFacing.Current();

Callers

nothing calls this directly

Calls 3

SetInvokerMethod · 0.80
FindMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected