castle-web-cli 0.4.85 → 0.4.87

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/shell/assets/{index-BJLaUTJE.js → index-BFCG4tLs.js} +3 -3
  2. package/dist/shell/assets/{index-DonnH--m.css → index-DSIr52Kl.css} +1 -1
  3. package/dist/shell/index.html +2 -2
  4. package/kits/basic-2d/CLAUDE.md +3 -3
  5. package/kits/basic-2d/behaviors/Collider.jsx +172 -26
  6. package/kits/basic-2d/behaviors/Layout.jsx +24 -0
  7. package/kits/basic-2d/editors/PlayOnly.jsx +11 -9
  8. package/kits/basic-2d/editors/PxArtEditor.jsx +155 -17
  9. package/kits/basic-2d/editors/SceneEditor.jsx +103 -19
  10. package/kits/basic-2d/editors/SelectionOverlay.jsx +21 -11
  11. package/kits/basic-2d/editors/behaviorRegistry.js +9 -3
  12. package/kits/basic-2d/editors/useArtboardFit.js +4 -1
  13. package/kits/basic-2d/engine/ScenePlayer.jsx +14 -1
  14. package/kits/basic-2d/engine/behaviorExtensions.js +28 -0
  15. package/kits/basic-2d/engine/collider.js +60 -6
  16. package/kits/basic-2d/engine/scene.js +28 -2
  17. package/kits/basic-2d/engine/systemRegistry.js +12 -0
  18. package/kits/basic-2d/engine/ui.jsx +9 -0
  19. package/kits/basic-2d/main.jsx +3 -2
  20. package/kits/physics-2d/behaviors/Collider.jsx +20 -6
  21. package/kits/physics-2d/editors/PxArtEditor.jsx +155 -17
  22. package/kits/physics-2d/editors/SceneEditor.jsx +111 -45
  23. package/kits/physics-2d/editors/useArtboardFit.js +4 -1
  24. package/kits/physics-2d/engine/ScenePlayer.jsx +14 -1
  25. package/kits/physics-2d/engine/behaviorExtensions.js +28 -0
  26. package/kits/physics-2d/engine/collider.js +6 -2
  27. package/kits/physics-2d/engine/scene.js +12 -13
  28. package/kits/physics-2d/engine/systemRegistry.js +12 -0
  29. package/kits/physics-2d/engine/ui.jsx +7 -0
  30. package/kits/physics-2d/physics/behaviors/AnalogStick.jsx +4 -2
  31. package/kits/physics-2d/physics/behaviors/Slingshot.jsx +8 -2
  32. package/kits/physics-2d/physics/controls.js +14 -0
  33. package/kits/physics-2d/physics/extensions/collider.js +15 -0
  34. package/kits/physics-2d/systems/physics.js +8 -0
  35. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { Panel } from '../../engine/ui';
3
3
  import { AutoFields } from '../../engine/autoInspector';
4
- import { inActorWorldSpace, slingLaunch, slingPull } from '../controls';
4
+ import { inActorWorldSpace, pressOnDraggable, slingLaunch, slingPull } from '../controls';
5
5
 
6
6
  // Slingshot: pull back and release to fling the actor the opposite way
7
7
  // (angry-birds style) -- the physics feel of castle-client's Sling. While
@@ -31,8 +31,14 @@ export class Slingshot {
31
31
  const pressed = p.down && !rt._slingWasDown;
32
32
  rt._slingWasDown = p.down;
33
33
 
34
+ // A press on a draggable is consumed by the drag; otherwise the sling grabs
35
+ // (anywhere, or on its own actor when grabAnywhere is off).
34
36
  const grabAnywhere = this.props.grabAnywhere ?? true;
35
- if (pressed && (grabAnywhere || scene.actorAt(p.x, p.y)?.id === actor.id)) {
37
+ if (
38
+ pressed &&
39
+ !pressOnDraggable(scene) &&
40
+ (grabAnywhere || scene.actorAt(p.x, p.y)?.id === actor.id)
41
+ ) {
36
42
  rt._slinging = true;
37
43
  // Anchor at the press point (like castle-client): the aim/launch depends
38
44
  // on the drag gesture, not where the press landed relative to the actor.
@@ -29,6 +29,20 @@ export function chaseVelocity(target, layout, props = {}) {
29
29
  return { x: (target.x - c.x) * stiffness, y: (target.y - c.y) * stiffness };
30
30
  }
31
31
 
32
+ // --- Touch ownership -------------------------------------------------------
33
+ // Hierarchy: a press that lands ON a Draggable object is CONSUMED by that drag,
34
+ // so Slingshot/AnalogStick ignore it. A press anywhere else is shared -- both
35
+ // Slingshot and AnalogStick act (no fair way to rank them). So the only gate the
36
+ // non-drag controls need is this: did the current press land on a draggable?
37
+ // Stateless -- a pure per-press query (the controls only ask on their press
38
+ // edge), so there's no owner to latch and nothing to reset.
39
+ export function pressOnDraggable(scene) {
40
+ const p = scene.pointer;
41
+ if (!p.down) return false;
42
+ const hit = scene.actorAt(p.x, p.y);
43
+ return !!hit && !!hit.components.Draggable;
44
+ }
45
+
32
46
  // Run `draw(ctx)` in world space, undoing the actor's Layout rotation that the
33
47
  // runtime applies about the actor's center. Overlay controls (Slingshot,
34
48
  // AnalogStick) use this so their on-screen UI stays anchored where the user
@@ -0,0 +1,15 @@
1
+ // Physics contributes material fields to the shared Collider behavior WITHOUT
2
+ // editing behaviors/Collider.jsx -- that file stays identical to basic-2d's, so
3
+ // the drift check treats it as a converged shared file. These fields are read
4
+ // by the physics simulation (see physics/matterBridge.js); a kit without the
5
+ // physics module never registers them, so its Collider has no material fields.
6
+ // See engine/behaviorExtensions.js for how this is discovered.
7
+ export const behaviorExtension = {
8
+ behaviorName: 'Collider',
9
+ defaultProps: {
10
+ // `bounciness` = restitution: 0 (dead) to ~1 (very bouncy); can exceed 1.
11
+ bounciness: 0,
12
+ // `friction` = surface friction.
13
+ friction: 0.1,
14
+ },
15
+ };
@@ -0,0 +1,8 @@
1
+ // Registers the physics simulation as a runtime system. Auto-discovered by
2
+ // engine/systemRegistry.js (`systems/*.js`) and invoked by makeScene, so the
3
+ // physics module plugs in without the shared engine ever referencing it.
4
+ import { installPhysics } from '../physics';
5
+
6
+ export function installSystem(runtime) {
7
+ installPhysics(runtime);
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "castle-web-cli",
3
- "version": "0.4.85",
3
+ "version": "0.4.87",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "castle-web": "./dist/index.js"