ChangePosition¶
A coroutine specifically made to be used inside an enemy action which allows to smoothly change the position of the enemy party member. When the coroutine completes, checkingdead
is set to null to inform the caller so it can yield on it.
Changing to Flying
or Ground
is supported as well as changing from Underground
to Ground
(but not Flying
). Changing to Underground
isn't supported (use Dig for that instead).
private IEnumerator ChangePosition(int entityid, BattlePosition position)
Parameters¶
entityid
: Theenemydata
index that will change itsposition
position
: The new BattlePosition to set. While any values will end up being set, not all of them will act smoothly, see the section above for details. If this new position is the same than the current one, this coroutine does nothing except settingcheckingdead
to null
Procedure¶
If the new position is the same than the enemy party memebr's position
, the coroutine does nothing except setting checkingdead
to null to inform the caller that it is completed.
Otherwise:
- Over the course of 20.0 frames, the enemy party member's
height
changes frominitialheight
tominheight
(fromminheight
toinitialheight
instead if the new position isFlying
) via a lerp - If the new position is
Flying
:- The enemy party member's
bobrange
andbobspeed
are set to theirstartbf
andstartbs
respectively - The enemy party member's
height
is set to theirinitialheight
- The enemy party member's
- Otherwise:
- If the current position is
Underground
:- The enemy party member's
digging
is set to false - Yield all frames until the enemy party member's
digtime
reached 0.0 or below - Yield for 0.25 seconds
- The enemy party member's
- The enemy party member's
bobrange
andbobspeed
are set to 0.0 - The enemy party member's
height
is set to theirminheight
- If the current position is
- The enemy party member's
position
is set to the new position checkingdead
is set to null informing the caller that this coroutine completed