LateUpdate¶
This is the LateUpdate of EntityControl. This is the main update loop of the component and it is done on late due to the guarantee that coroutines have all ran by then so anything that could have edited the fields like the animstate have done so already.
- Every 3 frames
- If paused, ensure the
transform
's position ispausepos
unlessactiveonpause
is true, we are in an event,iskill
is true ordead
is true - Calls
UpdateCamPos
which updatesincamera
with whether the entity is in the main camera range (ranging from (-0.6, -1.25) to (1.6, 2.25) in viewport coordinate while also being higher than -1 on the z axis) or true ifalwaysactive
is true,camdistance
to the distance of the entity to the main camera andcampos
being the viewport position of the entity using the main camera
- If paused, ensure the
- Ensure
latetrans
's position is set tolatepos
when applicable - If we aren't paused and there's a
forcemove
in progress, handle the failsafe logic- Decrease the
forcetimer
by framestep ifplayerentity
is true or that eitheralwaysactive
is true or the entity isincamera
and is within 30.0 units on the z axis unlessdisabletimer
is true which will bypass this decrease for any entity exceptplayerentity
- If the
forcetimer
expired, the entity isn'tdigging
and the player isn't free or it's not aplayerentity
then the failsafe will take effect by setting thetransform
's position toforcetarget
. Smokes will appear at the entity position before the failsafe and atforcetarget
after the failsafe if it isn'tshrink
and its scale's magnitude is higher than 0.2.
- Decrease the
- Handle the numb animation update logic if it is a battle entity while we are in a battle, the entity isn't
dead
oriskill
, the battledata of the entity atbattleid
indicatesisnumb
and the battle hasn'tcancelupdate
by calling Numb. This method handles setting the animstate accordingly as well as randomly displacing the entity every once in a while with a yellow color - Handles the
bubbleshield
position update if it is present- If the scale's magnitude is higher than 0.15, the default is to set the local position of the
bubbleshield
to (0.0,height
+ 1.25, 0.0), butoverrideshieldpos
being true can change this to be (overrideshieldpos
.x,height
+overrideshieldpos
.y,overrideshieldpos
.z) - Otherwise, the local position is set offscreen to (0.0, -999.0, 0.0)
- If the scale's magnitude is higher than 0.15, the default is to set the local position of the
- If the
hpbar
is present and active, ensure its local position is at (0.0, -0.5 + camoffset.y - battlecampos.y, 0.0) unless it's aKeyR
which changes the x to 0.5 or aPitcher
which changes the x to -0.5 - If the
sprite
is present and theanimid
isn'tNone
(-1), RefreshTrail is called which will update thetraildata
according totrail
- Ensure the
transform
is childed to the map if it's atempfollower
and thetransform
doesn't have a parent already - If
setup
is false, call LateStart - As long as the game isn't paused, call Follow which updates the following procedure
- If
alwaysflip
is true, call UpdateFlip - If the game is unpaused and
incamera
, theincamera
update will happen if we are in an event OR that thecampos
z is less than 25.0 OR less than 30.0 only if thenpcdata
'sstartlife
is smaller than 50.0 / not present- Assign
truescale
tostartscale
- If the
icecube
is present, set its scale by a lerp of its current scale tofreezesize
with a factor of framestep * 0.25 and set its position byfreezeoffset
+ Vector3.up *height
or by (freezeoffset
.x + Random.Range(-0.1, 0.1),freezeoffset
.y +height
,freezeoffset
.z + Random.Range(-0.1, 0.1)) ifshakeice
- If
springcooldown
is active while therigid
's velocity is descending on the y axis oronground
is true, deactivate the cooldown - General update methods are called under conditions:
- UpdateGround, UpdateAirAnim and UpdateVelocity are called every 2 frames except for
battle
entity or thenpcdata
is not NPC / not present where they will be called regardless of the current frame - UpdateGeneralAnim is called every 2 frames
- UpdateEmoticon is called when in an event or it is a
battle
entity or every 2 frames - UpdateMoveSmoke is called every 3 frames
- RefreshShadow is called when
isfollower
is true and the player is flying OR that there is nonpcdata
OR that it has one but it's also an Enemy, a SemiNPC for every 10 frames or it's an NPC/Object every 2 frames in addition that theinsideid
matches the current one - UpdateStatusIcons and UpdateSound are always called
- UpdateFlip is called either when we are not in a battle or the entity itself is a
battle
entity (ifalwaysflip
was true, this is means this can be called a second time)
- UpdateGround, UpdateAirAnim and UpdateVelocity are called every 2 frames except for
- Assign
- Otherwise, the inactive update will happen
- The entity is muted when applicable when
soundonpause
is true OR that it's not a battle battle and it either has nonpcdata
or it has one, but it's aMusticRange
Object, otherwise, UpdateSound is called instead - Reset the
emoticon
to none and theemoticoncooldown
to 0.0 when applicable - Deactivate the
movesmoke
if it is present and enabled
- The entity is muted when applicable when
- This is the general update handling when unpaused that applies to all entities
- Every 3 frames,
UpdateRotater
is called which will make sure therotater
's y angle matches the main camera one unlesslockrotater
is true. If we were not in an event UpdateCollider is called before it, but because this one only process every 2 frames, it will actually only process every 6 frames effectively. - Rendering updates happen if the entity is
incamera
, it is abattle
entity or that we are in an event- UpdateHeight is called when it's a battle entity or we are in an event or
alwaysactive
is true or it has nonpcdata
or it has one, but it's not an NPC or it is an NPC, but thestartlife
is below 50.0 - AnimSpecificQuirks and UpdateSprite are called
flyinganim
is set to true if theheight
is higher than 0.1 unlessoverridefly
is true which forces it to false
- UpdateHeight is called when it's a battle entity or we are in an event or
- If we aren't in an event, then
offgroundframes
is increased by framestep if it hasn't reached 1000.0 and thatonground
is false, otherwise, it is set to 0.0. If we are in an event, that it is decreased by framestep ifonground
is true and it hasn't gone below 0.0 - If the
jumpcooldown
has expired andstopspinonground
is true, it is set to false on top of zeroing outspin
- Every 3 frames,
lastpos
is set to thetransform
's positionoldground
is set toonground