Skip to content

Resource: notify subscribers when a resource is placed or moved - #1230

Merged
BioCam merged 1 commit into
mainfrom
resource-location-state
Sep 1, 2026
Merged

Resource: notify subscribers when a resource is placed or moved#1230
BioCam merged 1 commit into
mainfrom
resource-location-state

Conversation

@BioCam

@BioCam BioCam commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

A resource's position changes without anything being told. location is a plain attribute, so a resource can be assigned to a deck, moved to another carrier, or handed between machines and nothing reaches the state channel. A subscriber following it has to be notified some other way.

There is no method to hang the notification on, the way rotate exists for rotation - position is set by assignment, including inside assign_child_resource - so it has to be caught at the attribute itself.

This PR

  • location becomes a property over _location. The setter records the new position and calls _state_updated when the value actually changed and the resource has a parent, so a resource being built or sitting outside a tree stays silent.
  • serialize_state carries "location" alongside "rotation", and load_state reads it back.

Behaviour: reads and writes of .location are unchanged and no caller has to move. Placing a resource or moving a placed one now emits a state update. Unassigning does not, because the parent is cleared first. serialize_all_state gains a "location" key per placed resource, so state written now differs from state written before, though older files still load.

rotate still notifies as it always has and is not touched here. Rebinding rotation outright, or mutating either value in place, still notifies nothing - that gap is unchanged and common to both.

@BioCam
BioCam requested a review from rickwierenga September 1, 2026 13:51
`location` was a plain attribute, so a resource could be assigned to a deck,
moved to another carrier, or handed between machines without anything reaching
the state channel.

Position is set by assignment, including inside `assign_child_resource`, so
there is no method to hang the notification on and it is caught at the
attribute. The setter notifies only when the value actually changed and the
resource has a parent, so building a resource and holding one outside a tree
stay silent.

`serialize_state` carries "location" alongside "rotation", and `load_state`
reads it back.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
@BioCam
BioCam force-pushed the resource-location-state branch from a38aaa9 to 7e29dc3 Compare September 1, 2026 13:54
@BioCam
BioCam merged commit 2475a59 into main Sep 1, 2026
21 checks passed
@BioCam
BioCam deleted the resource-location-state branch September 1, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant