Added VoxelManPropProp.

This commit is contained in:
Relintai 2019-10-24 15:15:32 +02:00
parent 8e4e65371d
commit 2427e9a2ae
4 changed files with 82 additions and 0 deletions

1
SCsub
View File

@ -31,5 +31,6 @@ env.add_source_files(env.modules_sources,"props/voxelman_prop_entry.cpp")
env.add_source_files(env.modules_sources,"props/voxelman_prop_scene.cpp")
env.add_source_files(env.modules_sources,"props/voxelman_prop_mesh.cpp")
env.add_source_files(env.modules_sources,"props/voxelman_prop_light.cpp")
env.add_source_files(env.modules_sources,"props/voxelman_prop_prop.cpp")
env.add_source_files(env.modules_sources,"level_generator/voxelman_level_generator.cpp")

View File

@ -0,0 +1,45 @@
#include "voxelman_prop_prop.h"
Ref<VoxelmanProp> VoxelmanPropProp::get_prop() const {
return _prop;
}
void VoxelmanPropProp::set_prop(const Ref<VoxelmanProp> value) {
_prop = value;
}
bool VoxelmanPropProp::get_snap_to_mesh() {
return _snap_to_mesh;
}
void VoxelmanPropProp::set_snap_to_mesh(bool value) {
_snap_to_mesh = value;
}
Vector3 VoxelmanPropProp::get_snap_axis() {
return _snap_axis;
}
void VoxelmanPropProp::set_snap_axis(Vector3 value) {
_snap_axis = value;
}
VoxelmanPropProp::VoxelmanPropProp() {
_snap_to_mesh = true;
_snap_axis = Vector3(0, 1, 0);
}
VoxelmanPropProp::~VoxelmanPropProp() {
if (_prop.is_valid())
_prop.unref();
}
void VoxelmanPropProp::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_prop"), &VoxelmanPropProp::get_prop);
ClassDB::bind_method(D_METHOD("set_prop", "value"), &VoxelmanPropProp::set_prop);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "prop", PROPERTY_HINT_RESOURCE_TYPE, "VoxelmanProp"), "set_prop", "get_prop");
ClassDB::bind_method(D_METHOD("get_snap_to_mesh"), &VoxelmanPropProp::get_snap_to_mesh);
ClassDB::bind_method(D_METHOD("set_snap_to_mesh", "value"), &VoxelmanPropProp::set_snap_to_mesh);
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "snap_to_mesh"), "set_snap_to_mesh", "get_snap_to_mesh");
ClassDB::bind_method(D_METHOD("get_snap_axis"), &VoxelmanPropProp::get_snap_axis);
ClassDB::bind_method(D_METHOD("set_snap_axis", "value"), &VoxelmanPropProp::set_snap_axis);
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "snap_axis"), "set_snap_axis", "get_snap_axis");
}

View File

@ -0,0 +1,34 @@
#ifndef VOXELMAN_PROP_PROP_H
#define VOXELMAN_PROP_PROP_H
#include "voxelman_prop_entry.h"
#include "core/math/vector3.h"
#include "voxelman_prop.h"
class VoxelmanPropProp : public VoxelmanPropEntry {
GDCLASS(VoxelmanPropProp, VoxelmanPropEntry);
public:
Ref<VoxelmanProp> get_prop() const;
void set_prop(const Ref<VoxelmanProp> value);
bool get_snap_to_mesh();
void set_snap_to_mesh(bool value);
Vector3 get_snap_axis();
void set_snap_axis(Vector3 value);
VoxelmanPropProp();
~VoxelmanPropProp();
protected:
static void _bind_methods();
private:
bool _snap_to_mesh;
Vector3 _snap_axis;
Ref<VoxelmanProp> _prop;
};
#endif

View File

@ -24,6 +24,7 @@
#include "props/voxelman_prop_scene.h"
#include "props/voxelman_prop_mesh.h"
#include "props/voxelman_prop_light.h"
#include "props/voxelman_prop_prop.h"
#include "level_generator/voxelman_level_generator.h"
@ -53,6 +54,7 @@ void register_voxelman_types() {
ClassDB::register_class<VoxelmanPropScene>();
ClassDB::register_class<VoxelmanPropMesh>();
ClassDB::register_class<VoxelmanPropLight>();
ClassDB::register_class<VoxelmanPropProp>();
ClassDB::register_class<VoxelmanLevelGenerator>();
}