Skip to content
0.2.0-dev Download ZIP
90 lines ·3.7 KB Raw
1/**************************************************************************/
2/* navigation_server_2d_manager.h */
3/**************************************************************************/
4/* This file is part of: */
5/* GODOT ENGINE */
6/* https://godotengine.org */
7/**************************************************************************/
8/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10/* */
11/* Permission is hereby granted, free of charge, to any person obtaining */
12/* a copy of this software and associated documentation files (the */
13/* "Software"), to deal in the Software without restriction, including */
14/* without limitation the rights to use, copy, modify, merge, publish, */
15/* distribute, sublicense, and/or sell copies of the Software, and to */
16/* permit persons to whom the Software is furnished to do so, subject to */
17/* the following conditions: */
18/* */
19/* The above copyright notice and this permission notice shall be */
20/* included in all copies or substantial portions of the Software. */
21/* */
22/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29/**************************************************************************/
30
31#pragma once
32
33#include "core/object/object.h"
34
35class NavigationServer2D;
36
37class NavigationServer2DManager : public Object {
38 GDCLASS(NavigationServer2DManager, Object);
39
40 static inline NavigationServer2DManager *singleton = nullptr;
41
42 struct ClassInfo {
43 String name;
44 Callable create_callback;
45
46 ClassInfo() {}
47
48 ClassInfo(const String &p_name, const Callable &p_create_callback) :
49 name(p_name),
50 create_callback(p_create_callback) {}
51
52 ClassInfo(const ClassInfo &p_ci) :
53 name(p_ci.name),
54 create_callback(p_ci.create_callback) {}
55
56 void operator=(const ClassInfo &p_ci) {
57 name = p_ci.name;
58 create_callback = p_ci.create_callback;
59 }
60 };
61
62 Vector<ClassInfo> navigation_servers;
63 int default_server_id = -1;
64 int default_server_priority = -1;
65
66 void on_servers_changed();
67
68protected:
69 static void _bind_methods();
70
71public:
72 static const String setting_property_name;
73
74 static NavigationServer2DManager *get_singleton();
75
76 void register_server(const String &p_name, const Callable &p_create_callback);
77 void set_default_server(const String &p_name, int p_priority = 0);
78 int find_server_id(const String &p_name);
79 int get_servers_count();
80 String get_server_name(int p_id);
81 NavigationServer2D *new_default_server();
82 NavigationServer2D *new_server(const String &p_name);
83
84 static void initialize_server();
85 static void finalize_server();
86
87 static void initialize_server_manager();
88 static void finalize_server_manager();
89 static NavigationServer2D *create_dummy_server_callback();
90};