Changed Pre/Post(Un)Morph to take the other actor and a boolean indicating direction.

- 'current' is true for the actor that is the new body, false for the old body.
This commit is contained in:
Major Cooke 2020-03-08 09:19:20 -05:00 committed by Christoph Oelckers
parent 33b343ef31
commit 70f9b649aa
2 changed files with 23 additions and 23 deletions

View file

@ -28,12 +28,11 @@ extend class Actor
return null, 0, 0; return null, 0, 0;
} }
// [MC] Called when an actor morphs, on both the previous form (passive) and present form (!passive). // [MC] Called when an actor morphs, on both the previous form (!current) and present form (current).
// 'cls' points to the other class they transitioned from/to. virtual void PreMorph(Actor mo, bool current) {}
virtual void PreMorph(Class<Actor> cls) {} virtual void PostMorph(Actor mo, bool current) {}
virtual void PostMorph(Class<Actor> cls) {} virtual void PreUnmorph(Actor mo, bool current) {}
virtual void PreUnmorph(Class<Actor> cls) {} virtual void PostUnmorph(Actor mo, bool current) {}
virtual void PostUnmorph(Class<Actor> cls) {}
//=========================================================================== //===========================================================================
// //
@ -112,9 +111,9 @@ extend class Actor
let morphed = MorphedMonster(Spawn (spawntype, Pos, NO_REPLACE)); let morphed = MorphedMonster(Spawn (spawntype, Pos, NO_REPLACE));
// Use GetClass in the event someone actually allows replacements. // [MC] Notify that we're just about to start the transfer.
PreMorph(morphed.GetClass()); PreMorph(morphed, false); // False: No longer the current.
morphed.PreMorph(GetClass()); morphed.PreMorph(self, true); // True: Becoming this actor.
Substitute (morphed); Substitute (morphed);
if ((style & MRF_TRANSFERTRANSLATION) && !morphed.bDontTranslate) if ((style & MRF_TRANSFERTRANSLATION) && !morphed.bDontTranslate)
@ -151,8 +150,8 @@ extend class Actor
let eflash = Spawn(enter_flash ? enter_flash : (class<Actor>)("TeleportFog"), Pos + (0, 0, gameinfo.TELEFOGHEIGHT), ALLOW_REPLACE); let eflash = Spawn(enter_flash ? enter_flash : (class<Actor>)("TeleportFog"), Pos + (0, 0, gameinfo.TELEFOGHEIGHT), ALLOW_REPLACE);
if (eflash) if (eflash)
eflash.target = morphed; eflash.target = morphed;
PostMorph(morphed.GetClass()); PostMorph(morphed, false);
morphed.PostMorph(GetClass()); morphed.PostMorph(self, true);
return true; return true;
} }
} }

View file

@ -140,8 +140,8 @@ extend class PlayerPawn
let morphed = PlayerPawn(Spawn (spawntype, Pos, NO_REPLACE)); let morphed = PlayerPawn(Spawn (spawntype, Pos, NO_REPLACE));
// Use GetClass in the event someone actually allows replacements. // Use GetClass in the event someone actually allows replacements.
PreMorph(morphed.GetClass()); PreMorph(morphed, false);
morphed.PreMorph(GetClass()); morphed.PreMorph(self, true);
EndAllPowerupEffects(); EndAllPowerupEffects();
Substitute(morphed); Substitute(morphed);
@ -216,8 +216,8 @@ extend class PlayerPawn
morphed.ScoreIcon = ScoreIcon; // [GRB] morphed.ScoreIcon = ScoreIcon; // [GRB]
if (eflash) if (eflash)
eflash.target = morphed; eflash.target = morphed;
PostMorph(morphed.GetClass()); PostMorph(morphed, false); // No longer the current body
morphed.PostMorph(GetClass()); morphed.PostMorph(self, true); // This is the current body
return true; return true;
} }
@ -256,8 +256,9 @@ extend class PlayerPawn
player.morphTics = 2*TICRATE; player.morphTics = 2*TICRATE;
return false; return false;
} }
PreUnmorph(altmo.GetClass());
altmo.PreUnmorph(GetClass()); PreUnmorph(altmo, false); // This body's about to be left.
altmo.PreUnmorph(self, true); // This one's about to become current.
// No longer using tracer as morph storage. That is what 'alternative' is for. // No longer using tracer as morph storage. That is what 'alternative' is for.
// If the tracer has changed on the morph, change the original too. // If the tracer has changed on the morph, change the original too.
@ -405,8 +406,8 @@ extend class PlayerPawn
beastweap.Destroy (); beastweap.Destroy ();
} }
} }
PostUnmorph(altmo.GetClass()); PostUnmorph(altmo, false); // This body is no longer current.
altmo.PostUnmorph(GetClass()); altmo.PostUnmorph(self, true); // altmo body is current.
Destroy (); Destroy ();
// Restore playerclass armor to its normal amount. // Restore playerclass armor to its normal amount.
let hxarmor = HexenArmor(altmo.FindInventory('HexenArmor')); let hxarmor = HexenArmor(altmo.FindInventory('HexenArmor'));
@ -556,8 +557,8 @@ class MorphedMonster : Actor
UnmorphTime = level.time + 5*TICRATE; // Next try in 5 seconds UnmorphTime = level.time + 5*TICRATE; // Next try in 5 seconds
return false; return false;
} }
PreUnmorph(unmorphed.GetClass()); PreUnmorph(unmorphed, false);
unmorphed.PreUnmorph(GetClass()); unmorphed.PreUnmorph(self, true);
unmorphed.Angle = Angle; unmorphed.Angle = Angle;
unmorphed.target = target; unmorphed.target = target;
unmorphed.bShadow = bShadow; unmorphed.bShadow = bShadow;
@ -577,8 +578,8 @@ class MorphedMonster : Actor
unmorphed.args[4] = args[4]; unmorphed.args[4] = args[4];
unmorphed.CopyFriendliness (self, true); unmorphed.CopyFriendliness (self, true);
unmorphed.bUnmorphed = false; unmorphed.bUnmorphed = false;
PostUnmorph(unmorphed.GetClass()); PostUnmorph(unmorphed, false); // From is false here: Leaving the caller's body.
unmorphed.PostUnmorph(GetClass()); unmorphed.PostUnmorph(self, true); // True here: Entering this body from here.
UnmorphedMe = NULL; UnmorphedMe = NULL;
Substitute(unmorphed); Substitute(unmorphed);
Destroy (); Destroy ();