feat: implemented variable tile sizes
This commit is contained in:
parent
19b6a8e42a
commit
dc76f63bd6
2 changed files with 4 additions and 1 deletions
|
|
@ -8,6 +8,7 @@
|
|||
void Generator::_bind_methods() {
|
||||
BIND_HPROPERTY(Variant::OBJECT, state, PROPERTY_HINT_RESOURCE_TYPE, "Sentence");
|
||||
BIND_HPROPERTY(Variant::DICTIONARY, tiles_dict, PROPERTY_HINT_DICTIONARY_TYPE, vformat("String;PackedScene"));
|
||||
BIND_PROPERTY(Variant::FLOAT, tile_size);
|
||||
}
|
||||
|
||||
void Generator::initialise_state() {
|
||||
|
|
@ -54,7 +55,7 @@ void Generator::ready() {
|
|||
if (this->tiles.has(s)) {
|
||||
if (Node * node{ this->tiles.get(s)->instantiate() }) {
|
||||
if (Node3D * node3d{ cast_to<Node3D>(node) }) {
|
||||
node3d->set_position({ (float)at.x, 0, (float)at.y });
|
||||
node3d->set_position(Vector3{ (float)at.x, 0, (float)at.y } * this->tile_size);
|
||||
}
|
||||
this->add_child(node);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,10 @@ public:
|
|||
Rule *rule{ nullptr };
|
||||
typedef HashMap<Symbol, Ref<PackedScene>> TileMap;
|
||||
TileMap tiles{};
|
||||
float tile_size{ 1.f };
|
||||
|
||||
private:
|
||||
GET_SET_FNS(float, tile_size);
|
||||
GET_SET_FNS(Ref<Sentence>, state);
|
||||
GET_SET_REF_FNS(TileMap, tiles);
|
||||
void set_tiles_dict(Dictionary dict);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue