Skip to main content

pite_core/nodes/
collision_shape2d.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! CollisionShape2D: geometric collider attached to a physics body or area.
3
4use crate::schema::{DefaultPropVal, NodeTypeSchema, PropHint, PropSchema};
5
6pub static SCHEMA: NodeTypeSchema = NodeTypeSchema {
7    type_name: "CollisionShape2D",
8    description: "Geometric collider attached to a parent physics body or Area2D.",
9    inherits: Some("Node2D"),
10    abstract_class: false,
11    props: PROPS,
12};
13
14pub static PROPS: &[PropSchema] = &[
15    PropSchema {
16        key: "shape",
17        label: "Shape",
18        doc: "Geometry kind: `box`, `circle`, or `capsule`.",
19        default_value: DefaultPropVal::Str("box"),
20        hint: PropHint::Enum(&["box", "circle", "capsule"]),
21        read_only: false,
22    },
23    PropSchema {
24        key: "size",
25        label: "Size",
26        doc: "Bounding box size in world units. Only used when `shape = \"box\"`.",
27        default_value: DefaultPropVal::Vec2(32.0, 32.0),
28        hint: PropHint::Vec2 { speed: 1.0 },
29        read_only: false,
30    },
31    PropSchema {
32        key: "radius",
33        label: "Radius",
34        doc: "Circle or capsule radius in world units.",
35        default_value: DefaultPropVal::Num(16.0),
36        hint: PropHint::Num {
37            speed: 1.0,
38            min: 0.1,
39            max: 10000.0,
40        },
41        read_only: false,
42    },
43    PropSchema {
44        key: "height",
45        label: "Height",
46        doc: "Capsule height in world units (excludes the two hemispherical caps).",
47        default_value: DefaultPropVal::Num(32.0),
48        hint: PropHint::Num {
49            speed: 1.0,
50            min: 0.1,
51            max: 10000.0,
52        },
53        read_only: false,
54    },
55    PropSchema {
56        key: "disabled",
57        label: "Disabled",
58        doc: "When true the collider is not registered with the physics world.",
59        default_value: DefaultPropVal::Bool(false),
60        hint: PropHint::Bool,
61        read_only: false,
62    },
63];