scene_replication_config.h 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*************************************************************************/
  2. /* scene_replication_config.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
  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. #ifndef SCENE_REPLICATION_CONFIG_H
  31. #define SCENE_REPLICATION_CONFIG_H
  32. #include "core/io/resource.h"
  33. #include "core/variant/typed_array.h"
  34. class SceneReplicationConfig : public Resource {
  35. GDCLASS(SceneReplicationConfig, Resource);
  36. OBJ_SAVE_TYPE(SceneReplicationConfig);
  37. RES_BASE_EXTENSION("repl");
  38. private:
  39. struct ReplicationProperty {
  40. NodePath name;
  41. bool spawn = true;
  42. bool sync = true;
  43. bool operator==(const ReplicationProperty &p_to) {
  44. return name == p_to.name;
  45. }
  46. ReplicationProperty() {}
  47. ReplicationProperty(const NodePath &p_name) {
  48. name = p_name;
  49. }
  50. };
  51. List<ReplicationProperty> properties;
  52. List<NodePath> spawn_props;
  53. List<NodePath> sync_props;
  54. protected:
  55. static void _bind_methods();
  56. bool _set(const StringName &p_name, const Variant &p_value);
  57. bool _get(const StringName &p_name, Variant &r_ret) const;
  58. void _get_property_list(List<PropertyInfo> *p_list) const;
  59. public:
  60. TypedArray<NodePath> get_properties() const;
  61. void add_property(const NodePath &p_path, int p_index = -1);
  62. void remove_property(const NodePath &p_path);
  63. bool has_property(const NodePath &p_path) const;
  64. int property_get_index(const NodePath &p_path) const;
  65. bool property_get_spawn(const NodePath &p_path);
  66. void property_set_spawn(const NodePath &p_path, bool p_enabled);
  67. bool property_get_sync(const NodePath &p_path);
  68. void property_set_sync(const NodePath &p_path, bool p_enabled);
  69. const List<NodePath> &get_spawn_properties() { return spawn_props; }
  70. const List<NodePath> &get_sync_properties() { return sync_props; }
  71. SceneReplicationConfig() {}
  72. };
  73. #endif // SCENE_REPLICATION_CONFIG_H