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 ispauseposunlessactiveonpauseis true, we are in an event,iskillis true ordeadis true - Calls
UpdateCamPoswhich updatesincamerawith 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 ifalwaysactiveis true,camdistanceto the distance of the entity to the main camera andcamposbeing the viewport position of the entity using the main camera
- If paused, ensure the
- Ensure
latetrans's position is set tolateposwhen applicable - If we aren't paused and there's a
forcemovein progress, handle the failsafe logic- Decrease the
forcetimerby framestep ifplayerentityis true or that eitheralwaysactiveis true or the entity isincameraand is within 30.0 units on the z axis unlessdisabletimeris true which will bypass this decrease for any entity exceptplayerentity - If the
forcetimerexpired, the entity isn'tdiggingand the player isn't free or it's not aplayerentitythen the failsafe will take effect by setting thetransform's position toforcetarget. Smokes will appear at the entity position before the failsafe and atforcetargetafter the failsafe if it isn'tshrinkand 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
deadoriskill, the battledata of the entity atbattleidindicatesisnumband the battle hasn'tcancelupdateby 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
bubbleshieldposition 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
bubbleshieldto (0.0,height+ 1.25, 0.0), butoverrideshieldposbeing 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
hpbaris present and active, ensure its local position is at (0.0, -0.5 + camoffset.y - battlecampos.y, 0.0) unless it's aKeyRwhich changes the x to 0.5 or aPitcherwhich changes the x to -0.5 - If the
spriteis present and theanimidisn'tNone(-1), RefreshTrail is called which will update thetraildataaccording totrail - Ensure the
transformis childed to the map if it's atempfollowerand thetransformdoesn't have a parent already - If
setupis false, call LateStart - As long as the game isn't paused, call Follow which updates the following procedure
- If
alwaysflipis true, call UpdateFlip - If the game is unpaused and
incamera, theincameraupdate will happen if we are in an event OR that thecamposz is less than 25.0 OR less than 30.0 only if thenpcdata'sstartlifeis smaller than 50.0 / not present- Assign
truescaletostartscale - If the
icecubeis present, set its scale by a lerp of its current scale tofreezesizewith a factor of framestep * 0.25 and set its position byfreezeoffset+ Vector3.up *heightor by (freezeoffset.x + Random.Range(-0.1, 0.1),freezeoffset.y +height,freezeoffset.z + Random.Range(-0.1, 0.1)) ifshakeice - If
springcooldownis active while therigid's velocity is descending on the y axis orongroundis true, deactivate the cooldown - General update methods are called under conditions:
- UpdateGround, UpdateAirAnim and UpdateVelocity are called every 2 frames except for
battleentity or thenpcdatais 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
battleentity or every 2 frames - UpdateMoveSmoke is called every 3 frames
- RefreshShadow is called when
isfolloweris true and the player is flying OR that there is nonpcdataOR 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 theinsideidmatches 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
battleentity (ifalwaysflipwas 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
soundonpauseis true OR that it's not a battle battle and it either has nonpcdataor it has one, but it's aMusticRangeObject, otherwise, UpdateSound is called instead - Reset the
emoticonto none and theemoticoncooldownto 0.0 when applicable - Deactivate the
movesmokeif 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,
UpdateRotateris called which will make sure therotater's y angle matches the main camera one unlesslockrotateris 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 abattleentity or that we are in an event- UpdateHeight is called when it's a battle entity or we are in an event or
alwaysactiveis true or it has nonpcdataor it has one, but it's not an NPC or it is an NPC, but thestartlifeis below 50.0 - AnimSpecificQuirks and UpdateSprite are called
flyinganimis set to true if theheightis higher than 0.1 unlessoverrideflyis 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
offgroundframesis increased by framestep if it hasn't reached 1000.0 and thatongroundis false, otherwise, it is set to 0.0. If we are in an event, that it is decreased by framestep ifongroundis true and it hasn't gone below 0.0 - If the
jumpcooldownhas expired andstopspinongroundis true, it is set to false on top of zeroing outspin
- Every 3 frames,
lastposis set to thetransform's positionoldgroundis set toonground