Generated Code Example
Source File
#include <godot_cpp/classes/node.h>
#include "godot_object_compiler/macros.h"
#include "example.generated.h"
using namespace godot;
GODOT_CLASS();
class ExampleClass : public Node {
GODOT_GENERATED_BODY();
public:
GODOT_ENUM();
enum Regular {
REGULAR_VALUE_A,
REGULAR_VALUE_B,
REGULAR_VALUE_C,
};
GODOT_ENUM(EnumFlags);
enum Flags {
FLAG_NONE = 0,
FLAG_VALUE_A = 1,
FLAG_VALUE_B = 1 << 1,
FLAG_VALUE_C = 1 << 2,
};
GODOT_SIGNAL();
void something_happened(int p_param);
GODOT_FUNCTION();
Ref<Resource> function(Node* p_node);
GODOT_FUNCTION(ScriptVirtual);
void virtual_function(Node* p_node);
GODOT_FUNCTION(Authority, UnreliableOrdered, CallLocal, Channel(1));
void rpc_function(int p_param);
GODOT_CATEGORY("Properties");
GODOT_PROPERTY();
Ref<Resource> resource;
GODOT_PROPERTY(PublicGet, PrivateSet);
TypedDictionary<int, Resource> resources;
GODOT_PROPERTY(HintRange("0,1,0.1"));
float range = 0;
GODOT_GROUP("Enum Properties");
GODOT_PROPERTY();
Regular enum_property = REGULAR_VALUE_A;
GODOT_PROPERTY();
Flags flags_property = FLAG_NONE;
};
GODOT_GENERATED_GLOBAL();
Generated Header
/**************************************************************************/
/* example.generated.h */
/* ___ ___ ___ ___ _____ */
/* / __|/ _ \| \ / _ \_ _| */
/* | (_ | (_) | |) | (_) || | */
/* \___|\___/|___/ \___/ |_| */
/* ___ ___ _ ___ ___ _____ ___ ___ __ __ ___ ___ _ ___ ___ */
/* / _ \| _ )_ | | __/ __|_ _| / __/ _ \| \/ | _ \_ _| | | __| _ \ */
/* | (_) | _ \ || | _| (__ | | | (_| (_) | |\/| | _/| || |__| _|| / */
/* \___/|___/\__/|___\___| |_| \___\___/|_| |_|_| |___|____|___|_|_\ */
/* */
/* This file is generated by Godot Object Compiler 0.1 */
/**************************************************************************/
// NOLINTBEGIN
// clang-format off
#pragma once
#undef GOC_FILE_ID
#define GOC_FILE_ID() 107580388863103421
#include "godot_object_compiler/macros.h"
#include "godot_cpp/variant/string_name.hpp"
#define GOC_GENERATED_10_107580388863103421() GDCLASS (ExampleClass, Node) ;\
public:\
static void _bind_methods () ;\
void _notification (int p_notification) ;\
struct PropertyNames \
{\
static const godot::StringName& resource() {static const godot::StringName sn = "resource"; return sn; }\
static const godot::StringName& resources() {static const godot::StringName sn = "resources"; return sn; }\
static const godot::StringName& range() {static const godot::StringName sn = "range"; return sn; }\
static const godot::StringName& enum_property() {static const godot::StringName sn = "enum_property"; return sn; }\
static const godot::StringName& flags_property() {static const godot::StringName sn = "flags_property"; return sn; }\
} ;\
struct FunctionNames \
{\
static const godot::StringName& function() {static const godot::StringName sn = "function"; return sn; }\
static const godot::StringName& virtual_function() {static const godot::StringName sn = "virtual_function"; return sn; }\
static const godot::StringName& rpc_function() {static const godot::StringName sn = "rpc_function"; return sn; }\
} ;\
struct SignalNames \
{\
static const StringName& something_happened() {static const StringName sn = "something_happened"; return sn; }\
} ;\
void _virtual_function (Node * p_node) ;\
GDVIRTUAL1 (_virtual_function, godot::Node *) ;\
godot::Ref <godot::Resource> get_resource () const ;\
void set_resource (const godot::Ref <godot::Resource> & p_resource) ;\
godot::TypedDictionary <int, godot::Resource> get_resources () const ;\
float get_range () const ;\
void set_range (const float & p_range) ;\
int get_enum_property () const ;\
void set_enum_property (int p_enum_property) ;\
int get_flags_property () const ;\
void set_flags_property (int p_flags_property) ;\
protected:\
private:\
void set_resources (const godot::TypedDictionary <int, godot::Resource> & p_resources) ;
#define GOC_GENERATED_58_107580388863103421() VARIANT_ENUM_CAST (ExampleClass::Regular) ;\
VARIANT_BITFIELD_CAST (ExampleClass::Flags) ;
// clang-format on
// NOLINTEND
Generated Source
/**************************************************************************/
/* example.generated.cpp */
/* ___ ___ ___ ___ _____ */
/* / __|/ _ \| \ / _ \_ _| */
/* | (_ | (_) | |) | (_) || | */
/* \___|\___/|___/ \___/ |_| */
/* ___ ___ _ ___ ___ _____ ___ ___ __ __ ___ ___ _ ___ ___ */
/* / _ \| _ )_ | | __/ __|_ _| / __/ _ \| \/ | _ \_ _| | | __| _ \ */
/* | (_) | _ \ || | _| (__ | | | (_| (_) | |\/| | _/| || |__| _|| / */
/* \___/|___/\__/|___\___| |_| \___\___/|_| |_|_| |___|____|___|_|_\ */
/* */
/* This file is generated by Godot Object Compiler 0.1 */
/**************************************************************************/
// NOLINTBEGIN
// clang-format off
#include "example.h"
#include "example.h"
#include "godot_cpp/classes/multiplayer_api.hpp"
#include "godot_cpp/classes/multiplayer_peer.hpp"
#include "godot_cpp/classes/node.hpp"
#include "godot_cpp/classes/ref.hpp"
#include "godot_cpp/classes/resource.hpp"
#include "godot_cpp/variant/dictionary.hpp"
#include "godot_cpp/variant/typed_dictionary.hpp"
void ExampleClass::_bind_methods ()
{
BIND_ENUM_CONSTANT (REGULAR_VALUE_A) ;
BIND_ENUM_CONSTANT (REGULAR_VALUE_B) ;
BIND_ENUM_CONSTANT (REGULAR_VALUE_C) ;
BIND_BITFIELD_FLAG (FLAG_NONE) ;
BIND_BITFIELD_FLAG (FLAG_VALUE_A) ;
BIND_BITFIELD_FLAG (FLAG_VALUE_B) ;
BIND_BITFIELD_FLAG (FLAG_VALUE_C) ;
ADD_SIGNAL (MethodInfo ("something_happened", godot::PropertyInfo (godot::Variant::INT, "p_param", godot::PropertyHint::PROPERTY_HINT_NONE, "", godot::PropertyUsageFlags::PROPERTY_USAGE_DEFAULT))) ;
godot::ClassDB::bind_method (D_METHOD ("function", "p_node"), &ExampleClass::function) ;
GDVIRTUAL_BIND (_virtual_function, "p_node") ;
godot::ClassDB::bind_method (D_METHOD ("virtual_function", "p_node"), &ExampleClass::_virtual_function) ;
godot::ClassDB::bind_method (D_METHOD ("rpc_function", "p_param"), &ExampleClass::rpc_function) ;
ADD_GROUP ("Properties", "") ;
godot::ClassDB::bind_method (D_METHOD ("get_resource"), &ExampleClass::get_resource) ;
godot::ClassDB::bind_method (D_METHOD ("set_resource", "resource"), &ExampleClass::set_resource) ;
ADD_PROPERTY (godot::PropertyInfo (godot::Variant::OBJECT, "resource", godot::PropertyHint::PROPERTY_HINT_RESOURCE_TYPE, "Resource", godot::PropertyUsageFlags::PROPERTY_USAGE_DEFAULT), "set_resource", "get_resource") ;
godot::ClassDB::bind_method (D_METHOD ("get_resources"), &ExampleClass::get_resources) ;
godot::ClassDB::bind_method (D_METHOD ("set_resources", "resources"), &ExampleClass::set_resources) ;
ADD_PROPERTY (godot::PropertyInfo (godot::Variant::DICTIONARY, "resources", godot::PropertyHint::PROPERTY_HINT_DICTIONARY_TYPE, vformat("%s/%s:%s;%s/%s:%s", Variant::INT,PROPERTY_HINT_NONE,"",Variant::OBJECT,PROPERTY_HINT_RESOURCE_TYPE,"Resource"), godot::PropertyUsageFlags::PROPERTY_USAGE_DEFAULT), "set_resources", "get_resources") ;
godot::ClassDB::bind_method (D_METHOD ("get_range"), &ExampleClass::get_range) ;
godot::ClassDB::bind_method (D_METHOD ("set_range", "range"), &ExampleClass::set_range) ;
ADD_PROPERTY (godot::PropertyInfo (godot::Variant::FLOAT, "range", godot::PropertyHint::PROPERTY_HINT_RANGE, "0,1,0.1", godot::PropertyUsageFlags::PROPERTY_USAGE_DEFAULT), "set_range", "get_range") ;
ADD_GROUP ("Enum Properties", "") ;
godot::ClassDB::bind_method (D_METHOD ("get_enum_property"), &ExampleClass::get_enum_property) ;
godot::ClassDB::bind_method (D_METHOD ("set_enum_property", "enum_property"), &ExampleClass::set_enum_property) ;
ADD_PROPERTY (godot::PropertyInfo (godot::Variant::INT, "enum_property", godot::PropertyHint::PROPERTY_HINT_ENUM, "Regular Value A:0,Regular Value B:1,Regular Value C:2", godot::PropertyUsageFlags::PROPERTY_USAGE_DEFAULT), "set_enum_property", "get_enum_property") ;
godot::ClassDB::bind_method (D_METHOD ("get_flags_property"), &ExampleClass::get_flags_property) ;
godot::ClassDB::bind_method (D_METHOD ("set_flags_property", "flags_property"), &ExampleClass::set_flags_property) ;
ADD_PROPERTY (godot::PropertyInfo (godot::Variant::INT, "flags_property", godot::PropertyHint::PROPERTY_HINT_ENUM, "Flag None:0,Flag Value A:1,Flag Value B:2,Flag Value C:4", godot::PropertyUsageFlags::PROPERTY_USAGE_DEFAULT), "set_flags_property", "get_flags_property") ;
}
void ExampleClass::_notification (int p_notification)
{
if (p_notification == NOTIFICATION_ENTER_TREE)
{
{
godot::Dictionary opts;
opts["rpc_mode"] = godot::MultiplayerAPI::RPC_MODE_AUTHORITY;
opts["transfer_mode"] = godot::MultiplayerPeer::TRANSFER_MODE_UNRELIABLE_ORDERED;
opts["call_local"] = true;
opts["channel"] = 1;
rpc_config("rpc_function", opts);
}
}
}
void ExampleClass::something_happened (int p_param)
{
emit_signal ("something_happened", p_param) ;
}
void ExampleClass::_virtual_function (godot::Node * p_node)
{
if(! GDVIRTUAL_CALL (_virtual_function, p_node))
{
return virtual_function (p_node) ;
}
}
godot::Ref <godot::Resource> ExampleClass::get_resource () const
{
return resource;
}
void ExampleClass::set_resource (const godot::Ref <godot::Resource> & p_resource)
{
resource = p_resource;
}
godot::TypedDictionary <int, godot::Resource> ExampleClass::get_resources () const
{
return resources;
}
void ExampleClass::set_resources (const godot::TypedDictionary <int, godot::Resource> & p_resources)
{
resources = p_resources;
}
float ExampleClass::get_range () const
{
return range;
}
void ExampleClass::set_range (const float & p_range)
{
range = p_range;
}
int ExampleClass::get_enum_property () const
{
return enum_property;
}
void ExampleClass::set_enum_property (int p_enum_property)
{
enum_property = static_cast<ExampleClass::Regular>(p_enum_property);
}
int ExampleClass::get_flags_property () const
{
return flags_property;
}
void ExampleClass::set_flags_property (int p_flags_property)
{
flags_property = static_cast<ExampleClass::Flags>(p_flags_property);
}
// clang-format on
// NOLINTEND
Generated Register Types
/**************************************************************************/
/* generated_register_types.cpp */
/* ___ ___ ___ ___ _____ */
/* / __|/ _ \| \ / _ \_ _| */
/* | (_ | (_) | |) | (_) || | */
/* \___|\___/|___/ \___/ |_| */
/* ___ ___ _ ___ ___ _____ ___ ___ __ __ ___ ___ _ ___ ___ */
/* / _ \| _ )_ | | __/ __|_ _| / __/ _ \| \/ | _ \_ _| | | __| _ \ */
/* | (_) | _ \ || | _| (__ | | | (_| (_) | |\/| | _/| || |__| _|| / */
/* \___/|___/\__/|___\___| |_| \___\___/|_| |_|_| |___|____|___|_|_\ */
/* */
/* This file is generated by Godot Object Compiler 0.1 */
/**************************************************************************/
// NOLINTBEGIN
// clang-format off
#include "gdextension_interface.h"
#include "godot_cpp/core/class_db.hpp"
#include "godot_cpp/core/defs.hpp"
#include "generated_register_types.h"
void generated_register_module (godot::ModuleInitializationLevel p_level)
{
}
void generated_unregister_module (godot::ModuleInitializationLevel p_level)
{
}
// clang-format on
// NOLINTEND