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: Theenemydataindex that will change itspositionposition: 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 settingcheckingdeadto 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
heightchanges frominitialheighttominheight(fromminheighttoinitialheightinstead if the new position isFlying) via a lerp - If the new position is
Flying:- The enemy party member's
bobrangeandbobspeedare set to theirstartbfandstartbsrespectively - The enemy party member's
heightis set to theirinitialheight
- The enemy party member's
- Otherwise:
- If the current position is
Underground:- The enemy party member's
diggingis set to false - Yield all frames until the enemy party member's
digtimereached 0.0 or below - Yield for 0.25 seconds
- The enemy party member's
- The enemy party member's
bobrangeandbobspeedare set to 0.0 - The enemy party member's
heightis set to theirminheight
- If the current position is
- The enemy party member's
positionis set to the new position checkingdeadis set to null informing the caller that this coroutine completed