Cell Attachment Analysis

From the CreationKit Wiki
Jump to navigation Jump to search

This more of a self reminder for myself but I hope it proves useful to others.

It's been proven that cell attachment/detachment is the result of the engine checking a bool on the objectreference as to whether or not its cell is/was attached/detached. See OnCellAttach - ObjectReference talk page.

However, I'm going to extend the basic info about these two things a bit by breaking it down into 6 scenarios.

Scenario 1
Player is in the reference's parent Cell: [OnCellAttach]
Player leaves the reference's parent Cell: [OnCellDetach]

Scenario 2
Player is in the reference's parent cell: [OnCellAttach]
Reference moves to another cell: [OnDetachedFromCell]
-Because the reference has moved from its previously attached cell, to a cell that is currently not attached.

Scenario 3
Player is in the reference's parent cell: [OnCellAttach]
Player leaves the reference's parent cell: [OnCellDetach]
Reference moves to another cell: [OnAttachedToCell]
-Because the reference and the player both moved to the same cell and in the case of the reference, this new cell became attached.

Scenario 4
Player leaves the reference's newly attached parent cell: [OnCellDetach]

Scenario 5
Player is in the reference's parent cell from scenario 3: --
Reference moves back to the previous cell: [OnDetachedFromCell]
-Because the reference has moved from currently attached parent cell to the previous cell which was detached.

Scenario 6
Player is in the cell that the reference just left from scenario 5: --
Player moves back to the previous cell where the reference is: [OnCellAttach]
Player leaves the reference's parent cell: [OnCellDetach]

Scenario 7
Player is in the reference's parent cell: [OnCellAttach]
Player leaves the reference's parent cell: [OnCellDetach]
Reference moves to the player's cell: [OnAttachedToCell]

Scenario 8
Player leaves the reference's new parent cell from scenario 7: [OnCellDetach]
Reference moves to the player's new cell: [OnAttachedToCell]
Player leaves the reference's newly attached cell: [OnCellDetach]

--Rasikko (talk) 2021-10-20T00:02:13 (EDT)