visibility_notifier_2d.h
1 /*************************************************************************/
2 /* visibility_notifier_2d.h */
3 /*************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* http://www.godotengine.org */
7 /*************************************************************************/
8 /* Copyright (c) 2007-2016 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 /*************************************************************************/
29 #ifndef VISIBILITY_NOTIFIER_2D_H
30 #define VISIBILITY_NOTIFIER_2D_H
31 
32 #include "scene/2d/node_2d.h"
33 
34 class Viewport;
35 class VisibilityNotifier2D : public Node2D {
36 
37  OBJ_TYPE(VisibilityNotifier2D,Node2D);
38 
39  Set<Viewport*> viewports;
40 
41  Rect2 rect;
42 
43 protected:
44 friend class SpatialIndexer2D;
45 
46  void _enter_viewport(Viewport* p_viewport);
47  void _exit_viewport(Viewport* p_viewport);
48 
49 
50  virtual void _screen_enter() {}
51  virtual void _screen_exit() {}
52 
53  void _notification(int p_what);
54  static void _bind_methods();
55 public:
56 
57  void set_rect(const Rect2& p_rect);
58  Rect2 get_rect() const;
59 
60  bool is_on_screen() const;
61 
62  virtual Rect2 get_item_rect() const;
63 
65 };
66 
67 
69 
71 public:
72 
73  enum Enabler {
74  ENABLER_PAUSE_ANIMATIONS,
75  ENABLER_FREEZE_BODIES,
76  ENABLER_PAUSE_PARTICLES,
77  ENABLER_PARENT_PROCESS,
78  ENABLER_PARENT_FIXED_PROCESS,
79  ENABLER_MAX
80  };
81 
82 protected:
83 
84  virtual void _screen_enter();
85  virtual void _screen_exit();
86 
87  bool visible;
88 
89  void _find_nodes(Node* p_node);
90 
91  Map<Node*,Variant> nodes;
92  void _node_removed(Node* p_node);
93  bool enabler[ENABLER_MAX];
94 
95  void _change_node_state(Node* p_node,bool p_enabled);
96 
97  void _notification(int p_what);
98  static void _bind_methods();
99 
100 public:
101 
102  void set_enabler(Enabler p_enabler,bool p_enable);
103  bool is_enabler_enabled(Enabler p_enabler) const;
104 
106 
107 };
108 
109 VARIANT_ENUM_CAST(VisibilityEnabler2D::Enabler);
110 
111 
112 #endif // VISIBILITY_NOTIFIER_2D_H
Definition: viewport.h:75
Definition: node.h:42
Definition: math_2d.h:204
Definition: world_2d.cpp:39
Definition: visibility_notifier_2d.h:68
Definition: node_2d.h:34
Definition: visibility_notifier_2d.h:35