/**************************************************************************/1/* ray_cast_2d.h */2/**************************************************************************/3/* This file is part of: */4/* GODOT ENGINE */5/* https://godotengine.org */6/**************************************************************************/7/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */8/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */9/* */10/* Permission is hereby granted, free of charge, to any person obtaining */11/* a copy of this software and associated documentation files (the */12/* "Software"), to deal in the Software without restriction, including */13/* without limitation the rights to use, copy, modify, merge, publish, */14/* distribute, sublicense, and/or sell copies of the Software, and to */15/* permit persons to whom the Software is furnished to do so, subject to */16/* the following conditions: */17/* */18/* The above copyright notice and this permission notice shall be */19/* included in all copies or substantial portions of the Software. */20/* */21/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */22/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */23/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */24/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */25/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */26/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */27/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */28/**************************************************************************/2930#pragma once3132#include "scene/2d/node_2d.h"3334class CollisionObject2D;3536class RayCast2D : public Node2D {37GDCLASS(RayCast2D, Node2D);3839bool enabled = true;40bool collided = false;41ObjectID against;42RID against_rid;43int against_shape = 0;44Vector2 collision_point;45Vector2 collision_normal;46HashSet<RID> exclude;47uint32_t collision_mask = 1;48bool exclude_parent_body = true;4950Vector2 target_position = Vector2(0, 50);5152bool collide_with_areas = false;53bool collide_with_bodies = true;5455bool hit_from_inside = false;5657void _draw_debug_shape();5859protected:60void _notification(int p_what);61void _update_raycast_state();62static void _bind_methods();6364public:65void set_collide_with_areas(bool p_clip);66bool is_collide_with_areas_enabled() const;6768void set_collide_with_bodies(bool p_clip);69bool is_collide_with_bodies_enabled() const;7071void set_hit_from_inside(bool p_enable);72bool is_hit_from_inside_enabled() const;7374void set_enabled(bool p_enabled);75bool is_enabled() const;7677void set_target_position(const Vector2 &p_point);78Vector2 get_target_position() const;7980void set_collision_mask(uint32_t p_mask);81uint32_t get_collision_mask() const;8283void set_collision_mask_value(int p_layer_number, bool p_value);84bool get_collision_mask_value(int p_layer_number) const;8586void set_exclude_parent_body(bool p_exclude_parent_body);87bool get_exclude_parent_body() const;8889void force_raycast_update();9091bool is_colliding() const;92Object *get_collider() const;93RID get_collider_rid() const;94int get_collider_shape() const;95Vector2 get_collision_point() const;96Vector2 get_collision_normal() const;9798void add_exception_rid(const RID &p_rid);99void add_exception(const CollisionObject2D *p_node);100void remove_exception_rid(const RID &p_rid);101void remove_exception(const CollisionObject2D *p_node);102void clear_exceptions();103104RayCast2D();105};106107108